check the gecos format early: at the moment the -c option is parsed

This commit is contained in:
Baptiste Daroussin 2015-07-11 21:09:50 +00:00
parent a8921b867f
commit 49c195e61e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285408
3 changed files with 7 additions and 4 deletions

View File

@ -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);

View File

@ -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;
}
}

View File

@ -85,6 +85,7 @@ struct pwconf {
char etcpath[MAXPATHLEN];
char *newname;
char *config;
char *gecos;
int fd;
int which;
bool quiet;