aboutsummaryrefslogtreecommitdiff
path: root/networking/telnetd.c
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/telnetd.c
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/telnetd.c')
-rw-r--r--networking/telnetd.c12
1 files changed, 8 insertions, 4 deletions
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)). */