X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=plugins%2Fsudoers%2Falias.c;h=0b2ad0e064a52a8dbb65ef8c800d081dc35d13e0;hb=db542536bfb942d0168310cac588babc62657621;hp=274b446e1a19efe0d086042ff09ddc1fe32abc46;hpb=7a01b10fee894dea7ecb3252886912eab41e9693;p=debian%2Fsudo diff --git a/plugins/sudoers/alias.c b/plugins/sudoers/alias.c index 274b446..0b2ad0e 100644 --- a/plugins/sudoers/alias.c +++ b/plugins/sudoers/alias.c @@ -44,6 +44,7 @@ #include "parse.h" #include "redblack.h" #include +#include /* * Globals @@ -85,15 +86,19 @@ alias_find(char *name, int type) key.name = name; key.type = type; if ((node = rbfind(aliases, &key)) != NULL) { - /* - * Compare the global sequence number with the one stored - * in the alias. If they match then we've seen this alias - * before and found a loop. - */ - a = node->data; - if (a->seqno == alias_seqno) - return NULL; - a->seqno = alias_seqno; + /* + * Compare the global sequence number with the one stored + * in the alias. If they match then we've seen this alias + * before and found a loop. + */ + a = node->data; + if (a->seqno == alias_seqno) { + errno = ELOOP; + return NULL; + } + a->seqno = alias_seqno; + } else { + errno = ENOENT; } return a; } @@ -114,7 +119,7 @@ alias_add(char *name, int type, struct member *members) a->seqno = 0; list2tq(&a->members, members); if (rbinsert(aliases, a)) { - snprintf(errbuf, sizeof(errbuf), "Alias `%s' already defined", name); + snprintf(errbuf, sizeof(errbuf), _("Alias `%s' already defined"), name); alias_free(a); return errbuf; } @@ -175,8 +180,10 @@ alias_remove(char *name, int type) key.name = name; key.type = type; - if ((node = rbfind(aliases, &key)) == NULL) + if ((node = rbfind(aliases, &key)) == NULL) { + errno = ENOENT; return NULL; + } return rbdelete(aliases, node); }