summaryrefslogtreecommitdiff
path: root/usr.sbin/sliplogin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-17 03:58:01 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-17 03:58:01 +0000
commitdf225519d52543a14d6d05f8b69168c15b416af9 (patch)
tree4fe9f45d6213a73dc0085e5d87d364933c0efdbf /usr.sbin/sliplogin
parent89f293ede1a6e23d51b0b506a71652bbc45c9f48 (diff)
fix signal race issues
Diffstat (limited to 'usr.sbin/sliplogin')
-rw-r--r--usr.sbin/sliplogin/sliplogin.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/usr.sbin/sliplogin/sliplogin.c b/usr.sbin/sliplogin/sliplogin.c
index 38017ea82c1..241741f3a25 100644
--- a/usr.sbin/sliplogin/sliplogin.c
+++ b/usr.sbin/sliplogin/sliplogin.c
@@ -39,7 +39,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)sliplogin.c 5.6 (Berkeley) 3/2/91";*/
-static char rcsid[] = "$Id: sliplogin.c,v 1.16 2001/11/05 09:58:13 deraadt Exp $";
+static char rcsid[] = "$Id: sliplogin.c,v 1.17 2001/11/17 03:58:00 deraadt Exp $";
#endif /* not lint */
/*
@@ -180,30 +180,13 @@ sigstr(s)
}
}
+int die;
+
void
hup_handler(s)
int s;
{
- char logoutfile[MAXPATHLEN];
- struct syslog_data sdata = SYSLOG_DATA_INIT;
-
- seteuid(0);
- (void)snprintf(logoutfile, sizeof logoutfile, "%s.%s",
- _PATH_LOGOUT, loginname);
- if (access(logoutfile, R_OK|X_OK) != 0)
- (void)strlcpy(logoutfile, _PATH_LOGOUT, sizeof(logoutfile));
- if (access(logoutfile, R_OK|X_OK) == 0) {
- char logincmd[2*MAXPATHLEN+32];
-
- (void) snprintf(logincmd, sizeof logincmd, "%s %d %d %s",
- logoutfile, unit, speed, loginargs);
- (void) system(logincmd); /* XXX major race!! */
- }
- (void) close(0);
- syslog_r(LOG_INFO, &sdata, "closed %s slip unit %d (%s)",
- loginname, unit, sigstr(s));
- _exit(1);
- /* NOTREACHED */
+ die = 1;
}
main(argc, argv)
@@ -381,8 +364,32 @@ main(argc, argv)
/* twiddle thumbs until we get a signal; allow user to kill */
seteuid(uid);
sigemptyset(&emptyset);
- while (1)
+ while (1) {
+ if (die) {
+ char logoutfile[MAXPATHLEN];
+
+ seteuid(0);
+ (void)snprintf(logoutfile, sizeof logoutfile, "%s.%s",
+ _PATH_LOGOUT, loginname);
+ if (access(logoutfile, R_OK|X_OK) != 0)
+ (void)strlcpy(logoutfile, _PATH_LOGOUT,
+ sizeof(logoutfile));
+ if (access(logoutfile, R_OK|X_OK) == 0) {
+ char logincmd[2*MAXPATHLEN+32];
+
+ (void) snprintf(logincmd, sizeof logincmd,
+ "%s %d %d %s",
+ logoutfile, unit, speed, loginargs);
+ (void) system(logincmd);
+ }
+ (void) close(0);
+ syslog(LOG_INFO, "closed %s slip unit %d (%s)",
+ loginname, unit, sigstr(s));
+ exit(1);
+ /* NOTREACHED */
+ }
sigsuspend(&emptyset);
+ }
/* NOTREACHED */
}