summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pw/pw_user.c
diff options
context:
space:
mode:
authordavidn <davidn@FreeBSD.org>2000-06-18 02:18:15 +0000
committerdavidn <davidn@FreeBSD.org>2000-06-18 02:18:15 +0000
commit1553afea7578052fa090a855d0825174fd36689d (patch)
tree356ef99d3d0cc3d99ef0d691991a875bcf3a42f8 /usr.sbin/pw/pw_user.c
parentfaaa880c55621acd4067b9d0f51874ae2e13eb18 (diff)
downloadFreeBSD-src-1553afea7578052fa090a855d0825174fd36689d.zip
FreeBSD-src-1553afea7578052fa090a855d0825174fd36689d.tar.gz
Fix a long-standing bug in the rename case previously masked by another bug
just fixed in .db file updating.
Diffstat (limited to 'usr.sbin/pw/pw_user.c')
-rw-r--r--usr.sbin/pw/pw_user.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 395b69a..1a93990 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/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);
OpenPOWER on IntegriCloud