Add struct sudoers_parser_config and pass it to init_parser().

This struct contains parser configuration such as the sudoers file
uid/gid/mode and parse flags such as verbose, strict and recovery.
This commit is contained in:
Todd C. Miller
2023-05-08 17:03:31 -06:00
parent fb9d0d79a7
commit 9d7c30c5a8
15 changed files with 604 additions and 477 deletions

View File

@@ -322,6 +322,26 @@ struct cmnd_info {
bool intercepted;
};
/*
* Parse configuration settings, passed to init_parser().
*/
struct sudoers_parser_config {
bool strict;
bool recovery;
int verbose;
mode_t sudoers_mode;
uid_t sudoers_uid;
gid_t sudoers_gid;
};
#define SUDOERS_PARSER_CONFIG_INITIALIZER { \
false, /* strict */ \
true, /* recovery */ \
1, /* verbose level 1 */ \
SUDOERS_MODE, \
SUDOERS_UID, \
SUDOERS_GID \
}
/*
* The parser passes pointers to data structures that are not stored anywhere.
* We add them to the leak list at allocation time and remove them from
@@ -372,7 +392,7 @@ int check_aliases(struct sudoers_parse_tree *parse_tree, bool strict, bool quiet
/* gram.y */
extern struct sudoers_parse_tree parsed_policy;
extern bool (*sudoers_error_hook)(const char *file, int line, int column, const char *fmt, va_list args);
bool init_parser(const char *file, const char *path, bool strict, int verbose);
bool init_parser(const char *file, const char *path, const struct sudoers_parser_config *conf);
bool reset_parser(void);
void free_member(struct member *m);
void free_members(struct member_list *members);