int nis_update(void);
int boolean_val(char const * str, int dflt);
+int passwd_val(char const * str, int dflt);
char const *boolean_str(int val);
char *newstr(char const * p);
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;
return -1;
if (strcmp(str, "none") == 0)
return -2;
+
+ errx(1, "Invalid value for default password");
}
return dflt;
}
#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);
mix_config(cmdcnf, cnf);
if (default_passwd)
- cmdcnf->default_password = boolean_val(default_passwd,
+ cmdcnf->default_password = passwd_val(default_passwd,
cnf->default_password);
if (genconf) {
if (name != NULL)
if (lc == NULL || login_setcryptfmt(lc, "sha512", NULL) == NULL)
warn("setting crypt(3) format");
login_close(lc);
- cnf->default_password = boolean_val(passwd,
+ cnf->default_password = passwd_val(passwd,
cnf->default_password);
pwd->pw_passwd = pw_password(cnf, pwd->pw_name, dryrun);
edited = true;