Move check_user_shell() to pwutil.c as user_shell_valid()

This will make it possible to support a different backend which may
be used by testsudoers in the future.
This commit is contained in:
Todd C. Miller
2023-09-09 14:07:28 -06:00
parent 28a13501d8
commit d18ee8e0e7
8 changed files with 41 additions and 35 deletions

View File

@@ -31,31 +31,6 @@
#include "sudoers.h"
/*
* Returns true if the specified shell is allowed by /etc/shells, else false.
*/
bool
check_user_shell(const struct passwd *pw)
{
const char *shell;
debug_decl(check_user_shell, SUDOERS_DEBUG_AUTH);
if (!def_runas_check_shell)
debug_return_bool(true);
sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: checking /etc/shells for %s", __func__, pw->pw_shell);
setusershell();
while ((shell = getusershell()) != NULL) {
if (strcmp(shell, pw->pw_shell) == 0)
debug_return_bool(true);
}
endusershell();
debug_return_bool(false);
}
/*
* Check whether specified runchroot matches def_runchroot.
* Returns true if matched, false if not matched and -1 on error.