diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-12-07 04:15:09 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-12-07 04:15:09 +0000 |
commit | 046e1311c7321bc45be087afa795307867c54882 (patch) | |
tree | 0e8fc501aca5b71a7fd302690e8552c9cc166805 /usr.bin | |
parent | 678a3da1587d4d9b55b7bba08dd34904fdd74005 (diff) |
Catch SIGINT and SIGQUIT via the kbintr() signal handler in ypgetnewpasswd()
too. Restore old signal handler at the end of ypgetnewpasswd() and
getnewpasswd().
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/passwd/local_passwd.c | 15 | ||||
-rw-r--r-- | usr.bin/passwd/yp_passwd.c | 12 |
2 files changed, 18 insertions, 9 deletions
diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c index ae4e14eb7ae..3d215e9d6bd 100644 --- a/usr.bin/passwd/local_passwd.c +++ b/usr.bin/passwd/local_passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: local_passwd.c,v 1.23 2001/12/07 03:48:39 millert Exp $ */ +/* $OpenBSD: local_passwd.c,v 1.24 2001/12/07 04:15:08 millert Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -35,7 +35,7 @@ #ifndef lint /*static const char sccsid[] = "from: @(#)local_passwd.c 5.5 (Berkeley) 5/6/91";*/ -static const char rcsid[] = "$OpenBSD: local_passwd.c,v 1.23 2001/12/07 03:48:39 millert Exp $"; +static const char rcsid[] = "$OpenBSD: local_passwd.c,v 1.24 2001/12/07 04:15:08 millert Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -151,9 +151,10 @@ getnewpasswd(pw, lc, authenticated) char *p; int tries, pwd_tries; char buf[_PASSWORD_LEN+1], salt[_PASSWORD_LEN]; + sig_t saveint, savequit; - (void)signal(SIGINT, kbintr); - (void)signal(SIGQUIT, kbintr); + saveint = signal(SIGINT, kbintr); + savequit = signal(SIGQUIT, kbintr); if (!authenticated) { (void)printf("Changing local password for %s.\n", pw->pw_name); @@ -190,8 +191,8 @@ getnewpasswd(pw, lc, authenticated) (void)printf("Couldn't generate salt.\n"); pw_error(NULL, 0, 0); } - (void)signal(SIGINT, SIG_DFL); - (void)signal(SIGQUIT, SIG_DFL); + (void)signal(SIGINT, saveint); + (void)signal(SIGQUIT, savequit); return(crypt(buf, salt)); } @@ -204,7 +205,7 @@ kbintr(signo) struct iovec iv[5]; extern char *__progname; - iv[0].iov_base = "\nPassword unchanged.\n"; + iv[0].iov_base = msg; iv[0].iov_len = sizeof(msg) - 1; iv[1].iov_base = __progname; iv[1].iov_len = strlen(__progname); diff --git a/usr.bin/passwd/yp_passwd.c b/usr.bin/passwd/yp_passwd.c index ec721a32a22..d50eece54c7 100644 --- a/usr.bin/passwd/yp_passwd.c +++ b/usr.bin/passwd/yp_passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yp_passwd.c,v 1.18 2001/07/07 00:10:49 millert Exp $ */ +/* $OpenBSD: yp_passwd.c,v 1.19 2001/12/07 04:15:08 millert Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. @@ -34,7 +34,7 @@ */ #ifndef lint /*static const char sccsid[] = "from: @(#)yp_passwd.c 1.0 2/2/93";*/ -static const char rcsid[] = "$OpenBSD: yp_passwd.c,v 1.18 2001/07/07 00:10:49 millert Exp $"; +static const char rcsid[] = "$OpenBSD: yp_passwd.c,v 1.19 2001/12/07 04:15:08 millert Exp $"; #endif /* not lint */ #ifdef YP @@ -64,6 +64,7 @@ static const char rcsid[] = "$OpenBSD: yp_passwd.c,v 1.18 2001/07/07 00:10:49 mi extern int pwd_gensalt __P((char *, int, struct passwd *, login_cap_t *, char)); extern int pwd_check __P((struct passwd *, login_cap_t *, char *)); extern int pwd_gettries __P((struct passwd *, login_cap_t *)); +extern void kbintr __P((int)); char *ypgetnewpasswd __P((struct passwd *, login_cap_t *, char **)); struct passwd *ypgetpwnam __P((char *)); @@ -193,6 +194,10 @@ ypgetnewpasswd(pw, lc, old_pass) char *p; int tries, pwd_tries; char salt[_PASSWORD_LEN]; + sig_t saveint, savequit; + + saveint = signal(SIGINT, kbintr); + savequit = signal(SIGQUIT, kbintr); printf("Changing YP password for %s.\n", pw->pw_name); if (old_pass) { @@ -239,6 +244,9 @@ ypgetnewpasswd(pw, lc, old_pass) p = strdup(crypt(buf, salt)); if (p == NULL) pw_error(NULL, 1, 1); + (void)signal(SIGINT, saveint); + (void)signal(SIGQUIT, savequit); + return (p); } |