Author: bapt
Date: Sat Jul 11 21:09:50 2015
New Revision: 285408
URL: https://svnweb.freebsd.org/changeset/base/285408

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

Modified:
  head/usr.sbin/pw/pw.c
  head/usr.sbin/pw/pw_user.c
  head/usr.sbin/pw/pwupd.h

Modified: head/usr.sbin/pw/pw.c
==============================================================================
--- head/usr.sbin/pw/pw.c       Sat Jul 11 21:09:43 2015        (r285407)
+++ head/usr.sbin/pw/pw.c       Sat Jul 11 21:09:50 2015        (r285408)
@@ -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);

Modified: head/usr.sbin/pw/pw_user.c
==============================================================================
--- head/usr.sbin/pw/pw_user.c  Sat Jul 11 21:09:43 2015        (r285407)
+++ head/usr.sbin/pw/pw_user.c  Sat Jul 11 21:09:50 2015        (r285408)
@@ -650,10 +650,9 @@ pw_user(int mode, char *name, long id, s
        /*
         * 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;
                }
        }

Modified: head/usr.sbin/pw/pwupd.h
==============================================================================
--- head/usr.sbin/pw/pwupd.h    Sat Jul 11 21:09:43 2015        (r285407)
+++ head/usr.sbin/pw/pwupd.h    Sat Jul 11 21:09:50 2015        (r285408)
@@ -85,6 +85,7 @@ struct pwconf {
        char             etcpath[MAXPATHLEN];
        char            *newname;
        char            *config;
+       char            *gecos;
        int              fd;
        int              which;
        bool             quiet;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to