]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Really restore the old behaviour for pw usermod -m
authorBaptiste Daroussin <bapt@FreeBSD.org>
Sun, 22 Jan 2017 20:03:18 +0000 (20:03 +0000)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Sun, 22 Jan 2017 20:03:18 +0000 (20:03 +0000)
It again reinstall missing skel files without overwriting changed one
Add a regression test about it

Reported by: ae
MFC after: 3 days

pw/psdate.c
pw/pw_user.c

index bd2aa152b437522d96e8b7d6869bf7565ea385bb..b63d882bc7bc56bf1feb1f4bae8d8c5a42b0afff 100644 (file)
@@ -41,12 +41,8 @@ static const char rcsid[] =
 static int
 numerics(char const * str)
 {
-       int             rc = isdigit((unsigned char)*str);
 
-       if (rc)
-               while (isdigit((unsigned char)*str) || *str == 'x')
-                       ++str;
-       return rc && !*str;
+       return (str[strspn(str, "0123456789x")] == '\0');
 }
 
 static int
index 6e991a858d8f3d18c7fe95ec77cf0522358184b8..8cffac98b558bf27bbfc4ce942d77841420785fc 100644 (file)
@@ -1493,7 +1493,7 @@ pw_user_mod(int argc, char **argv, char *arg1)
        intmax_t id = -1;
        int ch, fd = -1;
        size_t i, j;
-       bool quiet, createhome, pretty, dryrun, nis, edited, docreatehome;
+       bool quiet, createhome, pretty, dryrun, nis, edited;
        bool precrypted;
        mode_t homemode = 0;
        time_t expire_days, password_days, now;
@@ -1503,7 +1503,7 @@ pw_user_mod(int argc, char **argv, char *arg1)
        passwd = NULL;
        class = nispasswd = NULL;
        quiet = createhome = pretty = dryrun = nis = precrypted = false;
-       edited = docreatehome = false;
+       edited = false;
 
        if (arg1 != NULL) {
                if (arg1[strspn(arg1, "0123456789")] == '\0')
@@ -1697,10 +1697,6 @@ pw_user_mod(int argc, char **argv, char *arg1)
                edited = true;
        }
 
-       if (createhome && fstatat(conf.rootfd, pwd->pw_dir, &st, 0) == -1) {
-               docreatehome = true;
-       }
-
        if (homedir && strcmp(pwd->pw_dir, homedir) != 0) {
                pwd->pw_dir = homedir;
                edited = true;
@@ -1708,8 +1704,6 @@ pw_user_mod(int argc, char **argv, char *arg1)
                        if (!createhome)
                                warnx("WARNING: home `%s' does not exist",
                                    pwd->pw_dir);
-                       else
-                               docreatehome = true;
                } else if (!S_ISDIR(st.st_mode)) {
                        warnx("WARNING: home `%s' is not a directory",
                            pwd->pw_dir);
@@ -1801,7 +1795,7 @@ pw_user_mod(int argc, char **argv, char *arg1)
         * that this also `works' for editing users if -m is used, but
         * existing files will *not* be overwritten.
         */
-       if (PWALTDIR() != PWF_ALT && docreatehome && pwd->pw_dir &&
+       if (PWALTDIR() != PWF_ALT && createhome && pwd->pw_dir &&
            *pwd->pw_dir == '/' && pwd->pw_dir[1]) {
                if (!skel)
                        skel = cnf->dotdir;