summaryrefslogtreecommitdiff
path: root/usr.bin/chpass/chpass.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-08-27 02:57:08 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-08-27 02:57:08 +0000
commit1defc1e9c00f64228ef1a61ee2dc0717cf485b4e (patch)
tree2648bed0ddacc0c105a78af32a160a0b90023b29 /usr.bin/chpass/chpass.c
parent5b135cfa879ad2271736b3d7c562f84c0bc58e76 (diff)
Instead of prompting the user whether or not they wish to continue to
wait for the lock on password file just tell the user to interrupt with ^C. This simplifies the locking loop a bit. Update man page to this effect.
Diffstat (limited to 'usr.bin/chpass/chpass.c')
-rw-r--r--usr.bin/chpass/chpass.c49
1 files changed, 12 insertions, 37 deletions
diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c
index bdb3a1b3cb7..d41925acb61 100644
--- a/usr.bin/chpass/chpass.c
+++ b/usr.bin/chpass/chpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chpass.c,v 1.19 2001/08/16 18:29:27 millert Exp $ */
+/* $OpenBSD: chpass.c,v 1.20 2001/08/27 02:57:07 millert Exp $ */
/* $NetBSD: chpass.c,v 1.8 1996/05/15 21:50:43 jtc Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)chpass.c 8.4 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$OpenBSD: chpass.c,v 1.19 2001/08/16 18:29:27 millert Exp $";
+static char rcsid[] = "$OpenBSD: chpass.c,v 1.20 2001/08/27 02:57:07 millert Exp $";
#endif
#endif /* not lint */
@@ -54,7 +54,6 @@ static char rcsid[] = "$OpenBSD: chpass.c,v 1.19 2001/08/16 18:29:27 millert Exp
#include <sys/time.h>
#include <sys/uio.h>
-#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
@@ -94,9 +93,8 @@ main(argc, argv)
char **argv;
{
struct passwd *pw, lpw;
- int ch, pfd, tfd, dfd;
+ int i, ch, pfd, tfd, dfd;
char *arg;
- char *s = NULL;
sigset_t fullset;
#ifdef YP
@@ -203,41 +201,18 @@ main(argc, argv)
/* Get the passwd lock file and open the passwd file for reading. */
pw_init();
- for (;;) {
- int i, c, d;
-
- for (i = 0; i < (s ? 64 : 8) && (tfd = pw_lock(0)) == -1; i++) {
- if (i == 0)
- (void)fputs("Please wait", stderr);
- (void)signal(SIGINT, kbintr);
- fputc('.', stderr);
- usleep(250000);
- (void)signal(SIGINT, SIG_IGN);
- }
- if (i)
- fputc('\n', stderr);
- if (tfd != -1)
- break;
-
- /* Unable to lock passwd file, let the user decide. */
- if (errno == EEXIST) {
- if (s == NULL)
- s = "The passwd file is busy,";
- else
- s = "The passwd file is still busy,";
- } else
- s = "Unable to open passwd temp file,";
- (void)fprintf(stderr,
- "%s do you want to wait until it is available? [y/n] ", s);
+ for (i = 1; (tfd = pw_lock(0)) == -1; i++) {
+ if (i == 4)
+ (void)fputs("Attempting lock password file, "
+ "please wait or press ^C to abort", stderr);
(void)signal(SIGINT, kbintr);
- c = getchar();
+ if (i % 16 == 0)
+ fputc('.', stderr);
+ usleep(250000);
(void)signal(SIGINT, SIG_IGN);
- if (c != '\n')
- while ((d = getchar()) != '\n' && d != EOF)
- ;
- if (tolower(c) != 'y')
- pw_error(NULL, 0, 1);
}
+ if (i >= 4)
+ fputc('\n', stderr);
pfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0);
if (pfd == -1 || fcntl(pfd, F_SETFD, 1) == -1)
pw_error(_PATH_MASTERPASSWD, 1, 1);