cvtsudoers: merge aliases when multiple sudoers files are specified

Duplicate aliases are remove.  If there are conflicting alias names,
the conflicts are renamed by appending a numerical suffix.
For example, if there are two SERVERS Host_Aliases, the second one
will be renamed to SERVERS_1.
This commit is contained in:
Todd C. Miller
2021-11-19 12:29:21 -07:00
parent 33fbf59467
commit ab9e44a6ca
7 changed files with 600 additions and 27 deletions

View File

@@ -227,14 +227,14 @@ alias_free(void *v)
* Find the named alias, remove it from the tree and return it.
*/
struct alias *
alias_remove(struct sudoers_parse_tree *parse_tree, char *name, int type)
alias_remove(struct sudoers_parse_tree *parse_tree, const char *name, int type)
{
struct rbnode *node;
struct alias key;
debug_decl(alias_remove, SUDOERS_DEBUG_ALIAS);
if (parse_tree->aliases != NULL) {
key.name = name;
key.name = (char *)name;
key.type = type;
if ((node = rbfind(parse_tree->aliases, &key)) != NULL)
debug_return_ptr(rbdelete(parse_tree->aliases, node));