]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
pw: fix the checks in boolean_str() after r326738. Add related test
authorYuri Pankov <yuripv@FreeBSD.org>
Sun, 21 Oct 2018 14:23:56 +0000 (14:23 +0000)
committerYuri Pankov <yuripv@FreeBSD.org>
Sun, 21 Oct 2018 14:23:56 +0000 (14:23 +0000)
cases for `pw useradd -D -w`.

PR: 231649
Reviewed by: eugen
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D17299

pw/pw_conf.c

index 9dff3fe03efaf7590af404548777cfc5fd298fde..c446a663f0823178133e7ff5d75431871757df92 100644 (file)
@@ -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           *