check the gecos format early: at the moment the -c option is parsed
This commit is contained in:
parent
a8921b867f
commit
49c195e61e
@ -254,6 +254,9 @@ main(int argc, char *argv[])
|
|||||||
case 'a':
|
case 'a':
|
||||||
conf.all = true;
|
conf.all = true;
|
||||||
break;
|
break;
|
||||||
|
case 'c':
|
||||||
|
conf.gecos = pw_checkname(optarg, 1);
|
||||||
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
if (which == 0) { /* for user* */
|
if (which == 0) { /* for user* */
|
||||||
addarg(&arglist, 'g', optarg);
|
addarg(&arglist, 'g', optarg);
|
||||||
|
@ -650,10 +650,9 @@ pw_user(int mode, char *name, long id, struct cargs * args)
|
|||||||
/*
|
/*
|
||||||
* Shared add/edit code
|
* Shared add/edit code
|
||||||
*/
|
*/
|
||||||
if ((arg = getarg(args, 'c')) != NULL) {
|
if (conf.gecos != NULL) {
|
||||||
char *gecos = pw_checkname(arg->val, 1);
|
if (strcmp(pwd->pw_gecos, conf.gecos) != 0) {
|
||||||
if (strcmp(pwd->pw_gecos, gecos) != 0) {
|
pwd->pw_gecos = conf.gecos;
|
||||||
pwd->pw_gecos = gecos;
|
|
||||||
edited = 1;
|
edited = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ struct pwconf {
|
|||||||
char etcpath[MAXPATHLEN];
|
char etcpath[MAXPATHLEN];
|
||||||
char *newname;
|
char *newname;
|
||||||
char *config;
|
char *config;
|
||||||
|
char *gecos;
|
||||||
int fd;
|
int fd;
|
||||||
int which;
|
int which;
|
||||||
bool quiet;
|
bool quiet;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user