Add sudoerserrorf(), a printf-style yyerror() function.
Use this to display a better error message when using a reserved work in an alias definition.
This commit is contained in:
@@ -122,6 +122,7 @@ alias_add(struct sudoers_parse_tree *parse_tree, char *name, int type,
|
||||
|
||||
if (parse_tree->aliases == NULL) {
|
||||
if ((parse_tree->aliases = alloc_aliases()) == NULL) {
|
||||
/* XXX - return error code instead */
|
||||
strlcpy(errbuf, N_("unable to allocate memory"), sizeof(errbuf));
|
||||
debug_return_str(errbuf);
|
||||
}
|
||||
@@ -129,6 +130,7 @@ alias_add(struct sudoers_parse_tree *parse_tree, char *name, int type,
|
||||
|
||||
a = calloc(1, sizeof(*a));
|
||||
if (a == NULL) {
|
||||
/* XXX - return error code instead */
|
||||
strlcpy(errbuf, N_("unable to allocate memory"), sizeof(errbuf));
|
||||
debug_return_str(errbuf);
|
||||
}
|
||||
@@ -141,11 +143,13 @@ alias_add(struct sudoers_parse_tree *parse_tree, char *name, int type,
|
||||
HLTQ_TO_TAILQ(&a->members, members, entries);
|
||||
switch (rbinsert(parse_tree->aliases, a, NULL)) {
|
||||
case 1:
|
||||
/* XXX - return error code instead, this is not translatable. */
|
||||
(void)snprintf(errbuf, sizeof(errbuf),
|
||||
N_("Alias \"%s\" already defined"), name);
|
||||
alias_free(a);
|
||||
debug_return_str(errbuf);
|
||||
case -1:
|
||||
/* XXX - return error code instead */
|
||||
(void)strlcpy(errbuf, N_("unable to allocate memory"), sizeof(errbuf));
|
||||
alias_free(a);
|
||||
debug_return_str(errbuf);
|
||||
|
Reference in New Issue
Block a user