Subject: bin/1504: init doesn't notice lines deleted from /etc/ttys
To: None <gnats-bugs@gnats.netbsd.org>
From: Giles Lean <giles@nemeton.com.au>
List: netbsd-bugs
Date: 09/25/1995 08:23:48
>Number: 1504
>Category: bin
>Synopsis: init doesn't notice lines deleted from /etc/ttys
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Sep 25 11:50:03 1995
>Last-Modified:
>Originator: Giles Lean
>Organization:
Giles Lean Nemeton Pty Ltd
<giles@nemeton.com.au> phone: +61 3 480 2118
>Release: September 22 1995
>Environment:
System: NetBSD topaz.nemeton.com.au 1.0A NetBSD 1.0A (TOPAZ) #10: Sun Sep 24 16:55:33 EST 1995 giles@topaz.nemeton.com.au:/usr/src/sys/arch/i386/compile/TOPAZ i386
>Description:
If line(s) are deleted from /etc/ttys, init merrily continues
to create processes for those lines. This is surprising, at
least.
>How-To-Repeat:
Turn on a getty in /etc/ttys and signal init. Verify a getty
is running. Delete the line from /etc/ttys and signal init.
Check that the getty is still running, then kill it and see
that init spawns a new getty.
>Fix:
The following patch arranges for init to delete such sessions.
*** src/sbin/init/init.c.orig Sun Sep 24 17:24:05 1995
--- src/sbin/init/init.c Sun Sep 24 17:23:58 1995
***************
*** 136,141 ****
--- 136,142 ----
time_t se_started; /* used to avoid thrashing */
int se_flags; /* status of session */
#define SE_SHUTDOWN 0x1 /* session won't be restarted */
+ #define SE_CURRENT 0x2 /* session is in /etc/ttys */
char *se_device; /* filename of port */
char *se_getty; /* what to run on that port */
char **se_getty_argv; /* pre-parsed argument array */
***************
*** 1228,1233 ****
--- 1229,1235 ----
break;
if (sp) {
+ sp->se_flags |= SE_CURRENT;
if (sp->se_index != session_index) {
warning("port %s changed utmp index from %d to %d",
sp->se_device, sp->se_index,
***************
*** 1254,1259 ****
--- 1256,1269 ----
}
endttyent();
+
+ for (sp = sessions; sp; sp = sp->se_next)
+ if (sp->se_flags & SE_CURRENT) {
+ sp->se_flags &= ~SE_CURRENT;
+ } else {
+ sp->se_flags |= SE_SHUTDOWN;
+ kill(sp->se_process, SIGHUP);
+ }
return (state_func_t) multi_user;
}
>Audit-Trail:
>Unformatted: