aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-19 21:19:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-19 21:19:35 +0000
commit9af7c9d6b62ceb07a9ba24cee0cf4a08c689235e (patch)
tree69a650a8cd686f21087fc572a995420b6ac632cc /networking
parentf8c11aa65df2af4ab20c0effc42997bbd7357cc3 (diff)
downloadbusybox-w32-9af7c9d6b62ceb07a9ba24cee0cf4a08c689235e.tar.gz
busybox-w32-9af7c9d6b62ceb07a9ba24cee0cf4a08c689235e.tar.bz2
busybox-w32-9af7c9d6b62ceb07a9ba24cee0cf4a08c689235e.zip
openvt,getty,vfork_daemon_rexec,mount: tighten up fd cleanup code
(will close all fd's > 2 on daemonization now) getty: fix "getty -" support, and also do not try to chown/chmod "-" telnetd: fix "lost ctty" bug Yet another attempt on saner function names: bb_sanitize_server_stdio(0/1) -> bb_sanitize_stdio() + bb_daemonize();
Diffstat (limited to 'networking')
-rw-r--r--networking/fakeidentd.c2
-rw-r--r--networking/inetd.c4
-rw-r--r--networking/isrv_identd.c2
-rw-r--r--networking/telnetd.c12
-rw-r--r--networking/zcip.c5
5 files changed, 16 insertions, 9 deletions
diff --git a/networking/fakeidentd.c b/networking/fakeidentd.c
index 8c07082fc..6f766a827 100644
--- a/networking/fakeidentd.c
+++ b/networking/fakeidentd.c
@@ -1,3 +1,5 @@
1/* NB: this file is to be removed soon. See isrv_identd.c */
2
1/* vi: set sw=4 ts=4: */ 3/* vi: set sw=4 ts=4: */
2/* 4/*
3 * A fake identd server 5 * A fake identd server
diff --git a/networking/inetd.c b/networking/inetd.c
index 370dcbbe0..218f85e53 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1292,9 +1292,9 @@ inetd_main(int argc, char *argv[])
1292 /* reexec for vfork() do continue parent */ 1292 /* reexec for vfork() do continue parent */
1293 vfork_daemon_rexec(0, 0, argc, argv, "-f"); 1293 vfork_daemon_rexec(0, 0, argc, argv, "-f");
1294 } 1294 }
1295 bb_sanitize_server_stdio(0); 1295 bb_sanitize_stdio();
1296#else 1296#else
1297 bb_sanitize_server_stdio(!(opt & 2)); 1297 bb_sanitize_stdio_maybe_daemonize(!(opt & 2));
1298#endif 1298#endif
1299 openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON); 1299 openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
1300 logmode = LOGMODE_SYSLOG; 1300 logmode = LOGMODE_SYSLOG;
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c
index e757d7c29..2d4399cea 100644
--- a/networking/isrv_identd.c
+++ b/networking/isrv_identd.c
@@ -111,7 +111,7 @@ int fakeidentd_main(int argc, char **argv)
111 bogouser = argv[optind]; 111 bogouser = argv[optind];
112 112
113 /* Daemonize if no -f and no -i and no -w */ 113 /* Daemonize if no -f and no -i and no -w */
114 bb_sanitize_server_stdio(!(opt & OPT_fiw)); 114 bb_sanitize_stdio_maybe_daemonize(!(opt & OPT_fiw));
115 /* Where to log in inetd modes? "Classic" inetd 115 /* Where to log in inetd modes? "Classic" inetd
116 * probably has its stderr /dev/null'ed (we need log to syslog?), 116 * probably has its stderr /dev/null'ed (we need log to syslog?),
117 * but daemontools-like utilities usually expect that children 117 * but daemontools-like utilities usually expect that children
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 51bd0c012..25cba3eb0 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -283,15 +283,19 @@ make_new_session(
283 283
284 /* child */ 284 /* child */
285 285
286 /* make new process group */
287 setsid();
288 tcsetpgrp(0, getpid());
289 /* ^^^ strace says: "ioctl(0, TIOCSPGRP, [pid]) = -1 ENOTTY" -- ??! */
290
286 /* open the child's side of the tty. */ 291 /* open the child's side of the tty. */
287 fd = xopen(tty_name, O_RDWR /*| O_NOCTTY*/); 292 /* NB: setsid() disconnects from any previous ctty's. Therefore
293 * we must open child's side of the tty AFTER setsid! */
294 fd = xopen(tty_name, O_RDWR); /* becomes our ctty */
288 dup2(fd, 0); 295 dup2(fd, 0);
289 dup2(fd, 1); 296 dup2(fd, 1);
290 dup2(fd, 2); 297 dup2(fd, 2);
291 while (fd > 2) close(fd--); 298 while (fd > 2) close(fd--);
292 /* make new process group */
293 setsid();
294 tcsetpgrp(0, getpid());
295 299
296 /* The pseudo-terminal allocated to the client is configured to operate in 300 /* The pseudo-terminal allocated to the client is configured to operate in
297 * cooked mode, and with XTABS CRMOD enabled (see tty(4)). */ 301 * cooked mode, and with XTABS CRMOD enabled (see tty(4)). */
diff --git a/networking/zcip.c b/networking/zcip.c
index 27e281c93..5d57c4287 100644
--- a/networking/zcip.c
+++ b/networking/zcip.c
@@ -221,7 +221,8 @@ int zcip_main(int argc, char *argv[])
221 } 221 }
222 if (opts & 4) { // -r n.n.n.n 222 if (opts & 4) { // -r n.n.n.n
223 if (inet_aton(r_opt, &ip) == 0 223 if (inet_aton(r_opt, &ip) == 0
224 || (ntohl(ip.s_addr) & IN_CLASSB_NET) != LINKLOCAL_ADDR) { 224 || (ntohl(ip.s_addr) & IN_CLASSB_NET) != LINKLOCAL_ADDR
225 ) {
225 bb_error_msg_and_die("invalid link address"); 226 bb_error_msg_and_die("invalid link address");
226 } 227 }
227 } 228 }
@@ -270,7 +271,7 @@ int zcip_main(int argc, char *argv[])
270 // daemonize now; don't delay system startup 271 // daemonize now; don't delay system startup
271 if (!FOREGROUND) { 272 if (!FOREGROUND) {
272 setsid(); 273 setsid();
273 xdaemon(0, 0); 274 bb_daemonize();
274 bb_info_msg("start, interface %s", intf); 275 bb_info_msg("start, interface %s", intf);
275 } 276 }
276 277