diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c index 413eac4882c..dcf870ca1ed 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 75e96a64ba8..4b077875920 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