summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-07-02 01:36:20 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-07-02 01:36:20 +0000
commit2f303e60026a1506f769551722b98f83c9089935 (patch)
tree28476f796b15b67d6f9f96478f38f83dcb4b5c4e /usr.bin
parent56991998e4aa2ccbc3f3d16d08f486708e2aebb3 (diff)
Kill setjmp/longjmp from a signal handler. All we really need is
to use sigaction() w/o SA_RESTART to allow ^C to interrupt motd(). deraadt@ OK.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/login/login.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c
index 863622ed434..40d5298de92 100644
--- a/usr.bin/login/login.c
+++ b/usr.bin/login/login.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: login.c,v 1.47 2002/07/02 01:15:08 deraadt Exp $ */
+/* $OpenBSD: login.c,v 1.48 2002/07/02 01:36:19 millert Exp $ */
/* $NetBSD: login.c,v 1.13 1996/05/15 23:50:16 jtc Exp $ */
/*-
@@ -77,7 +77,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)login.c 8.4 (Berkeley) 4/2/94";
#endif
-static char rcsid[] = "$OpenBSD: login.c,v 1.47 2002/07/02 01:15:08 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: login.c,v 1.48 2002/07/02 01:36:19 millert Exp $";
#endif /* not lint */
/*
@@ -100,7 +100,6 @@ static char rcsid[] = "$OpenBSD: login.c,v 1.47 2002/07/02 01:15:08 deraadt Exp
#include <login_cap.h>
#include <netdb.h>
#include <pwd.h>
-#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
@@ -808,24 +807,30 @@ rootterm(char *ttyn)
return ((t = getttynam(ttyn)) && t->ty_status & TTY_SECURE);
}
-jmp_buf motdinterrupt;
-
void
motd(void)
{
char tbuf[8192], *motd;
int fd, nchars;
- sig_t oldint;
+ struct sigaction sa, osa;
motd = login_getcapstr(lc, "welcome", _PATH_MOTDFILE, _PATH_MOTDFILE);
if ((fd = open(motd, O_RDONLY, 0)) < 0)
return;
- oldint = signal(SIGINT, sigint);
- if (setjmp(motdinterrupt) == 0)
- while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0)
- (void)write(fileno(stdout), tbuf, nchars);
- (void)signal(SIGINT, oldint);
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = sigint;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0; /* don't set SA_RESTART */
+ (void)sigaction(SIGINT, &sa, &osa);
+
+ /* read and spew motd until EOF, error, or SIGINT */
+ while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0 &&
+ write(STDOUT_FILENO, tbuf, nchars) == nchars)
+ ;
+
+ (void)sigaction(SIGINT, &osa, NULL);
(void)close(fd);
}
@@ -833,7 +838,7 @@ motd(void)
void
sigint(int signo)
{
- longjmp(motdinterrupt, 1);
+ return; /* just interupt syscall */
}
/* ARGSUSED */