version 1.11, 1998/05/29 16:37:51 |
version 1.12, 1998/08/02 03:35:07 |
|
|
/* 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(); |
tfd = pw_lock(0); |
tfd = pw_lock(0); |
if (tfd < 0) { |
if (tfd == -1 || fcntl(tfd, F_SETFD, 1) == -1) { |
if (errno == EEXIST) |
if (errno == EEXIST) |
errx(1, "the passwd file is busy."); |
errx(1, "the passwd file is busy."); |
else |
else |
err(1, "can't open passwd temp file"); |
err(1, "can't open passwd temp file"); |
} |
} |
pfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0); |
pfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0); |
if (pfd < 0) |
if (pfd == -1 || fcntl(pfd, F_SETFD, 1) == -1) |
pw_error(_PATH_MASTERPASSWD, 1, 1); |
pw_error(_PATH_MASTERPASSWD, 1, 1); |
|
|
/* Edit the user passwd information if requested. */ |
/* Edit the user passwd information if requested. */ |
if (op == EDITENTRY) { |
if (op == EDITENTRY) { |
dfd = mkstemp(tempname); |
dfd = mkstemp(tempname); |
if (dfd < 0) |
if (dfd == -1 || fcntl(dfd, F_SETFD, 1) == -1) |
pw_error(tempname, 1, 1); |
pw_error(tempname, 1, 1); |
display(tempname, dfd, pw); |
display(tempname, dfd, pw); |
edit(tempname, pw); |
edit(tempname, pw); |
|
|
pw_copy(pfd, tfd, pw); |
pw_copy(pfd, tfd, pw); |
|
|
/* Now finish the passwd file update. */ |
/* Now finish the passwd file update. */ |
if (pw_mkdb() < 0) |
if (pw_mkdb() == -1) |
pw_error(NULL, 0, 1); |
pw_error(NULL, 0, 1); |
} |
} |
|
|