2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-03 15:55:40 +00:00

Update check for whether or not the runas user was set in the ldap

and sssd backends to match the sudoers file backend.  Introduces
the runas_user_set() macro to improve readability.  Previously,
runas_pw was set late, now it is set before checking sudoers.
This commit is contained in:
Todd C. Miller
2016-09-15 09:37:53 -06:00
parent db7ce3c219
commit ef82f792a1
4 changed files with 8 additions and 3 deletions

View File

@@ -764,7 +764,7 @@ sudo_ldap_check_runas_user(LDAP *ld, LDAPMessage *entry)
bool ret = false; bool ret = false;
debug_decl(sudo_ldap_check_runas_user, SUDOERS_DEBUG_LDAP) debug_decl(sudo_ldap_check_runas_user, SUDOERS_DEBUG_LDAP)
if (!runas_pw) if (!runas_user_set())
debug_return_int(UNSPEC); debug_return_int(UNSPEC);
/* get the runas user from the entry */ /* get the runas user from the entry */

View File

@@ -158,7 +158,7 @@ runaslist_matches(const struct member_list *user_list,
* and a runas group was specified. * and a runas group was specified.
* This logic assumes that we cache and refcount passwd structs. * This logic assumes that we cache and refcount passwd structs.
*/ */
if (!(runas_pw == sudo_user.pw && runas_gr != NULL)) { if (runas_user_set()) {
/* If no runas user or runas group listed in sudoers, use default. */ /* If no runas user or runas group listed in sudoers, use default. */
if (user_list == NULL && group_list == NULL) { if (user_list == NULL && group_list == NULL) {
debug_return_int(userpw_matches(def_runas_default, debug_return_int(userpw_matches(def_runas_default,

View File

@@ -27,6 +27,11 @@
#undef IMPLIED #undef IMPLIED
#define IMPLIED 2 #define IMPLIED 2
/*
* Returns true if a runas user was specified on the command line.
*/
#define runas_user_set() (runas_pw != sudo_user.pw || runas_gr == NULL)
/* /*
* Initialize all tags to UNSPEC. * Initialize all tags to UNSPEC.
*/ */

View File

@@ -568,7 +568,7 @@ sudo_sss_check_runas_user(struct sudo_sss_handle *handle, struct sss_sudo_rule *
int ret = false, i; int ret = false, i;
debug_decl(sudo_sss_check_runas_user, SUDOERS_DEBUG_SSSD); debug_decl(sudo_sss_check_runas_user, SUDOERS_DEBUG_SSSD);
if (!runas_pw) if (!runas_user_set())
debug_return_int(UNSPEC); debug_return_int(UNSPEC);
/* get the runas user from the entry */ /* get the runas user from the entry */