diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-04 09:42:05 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-04 09:42:05 +0000 |
commit | f3f33ebb0b325a0a5710cb39530449dd09c5ab70 (patch) | |
tree | 68438ccc64f1d0649ef323937036fa9f307738b8 | |
parent | f8157cafcb04a2c37b33bb68272cce1367a14777 (diff) | |
download | busybox-w32-f3f33ebb0b325a0a5710cb39530449dd09c5ab70.tar.gz busybox-w32-f3f33ebb0b325a0a5710cb39530449dd09c5ab70.tar.bz2 busybox-w32-f3f33ebb0b325a0a5710cb39530449dd09c5ab70.zip |
zcip: open ARP socket before openlog
(else we can thrash syslog socket)
-rw-r--r-- | networking/zcip.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/networking/zcip.c b/networking/zcip.c index 6e1c0d148..d8d9a2de1 100644 --- a/networking/zcip.c +++ b/networking/zcip.c | |||
@@ -178,7 +178,7 @@ int zcip_main(int argc, char **argv) | |||
178 | char *r_opt; | 178 | char *r_opt; |
179 | unsigned opts; | 179 | unsigned opts; |
180 | 180 | ||
181 | /* Ugly trick, but I want these zeroed in one go */ | 181 | // ugly trick, but I want these zeroed in one go |
182 | struct { | 182 | struct { |
183 | const struct in_addr null_ip; | 183 | const struct in_addr null_ip; |
184 | const struct ether_addr null_addr; | 184 | const struct ether_addr null_addr; |
@@ -212,8 +212,17 @@ int zcip_main(int argc, char **argv) | |||
212 | // exactly 2 args; -v accumulates and implies -f | 212 | // exactly 2 args; -v accumulates and implies -f |
213 | opt_complementary = "=2:vv:vf"; | 213 | opt_complementary = "=2:vv:vf"; |
214 | opts = getopt32(argv, "fqr:v", &r_opt, &verbose); | 214 | opts = getopt32(argv, "fqr:v", &r_opt, &verbose); |
215 | #if !BB_MMU | ||
216 | // on NOMMU reexec early (or else we will rerun things twice) | ||
217 | if (!FOREGROUND) | ||
218 | bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv); | ||
219 | #endif | ||
220 | // open an ARP socket | ||
221 | // (need to do it before openlog to prevent openlog from taking | ||
222 | // fd 3 (sock_fd==3)) | ||
223 | xmove_fd(xsocket(AF_PACKET, SOCK_PACKET, htons(ETH_P_ARP)), sock_fd); | ||
215 | if (!FOREGROUND) { | 224 | if (!FOREGROUND) { |
216 | /* Do it early, before all bb_xx_msg calls */ | 225 | // do it before all bb_xx_msg calls |
217 | openlog(applet_name, 0, LOG_DAEMON); | 226 | openlog(applet_name, 0, LOG_DAEMON); |
218 | logmode |= LOGMODE_SYSLOG; | 227 | logmode |= LOGMODE_SYSLOG; |
219 | } | 228 | } |
@@ -224,11 +233,6 @@ int zcip_main(int argc, char **argv) | |||
224 | bb_error_msg_and_die("invalid link address"); | 233 | bb_error_msg_and_die("invalid link address"); |
225 | } | 234 | } |
226 | } | 235 | } |
227 | // On NOMMU reexec early (or else we will rerun things twice) | ||
228 | #if !BB_MMU | ||
229 | if (!FOREGROUND) | ||
230 | bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv); | ||
231 | #endif | ||
232 | argc -= optind; | 236 | argc -= optind; |
233 | argv += optind; | 237 | argv += optind; |
234 | 238 | ||
@@ -247,8 +251,6 @@ int zcip_main(int argc, char **argv) | |||
247 | //TODO: are we leaving sa_family == 0 (AF_UNSPEC)?! | 251 | //TODO: are we leaving sa_family == 0 (AF_UNSPEC)?! |
248 | safe_strncpy(saddr.sa_data, intf, sizeof(saddr.sa_data)); | 252 | safe_strncpy(saddr.sa_data, intf, sizeof(saddr.sa_data)); |
249 | 253 | ||
250 | // open an ARP socket | ||
251 | xmove_fd(xsocket(AF_PACKET, SOCK_PACKET, htons(ETH_P_ARP)), sock_fd); | ||
252 | // bind to the interface's ARP socket | 254 | // bind to the interface's ARP socket |
253 | xbind(sock_fd, &saddr, sizeof(saddr)); | 255 | xbind(sock_fd, &saddr, sizeof(saddr)); |
254 | 256 | ||
@@ -288,7 +290,7 @@ int zcip_main(int argc, char **argv) | |||
288 | // restarting after address conflicts: | 290 | // restarting after address conflicts: |
289 | // - start with some address we want to try | 291 | // - start with some address we want to try |
290 | // - short random delay | 292 | // - short random delay |
291 | // - arp probes to see if another host else uses it | 293 | // - arp probes to see if another host uses it |
292 | // - arp announcements that we're claiming it | 294 | // - arp announcements that we're claiming it |
293 | // - use it | 295 | // - use it |
294 | // - defend it, within limits | 296 | // - defend it, within limits |
@@ -319,7 +321,7 @@ int zcip_main(int argc, char **argv) | |||
319 | switch (safe_poll(fds, 1, timeout_ms)) { | 321 | switch (safe_poll(fds, 1, timeout_ms)) { |
320 | 322 | ||
321 | default: | 323 | default: |
322 | /*bb_perror_msg("poll"); - done in safe_poll */ | 324 | //bb_perror_msg("poll"); - done in safe_poll |
323 | return EXIT_FAILURE; | 325 | return EXIT_FAILURE; |
324 | 326 | ||
325 | // timeout | 327 | // timeout |