X-Git-Url: https://git.cameronkatri.com/pw-darwin.git/blobdiff_plain/403307ec3a577cd210c8241520fd8c7b3fd4fc5a..1d9542a320d803b9bea3971687ccf33b252f2401:/pw/pw_conf.c diff --git a/pw/pw_conf.c b/pw/pw_conf.c index d30c80e..36bb8b6 100644 --- a/pw/pw_conf.c +++ b/pw/pw_conf.c @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 1996 * David L. Nugent. All rights reserved. * @@ -186,14 +188,32 @@ boolean_val(char const * str, int dflt) 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 P_YES; + for (i = 0; boolfalse[i]; i++) + if (strcmp(str, boolfalse[i]) == 0) + return P_NO; /* * Special cases for defaultpassword */ if (strcmp(str, "random") == 0) - return -1; + return P_RANDOM; if (strcmp(str, "none") == 0) - return -2; + return P_NONE; + + errx(1, "Invalid value for default password"); } return dflt; } @@ -258,7 +278,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);