aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2026-06-04 22:12:35 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2026-06-05 06:01:35 +0000
commit4fd8a69ec6623da5ef33818be134efffebe37f75 (patch)
tree6a576b00b7cf28313c21a8a649ea62e771295b52
parent13f4a37b536b60d559c766b3ec4f2d5d25279ea3 (diff)
pw: fix inverted condition in shell_path error handling
-rw-r--r--usr.sbin/pw/pw_user.c2
-rwxr-xr-xusr.sbin/pw/tests/pw_useradd_test.sh2
2 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 413eac4882cc..dcf870ca1edc 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -464,7 +464,7 @@ shell_path(char const * path, char *shells[], char *sh)
return shellpath;
}
}
- if (sh == NULL)
+ if (sh != NULL)
errx(EX_OSFILE, "can't find shell `%s' in shell paths", sh);
errx(EX_CONFIG, "no default shell available or defined");
return NULL;
diff --git a/usr.sbin/pw/tests/pw_useradd_test.sh b/usr.sbin/pw/tests/pw_useradd_test.sh
index 75e96a64ba8e..4b0778759203 100755
--- a/usr.sbin/pw/tests/pw_useradd_test.sh
+++ b/usr.sbin/pw/tests/pw_useradd_test.sh
@@ -402,7 +402,7 @@ user_add_bad_shell_body() {
populate_etc_skel
atf_check -s exit:0 ${PW} useradd foo -s sh
- atf_check -s exit:78 -e ignore ${PW} useradd bar -s badshell
+ atf_check -s exit:72 -e inline:"pw: can't find shell \`badshell' in shell paths\n" ${PW} useradd bar -s badshell
}
atf_test_case user_add_already_exists