diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-07-11 21:09:50 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-07-11 21:09:50 +0000 |
commit | 13824e6c6765b7a1d67b0ffaab60aa0612bee252 (patch) | |
tree | 03447f40cef8276ed48162e5726f971236c93fad | |
parent | b1134e75ce7b8f0deb1b1880f35c42f2a09ddb4e (diff) | |
download | pw-darwin-13824e6c6765b7a1d67b0ffaab60aa0612bee252.tar.gz pw-darwin-13824e6c6765b7a1d67b0ffaab60aa0612bee252.tar.zst pw-darwin-13824e6c6765b7a1d67b0ffaab60aa0612bee252.zip |
check the gecos format early: at the moment the -c option is parsed
-rw-r--r-- | pw/pw.c | 3 | ||||
-rw-r--r-- | pw/pw_user.c | 7 | ||||
-rw-r--r-- | pw/pwupd.h | 1 |
3 files changed, 7 insertions, 4 deletions
@@ -254,6 +254,9 @@ main(int argc, char *argv[]) case 'a': conf.all = true; break; + case 'c': + conf.gecos = pw_checkname(optarg, 1); + break; case 'g': if (which == 0) { /* for user* */ addarg(&arglist, 'g', optarg); diff --git a/pw/pw_user.c b/pw/pw_user.c index 7e8534e..9e16793 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -650,10 +650,9 @@ pw_user(int mode, char *name, long id, struct cargs * args) /* * Shared add/edit code */ - if ((arg = getarg(args, 'c')) != NULL) { - char *gecos = pw_checkname(arg->val, 1); - if (strcmp(pwd->pw_gecos, gecos) != 0) { - pwd->pw_gecos = gecos; + if (conf.gecos != NULL) { + if (strcmp(pwd->pw_gecos, conf.gecos) != 0) { + pwd->pw_gecos = conf.gecos; edited = 1; } } @@ -85,6 +85,7 @@ struct pwconf { char etcpath[MAXPATHLEN]; char *newname; char *config; + char *gecos; int fd; int which; bool quiet; |