]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Partial revert of r286152
authorBaptiste Daroussin <bapt@FreeBSD.org>
Sat, 1 Aug 2015 12:18:48 +0000 (12:18 +0000)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Sat, 1 Aug 2015 12:18:48 +0000 (12:18 +0000)
More work needed on the cli validation

pw/pw.c
pw/pw_conf.c
pw/pw_user.c
pw/pwupd.h

diff --git a/pw/pw.c b/pw/pw.c
index bca67159a91a7ec57b9b53229d03c4679732ffb1..88c83dbfa125a5cdda983d620d2a555ab774c6c0 100644 (file)
--- a/pw/pw.c
+++ b/pw/pw.c
@@ -262,11 +262,6 @@ main(int argc, char *argv[])
                case 'c':
                        conf.gecos = pw_checkname(optarg, 1);
                        break;
                case 'c':
                        conf.gecos = pw_checkname(optarg, 1);
                        break;
-               case 'e':
-                       conf.expire_days = strtonum(optarg, 0, INT_MAX, &errstr);
-                       if (errstr)
-                               errx(EX_USAGE, "Invalid expired days: %s", optarg);
-                       break;
                case 'g':
                        if (which == 0) { /* for user* */
                                addarg(&arglist, 'g', optarg);
                case 'g':
                        if (which == 0) { /* for user* */
                                addarg(&arglist, 'g', optarg);
@@ -326,11 +321,6 @@ main(int argc, char *argv[])
                case 'o':
                        conf.checkduplicate = false;
                        break;
                case 'o':
                        conf.checkduplicate = false;
                        break;
-               case 'p':
-                       conf.password_days = strtonum(optarg, 0, INT_MAX, &errstr);
-                       if (errstr)
-                               errx(EX_USAGE, "Invalid password days: %s", optarg);
-                       break;
                case 'q':
                        conf.quiet = true;
                        break;
                case 'q':
                        conf.quiet = true;
                        break;
index b723c31a39dd72bbbd7c0a3967e774db4901fac9..8ba8c07fd455697a3f0f45e0a952a9df5482c4b6 100644 (file)
@@ -367,6 +367,8 @@ read_userconfig(char const * file)
                                                warnx("Invalid expire days:"
                                                    " '%s'; ignoring", q);
                                }
                                                warnx("Invalid expire days:"
                                                    " '%s'; ignoring", q);
                                }
+                               if ((q = unquote(q)) != NULL && isdigit(*q))
+                                       config.expire_days = atoi(q);
                                break;
                        case _UC_PASSWORD:
                                if ((q = unquote(q)) != NULL) {
                                break;
                        case _UC_PASSWORD:
                                if ((q = unquote(q)) != NULL) {
index 6e07f1f8ea4dc97bba20a6505fefccb683ebd2bb..eca8235f6e23aa9794de9b99c24fc50433fe5838 100644 (file)
@@ -418,14 +418,14 @@ pw_user(int mode, char *name, long id, struct cargs * args)
                        errx(EX_OSFILE, "root home `%s' is not a directory", cnf->home);
        }
 
                        errx(EX_OSFILE, "root home `%s' is not a directory", cnf->home);
        }
 
-       if (conf.expire_days > 0)
-               cnf->expire_days = conf.expire_days;
+       if ((arg = getarg(args, 'e')) != NULL)
+               cnf->expire_days = atoi(arg->val);
 
        if ((arg = getarg(args, 'y')) != NULL)
                cnf->nispasswd = arg->val;
 
 
        if ((arg = getarg(args, 'y')) != NULL)
                cnf->nispasswd = arg->val;
 
-       if (conf.password_days > 0)
-               cnf->password_days = conf.password_days;
+       if ((arg = getarg(args, 'p')) != NULL && arg->val)
+               cnf->password_days = atoi(arg->val);
 
        if ((arg = getarg(args, 'g')) != NULL) {
                if (!*(p = arg->val))   /* Handle empty group list specially */
 
        if ((arg = getarg(args, 'g')) != NULL) {
                if (!*(p = arg->val))   /* Handle empty group list specially */
index 9685bea603c48529a5cde6db5af969301df7d160..054c5a55293b36d1f1938df05bf15b460609aafc 100644 (file)
@@ -86,8 +86,6 @@ struct pwconf {
        char            *newname;
        char            *config;
        char            *gecos;
        char            *newname;
        char            *config;
        char            *gecos;
-       int              expire_days;
-       int              password_days;
        int              fd;
        int              rootfd;
        int              which;
        int              fd;
        int              rootfd;
        int              which;