diff options
author | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-12 18:24:37 +0000 |
---|---|---|
committer | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-12 18:24:37 +0000 |
commit | 04f8875fd522ea63205b3e223d56979117245d1f (patch) | |
tree | 74b3e38f1b7caef23bbf06a92b6e5d05530d50a6 /networking | |
parent | 36abcfa57f39129886621df00e4f4bc3381b479f (diff) | |
download | busybox-w32-04f8875fd522ea63205b3e223d56979117245d1f.tar.gz busybox-w32-04f8875fd522ea63205b3e223d56979117245d1f.tar.bz2 busybox-w32-04f8875fd522ea63205b3e223d56979117245d1f.zip |
- patch from Denis Vlasenko to add bb_xbind() and bb_xlisten()
git-svn-id: svn://busybox.net/trunk/busybox@14836 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r-- | networking/dnsd.c | 5 | ||||
-rw-r--r-- | networking/fakeidentd.c | 4 | ||||
-rw-r--r-- | networking/httpd.c | 9 | ||||
-rw-r--r-- | networking/nc.c | 7 | ||||
-rw-r--r-- | networking/telnetd.c | 10 | ||||
-rw-r--r-- | networking/traceroute.c | 4 |
6 files changed, 12 insertions, 27 deletions
diff --git a/networking/dnsd.c b/networking/dnsd.c index d78ea04c0..b9d022170 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c | |||
@@ -216,9 +216,8 @@ listen_socket(char *iface_addr, int listen_port) | |||
216 | a.sin_family = AF_INET; | 216 | a.sin_family = AF_INET; |
217 | if (!inet_aton(iface_addr, &a.sin_addr)) | 217 | if (!inet_aton(iface_addr, &a.sin_addr)) |
218 | bb_perror_msg_and_die("bad iface address"); | 218 | bb_perror_msg_and_die("bad iface address"); |
219 | if (bind(s, (struct sockaddr *)&a, sizeof(a)) < 0) | 219 | bb_xbind(s, (struct sockaddr *)&a, sizeof(a)); |
220 | bb_perror_msg_and_die("bind() failed"); | 220 | listen(s, 50); /* bb_xlisten? */ |
221 | listen(s, 50); | ||
222 | sprintf(msg, "accepting UDP packets on addr:port %s:%d\n", | 221 | sprintf(msg, "accepting UDP packets on addr:port %s:%d\n", |
223 | iface_addr, (int)listen_port); | 222 | iface_addr, (int)listen_port); |
224 | log_message(LOG_FILE, msg); | 223 | log_message(LOG_FILE, msg); |
diff --git a/networking/fakeidentd.c b/networking/fakeidentd.c index 26efdcb34..cae6b8138 100644 --- a/networking/fakeidentd.c +++ b/networking/fakeidentd.c | |||
@@ -113,10 +113,10 @@ static void inetbind(void) | |||
113 | addr.sin_family = AF_INET; | 113 | addr.sin_family = AF_INET; |
114 | addr.sin_port = htons(port); | 114 | addr.sin_port = htons(port); |
115 | 115 | ||
116 | if (bind(s, (struct sockaddr *)&addr, len) < 0) | 116 | if (bind(s, (struct sockaddr *)&addr, len) < 0) /* bb_xbind? */ |
117 | bb_perror_msg_and_die("Cannot bind() port %i", IDENT_PORT); | 117 | bb_perror_msg_and_die("Cannot bind() port %i", IDENT_PORT); |
118 | 118 | ||
119 | if (listen(s, 5) < 0) | 119 | if (listen(s, 5) < 0) /* bb_xlisten? */ |
120 | bb_perror_msg_and_die("Cannot listen() on port %i", IDENT_PORT); | 120 | bb_perror_msg_and_die("Cannot listen() on port %i", IDENT_PORT); |
121 | 121 | ||
122 | movefd(s, 0); | 122 | movefd(s, 0); |
diff --git a/networking/httpd.c b/networking/httpd.c index 354c199e7..0f6174140 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -958,12 +958,9 @@ static int openServer(void) | |||
958 | #else | 958 | #else |
959 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ; | 959 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ; |
960 | #endif | 960 | #endif |
961 | if (bind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)) == 0) { | 961 | bb_xbind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)); |
962 | listen(fd, 9); | 962 | listen(fd, 9); /* bb_xlisten? */ |
963 | signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ | 963 | signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ |
964 | } else { | ||
965 | bb_perror_msg_and_die("bind"); | ||
966 | } | ||
967 | return fd; | 964 | return fd; |
968 | } | 965 | } |
969 | #endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */ | 966 | #endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */ |
diff --git a/networking/nc.c b/networking/nc.c index 86f0b99df..57b091744 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -90,16 +90,13 @@ int nc_main(int argc, char **argv) | |||
90 | memset(&address.sin_addr, 0, sizeof(address.sin_addr)); | 90 | memset(&address.sin_addr, 0, sizeof(address.sin_addr)); |
91 | address.sin_port = lport; | 91 | address.sin_port = lport; |
92 | 92 | ||
93 | if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) | 93 | bb_xbind(sfd, (struct sockaddr *) &address, sizeof(address)); |
94 | bb_perror_msg_and_die("bind"); | ||
95 | } | 94 | } |
96 | 95 | ||
97 | if (do_listen) { | 96 | if (do_listen) { |
98 | socklen_t addrlen = sizeof(address); | 97 | socklen_t addrlen = sizeof(address); |
99 | 98 | ||
100 | if (listen(sfd, 1) < 0) | 99 | bb_xlisten(sfd, 1); |
101 | bb_perror_msg_and_die("listen"); | ||
102 | |||
103 | if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &addrlen)) < 0) | 100 | if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &addrlen)) < 0) |
104 | bb_perror_msg_and_die("accept"); | 101 | bb_perror_msg_and_die("accept"); |
105 | 102 | ||
diff --git a/networking/telnetd.c b/networking/telnetd.c index d53f56b14..1a53c0c0c 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -461,14 +461,8 @@ telnetd_main(int argc, char **argv) | |||
461 | sa.sin_addr = bind_addr; | 461 | sa.sin_addr = bind_addr; |
462 | #endif | 462 | #endif |
463 | 463 | ||
464 | if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { | 464 | bb_xbind(master_fd, (struct sockaddr *) &sa, sizeof(sa)); |
465 | bb_perror_msg_and_die("bind"); | 465 | bb_xlisten(master_fd, 1); |
466 | } | ||
467 | |||
468 | if (listen(master_fd, 1) < 0) { | ||
469 | bb_perror_msg_and_die("listen"); | ||
470 | } | ||
471 | |||
472 | bb_xdaemon(0, 0); | 466 | bb_xdaemon(0, 0); |
473 | 467 | ||
474 | maxfd = master_fd; | 468 | maxfd = master_fd; |
diff --git a/networking/traceroute.c b/networking/traceroute.c index 0abd9047d..4f7ebf176 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -1253,9 +1253,7 @@ traceroute_main(int argc, char *argv[]) | |||
1253 | 1253 | ||
1254 | outip->ip_src = from->sin_addr; | 1254 | outip->ip_src = from->sin_addr; |
1255 | #ifndef IP_HDRINCL | 1255 | #ifndef IP_HDRINCL |
1256 | if (bind(sndsock, (struct sockaddr *)from, sizeof(*from)) < 0) { | 1256 | bb_xbind(sndsock, (struct sockaddr *)from, sizeof(*from)); |
1257 | bb_perror_msg_and_die("bind"); | ||
1258 | } | ||
1259 | #endif | 1257 | #endif |
1260 | 1258 | ||
1261 | fprintf(stderr, "traceroute to %s (%s)", hostname, inet_ntoa(to->sin_addr)); | 1259 | fprintf(stderr, "traceroute to %s (%s)", hostname, inet_ntoa(to->sin_addr)); |