diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-06 09:49:47 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-06 09:49:47 +0000 |
commit | c12f53090bd41dbb87279083bc442769cb0610f0 (patch) | |
tree | 079fff1c37f04ea7f25f00cdc4360d52a69b77c5 | |
parent | 4e6ceb44554d265eed24c414b9a201d51d00fee2 (diff) | |
download | busybox-w32-c12f53090bd41dbb87279083bc442769cb0610f0.tar.gz busybox-w32-c12f53090bd41dbb87279083bc442769cb0610f0.tar.bz2 busybox-w32-c12f53090bd41dbb87279083bc442769cb0610f0.zip |
dnsd fix; option_mask32 added. dnsd needs more love.
-rw-r--r-- | include/libbb.h | 3 | ||||
-rw-r--r-- | libbb/getopt32.c | 4 | ||||
-rw-r--r-- | modutils/insmod.c | 17 | ||||
-rw-r--r-- | networking/dnsd.c | 138 | ||||
-rw-r--r-- | networking/ifupdown.c | 17 | ||||
-rw-r--r-- | procps/top.c | 11 | ||||
-rw-r--r-- | runit/chpst.c | 73 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 39 |
8 files changed, 154 insertions, 148 deletions
diff --git a/include/libbb.h b/include/libbb.h index adfeca590..84c8af4b6 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -206,9 +206,10 @@ extern void xsetgid(gid_t gid); | |||
206 | extern void xsetuid(uid_t uid); | 206 | extern void xsetuid(uid_t uid); |
207 | extern off_t fdlength(int fd); | 207 | extern off_t fdlength(int fd); |
208 | 208 | ||
209 | #define BB_GETOPT_ERROR 0x80000000UL | 209 | enum { BB_GETOPT_ERROR = 0x80000000 }; |
210 | extern const char *opt_complementary; | 210 | extern const char *opt_complementary; |
211 | extern const struct option *applet_long_options; | 211 | extern const struct option *applet_long_options; |
212 | extern uint32_t option_mask32; | ||
212 | extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...); | 213 | extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...); |
213 | 214 | ||
214 | extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format, | 215 | extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format, |
diff --git a/libbb/getopt32.c b/libbb/getopt32.c index e08496578..2f2f0b9e9 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c | |||
@@ -302,6 +302,8 @@ static const struct option bb_default_long_options[] = { | |||
302 | const struct option *applet_long_options = bb_default_long_options; | 302 | const struct option *applet_long_options = bb_default_long_options; |
303 | #endif | 303 | #endif |
304 | 304 | ||
305 | uint32_t option_mask32; | ||
306 | |||
305 | uint32_t | 307 | uint32_t |
306 | getopt32(int argc, char **argv, const char *applet_opts, ...) | 308 | getopt32(int argc, char **argv, const char *applet_opts, ...) |
307 | { | 309 | { |
@@ -512,5 +514,7 @@ loop_arg_is_opt: | |||
512 | argc -= optind; | 514 | argc -= optind; |
513 | if (argc < min_arg || (max_arg >= 0 && argc > max_arg)) | 515 | if (argc < min_arg || (max_arg >= 0 && argc > max_arg)) |
514 | bb_show_usage(); | 516 | bb_show_usage(); |
517 | |||
518 | option_mask32 = flags; | ||
515 | return flags; | 519 | return flags; |
516 | } | 520 | } |
diff --git a/modutils/insmod.c b/modutils/insmod.c index 0554def06..348feed8d 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -693,7 +693,6 @@ enum { STRVERSIONLEN = 32 }; | |||
693 | 693 | ||
694 | /*======================================================================*/ | 694 | /*======================================================================*/ |
695 | 695 | ||
696 | static unsigned option_mask; | ||
697 | #define OPTION_STR "sLo:fkvqx" USE_FEATURE_INSMOD_LOAD_MAP("m") | 696 | #define OPTION_STR "sLo:fkvqx" USE_FEATURE_INSMOD_LOAD_MAP("m") |
698 | enum { | 697 | enum { |
699 | OPT_s = 0x1, // -s /* log to syslog */ | 698 | OPT_s = 0x1, // -s /* log to syslog */ |
@@ -713,13 +712,13 @@ enum { | |||
713 | OPT_x = 0x80, // -x /* do not export externs */ | 712 | OPT_x = 0x80, // -x /* do not export externs */ |
714 | OPT_m = 0x100, // -m /* print module load map */ | 713 | OPT_m = 0x100, // -m /* print module load map */ |
715 | }; | 714 | }; |
716 | #define flag_force_load (option_mask & OPT_f) | 715 | #define flag_force_load (option_mask32 & OPT_f) |
717 | #define flag_autoclean (option_mask & OPT_k) | 716 | #define flag_autoclean (option_mask32 & OPT_k) |
718 | #define flag_verbose (option_mask & OPT_v) | 717 | #define flag_verbose (option_mask32 & OPT_v) |
719 | #define flag_quiet (option_mask & OPT_q) | 718 | #define flag_quiet (option_mask32 & OPT_q) |
720 | #define flag_noexport (option_mask & OPT_x) | 719 | #define flag_noexport (option_mask32 & OPT_x) |
721 | #ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP | 720 | #ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP |
722 | #define flag_print_load_map (option_mask & OPT_m) | 721 | #define flag_print_load_map (option_mask32 & OPT_m) |
723 | #else | 722 | #else |
724 | #define flag_print_load_map 0 | 723 | #define flag_print_load_map 0 |
725 | #endif | 724 | #endif |
@@ -3983,8 +3982,8 @@ int insmod_main( int argc, char **argv) | |||
3983 | struct utsname myuname; | 3982 | struct utsname myuname; |
3984 | 3983 | ||
3985 | /* Parse any options */ | 3984 | /* Parse any options */ |
3986 | option_mask = getopt32(argc, argv, OPTION_STR, &opt_o); | 3985 | getopt32(argc, argv, OPTION_STR, &opt_o); |
3987 | if (option_mask & OPT_o) { // -o /* name the output module */ | 3986 | if (option_mask32 & OPT_o) { // -o /* name the output module */ |
3988 | free(m_name); | 3987 | free(m_name); |
3989 | m_name = xstrdup(opt_o); | 3988 | m_name = xstrdup(opt_o); |
3990 | } | 3989 | } |
diff --git a/networking/dnsd.c b/networking/dnsd.c index ab3704707..35f6c1096 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c | |||
@@ -23,6 +23,12 @@ static char *fileconf = "/etc/dnsd.conf"; | |||
23 | #define LOCK_FILE "/var/run/dnsd.lock" | 23 | #define LOCK_FILE "/var/run/dnsd.lock" |
24 | #define LOG_FILE "/var/log/dnsd.log" | 24 | #define LOG_FILE "/var/log/dnsd.log" |
25 | 25 | ||
26 | // Must matct getopt32 call | ||
27 | #define OPT_daemon (option_mask32 & 0x10) | ||
28 | #define OPT_verbose (option_mask32 & 0x20) | ||
29 | |||
30 | //#define DEBUG 1 | ||
31 | |||
26 | enum { | 32 | enum { |
27 | MAX_HOST_LEN = 16, // longest host name allowed is 15 | 33 | MAX_HOST_LEN = 16, // longest host name allowed is 15 |
28 | IP_STRING_LEN = 18, // .xxx.xxx.xxx.xxx\0 | 34 | IP_STRING_LEN = 18, // .xxx.xxx.xxx.xxx\0 |
@@ -70,7 +76,8 @@ struct dns_entry { // element of known name, ip address and reversed ip address | |||
70 | }; | 76 | }; |
71 | 77 | ||
72 | static struct dns_entry *dnsentry = NULL; | 78 | static struct dns_entry *dnsentry = NULL; |
73 | static int daemonmode = 0; | 79 | // FIXME! unused! :( |
80 | static int daemonmode; | ||
74 | static uint32_t ttl = DEFAULT_TTL; | 81 | static uint32_t ttl = DEFAULT_TTL; |
75 | 82 | ||
76 | /* | 83 | /* |
@@ -79,7 +86,7 @@ static uint32_t ttl = DEFAULT_TTL; | |||
79 | static void convname(char *a, uint8_t *q) | 86 | static void convname(char *a, uint8_t *q) |
80 | { | 87 | { |
81 | int i = (q[0] == '.') ? 0 : 1; | 88 | int i = (q[0] == '.') ? 0 : 1; |
82 | for(; i < MAX_HOST_LEN-1 && *q; i++, q++) | 89 | for (; i < MAX_HOST_LEN-1 && *q; i++, q++) |
83 | a[i] = tolower(*q); | 90 | a[i] = tolower(*q); |
84 | a[0] = i - 1; | 91 | a[0] = i - 1; |
85 | a[i] = 0; | 92 | a[i] = 0; |
@@ -91,9 +98,10 @@ static void convname(char *a, uint8_t *q) | |||
91 | static void undot(uint8_t * rip) | 98 | static void undot(uint8_t * rip) |
92 | { | 99 | { |
93 | int i = 0, s = 0; | 100 | int i = 0, s = 0; |
94 | while(rip[i]) i++; | 101 | while (rip[i]) |
95 | for(--i; i >= 0; i--) { | 102 | i++; |
96 | if(rip[i] == '.') { | 103 | for (--i; i >= 0; i--) { |
104 | if (rip[i] == '.') { | ||
97 | rip[i] = s; | 105 | rip[i] = s; |
98 | s = 0; | 106 | s = 0; |
99 | } else s++; | 107 | } else s++; |
@@ -124,41 +132,42 @@ static void log_message(char *filename, char *message) | |||
124 | * converting to a length/string substring for that label. | 132 | * converting to a length/string substring for that label. |
125 | */ | 133 | */ |
126 | 134 | ||
127 | static int getfileentry(FILE * fp, struct dns_entry *s, int verb) | 135 | static int getfileentry(FILE * fp, struct dns_entry *s) |
128 | { | 136 | { |
129 | unsigned int a,b,c,d; | 137 | unsigned int a,b,c,d; |
130 | char *r, *name; | 138 | char *r, *name; |
131 | 139 | ||
132 | restart: | 140 | restart: |
133 | if(!(r = bb_get_line_from_file(fp))) | 141 | r = bb_get_line_from_file(fp); |
142 | if (!r) | ||
134 | return -1; | 143 | return -1; |
135 | while(*r == ' ' || *r == '\t') { | 144 | while (*r == ' ' || *r == '\t') { |
136 | r++; | 145 | r++; |
137 | if(!*r || *r == '#' || *r == '\n') | 146 | if (!*r || *r == '#' || *r == '\n') |
138 | goto restart; /* skipping empty/blank and commented lines */ | 147 | goto restart; /* skipping empty/blank and commented lines */ |
139 | } | 148 | } |
140 | name = r; | 149 | name = r; |
141 | while(*r != ' ' && *r != '\t') | 150 | while (*r != ' ' && *r != '\t') |
142 | r++; | 151 | r++; |
143 | *r++ = 0; | 152 | *r++ = 0; |
144 | if(sscanf(r,"%u.%u.%u.%u",&a,&b,&c,&d) != 4) | 153 | if (sscanf(r, "%u.%u.%u.%u", &a, &b, &c, &d) != 4) |
145 | goto restart; /* skipping wrong lines */ | 154 | goto restart; /* skipping wrong lines */ |
146 | 155 | ||
147 | sprintf(s->ip,"%u.%u.%u.%u",a,b,c,d); | 156 | sprintf(s->ip, "%u.%u.%u.%u", a, b, c, d); |
148 | sprintf(s->rip,".%u.%u.%u.%u",d,c,b,a); | 157 | sprintf(s->rip, ".%u.%u.%u.%u", d, c, b, a); |
149 | undot((uint8_t*)s->rip); | 158 | undot((uint8_t*)s->rip); |
150 | convname(s->name,(uint8_t*)name); | 159 | convname(s->name,(uint8_t*)name); |
151 | 160 | ||
152 | if(verb) | 161 | if (OPT_verbose) |
153 | fprintf(stderr,"\tname:%s, ip:%s\n",&(s->name[1]),s->ip); | 162 | fprintf(stderr, "\tname:%s, ip:%s\n", &(s->name[1]),s->ip); |
154 | 163 | ||
155 | return 0; /* warningkiller */ | 164 | return 0; |
156 | } | 165 | } |
157 | 166 | ||
158 | /* | 167 | /* |
159 | * Read hostname/IP records from file | 168 | * Read hostname/IP records from file |
160 | */ | 169 | */ |
161 | static void dnsentryinit(int verb) | 170 | static void dnsentryinit(void) |
162 | { | 171 | { |
163 | FILE *fp; | 172 | FILE *fp; |
164 | struct dns_entry *m, *prev; | 173 | struct dns_entry *m, *prev; |
@@ -170,7 +179,7 @@ static void dnsentryinit(int verb) | |||
170 | m = xmalloc(sizeof(struct dns_entry)); | 179 | m = xmalloc(sizeof(struct dns_entry)); |
171 | 180 | ||
172 | m->next = NULL; | 181 | m->next = NULL; |
173 | if (getfileentry(fp, m, verb)) | 182 | if (getfileentry(fp, m)) |
174 | break; | 183 | break; |
175 | 184 | ||
176 | if (prev == NULL) | 185 | if (prev == NULL) |
@@ -224,28 +233,32 @@ static int table_lookup(uint16_t type, uint8_t * as, uint8_t * qs) | |||
224 | char *p,*q; | 233 | char *p,*q; |
225 | q = (char *)&(qs[1]); | 234 | q = (char *)&(qs[1]); |
226 | p = &(d->name[1]); | 235 | p = &(d->name[1]); |
227 | fprintf(stderr, "\ntest: %d <%s> <%s> %d", strlen(p), p, q, strlen(q)); | 236 | fprintf(stderr, "\n%s: %d/%d p:%s q:%s %d", |
237 | __FUNCTION__, strlen(p), (int)(d->name[0]), p, q, strlen(q)); | ||
228 | #endif | 238 | #endif |
229 | if (type == REQ_A) { /* search by host name */ | 239 | if (type == REQ_A) { /* search by host name */ |
230 | for(i = 1; i <= (int)(d->name[0]); i++) | 240 | for (i = 1; i <= (int)(d->name[0]); i++) |
231 | if(tolower(qs[i]) != d->name[i]) | 241 | if (tolower(qs[i]) != d->name[i]) |
232 | continue; | 242 | break; |
243 | if (i > (int)(d->name[0])) { | ||
233 | #ifdef DEBUG | 244 | #ifdef DEBUG |
234 | fprintf(stderr, " OK"); | 245 | fprintf(stderr, " OK"); |
235 | #endif | 246 | #endif |
236 | strcpy((char *)as, d->ip); | 247 | strcpy((char *)as, d->ip); |
237 | #ifdef DEBUG | 248 | #ifdef DEBUG |
238 | fprintf(stderr, " %s ", as); | 249 | fprintf(stderr, " as:%s\n", as); |
239 | #endif | 250 | #endif |
240 | return 0; | 251 | return 0; |
241 | } | 252 | } |
242 | else if (type == REQ_PTR) { /* search by IP-address */ | 253 | } else |
254 | if (type == REQ_PTR) { /* search by IP-address */ | ||
243 | if (!strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) { | 255 | if (!strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) { |
244 | strcpy((char *)as, d->name); | 256 | strcpy((char *)as, d->name); |
245 | return 0; | 257 | return 0; |
246 | } | 258 | } |
247 | } | 259 | } |
248 | } while ((d = d->next) != NULL); | 260 | d = d->next; |
261 | } while (d); | ||
249 | return -1; | 262 | return -1; |
250 | } | 263 | } |
251 | 264 | ||
@@ -253,7 +266,7 @@ static int table_lookup(uint16_t type, uint8_t * as, uint8_t * qs) | |||
253 | /* | 266 | /* |
254 | * Decode message and generate answer | 267 | * Decode message and generate answer |
255 | */ | 268 | */ |
256 | #define eret(s) do { fprintf (stderr, "%s\n", s); return -1; } while (0) | 269 | #define eret(s) do { fputs(s, stderr); return -1; } while (0) |
257 | static int process_packet(uint8_t * buf) | 270 | static int process_packet(uint8_t * buf) |
258 | { | 271 | { |
259 | struct dns_head *head; | 272 | struct dns_head *head; |
@@ -269,13 +282,13 @@ static int process_packet(uint8_t * buf) | |||
269 | 282 | ||
270 | head = (struct dns_head *)buf; | 283 | head = (struct dns_head *)buf; |
271 | if (head->nquer == 0) | 284 | if (head->nquer == 0) |
272 | eret("no queries"); | 285 | eret("no queries\n"); |
273 | 286 | ||
274 | if ((head->flags & 0x8000)) | 287 | if (head->flags & 0x8000) |
275 | eret("ignoring response packet"); | 288 | eret("ignoring response packet\n"); |
276 | 289 | ||
277 | from = (void *)&head[1]; // start of query string | 290 | from = (void *)&head[1]; // start of query string |
278 | next = answb = from + strlen((char *)&head[1]) + 1 + sizeof(struct dns_prop); // where to append answer block | 291 | next = answb = from + strlen((char *)from) + 1 + sizeof(struct dns_prop); // where to append answer block |
279 | 292 | ||
280 | outr.rlen = 0; // may change later | 293 | outr.rlen = 0; // may change later |
281 | outr.r = NULL; | 294 | outr.r = NULL; |
@@ -299,9 +312,8 @@ static int process_packet(uint8_t * buf) | |||
299 | goto empty_packet; | 312 | goto empty_packet; |
300 | 313 | ||
301 | // We have a standard query | 314 | // We have a standard query |
302 | 315 | log_message(LOG_FILE, (char *)from); | |
303 | log_message(LOG_FILE, (char *)head); | 316 | lookup_result = table_lookup(type, answstr, (uint8_t*)from); |
304 | lookup_result = table_lookup(type, answstr, (uint8_t*)(&head[1])); | ||
305 | if (lookup_result != 0) { | 317 | if (lookup_result != 0) { |
306 | outr.flags = 3 | 0x0400; //name do not exist and auth | 318 | outr.flags = 3 | 0x0400; //name do not exist and auth |
307 | goto empty_packet; | 319 | goto empty_packet; |
@@ -335,7 +347,7 @@ static int process_packet(uint8_t * buf) | |||
335 | memcpy(next, (void *)answstr, outr.rlen); | 347 | memcpy(next, (void *)answstr, outr.rlen); |
336 | next += outr.rlen; | 348 | next += outr.rlen; |
337 | 349 | ||
338 | empty_packet: | 350 | empty_packet: |
339 | 351 | ||
340 | flags = ntohs(head->flags); | 352 | flags = ntohs(head->flags); |
341 | // clear rcode and RA, set responsebit and our new flags | 353 | // clear rcode and RA, set responsebit and our new flags |
@@ -358,35 +370,31 @@ static void interrupt(int x) | |||
358 | exit(2); | 370 | exit(2); |
359 | } | 371 | } |
360 | 372 | ||
361 | #define is_daemon() (flags&16) | ||
362 | #define is_verbose() (flags&32) | ||
363 | //#define DEBUG 1 | ||
364 | |||
365 | int dnsd_main(int argc, char **argv) | 373 | int dnsd_main(int argc, char **argv) |
366 | { | 374 | { |
367 | int udps; | 375 | int udps; |
368 | uint16_t port = 53; | 376 | uint16_t port = 53; |
369 | uint8_t buf[MAX_PACK_LEN]; | 377 | uint8_t buf[MAX_PACK_LEN]; |
370 | unsigned long flags = 0; | ||
371 | char *listen_interface = "0.0.0.0"; | 378 | char *listen_interface = "0.0.0.0"; |
372 | char *sttl=NULL, *sport=NULL; | 379 | char *sttl, *sport; |
373 | 380 | ||
374 | if(argc > 1) | 381 | getopt32(argc, argv, "i:c:t:p:dv", &listen_interface, &fileconf, &sttl, &sport); |
375 | flags = getopt32(argc, argv, "i:c:t:p:dv", &listen_interface, &fileconf, &sttl, &sport); | 382 | //if (option_mask32 & 0x1) // -i |
376 | if(sttl) | 383 | //if (option_mask32 & 0x2) // -c |
377 | if(!(ttl = atol(sttl))) | 384 | if (option_mask32 & 0x4) // -t |
385 | if (!(ttl = atol(sttl))) | ||
378 | bb_show_usage(); | 386 | bb_show_usage(); |
379 | if(sport) | 387 | if (option_mask32 & 0x8) // -p |
380 | if(!(port = atol(sport))) | 388 | if (!(port = atol(sport))) |
381 | bb_show_usage(); | 389 | bb_show_usage(); |
382 | 390 | ||
383 | if(is_verbose()) { | 391 | if (OPT_verbose) { |
384 | fprintf(stderr,"listen_interface: %s\n", listen_interface); | 392 | bb_info_msg("listen_interface: %s", listen_interface); |
385 | fprintf(stderr,"ttl: %d, port: %d\n", ttl, port); | 393 | bb_info_msg("ttl: %d, port: %d", ttl, port); |
386 | fprintf(stderr,"fileconf: %s\n", fileconf); | 394 | bb_info_msg("fileconf: %s", fileconf); |
387 | } | 395 | } |
388 | 396 | ||
389 | if(is_daemon()) | 397 | if (OPT_daemon) |
390 | #ifdef BB_NOMMU | 398 | #ifdef BB_NOMMU |
391 | /* reexec for vfork() do continue parent */ | 399 | /* reexec for vfork() do continue parent */ |
392 | vfork_daemon_rexec(1, 0, argc, argv, "-d"); | 400 | vfork_daemon_rexec(1, 0, argc, argv, "-d"); |
@@ -394,7 +402,7 @@ int dnsd_main(int argc, char **argv) | |||
394 | xdaemon(1, 0); | 402 | xdaemon(1, 0); |
395 | #endif | 403 | #endif |
396 | 404 | ||
397 | dnsentryinit(is_verbose()); | 405 | dnsentryinit(); |
398 | 406 | ||
399 | signal(SIGINT, interrupt); | 407 | signal(SIGINT, interrupt); |
400 | signal(SIGPIPE, SIG_IGN); | 408 | signal(SIGPIPE, SIG_IGN); |
@@ -417,20 +425,20 @@ int dnsd_main(int argc, char **argv) | |||
417 | FD_ZERO(&fdset); | 425 | FD_ZERO(&fdset); |
418 | FD_SET(udps, &fdset); | 426 | FD_SET(udps, &fdset); |
419 | // Block until a message arrives | 427 | // Block until a message arrives |
420 | if((r = select(udps + 1, &fdset, NULL, NULL, NULL)) < 0) | 428 | r = select(udps + 1, &fdset, NULL, NULL, NULL); |
429 | if (r < 0) | ||
421 | bb_perror_msg_and_die("select error"); | 430 | bb_perror_msg_and_die("select error"); |
422 | else | 431 | if (r == 0) |
423 | if(r == 0) | ||
424 | bb_perror_msg_and_die("select spurious return"); | 432 | bb_perror_msg_and_die("select spurious return"); |
425 | 433 | ||
426 | /* Can this test ever be false? */ | 434 | /* Can this test ever be false? - yes */ |
427 | if (FD_ISSET(udps, &fdset)) { | 435 | if (FD_ISSET(udps, &fdset)) { |
428 | struct sockaddr_in from; | 436 | struct sockaddr_in from; |
429 | int fromlen = sizeof(from); | 437 | int fromlen = sizeof(from); |
430 | r = recvfrom(udps, buf, sizeof(buf), 0, | 438 | r = recvfrom(udps, buf, sizeof(buf), 0, |
431 | (struct sockaddr *)&from, | 439 | (struct sockaddr *)&from, |
432 | (void *)&fromlen); | 440 | (void *)&fromlen); |
433 | if(is_verbose()) | 441 | if (OPT_verbose) |
434 | fprintf(stderr, "\n--- Got UDP "); | 442 | fprintf(stderr, "\n--- Got UDP "); |
435 | log_message(LOG_FILE, "\n--- Got UDP "); | 443 | log_message(LOG_FILE, "\n--- Got UDP "); |
436 | 444 | ||
@@ -445,9 +453,7 @@ int dnsd_main(int argc, char **argv) | |||
445 | r, 0, (struct sockaddr *)&from, | 453 | r, 0, (struct sockaddr *)&from, |
446 | fromlen); | 454 | fromlen); |
447 | } | 455 | } |
448 | } // end if | 456 | } // end if |
449 | } // end while | 457 | } // end while |
450 | return 0; | 458 | return 0; |
451 | } | 459 | } |
452 | |||
453 | |||
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 6334cbc43..f572b487d 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -89,7 +89,6 @@ struct interfaces_file_t | |||
89 | struct mapping_defn_t *mappings; | 89 | struct mapping_defn_t *mappings; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | static unsigned option_mask; | ||
93 | #define OPTION_STR "anvf" USE_FEATURE_IFUPDOWN_MAPPING("m") "i:" | 92 | #define OPTION_STR "anvf" USE_FEATURE_IFUPDOWN_MAPPING("m") "i:" |
94 | enum { | 93 | enum { |
95 | OPT_do_all = 0x1, | 94 | OPT_do_all = 0x1, |
@@ -98,11 +97,11 @@ enum { | |||
98 | OPT_force = 0x8, | 97 | OPT_force = 0x8, |
99 | OPT_no_mappings = 0x10, | 98 | OPT_no_mappings = 0x10, |
100 | }; | 99 | }; |
101 | #define DO_ALL (option_mask & OPT_do_all) | 100 | #define DO_ALL (option_mask32 & OPT_do_all) |
102 | #define NO_ACT (option_mask & OPT_no_act) | 101 | #define NO_ACT (option_mask32 & OPT_no_act) |
103 | #define VERBOSE (option_mask & OPT_verbose) | 102 | #define VERBOSE (option_mask32 & OPT_verbose) |
104 | #define FORCE (option_mask & OPT_force) | 103 | #define FORCE (option_mask32 & OPT_force) |
105 | #define NO_MAPPINGS (option_mask & OPT_no_mappings) | 104 | #define NO_MAPPINGS (option_mask32 & OPT_no_mappings) |
106 | 105 | ||
107 | static char **__myenviron; | 106 | static char **__myenviron; |
108 | 107 | ||
@@ -881,10 +880,10 @@ static void set_environ(struct interface_defn_t *iface, const char *mode) | |||
881 | 880 | ||
882 | static int doit(char *str) | 881 | static int doit(char *str) |
883 | { | 882 | { |
884 | if (option_mask & (OPT_no_act|OPT_verbose)) { | 883 | if (option_mask32 & (OPT_no_act|OPT_verbose)) { |
885 | puts(str); | 884 | puts(str); |
886 | } | 885 | } |
887 | if (!(option_mask & OPT_no_act)) { | 886 | if (!(option_mask32 & OPT_no_act)) { |
888 | pid_t child; | 887 | pid_t child; |
889 | int status; | 888 | int status; |
890 | 889 | ||
@@ -1088,7 +1087,7 @@ int ifupdown_main(int argc, char **argv) | |||
1088 | cmds = iface_down; | 1087 | cmds = iface_down; |
1089 | } | 1088 | } |
1090 | 1089 | ||
1091 | option_mask = getopt32(argc, argv, OPTION_STR, &interfaces); | 1090 | getopt32(argc, argv, OPTION_STR, &interfaces); |
1092 | if (argc - optind > 0) { | 1091 | if (argc - optind > 0) { |
1093 | if (DO_ALL) bb_show_usage(); | 1092 | if (DO_ALL) bb_show_usage(); |
1094 | } else | 1093 | } else |
diff --git a/procps/top.c b/procps/top.c index ebfbcb80c..be1c45faa 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -34,8 +34,7 @@ typedef int (*cmp_t)(procps_status_t *P, procps_status_t *Q); | |||
34 | 34 | ||
35 | static procps_status_t *top; /* Hehe */ | 35 | static procps_status_t *top; /* Hehe */ |
36 | static int ntop; | 36 | static int ntop; |
37 | static unsigned option_mask; | 37 | #define OPT_BATCH_MODE (option_mask32 & 0x4) |
38 | #define OPT_BATCH_MODE (option_mask & 0x4) | ||
39 | 38 | ||
40 | #ifdef CONFIG_FEATURE_USE_TERMIOS | 39 | #ifdef CONFIG_FEATURE_USE_TERMIOS |
41 | static int pid_sort(procps_status_t *P, procps_status_t *Q) | 40 | static int pid_sort(procps_status_t *P, procps_status_t *Q) |
@@ -398,11 +397,11 @@ int top_main(int argc, char **argv) | |||
398 | /* do normal option parsing */ | 397 | /* do normal option parsing */ |
399 | interval = 5; | 398 | interval = 5; |
400 | opt_complementary = "-"; | 399 | opt_complementary = "-"; |
401 | option_mask = getopt32(argc, argv, "d:n:b", | 400 | getopt32(argc, argv, "d:n:b", |
402 | &sinterval, &siterations); | 401 | &sinterval, &siterations); |
403 | if (option_mask & 0x1) interval = atoi(sinterval); // -d | 402 | if (option_mask32 & 0x1) interval = atoi(sinterval); // -d |
404 | if (option_mask & 0x2) iterations = atoi(siterations); // -n | 403 | if (option_mask32 & 0x2) iterations = atoi(siterations); // -n |
405 | //if (option_mask & 0x4) // -b | 404 | //if (option_mask32 & 0x4) // -b |
406 | 405 | ||
407 | /* change to /proc */ | 406 | /* change to /proc */ |
408 | xchdir("/proc"); | 407 | xchdir("/proc"); |
diff --git a/runit/chpst.c b/runit/chpst.c index b26d62866..4c44e3c0c 100644 --- a/runit/chpst.c +++ b/runit/chpst.c | |||
@@ -2,13 +2,12 @@ | |||
2 | 2 | ||
3 | #include <dirent.h> | 3 | #include <dirent.h> |
4 | 4 | ||
5 | static unsigned option_mask; | ||
6 | // Must match constants in chpst_main! | 5 | // Must match constants in chpst_main! |
7 | #define OPT_verbose (option_mask & 0x2000) | 6 | #define OPT_verbose (option_mask32 & 0x2000) |
8 | #define OPT_pgrp (option_mask & 0x4000) | 7 | #define OPT_pgrp (option_mask32 & 0x4000) |
9 | #define OPT_nostdin (option_mask & 0x8000) | 8 | #define OPT_nostdin (option_mask32 & 0x8000) |
10 | #define OPT_nostdout (option_mask & 0x10000) | 9 | #define OPT_nostdout (option_mask32 & 0x10000) |
11 | #define OPT_nostderr (option_mask & 0x20000) | 10 | #define OPT_nostderr (option_mask32 & 0x20000) |
12 | 11 | ||
13 | static char *set_user; | 12 | static char *set_user; |
14 | static char *env_user; | 13 | static char *env_user; |
@@ -224,28 +223,28 @@ int chpst_main(int argc, char **argv) | |||
224 | 223 | ||
225 | { | 224 | { |
226 | char *m,*d,*o,*p,*f,*c,*r,*t,*n; | 225 | char *m,*d,*o,*p,*f,*c,*r,*t,*n; |
227 | option_mask = getopt32(argc, argv, "u:U:e:m:d:o:p:f:c:r:t:/:n:vP012", | 226 | getopt32(argc, argv, "u:U:e:m:d:o:p:f:c:r:t:/:n:vP012", |
228 | &set_user,&env_user,&env_dir, | 227 | &set_user,&env_user,&env_dir, |
229 | &m,&d,&o,&p,&f,&c,&r,&t,&root,&n); | 228 | &m,&d,&o,&p,&f,&c,&r,&t,&root,&n); |
230 | // if (option_mask & 0x1) // -u | 229 | // if (option_mask32 & 0x1) // -u |
231 | // if (option_mask & 0x2) // -U | 230 | // if (option_mask32 & 0x2) // -U |
232 | // if (option_mask & 0x4) // -e | 231 | // if (option_mask32 & 0x4) // -e |
233 | if (option_mask & 0x8) limits = limitl = limita = limitd = bb_xgetularg10(m); // -m | 232 | if (option_mask32 & 0x8) limits = limitl = limita = limitd = bb_xgetularg10(m); // -m |
234 | if (option_mask & 0x10) limitd = bb_xgetularg10(d); // -d | 233 | if (option_mask32 & 0x10) limitd = bb_xgetularg10(d); // -d |
235 | if (option_mask & 0x20) limito = bb_xgetularg10(o); // -o | 234 | if (option_mask32 & 0x20) limito = bb_xgetularg10(o); // -o |
236 | if (option_mask & 0x40) limitp = bb_xgetularg10(p); // -p | 235 | if (option_mask32 & 0x40) limitp = bb_xgetularg10(p); // -p |
237 | if (option_mask & 0x80) limitf = bb_xgetularg10(f); // -f | 236 | if (option_mask32 & 0x80) limitf = bb_xgetularg10(f); // -f |
238 | if (option_mask & 0x100) limitc = bb_xgetularg10(c); // -c | 237 | if (option_mask32 & 0x100) limitc = bb_xgetularg10(c); // -c |
239 | if (option_mask & 0x200) limitr = bb_xgetularg10(r); // -r | 238 | if (option_mask32 & 0x200) limitr = bb_xgetularg10(r); // -r |
240 | if (option_mask & 0x400) limitt = bb_xgetularg10(t); // -t | 239 | if (option_mask32 & 0x400) limitt = bb_xgetularg10(t); // -t |
241 | // if (option_mask & 0x800) // -/ | 240 | // if (option_mask32 & 0x800) // -/ |
242 | if (option_mask & 0x1000) nicelvl = bb_xgetlarg_bnd_sfx(n, 10, -20, 20, NULL); // -n | 241 | if (option_mask32 & 0x1000) nicelvl = bb_xgetlarg_bnd_sfx(n, 10, -20, 20, NULL); // -n |
243 | // The below consts should match #defines at top! | 242 | // The below consts should match #defines at top! |
244 | //if (option_mask & 0x2000) OPT_verbose = 1; // -v | 243 | //if (option_mask32 & 0x2000) OPT_verbose = 1; // -v |
245 | //if (option_mask & 0x4000) OPT_pgrp = 1; // -P | 244 | //if (option_mask32 & 0x4000) OPT_pgrp = 1; // -P |
246 | //if (option_mask & 0x8000) OPT_nostdin = 1; // -0 | 245 | //if (option_mask32 & 0x8000) OPT_nostdin = 1; // -0 |
247 | //if (option_mask & 0x10000) OPT_nostdout = 1; // -1 | 246 | //if (option_mask32 & 0x10000) OPT_nostdout = 1; // -1 |
248 | //if (option_mask & 0x20000) OPT_nostderr = 1; // -2 | 247 | //if (option_mask32 & 0x20000) OPT_nostderr = 1; // -2 |
249 | } | 248 | } |
250 | argv += optind; | 249 | argv += optind; |
251 | if (!argv || !*argv) bb_show_usage(); | 250 | if (!argv || !*argv) bb_show_usage(); |
@@ -311,19 +310,19 @@ static void envdir(int argc, char **argv) | |||
311 | static void softlimit(int argc, char **argv) | 310 | static void softlimit(int argc, char **argv) |
312 | { | 311 | { |
313 | char *a,*c,*d,*f,*l,*m,*o,*p,*r,*s,*t; | 312 | char *a,*c,*d,*f,*l,*m,*o,*p,*r,*s,*t; |
314 | option_mask = getopt32(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:", | 313 | getopt32(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:", |
315 | &a,&c,&d,&f,&l,&m,&o,&p,&r,&s,&t); | 314 | &a,&c,&d,&f,&l,&m,&o,&p,&r,&s,&t); |
316 | if (option_mask & 0x001) limita = bb_xgetularg10(a); // -a | 315 | if (option_mask32 & 0x001) limita = bb_xgetularg10(a); // -a |
317 | if (option_mask & 0x002) limitc = bb_xgetularg10(c); // -c | 316 | if (option_mask32 & 0x002) limitc = bb_xgetularg10(c); // -c |
318 | if (option_mask & 0x004) limitd = bb_xgetularg10(d); // -d | 317 | if (option_mask32 & 0x004) limitd = bb_xgetularg10(d); // -d |
319 | if (option_mask & 0x008) limitf = bb_xgetularg10(f); // -f | 318 | if (option_mask32 & 0x008) limitf = bb_xgetularg10(f); // -f |
320 | if (option_mask & 0x010) limitl = bb_xgetularg10(l); // -l | 319 | if (option_mask32 & 0x010) limitl = bb_xgetularg10(l); // -l |
321 | if (option_mask & 0x020) limits = limitl = limita = limitd = bb_xgetularg10(m); // -m | 320 | if (option_mask32 & 0x020) limits = limitl = limita = limitd = bb_xgetularg10(m); // -m |
322 | if (option_mask & 0x040) limito = bb_xgetularg10(o); // -o | 321 | if (option_mask32 & 0x040) limito = bb_xgetularg10(o); // -o |
323 | if (option_mask & 0x080) limitp = bb_xgetularg10(p); // -p | 322 | if (option_mask32 & 0x080) limitp = bb_xgetularg10(p); // -p |
324 | if (option_mask & 0x100) limitr = bb_xgetularg10(r); // -r | 323 | if (option_mask32 & 0x100) limitr = bb_xgetularg10(r); // -r |
325 | if (option_mask & 0x200) limits = bb_xgetularg10(s); // -s | 324 | if (option_mask32 & 0x200) limits = bb_xgetularg10(s); // -s |
326 | if (option_mask & 0x400) limitt = bb_xgetularg10(t); // -t | 325 | if (option_mask32 & 0x400) limitt = bb_xgetularg10(t); // -t |
327 | argv += optind; | 326 | argv += optind; |
328 | if (!argv[0]) bb_show_usage(); | 327 | if (!argv[0]) bb_show_usage(); |
329 | slimit(); | 328 | slimit(); |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 40b98c1cb..254d7e73c 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -55,7 +55,6 @@ static struct sockaddr_in remoteaddr; | |||
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | /* options */ | 57 | /* options */ |
58 | static unsigned option_mask; | ||
59 | /* Correct regardless of combination of CONFIG_xxx */ | 58 | /* Correct regardless of combination of CONFIG_xxx */ |
60 | enum { | 59 | enum { |
61 | OPTBIT_mark = 0, // -m | 60 | OPTBIT_mark = 0, // -m |
@@ -298,7 +297,7 @@ static void message(char *fmt, ...) | |||
298 | fl.l_len = 1; | 297 | fl.l_len = 1; |
299 | 298 | ||
300 | #ifdef CONFIG_FEATURE_IPC_SYSLOG | 299 | #ifdef CONFIG_FEATURE_IPC_SYSLOG |
301 | if ((option_mask & OPT_circularlog) && shbuf) { | 300 | if ((option_mask32 & OPT_circularlog) && shbuf) { |
302 | char b[1024]; | 301 | char b[1024]; |
303 | 302 | ||
304 | va_start(arguments, fmt); | 303 | va_start(arguments, fmt); |
@@ -404,7 +403,7 @@ static void logMessage(int pri, char *msg) | |||
404 | /* todo: supress duplicates */ | 403 | /* todo: supress duplicates */ |
405 | 404 | ||
406 | #ifdef CONFIG_FEATURE_REMOTE_LOG | 405 | #ifdef CONFIG_FEATURE_REMOTE_LOG |
407 | if (option_mask & OPT_remotelog) { | 406 | if (option_mask32 & OPT_remotelog) { |
408 | char line[MAXLINE + 1]; | 407 | char line[MAXLINE + 1]; |
409 | /* trying connect the socket */ | 408 | /* trying connect the socket */ |
410 | if (-1 == remotefd) { | 409 | if (-1 == remotefd) { |
@@ -419,12 +418,12 @@ static void logMessage(int pri, char *msg) | |||
419 | } | 418 | } |
420 | } | 419 | } |
421 | 420 | ||
422 | if (option_mask & OPT_locallog) | 421 | if (option_mask32 & OPT_locallog) |
423 | #endif | 422 | #endif |
424 | { | 423 | { |
425 | /* now spew out the message to wherever it is supposed to go */ | 424 | /* now spew out the message to wherever it is supposed to go */ |
426 | if (pri == 0 || LOG_PRI(pri) < logLevel) { | 425 | if (pri == 0 || LOG_PRI(pri) < logLevel) { |
427 | if (option_mask & OPT_small) | 426 | if (option_mask32 & OPT_small) |
428 | message("%s %s\n", timestamp, msg); | 427 | message("%s %s\n", timestamp, msg); |
429 | else | 428 | else |
430 | message("%s %s %s %s\n", timestamp, LocalHostName, res, msg); | 429 | message("%s %s %s %s\n", timestamp, LocalHostName, res, msg); |
@@ -531,7 +530,7 @@ static void doSyslogd(void) | |||
531 | if (chmod(lfile, 0666) < 0) { | 530 | if (chmod(lfile, 0666) < 0) { |
532 | bb_perror_msg_and_die("cannot set permission on %s", lfile); | 531 | bb_perror_msg_and_die("cannot set permission on %s", lfile); |
533 | } | 532 | } |
534 | if (ENABLE_FEATURE_IPC_SYSLOG && (option_mask & OPT_circularlog)) { | 533 | if (ENABLE_FEATURE_IPC_SYSLOG && (option_mask32 & OPT_circularlog)) { |
535 | ipcsyslog_init(); | 534 | ipcsyslog_init(); |
536 | } | 535 | } |
537 | 536 | ||
@@ -575,26 +574,26 @@ int syslogd_main(int argc, char **argv) | |||
575 | char *p; | 574 | char *p; |
576 | 575 | ||
577 | /* do normal option parsing */ | 576 | /* do normal option parsing */ |
578 | option_mask = getopt32(argc, argv, OPTION_STR, OPTION_PARAM); | 577 | getopt32(argc, argv, OPTION_STR, OPTION_PARAM); |
579 | if (option_mask & OPT_mark) MarkInterval = atoi(opt_m) * 60; // -m | 578 | if (option_mask32 & OPT_mark) MarkInterval = atoi(opt_m) * 60; // -m |
580 | //if (option_mask & OPT_nofork) // -n | 579 | //if (option_mask32 & OPT_nofork) // -n |
581 | //if (option_mask & OPT_outfile) // -O | 580 | //if (option_mask32 & OPT_outfile) // -O |
582 | if (option_mask & OPT_loglevel) { // -l | 581 | if (option_mask32 & OPT_loglevel) { // -l |
583 | logLevel = atoi(opt_l); | 582 | logLevel = atoi(opt_l); |
584 | /* Valid levels are between 1 and 8 */ | 583 | /* Valid levels are between 1 and 8 */ |
585 | if (logLevel < 1 || logLevel > 8) | 584 | if (logLevel < 1 || logLevel > 8) |
586 | bb_show_usage(); | 585 | bb_show_usage(); |
587 | } | 586 | } |
588 | //if (option_mask & OPT_small) // -S | 587 | //if (option_mask32 & OPT_small) // -S |
589 | #if ENABLE_FEATURE_ROTATE_LOGFILE | 588 | #if ENABLE_FEATURE_ROTATE_LOGFILE |
590 | if (option_mask & OPT_filesize) logFileSize = atoi(opt_s) * 1024; // -s | 589 | if (option_mask32 & OPT_filesize) logFileSize = atoi(opt_s) * 1024; // -s |
591 | if (option_mask & OPT_rotatecnt) { // -b | 590 | if (option_mask32 & OPT_rotatecnt) { // -b |
592 | logFileRotate = atoi(opt_b); | 591 | logFileRotate = atoi(opt_b); |
593 | if (logFileRotate > 99) logFileRotate = 99; | 592 | if (logFileRotate > 99) logFileRotate = 99; |
594 | } | 593 | } |
595 | #endif | 594 | #endif |
596 | #if ENABLE_FEATURE_REMOTE_LOG | 595 | #if ENABLE_FEATURE_REMOTE_LOG |
597 | if (option_mask & OPT_remotelog) { // -R | 596 | if (option_mask32 & OPT_remotelog) { // -R |
598 | int port = 514; | 597 | int port = 514; |
599 | char *host = xstrdup(opt_R); | 598 | char *host = xstrdup(opt_R); |
600 | p = strchr(host, ':'); | 599 | p = strchr(host, ':'); |
@@ -608,10 +607,10 @@ int syslogd_main(int argc, char **argv) | |||
608 | remoteaddr.sin_port = htons(port); | 607 | remoteaddr.sin_port = htons(port); |
609 | free(host); | 608 | free(host); |
610 | } | 609 | } |
611 | //if (option_mask & OPT_locallog) // -L | 610 | //if (option_mask32 & OPT_locallog) // -L |
612 | #endif | 611 | #endif |
613 | #if ENABLE_FEATURE_IPC_SYSLOG | 612 | #if ENABLE_FEATURE_IPC_SYSLOG |
614 | if (option_mask & OPT_circularlog) { // -C | 613 | if (option_mask32 & OPT_circularlog) { // -C |
615 | if (opt_C) { | 614 | if (opt_C) { |
616 | int buf_size = atoi(opt_C); | 615 | int buf_size = atoi(opt_C); |
617 | if (buf_size >= 4) | 616 | if (buf_size >= 4) |
@@ -621,8 +620,8 @@ int syslogd_main(int argc, char **argv) | |||
621 | #endif | 620 | #endif |
622 | 621 | ||
623 | /* If they have not specified remote logging, then log locally */ | 622 | /* If they have not specified remote logging, then log locally */ |
624 | if (ENABLE_FEATURE_REMOTE_LOG && !(option_mask & OPT_remotelog)) | 623 | if (ENABLE_FEATURE_REMOTE_LOG && !(option_mask32 & OPT_remotelog)) |
625 | option_mask |= OPT_locallog; | 624 | option_mask32 |= OPT_locallog; |
626 | 625 | ||
627 | /* Store away localhost's name before the fork */ | 626 | /* Store away localhost's name before the fork */ |
628 | gethostname(LocalHostName, sizeof(LocalHostName)); | 627 | gethostname(LocalHostName, sizeof(LocalHostName)); |
@@ -633,7 +632,7 @@ int syslogd_main(int argc, char **argv) | |||
633 | 632 | ||
634 | umask(0); | 633 | umask(0); |
635 | 634 | ||
636 | if (!(option_mask & OPT_nofork)) { | 635 | if (!(option_mask32 & OPT_nofork)) { |
637 | #ifdef BB_NOMMU | 636 | #ifdef BB_NOMMU |
638 | vfork_daemon_rexec(0, 1, argc, argv, "-n"); | 637 | vfork_daemon_rexec(0, 1, argc, argv, "-n"); |
639 | #else | 638 | #else |