version 1.29, 2003/11/26 00:33:58 |
version 1.30, 2004/04/20 23:21:23 |
|
|
int |
int |
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
{ |
{ |
struct passwd *pw = NULL, lpw; |
struct passwd *pw = NULL, *opw, lpw; |
int i, ch, pfd, tfd, dfd; |
int i, ch, pfd, tfd, dfd; |
char *arg = NULL; |
char *arg = NULL; |
sigset_t fullset; |
sigset_t fullset; |
|
|
if (!pw_scan(arg, pw, NULL)) |
if (!pw_scan(arg, pw, NULL)) |
exit(1); |
exit(1); |
} |
} |
|
if ((opw = pw_dup(pw)) == NULL) |
|
err(1, NULL); |
|
|
/* Edit the user passwd information if requested. */ |
/* Edit the user passwd information if requested. */ |
if (op == EDITENTRY) { |
if (op == EDITENTRY) { |
char tempname[] = _PATH_VARTMP "pw.XXXXXXXXXX"; |
char tempname[] = _PATH_VARTMP "pw.XXXXXXXXXX"; |
int edit_status; |
int edit_status; |
|
|
|
if ((pw = pw_dup(pw)) == NULL) |
|
pw_error(NULL, 1, 1); |
dfd = mkstemp(tempname); |
dfd = mkstemp(tempname); |
if (dfd == -1 || fcntl(dfd, F_SETFD, 1) == -1) |
if (dfd == -1 || fcntl(dfd, F_SETFD, 1) == -1) |
pw_error(tempname, 1, 1); |
pw_error(tempname, 1, 1); |
|
|
#endif /* YP */ |
#endif /* YP */ |
{ |
{ |
/* Copy the passwd file to the lock file, updating pw. */ |
/* Copy the passwd file to the lock file, updating pw. */ |
pw_copy(pfd, tfd, pw); |
pw_copy(pfd, tfd, pw, opw); |
|
|
|
/* If username changed we need to rebuild the entire db. */ |
|
arg = !strcmp(opw->pw_name, pw->pw_name) ? pw->pw_name : NULL; |
|
|
/* Now finish the passwd file update. */ |
/* Now finish the passwd file update. */ |
if (pw_mkdb(pw->pw_name, 0) == -1) |
if (pw_mkdb(arg, 0) == -1) |
pw_error(NULL, 0, 1); |
pw_error(NULL, 0, 1); |
} |
} |
|
|