version 1.19, 2001/08/16 18:29:27 |
version 1.20, 2001/08/27 02:57:07 |
|
|
#include <sys/time.h> |
#include <sys/time.h> |
#include <sys/uio.h> |
#include <sys/uio.h> |
|
|
#include <ctype.h> |
|
#include <err.h> |
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
|
|
char **argv; |
char **argv; |
{ |
{ |
struct passwd *pw, lpw; |
struct passwd *pw, lpw; |
int ch, pfd, tfd, dfd; |
int i, ch, pfd, tfd, dfd; |
char *arg; |
char *arg; |
char *s = NULL; |
|
sigset_t fullset; |
sigset_t fullset; |
|
|
#ifdef YP |
#ifdef YP |
|
|
|
|
/* Get the passwd lock file and open the passwd file for reading. */ |
/* Get the passwd lock file and open the passwd file for reading. */ |
pw_init(); |
pw_init(); |
for (;;) { |
for (i = 1; (tfd = pw_lock(0)) == -1; i++) { |
int i, c, d; |
if (i == 4) |
|
(void)fputs("Attempting lock password file, " |
for (i = 0; i < (s ? 64 : 8) && (tfd = pw_lock(0)) == -1; i++) { |
"please wait or press ^C to abort", stderr); |
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); |
|
(void)signal(SIGINT, kbintr); |
(void)signal(SIGINT, kbintr); |
c = getchar(); |
if (i % 16 == 0) |
|
fputc('.', stderr); |
|
usleep(250000); |
(void)signal(SIGINT, SIG_IGN); |
(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); |
pfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0); |
if (pfd == -1 || fcntl(pfd, F_SETFD, 1) == -1) |
if (pfd == -1 || fcntl(pfd, F_SETFD, 1) == -1) |
pw_error(_PATH_MASTERPASSWD, 1, 1); |
pw_error(_PATH_MASTERPASSWD, 1, 1); |