summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2015-07-11 21:09:50 +0000
committerbapt <bapt@FreeBSD.org>2015-07-11 21:09:50 +0000
commit394857c344323f2f4f816462009badf094ce9b31 (patch)
tree7e85f4297e1c23fed136550b2dade767993f46f4
parent5e85f1c8a905c7049e28fad2721be1bdd20eca58 (diff)
downloadFreeBSD-src-394857c344323f2f4f816462009badf094ce9b31.zip
FreeBSD-src-394857c344323f2f4f816462009badf094ce9b31.tar.gz
check the gecos format early: at the moment the -c option is parsed
-rw-r--r--usr.sbin/pw/pw.c3
-rw-r--r--usr.sbin/pw/pw_user.c7
-rw-r--r--usr.sbin/pw/pwupd.h1
3 files changed, 7 insertions, 4 deletions
diff --git a/usr.sbin/pw/pw.c b/usr.sbin/pw/pw.c
index 112b1f0..3d4fcf2 100644
--- a/usr.sbin/pw/pw.c
+++ b/usr.sbin/pw/pw.c
@@ -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/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 7e8534e..9e16793 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/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;
}
}
diff --git a/usr.sbin/pw/pwupd.h b/usr.sbin/pw/pwupd.h
index 669cbb1..7a0cd2d 100644
--- a/usr.sbin/pw/pwupd.h
+++ b/usr.sbin/pw/pwupd.h
@@ -85,6 +85,7 @@ struct pwconf {
char etcpath[MAXPATHLEN];
char *newname;
char *config;
+ char *gecos;
int fd;
int which;
bool quiet;
OpenPOWER on IntegriCloud