Avoid passing NULL to printf in match debug code for LDAP/SSSD.
The file name in struct userspec was not set for the LDAP and SSSD backends. There is no actual file in this case so set the name to LDAP/SSSD. Also add a guard to make sure we don't try to print NULL in sudoers_lookup_check() if name is left unset.
This commit is contained in:
@@ -1248,6 +1248,7 @@ ldap_to_sudoers(LDAP *ld, struct ldap_result *lres,
|
|||||||
/* We only have a single userspec */
|
/* We only have a single userspec */
|
||||||
if ((us = calloc(1, sizeof(*us))) == NULL)
|
if ((us = calloc(1, sizeof(*us))) == NULL)
|
||||||
goto oom;
|
goto oom;
|
||||||
|
us->file = rcstr_dup("LDAP");
|
||||||
TAILQ_INIT(&us->users);
|
TAILQ_INIT(&us->users);
|
||||||
TAILQ_INIT(&us->privileges);
|
TAILQ_INIT(&us->privileges);
|
||||||
STAILQ_INIT(&us->comments);
|
STAILQ_INIT(&us->comments);
|
||||||
|
@@ -161,7 +161,8 @@ sudoers_lookup_check(struct sudo_nss *nss, struct passwd *pw,
|
|||||||
*matching_cs = cs;
|
*matching_cs = cs;
|
||||||
*defs = &priv->defaults;
|
*defs = &priv->defaults;
|
||||||
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
|
||||||
"userspec matched @ %s:%d %s", us->file, us->lineno,
|
"userspec matched @ %s:%d %s",
|
||||||
|
us->file ? us->file : "???", us->lineno,
|
||||||
cmnd_match ? "allowed" : "denied");
|
cmnd_match ? "allowed" : "denied");
|
||||||
debug_return_int(cmnd_match);
|
debug_return_int(cmnd_match);
|
||||||
}
|
}
|
||||||
|
@@ -364,6 +364,7 @@ sss_to_sudoers(struct sudo_sss_handle *handle,
|
|||||||
/* We only have a single userspec */
|
/* We only have a single userspec */
|
||||||
if ((us = calloc(1, sizeof(*us))) == NULL)
|
if ((us = calloc(1, sizeof(*us))) == NULL)
|
||||||
goto oom;
|
goto oom;
|
||||||
|
us->file = rcstr_dup("SSSD");
|
||||||
TAILQ_INIT(&us->users);
|
TAILQ_INIT(&us->users);
|
||||||
TAILQ_INIT(&us->privileges);
|
TAILQ_INIT(&us->privileges);
|
||||||
STAILQ_INIT(&us->comments);
|
STAILQ_INIT(&us->comments);
|
||||||
|
Reference in New Issue
Block a user