summaryrefslogtreecommitdiffstats
path: root/pw
diff options
context:
space:
mode:
authorDavid Nugent <davidn@FreeBSD.org>2000-06-18 02:18:15 +0000
committerDavid Nugent <davidn@FreeBSD.org>2000-06-18 02:18:15 +0000
commit4205d2d71c2eaf3380216ab31b2e0619f8001539 (patch)
tree2be5b717e3a273ba1439e2dadb0a6ac4f7a20fb0 /pw
parentcf75e4c4fe862eb5b50d6146d9e8daafd95c243e (diff)
downloadpw-darwin-4205d2d71c2eaf3380216ab31b2e0619f8001539.tar.gz
pw-darwin-4205d2d71c2eaf3380216ab31b2e0619f8001539.tar.zst
pw-darwin-4205d2d71c2eaf3380216ab31b2e0619f8001539.zip
Fix a long-standing bug in the rename case previously masked by another bug
just fixed in .db file updating.
Diffstat (limited to 'pw')
-rw-r--r--pw/pw_user.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c
index 395b69a..1a93990 100644
--- a/pw/pw_user.c
+++ b/pw/pw_user.c
@@ -681,8 +681,16 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
if (mode == M_ADD || getarg(args, 'G') != NULL)
editgroups(pwd->pw_name, cnf->groups);
- /* pwd may have been invalidated */
- if ((pwd = GETPWNAM(a_name->val)) == NULL)
+ /* go get a current version of pwd */
+ pwd = GETPWNAM(a_name->val);
+ if (pwd == NULL) {
+ /* This will fail when we rename, so special case that */
+ if (mode == M_UPDATE && (arg = getarg(args, 'l')) != NULL) {
+ a_name->val = arg->val; /* update new name */
+ pwd = GETPWNAM(a_name->val); /* refetch renamed rec */
+ }
+ }
+ if (pwd == NULL) /* can't go on without this */
errx(EX_NOUSER, "user '%s' disappeared during update", a_name->val);
grp = GETGRGID(pwd->pw_gid);