o Move userspecs, defaults and aliases into a new struct sudoers_parse_tree.
o The parse tree is now passed to the alias, match and defaults functions. o The nss API has been changed so that the nss parse() function returns a pointer to a struct sudoers_parse_tree which will be filled in by the getdefs() and query() functions.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1998-2000, 2004, 2007-2016
|
||||
* Copyright (c) 1996, 1998-2000, 2004, 2007-2018
|
||||
* Todd C. Miller <Todd.Miller@sudo.ws>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
@@ -239,26 +239,29 @@ struct defaults {
|
||||
};
|
||||
|
||||
/*
|
||||
* Parsed sudoers info.
|
||||
* Parsed sudoers policy.
|
||||
*/
|
||||
extern struct userspec_list userspecs;
|
||||
extern struct defaults_list defaults;
|
||||
struct sudoers_parse_tree {
|
||||
struct userspec_list userspecs;
|
||||
struct defaults_list defaults;
|
||||
struct rbtree *aliases;
|
||||
};
|
||||
|
||||
/* alias.c */
|
||||
bool no_aliases(void);
|
||||
struct rbtree *replace_aliases(struct rbtree *new_aliases);
|
||||
const char *alias_add(char *name, int type, char *file, int lineno, struct member *members);
|
||||
struct rbtree *alloc_aliases(void);
|
||||
void free_aliases(struct rbtree *aliases);
|
||||
bool no_aliases(struct sudoers_parse_tree *parse_tree);
|
||||
const char *alias_add(struct sudoers_parse_tree *parse_tree, char *name, int type, char *file, int lineno, struct member *members);
|
||||
const char *alias_type_to_string(int alias_type);
|
||||
int alias_compare(const void *a1, const void *a2);
|
||||
struct alias *alias_get(const char *name, int type);
|
||||
struct alias *alias_remove(char *name, int type);
|
||||
bool alias_find_used(struct rbtree *used_aliases);
|
||||
void alias_apply(int (*func)(void *, void *), void *cookie);
|
||||
struct alias *alias_get(struct sudoers_parse_tree *parse_tree, const char *name, int type);
|
||||
struct alias *alias_remove(struct sudoers_parse_tree *parse_tree, char *name, int type);
|
||||
bool alias_find_used(struct sudoers_parse_tree *parse_tree, struct rbtree *used_aliases);
|
||||
void alias_apply(struct sudoers_parse_tree *parse_tree, int (*func)(void *, void *), void *cookie);
|
||||
void alias_free(void *a);
|
||||
void alias_put(struct alias *a);
|
||||
bool init_aliases(void);
|
||||
|
||||
/* gram.c */
|
||||
extern struct sudoers_parse_tree parsed_policy;
|
||||
bool init_parser(const char *path, bool quiet);
|
||||
void free_member(struct member *m);
|
||||
void free_members(struct member_list *members);
|
||||
@@ -267,6 +270,9 @@ void free_userspec(struct userspec *us);
|
||||
void free_userspecs(struct userspec_list *usl);
|
||||
void free_default(struct defaults *def, struct member_list **binding);
|
||||
void free_defaults(struct defaults_list *defs);
|
||||
void init_parse_tree(struct sudoers_parse_tree *parse_tree);
|
||||
void free_parse_tree(struct sudoers_parse_tree *parse_tree);
|
||||
void reparent_parse_tree(struct sudoers_parse_tree *new_tree);
|
||||
|
||||
/* match_addr.c */
|
||||
bool addr_matches(char *n);
|
||||
@@ -280,13 +286,13 @@ bool hostname_matches(const char *shost, const char *lhost, const char *pattern)
|
||||
bool netgr_matches(const char *netgr, const char *lhost, const char *shost, const char *user);
|
||||
bool usergr_matches(const char *group, const char *user, const struct passwd *pw);
|
||||
bool userpw_matches(const char *sudoers_user, const char *user, const struct passwd *pw);
|
||||
int cmnd_matches(const struct member *m);
|
||||
int cmndlist_matches(const struct member_list *list);
|
||||
int host_matches(const struct passwd *pw, const char *host, const char *shost, const struct member *m);
|
||||
int hostlist_matches(const struct passwd *pw, const struct member_list *list);
|
||||
int runaslist_matches(const struct member_list *user_list, const struct member_list *group_list, struct member **matching_user, struct member **matching_group);
|
||||
int user_matches(const struct passwd *pw, const struct member *m);
|
||||
int userlist_matches(const struct passwd *pw, const struct member_list *list);
|
||||
int cmnd_matches(struct sudoers_parse_tree *parse_tree, const struct member *m);
|
||||
int cmndlist_matches(struct sudoers_parse_tree *parse_tree, const struct member_list *list);
|
||||
int host_matches(struct sudoers_parse_tree *parse_tree, const struct passwd *pw, const char *host, const char *shost, const struct member *m);
|
||||
int hostlist_matches(struct sudoers_parse_tree *parse_tree, const struct passwd *pw, const struct member_list *list);
|
||||
int runaslist_matches(struct sudoers_parse_tree *parse_tree, const struct member_list *user_list, const struct member_list *group_list, struct member **matching_user, struct member **matching_group);
|
||||
int user_matches(struct sudoers_parse_tree *parse_tree, const struct passwd *pw, const struct member *m);
|
||||
int userlist_matches(struct sudoers_parse_tree *parse_tree, const struct passwd *pw, const struct member_list *list);
|
||||
const char *sudo_getdomainname(void);
|
||||
|
||||
/* toke.c */
|
||||
@@ -322,12 +328,12 @@ int display_cmnd(struct sudo_nss_list *snl, struct passwd *pw);
|
||||
|
||||
/* fmtsudoers.c */
|
||||
struct sudo_lbuf;
|
||||
bool sudoers_format_cmndspec(struct sudo_lbuf *lbuf, struct cmndspec *cs, struct cmndspec *prev_cs, bool expand_aliases);
|
||||
bool sudoers_format_cmndspec(struct sudo_lbuf *lbuf, struct sudoers_parse_tree *parse_tree, struct cmndspec *cs, struct cmndspec *prev_cs, bool expand_aliases);
|
||||
bool sudoers_format_default(struct sudo_lbuf *lbuf, struct defaults *d);
|
||||
bool sudoers_format_default_line(struct sudo_lbuf *lbuf, struct defaults *d, struct defaults **next, bool expand_aliases);
|
||||
bool sudoers_format_member(struct sudo_lbuf *lbuf, struct member *m, const char *separator, int alias_type);
|
||||
bool sudoers_format_privilege(struct sudo_lbuf *lbuf, struct privilege *priv, bool expand_aliases);
|
||||
bool sudoers_format_userspec(struct sudo_lbuf *lbuf, struct userspec *us, bool expand_aliases);
|
||||
bool sudoers_format_userspecs(struct sudo_lbuf *lbuf, struct userspec_list *usl, const char *separator, bool expand_aliases, bool flush);
|
||||
bool sudoers_format_default_line(struct sudo_lbuf *lbuf, struct sudoers_parse_tree *parse_tree, struct defaults *d, struct defaults **next, bool expand_aliases);
|
||||
bool sudoers_format_member(struct sudo_lbuf *lbuf, struct sudoers_parse_tree *parse_tree, struct member *m, const char *separator, int alias_type);
|
||||
bool sudoers_format_privilege(struct sudo_lbuf *lbuf, struct sudoers_parse_tree *parse_tree, struct privilege *priv, bool expand_aliases);
|
||||
bool sudoers_format_userspec(struct sudo_lbuf *lbuf, struct sudoers_parse_tree *parse_tree, struct userspec *us, bool expand_aliases);
|
||||
bool sudoers_format_userspecs(struct sudo_lbuf *lbuf, struct sudoers_parse_tree *parse_tree, const char *separator, bool expand_aliases, bool flush);
|
||||
|
||||
#endif /* SUDOERS_PARSE_H */
|
||||
|
Reference in New Issue
Block a user