From afc38d0730cc1ba87365292cf6507420b200ea4e Mon Sep 17 00:00:00 2001 From: jmallett Date: Mon, 27 May 2002 08:10:24 +0000 Subject: Don't risk catching a signal while handling a signal for a dying child, as we can then end up not properly clearing wtmp/utmp entries. PR: bin/37934 Submitted by: Sandeep Kumar Reviewed by: markm MFC after: 2 weeks --- contrib/telnet/telnetd/sys_term.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'contrib/telnet') diff --git a/contrib/telnet/telnetd/sys_term.c b/contrib/telnet/telnetd/sys_term.c index 419f4fb..1e832e3 100644 --- a/contrib/telnet/telnetd/sys_term.c +++ b/contrib/telnet/telnetd/sys_term.c @@ -1317,8 +1317,16 @@ void cleanup(int sig __unused) { char *p; + sigset_t mask; p = line + sizeof(_PATH_DEV) - 1; + /* + * Block all signals before clearing the utmp entry. We don't want to + * be called again after calling logout() and then not add the wtmp + * entry because of not finding the corresponding entry in utmp. + */ + sigfillset(&mask); + sigprocmask(SIG_SETMASK, &mask, NULL); if (logout(p)) logwtmp(p, "", ""); (void)chmod(line, 0666); -- cgit v1.1