summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuri Pankov <yuripv@FreeBSD.org>2018-10-21 14:23:56 +0000
committerYuri Pankov <yuripv@FreeBSD.org>2018-10-21 14:23:56 +0000
commitd144a8e142a926ef42e0793ec726e086567337f8 (patch)
treec991a0278188f8c7dfe175f22bbecc4d6eccb2c3
parent29aa58a639334f34b8a5f1629a0b469cdf577c68 (diff)
downloadpw-darwin-d144a8e142a926ef42e0793ec726e086567337f8.tar.gz
pw-darwin-d144a8e142a926ef42e0793ec726e086567337f8.tar.zst
pw-darwin-d144a8e142a926ef42e0793ec726e086567337f8.zip
pw: fix the checks in boolean_str() after r326738. Add related test
cases for `pw useradd -D -w`. PR: 231649 Reviewed by: eugen Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D17299
-rw-r--r--pw/pw_conf.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/pw/pw_conf.c b/pw/pw_conf.c
index 9dff3fe..c446a66 100644
--- a/pw/pw_conf.c
+++ b/pw/pw_conf.c
@@ -221,12 +221,14 @@ passwd_val(char const * str, int dflt)
char const *
boolean_str(int val)
{
- if (val == -1)
- return "random";
- else if (val == -2)
- return "none";
+ if (val == P_NO)
+ return (boolfalse[0]);
+ else if (val == P_RANDOM)
+ return ("random");
+ else if (val == P_NONE)
+ return ("none");
else
- return val ? booltrue[0] : boolfalse[0];
+ return (booltrue[0]);
}
char *