Move new_member_all to ldap_util.c, it is only used by ldap/sssd.

This commit is contained in:
Todd C. Miller
2021-01-31 05:44:40 -07:00
parent a74e8502c0
commit 568931035d
7 changed files with 16 additions and 24 deletions

View File

@@ -3421,16 +3421,6 @@ new_member(char *name, int type)
debug_return_ptr(m); debug_return_ptr(m);
} }
/*
* Like new_member() but uses ALL for the type.
* Used by the ldap and sssd back-ends, which don't include gram.h.
*/
struct member *
new_member_all(char *name)
{
return new_member(name, ALL);
}
static struct sudo_command * static struct sudo_command *
new_command(char *cmnd, char *args) new_command(char *cmnd, char *args)
{ {

View File

@@ -1270,16 +1270,6 @@ new_member(char *name, int type)
debug_return_ptr(m); debug_return_ptr(m);
} }
/*
* Like new_member() but uses ALL for the type.
* Used by the ldap and sssd back-ends, which don't include gram.h.
*/
struct member *
new_member_all(char *name)
{
return new_member(name, ALL);
}
static struct sudo_command * static struct sudo_command *
new_command(char *cmnd, char *args) new_command(char *cmnd, char *args)
{ {

View File

@@ -1258,7 +1258,7 @@ ldap_to_sudoers(LDAP *ld, struct ldap_result *lres,
TAILQ_INSERT_TAIL(ldap_userspecs, us, entries); TAILQ_INSERT_TAIL(ldap_userspecs, us, entries);
/* The user has already matched, use ALL as wildcard. */ /* The user has already matched, use ALL as wildcard. */
if ((m = new_member_all(NULL)) == NULL) if ((m = sudo_ldap_new_member_all()) == NULL)
goto oom; goto oom;
TAILQ_INSERT_TAIL(&us->users, m, entries); TAILQ_INSERT_TAIL(&us->users, m, entries);

View File

@@ -409,7 +409,7 @@ sudo_ldap_role_to_priv(const char *cn, void *hosts, void *runasusers,
if (hosts == NULL) { if (hosts == NULL) {
/* The host has already matched, use ALL as wildcard. */ /* The host has already matched, use ALL as wildcard. */
if ((m = new_member_all(NULL)) == NULL) if ((m = sudo_ldap_new_member_all()) == NULL)
goto oom; goto oom;
TAILQ_INSERT_TAIL(&priv->hostlist, m, entries); TAILQ_INSERT_TAIL(&priv->hostlist, m, entries);
} else { } else {
@@ -653,3 +653,15 @@ oom:
} }
debug_return_ptr(NULL); debug_return_ptr(NULL);
} }
/* So ldap.c and sssd.c don't need to include gram.h */
struct member *
sudo_ldap_new_member_all(void)
{
struct member *m;
debug_decl(sudo_ldap_new_member_all, SUDOERS_DEBUG_LDAP);
if ((m = calloc(1, sizeof(*m))) != NULL)
m->type = ALL;
debug_return_ptr(m);
}

View File

@@ -341,7 +341,6 @@ void alias_put(struct alias *a);
/* gram.c */ /* gram.c */
extern struct sudoers_parse_tree parsed_policy; extern struct sudoers_parse_tree parsed_policy;
bool init_parser(const char *path, bool quiet, bool strict); bool init_parser(const char *path, bool quiet, bool strict);
struct member *new_member_all(char *name);
void free_member(struct member *m); void free_member(struct member *m);
void free_members(struct member_list *members); void free_members(struct member_list *members);
void free_cmndspecs(struct cmndspec_list *csl); void free_cmndspecs(struct cmndspec_list *csl);

View File

@@ -370,7 +370,7 @@ sss_to_sudoers(struct sudo_sss_handle *handle,
TAILQ_INSERT_TAIL(&handle->parse_tree.userspecs, us, entries); TAILQ_INSERT_TAIL(&handle->parse_tree.userspecs, us, entries);
/* We only include rules where the user matches. */ /* We only include rules where the user matches. */
if ((m = new_member_all(NULL)) == NULL) if ((m = sudo_ldap_new_member_all()) == NULL)
goto oom; goto oom;
TAILQ_INSERT_TAIL(&us->users, m, entries); TAILQ_INSERT_TAIL(&us->users, m, entries);

View File

@@ -27,5 +27,6 @@ bool sudo_ldap_is_negated(char **valp);
bool sudo_ldap_add_default(const char *var, const char *val, int op, char *source, struct defaults_list *defs); bool sudo_ldap_add_default(const char *var, const char *val, int op, char *source, struct defaults_list *defs);
int sudo_ldap_parse_option(char *optstr, char **varp, char **valp); int sudo_ldap_parse_option(char *optstr, char **varp, char **valp);
struct privilege *sudo_ldap_role_to_priv(const char *cn, void *hosts, void *runasusers, void *runasgroups, void *cmnds, void *opts, const char *notbefore, const char *notafter, bool warnings, bool store_options, sudo_ldap_iter_t iter); struct privilege *sudo_ldap_role_to_priv(const char *cn, void *hosts, void *runasusers, void *runasgroups, void *cmnds, void *opts, const char *notbefore, const char *notafter, bool warnings, bool store_options, sudo_ldap_iter_t iter);
struct member *sudo_ldap_new_member_all(void);
#endif /* SUDOERS_LDAP_H */ #endif /* SUDOERS_LDAP_H */