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-9af7c9d6b62ceb07a9ba24cee0cf4a08c689235e.tar.gz
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 @@
+/* NB: this file is to be removed soon. See isrv_identd.c */
+
/* vi: set sw=4 ts=4: */
/*
* 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[])
/* reexec for vfork() do continue parent */
vfork_daemon_rexec(0, 0, argc, argv, "-f");
}
- bb_sanitize_server_stdio(0);
+ bb_sanitize_stdio();
#else
- bb_sanitize_server_stdio(!(opt & 2));
+ bb_sanitize_stdio_maybe_daemonize(!(opt & 2));
#endif
openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
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)
bogouser = argv[optind];
/* Daemonize if no -f and no -i and no -w */
- bb_sanitize_server_stdio(!(opt & OPT_fiw));
+ bb_sanitize_stdio_maybe_daemonize(!(opt & OPT_fiw));
/* Where to log in inetd modes? "Classic" inetd
* probably has its stderr /dev/null'ed (we need log to syslog?),
* 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(
/* child */
+ /* make new process group */
+ setsid();
+ tcsetpgrp(0, getpid());
+ /* ^^^ strace says: "ioctl(0, TIOCSPGRP, [pid]) = -1 ENOTTY" -- ??! */
+
/* open the child's side of the tty. */
- fd = xopen(tty_name, O_RDWR /*| O_NOCTTY*/);
+ /* NB: setsid() disconnects from any previous ctty's. Therefore
+ * we must open child's side of the tty AFTER setsid! */
+ fd = xopen(tty_name, O_RDWR); /* becomes our ctty */
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
while (fd > 2) close(fd--);
- /* make new process group */
- setsid();
- tcsetpgrp(0, getpid());
/* The pseudo-terminal allocated to the client is configured to operate in
* 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[])
}
if (opts & 4) { // -r n.n.n.n
if (inet_aton(r_opt, &ip) == 0
- || (ntohl(ip.s_addr) & IN_CLASSB_NET) != LINKLOCAL_ADDR) {
+ || (ntohl(ip.s_addr) & IN_CLASSB_NET) != LINKLOCAL_ADDR
+ ) {
bb_error_msg_and_die("invalid link address");
}
}
@@ -270,7 +271,7 @@ int zcip_main(int argc, char *argv[])
// daemonize now; don't delay system startup
if (!FOREGROUND) {
setsid();
- xdaemon(0, 0);
+ bb_daemonize();
bb_info_msg("start, interface %s", intf);
}