]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - pw/pw_conf.c
Merge ^/head r305687 through r305890.
[pw-darwin.git] / pw / pw_conf.c
index e9606b4e6a2f0563354b0223c4501955b67a73bf..a3bd0bd367333a7876bf70ee3d9b8b191bb1d383 100644 (file)
@@ -180,6 +180,22 @@ boolean_val(char const * str, int dflt)
        if ((str = unquote(str)) != NULL) {
                int             i;
 
+               for (i = 0; booltrue[i]; i++)
+                       if (strcmp(str, booltrue[i]) == 0)
+                               return 1;
+               for (i = 0; boolfalse[i]; i++)
+                       if (strcmp(str, boolfalse[i]) == 0)
+                               return 0;
+       }
+       return dflt;
+}
+
+int
+passwd_val(char const * str, int dflt)
+{
+       if ((str = unquote(str)) != NULL) {
+               int             i;
+
                for (i = 0; booltrue[i]; i++)
                        if (strcmp(str, booltrue[i]) == 0)
                                return 1;
@@ -194,6 +210,8 @@ boolean_val(char const * str, int dflt)
                        return -1;
                if (strcmp(str, "none") == 0)
                        return -2;
+
+               errx(1, "Invalid value for default password");
        }
        return dflt;
 }
@@ -258,7 +276,7 @@ read_userconfig(char const * file)
 #endif
                        switch (i) {
                        case _UC_DEFAULTPWD:
-                               config.default_password = boolean_val(q, 1);
+                               config.default_password = passwd_val(q, 1);
                                break;
                        case _UC_REUSEUID:
                                config.reuse_uids = boolean_val(q, 0);
@@ -313,7 +331,7 @@ read_userconfig(char const * file)
                                        ? NULL : newstr(q);
                                break;
                        case _UC_EXTRAGROUPS:
-                               for (i = 0; q != NULL; q = strtok(NULL, toks)) {
+                               while ((q = strtok(NULL, toks)) != NULL) {
                                        if (config.groups == NULL)
                                                config.groups = sl_init();
                                        sl_add(config.groups, newstr(q));