From: Todd C. Miller Date: Tue, 18 Nov 2008 15:50:53 +0000 (+0000) Subject: fix check_aliases X-Git-Tag: SUDO_1_7_0~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d27ceff8eac8643a5d3b40fd208b986a67a59d3d;p=sudo fix check_aliases --- diff --git a/visudo.c b/visudo.c index c32cad841..e211d4565 100644 --- a/visudo.c +++ b/visudo.c @@ -921,8 +921,9 @@ check_aliases(strict) /* Forward check. */ tq_foreach_fwd(&userspecs, us) { tq_foreach_fwd(&us->users, m) { - if (m->type == USERALIAS) { - if (find_alias(m->name, m->type) == NULL) { + if (m->type == ALIAS) { + alias_seqno++; + if (find_alias(m->name, USERALIAS) == NULL) { warningx("%s: User_Alias `%s' referenced but not defined", strict ? "Error" : "Warning", m->name); error++; @@ -931,8 +932,9 @@ check_aliases(strict) } tq_foreach_fwd(&us->privileges, priv) { tq_foreach_fwd(&priv->hostlist, m) { - if (m->type == HOSTALIAS) { - if (find_alias(m->name, m->type) == NULL) { + if (m->type == ALIAS) { + alias_seqno++; + if (find_alias(m->name, HOSTALIAS) == NULL) { warningx("%s: Host_Alias `%s' referenced but not defined", strict ? "Error" : "Warning", m->name); error++; @@ -941,16 +943,18 @@ check_aliases(strict) } tq_foreach_fwd(&priv->cmndlist, cs) { tq_foreach_fwd(&cs->runasuserlist, m) { - if (m->type == RUNASALIAS) { - if (find_alias(m->name, m->type) == NULL) { + if (m->type == ALIAS) { + alias_seqno++; + if (find_alias(m->name, RUNASALIAS) == NULL) { warningx("%s: Runas_Alias `%s' referenced but not defined", strict ? "Error" : "Warning", m->name); error++; } } } - if ((m = cs->cmnd)->type == CMNDALIAS) { - if (find_alias(m->name, m->type) == NULL) { + if ((m = cs->cmnd)->type == ALIAS) { + alias_seqno++; + if (find_alias(m->name, CMNDALIAS) == NULL) { warningx("%s: Cmnd_Alias `%s' referenced but not defined", strict ? "Error" : "Warning", m->name); error++; @@ -963,21 +967,21 @@ check_aliases(strict) /* Reverse check (destructive) */ tq_foreach_fwd(&userspecs, us) { tq_foreach_fwd(&us->users, m) { - if (m->type == USERALIAS) - (void) alias_remove(m->name, m->type); + if (m->type == ALIAS) + (void) alias_remove(m->name, USERALIAS); } tq_foreach_fwd(&us->privileges, priv) { tq_foreach_fwd(&priv->hostlist, m) { - if (m->type == HOSTALIAS) - (void) alias_remove(m->name, m->type); + if (m->type == ALIAS) + (void) alias_remove(m->name, HOSTALIAS); } tq_foreach_fwd(&priv->cmndlist, cs) { tq_foreach_fwd(&cs->runasuserlist, m) { - if (m->type == RUNASALIAS) - (void) alias_remove(m->name, m->type); + if (m->type == ALIAS) + (void) alias_remove(m->name, RUNASALIAS); } - if ((m = cs->cmnd)->type == CMNDALIAS) - (void) alias_remove(m->name, m->type); + if ((m = cs->cmnd)->type == ALIAS) + (void) alias_remove(m->name, CMNDALIAS); } } }