diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-06-07 19:33:25 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-06-07 19:33:25 +0000 |
commit | fd1b4fc5f4c3f3eb1ee87ab1f07b7640efd15792 (patch) | |
tree | 021a93deb9a9c3dc06d5d56be3addb65fa7c988c /pw/pw_user.c | |
parent | ecddcdd12d894cb5522d8c22536d53f1c8cce857 (diff) | |
download | pw-darwin-fd1b4fc5f4c3f3eb1ee87ab1f07b7640efd15792.tar.gz pw-darwin-fd1b4fc5f4c3f3eb1ee87ab1f07b7640efd15792.tar.zst pw-darwin-fd1b4fc5f4c3f3eb1ee87ab1f07b7640efd15792.zip |
In case of rename validate the length of the new name
Check early that the new name fits MAXLOGNAME and store it in pwconf
Diffstat (limited to 'pw/pw_user.c')
-rw-r--r-- | pw/pw_user.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c index c9093bb..6b3a266 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -382,10 +382,10 @@ pw_user(int mode, char *name, long id, struct cargs * args) /* * The rest is edit code */ - if ((arg = getarg(args, 'l')) != NULL) { + if (conf.newname != NULL) { if (strcmp(pwd->pw_name, "root") == 0) errx(EX_DATAERR, "can't rename `root' account"); - pwd->pw_name = pw_checkname(arg->val, 0); + pwd->pw_name = pw_checkname(conf.newname, 0); edited = 1; } @@ -676,8 +676,8 @@ pw_user(int mode, char *name, long id, struct cargs * args) pwd = GETPWNAM(name); if (pwd == NULL) { /* This will fail when we rename, so special case that */ - if (mode == M_UPDATE && (arg = getarg(args, 'l')) != NULL) { - name = arg->val; /* update new name */ + if (mode == M_UPDATE && conf.newname != NULL) { + name = conf.newname; /* update new name */ pwd = GETPWNAM(name); /* refetch renamed rec */ } } |