rename lh_ -> tq_
This commit is contained in:
2
alias.c
2
alias.c
@@ -114,7 +114,7 @@ alias_add(name, type, members)
|
|||||||
a = emalloc(sizeof(*a));
|
a = emalloc(sizeof(*a));
|
||||||
a->name = name;
|
a->name = name;
|
||||||
a->type = type;
|
a->type = type;
|
||||||
list2head(&a->members, members);
|
list2tq(&a->members, members);
|
||||||
if (rbinsert(aliases, a)) {
|
if (rbinsert(aliases, a)) {
|
||||||
efree(a);
|
efree(a);
|
||||||
snprintf(errbuf, sizeof(errbuf), "Alias `%s' already defined", name);
|
snprintf(errbuf, sizeof(errbuf), "Alias `%s' already defined", name);
|
||||||
|
@@ -501,7 +501,7 @@ update_defaults(skip_cmnd)
|
|||||||
{
|
{
|
||||||
struct defaults *def;
|
struct defaults *def;
|
||||||
|
|
||||||
lh_foreach_fwd(&defaults, def) {
|
tq_foreach_fwd(&defaults, def) {
|
||||||
if (skip_cmnd == (def->type == DEFAULTS_CMND))
|
if (skip_cmnd == (def->type == DEFAULTS_CMND))
|
||||||
continue;
|
continue;
|
||||||
switch (def->type) {
|
switch (def->type) {
|
||||||
|
50
gram.y
50
gram.y
@@ -242,8 +242,8 @@ privileges : privilege
|
|||||||
|
|
||||||
privilege : hostlist '=' cmndspeclist {
|
privilege : hostlist '=' cmndspeclist {
|
||||||
struct privilege *p = emalloc(sizeof(*p));
|
struct privilege *p = emalloc(sizeof(*p));
|
||||||
list2head(&p->hostlist, $1);
|
list2tq(&p->hostlist, $1);
|
||||||
list2head(&p->cmndlist, $3);
|
list2tq(&p->cmndlist, $3);
|
||||||
p->prev = p;
|
p->prev = p;
|
||||||
p->next = NULL;
|
p->next = NULL;
|
||||||
$$ = p;
|
$$ = p;
|
||||||
@@ -287,8 +287,8 @@ cmndspeclist : cmndspec
|
|||||||
$3->tags.noexec = $3->prev->tags.noexec;
|
$3->tags.noexec = $3->prev->tags.noexec;
|
||||||
if ($3->tags.setenv == UNSPEC)
|
if ($3->tags.setenv == UNSPEC)
|
||||||
$3->tags.setenv = $3->prev->tags.setenv;
|
$3->tags.setenv = $3->prev->tags.setenv;
|
||||||
if (lh_empty(&$3->runaslist) &&
|
if (tq_empty(&$3->runaslist) &&
|
||||||
!lh_empty(&$3->prev->runaslist))
|
!tq_empty(&$3->prev->runaslist))
|
||||||
$3->runaslist = $3->prev->runaslist;
|
$3->runaslist = $3->prev->runaslist;
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
@@ -296,7 +296,7 @@ cmndspeclist : cmndspec
|
|||||||
|
|
||||||
cmndspec : runasspec cmndtag opcmnd {
|
cmndspec : runasspec cmndtag opcmnd {
|
||||||
struct cmndspec *cs = emalloc(sizeof(*cs));
|
struct cmndspec *cs = emalloc(sizeof(*cs));
|
||||||
list2head(&cs->runaslist, $1);
|
list2tq(&cs->runaslist, $1);
|
||||||
cs->tags = $2;
|
cs->tags = $2;
|
||||||
cs->cmnd = $3;
|
cs->cmnd = $3;
|
||||||
cs->prev = cs;
|
cs->prev = cs;
|
||||||
@@ -506,7 +506,7 @@ new_default(var, val, op)
|
|||||||
d = emalloc(sizeof(struct defaults));
|
d = emalloc(sizeof(struct defaults));
|
||||||
d->var = var;
|
d->var = var;
|
||||||
d->val = val;
|
d->val = val;
|
||||||
lh_init(&d->binding);
|
tq_init(&d->binding);
|
||||||
d->type = 0;
|
d->type = 0;
|
||||||
d->op = op;
|
d->op = op;
|
||||||
d->prev = d;
|
d->prev = d;
|
||||||
@@ -549,9 +549,9 @@ add_defaults(type, binding, defs)
|
|||||||
*/
|
*/
|
||||||
for (d = defs; d != NULL; d = d->next) {
|
for (d = defs; d != NULL; d = d->next) {
|
||||||
d->type = type;
|
d->type = type;
|
||||||
list2head(&d->binding, binding);
|
list2tq(&d->binding, binding);
|
||||||
}
|
}
|
||||||
lh_append(&defaults, defs);
|
tq_append(&defaults, defs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -566,11 +566,11 @@ add_userspec(members, privs)
|
|||||||
struct userspec *u;
|
struct userspec *u;
|
||||||
|
|
||||||
u = emalloc(sizeof(*u));
|
u = emalloc(sizeof(*u));
|
||||||
list2head(&u->users, members);
|
list2tq(&u->users, members);
|
||||||
list2head(&u->privileges, privs);
|
list2tq(&u->privileges, privs);
|
||||||
u->prev = u;
|
u->prev = u;
|
||||||
u->next = NULL;
|
u->next = NULL;
|
||||||
lh_append(&userspecs, u);
|
tq_append(&userspecs, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -588,21 +588,21 @@ init_parser(path, quiet)
|
|||||||
struct privilege *priv;
|
struct privilege *priv;
|
||||||
struct cmndspec *cs;
|
struct cmndspec *cs;
|
||||||
|
|
||||||
while ((us = lh_pop(&userspecs)) != NULL) {
|
while ((us = tq_pop(&userspecs)) != NULL) {
|
||||||
while ((m = lh_pop(&us->users)) != NULL) {
|
while ((m = tq_pop(&us->users)) != NULL) {
|
||||||
efree(m->name);
|
efree(m->name);
|
||||||
efree(m);
|
efree(m);
|
||||||
}
|
}
|
||||||
while ((priv = lh_pop(&us->privileges)) != NULL) {
|
while ((priv = tq_pop(&us->privileges)) != NULL) {
|
||||||
while ((m = lh_pop(&priv->hostlist)) != NULL) {
|
while ((m = tq_pop(&priv->hostlist)) != NULL) {
|
||||||
efree(m->name);
|
efree(m->name);
|
||||||
efree(m);
|
efree(m);
|
||||||
}
|
}
|
||||||
freed = NULL;
|
freed = NULL;
|
||||||
while ((cs = lh_pop(&priv->cmndlist)) != NULL) {
|
while ((cs = tq_pop(&priv->cmndlist)) != NULL) {
|
||||||
if (lh_last(&cs->runaslist) != freed) {
|
if (tq_last(&cs->runaslist) != freed) {
|
||||||
freed = lh_last(&cs->runaslist);
|
freed = tq_last(&cs->runaslist);
|
||||||
while ((m = lh_pop(&cs->runaslist)) != NULL) {
|
while ((m = tq_pop(&cs->runaslist)) != NULL) {
|
||||||
efree(m->name);
|
efree(m->name);
|
||||||
efree(m);
|
efree(m);
|
||||||
}
|
}
|
||||||
@@ -614,13 +614,13 @@ init_parser(path, quiet)
|
|||||||
efree(priv);
|
efree(priv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lh_init(&userspecs);
|
tq_init(&userspecs);
|
||||||
|
|
||||||
freed = NULL;
|
freed = NULL;
|
||||||
while ((d = lh_pop(&defaults)) != NULL) {
|
while ((d = tq_pop(&defaults)) != NULL) {
|
||||||
if (lh_last(&d->binding) != freed) {
|
if (tq_last(&d->binding) != freed) {
|
||||||
freed = lh_last(&d->binding);
|
freed = tq_last(&d->binding);
|
||||||
while ((m = lh_pop(&d->binding)) != NULL) {
|
while ((m = tq_pop(&d->binding)) != NULL) {
|
||||||
efree(m->name);
|
efree(m->name);
|
||||||
efree(m);
|
efree(m);
|
||||||
}
|
}
|
||||||
@@ -629,7 +629,7 @@ init_parser(path, quiet)
|
|||||||
efree(d->val);
|
efree(d->val);
|
||||||
efree(d);
|
efree(d);
|
||||||
}
|
}
|
||||||
lh_init(&defaults);
|
tq_init(&defaults);
|
||||||
|
|
||||||
init_aliases();
|
init_aliases();
|
||||||
|
|
||||||
|
8
list.c
8
list.c
@@ -51,13 +51,13 @@ struct list_head_proto {
|
|||||||
* Returns the popped element.
|
* Returns the popped element.
|
||||||
*/
|
*/
|
||||||
void *
|
void *
|
||||||
lh_pop(vh)
|
tq_pop(vh)
|
||||||
void *vh;
|
void *vh;
|
||||||
{
|
{
|
||||||
struct list_head_proto *h = (struct list_head_proto *)vh;
|
struct list_head_proto *h = (struct list_head_proto *)vh;
|
||||||
void *last = NULL;
|
void *last = NULL;
|
||||||
|
|
||||||
if (!lh_empty(h)) {
|
if (!tq_empty(h)) {
|
||||||
last = (void *)h->last;
|
last = (void *)h->last;
|
||||||
if (h->first == h->last) {
|
if (h->first == h->last) {
|
||||||
h->first = NULL;
|
h->first = NULL;
|
||||||
@@ -75,7 +75,7 @@ lh_pop(vh)
|
|||||||
* with a head node.
|
* with a head node.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
list2head(vh, vl)
|
list2tq(vh, vl)
|
||||||
void *vh;
|
void *vh;
|
||||||
void *vl;
|
void *vl;
|
||||||
{
|
{
|
||||||
@@ -115,7 +115,7 @@ list_append(vl1, vl2)
|
|||||||
* e from a semi-circle queue to normal doubly-linked list.
|
* e from a semi-circle queue to normal doubly-linked list.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
lh_append(vh, vl)
|
tq_append(vh, vl)
|
||||||
void *vh;
|
void *vh;
|
||||||
void *vl;
|
void *vl;
|
||||||
{
|
{
|
||||||
|
34
list.h
34
list.h
@@ -23,13 +23,13 @@
|
|||||||
* Convenience macro for declaring a list head.
|
* Convenience macro for declaring a list head.
|
||||||
*/
|
*/
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
#define LH_DECLARE(n) \
|
#define TQ_DECLARE(n) \
|
||||||
struct n##_list { \
|
struct n##_list { \
|
||||||
struct n *first; \
|
struct n *first; \
|
||||||
struct n *last; \
|
struct n *last; \
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
#define LH_DECLARE(n) \
|
#define TQ_DECLARE(n) \
|
||||||
struct n/**/_list { \
|
struct n/**/_list { \
|
||||||
struct n *first; \
|
struct n *first; \
|
||||||
struct n *last; \
|
struct n *last; \
|
||||||
@@ -39,19 +39,19 @@ struct n/**/_list { \
|
|||||||
/*
|
/*
|
||||||
* Foreach loops: forward and reverse
|
* Foreach loops: forward and reverse
|
||||||
*/
|
*/
|
||||||
#undef lh_foreach_fwd
|
#undef tq_foreach_fwd
|
||||||
#define lh_foreach_fwd(h, v) \
|
#define tq_foreach_fwd(h, v) \
|
||||||
for ((v) = (h)->first; (v) != NULL; (v) = (v)->next)
|
for ((v) = (h)->first; (v) != NULL; (v) = (v)->next)
|
||||||
|
|
||||||
#undef lh_foreach_rev
|
#undef tq_foreach_rev
|
||||||
#define lh_foreach_rev(h, v) \
|
#define tq_foreach_rev(h, v) \
|
||||||
for ((v) = (h)->last; (v) != NULL; (v) = (v)->prev)
|
for ((v) = (h)->last; (v) != NULL; (v) = (v)->prev)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Init a list head.
|
* Init a list head.
|
||||||
*/
|
*/
|
||||||
#undef lh_init
|
#undef tq_init
|
||||||
#define lh_init(h) do { \
|
#define tq_init(h) do { \
|
||||||
(h)->first = NULL; \
|
(h)->first = NULL; \
|
||||||
(h)->last = NULL; \
|
(h)->last = NULL; \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -59,14 +59,14 @@ struct n/**/_list { \
|
|||||||
/*
|
/*
|
||||||
* Simple macros to avoid exposing first/last and prev/next.
|
* Simple macros to avoid exposing first/last and prev/next.
|
||||||
*/
|
*/
|
||||||
#undef lh_empty
|
#undef tq_empty
|
||||||
#define lh_empty(h) ((h)->first == NULL)
|
#define tq_empty(h) ((h)->first == NULL)
|
||||||
|
|
||||||
#undef lh_first
|
#undef tq_first
|
||||||
#define lh_first(h) ((h)->first)
|
#define tq_first(h) ((h)->first)
|
||||||
|
|
||||||
#undef lh_last
|
#undef tq_last
|
||||||
#define lh_last(h) ((h)->last)
|
#define tq_last(h) ((h)->last)
|
||||||
|
|
||||||
#undef list_next
|
#undef list_next
|
||||||
#define list_next(e) ((e)->next)
|
#define list_next(e) ((e)->next)
|
||||||
@@ -77,9 +77,9 @@ struct n/**/_list { \
|
|||||||
/*
|
/*
|
||||||
* Prototypes for list.c
|
* Prototypes for list.c
|
||||||
*/
|
*/
|
||||||
void *lh_pop __P((void *));
|
void *tq_pop __P((void *));
|
||||||
void lh_append __P((void *, void *));
|
void tq_append __P((void *, void *));
|
||||||
void list_append __P((void *, void *));
|
void list_append __P((void *, void *));
|
||||||
void list2head __P((void *, void *));
|
void list2tq __P((void *, void *));
|
||||||
|
|
||||||
#endif /* _SUDO_LIST_H */
|
#endif /* _SUDO_LIST_H */
|
||||||
|
10
match.c
10
match.c
@@ -111,7 +111,7 @@ userlist_matches(pw, list)
|
|||||||
struct alias *a;
|
struct alias *a;
|
||||||
int rval, matched = UNSPEC;
|
int rval, matched = UNSPEC;
|
||||||
|
|
||||||
lh_foreach_rev(list, m) {
|
tq_foreach_rev(list, m) {
|
||||||
switch (m->type) {
|
switch (m->type) {
|
||||||
case ALL:
|
case ALL:
|
||||||
matched = !m->negated;
|
matched = !m->negated;
|
||||||
@@ -156,10 +156,10 @@ runaslist_matches(list)
|
|||||||
struct alias *a;
|
struct alias *a;
|
||||||
int rval, matched = UNSPEC;
|
int rval, matched = UNSPEC;
|
||||||
|
|
||||||
if (lh_empty(list))
|
if (tq_empty(list))
|
||||||
return(userpw_matches(def_runas_default, runas_pw->pw_name, runas_pw));
|
return(userpw_matches(def_runas_default, runas_pw->pw_name, runas_pw));
|
||||||
|
|
||||||
lh_foreach_rev(list, m) {
|
tq_foreach_rev(list, m) {
|
||||||
switch (m->type) {
|
switch (m->type) {
|
||||||
case ALL:
|
case ALL:
|
||||||
matched = !m->negated;
|
matched = !m->negated;
|
||||||
@@ -203,7 +203,7 @@ hostlist_matches(list)
|
|||||||
struct alias *a;
|
struct alias *a;
|
||||||
int rval, matched = UNSPEC;
|
int rval, matched = UNSPEC;
|
||||||
|
|
||||||
lh_foreach_rev(list, m) {
|
tq_foreach_rev(list, m) {
|
||||||
switch (m->type) {
|
switch (m->type) {
|
||||||
case ALL:
|
case ALL:
|
||||||
matched = !m->negated;
|
matched = !m->negated;
|
||||||
@@ -278,7 +278,7 @@ cmndlist_matches(list)
|
|||||||
struct member *m;
|
struct member *m;
|
||||||
int rval, matched = UNSPEC;
|
int rval, matched = UNSPEC;
|
||||||
|
|
||||||
lh_foreach_rev(list, m) {
|
tq_foreach_rev(list, m) {
|
||||||
rval = cmnd_matches(m);
|
rval = cmnd_matches(m);
|
||||||
if (rval != UNSPEC) {
|
if (rval != UNSPEC) {
|
||||||
matched = m->negated ? !rval : rval;
|
matched = m->negated ? !rval : rval;
|
||||||
|
44
parse.c
44
parse.c
@@ -109,13 +109,13 @@ sudoers_lookup(pwflag)
|
|||||||
CLR(validated, FLAG_NO_USER);
|
CLR(validated, FLAG_NO_USER);
|
||||||
CLR(validated, FLAG_NO_HOST);
|
CLR(validated, FLAG_NO_HOST);
|
||||||
match = DENY;
|
match = DENY;
|
||||||
lh_foreach_rev(&userspecs, us) {
|
tq_foreach_rev(&userspecs, us) {
|
||||||
if (userlist_matches(sudo_user.pw, &us->users) != ALLOW)
|
if (userlist_matches(sudo_user.pw, &us->users) != ALLOW)
|
||||||
continue;
|
continue;
|
||||||
lh_foreach_rev(&us->privileges, priv) {
|
tq_foreach_rev(&us->privileges, priv) {
|
||||||
if (hostlist_matches(&priv->hostlist) != ALLOW)
|
if (hostlist_matches(&priv->hostlist) != ALLOW)
|
||||||
continue;
|
continue;
|
||||||
lh_foreach_rev(&priv->cmndlist, cs) {
|
tq_foreach_rev(&priv->cmndlist, cs) {
|
||||||
/* Only check the command when listing another user. */
|
/* Only check the command when listing another user. */
|
||||||
if (user_uid == 0 || list_pw == NULL ||
|
if (user_uid == 0 || list_pw == NULL ||
|
||||||
user_uid == list_pw->pw_uid ||
|
user_uid == list_pw->pw_uid ||
|
||||||
@@ -146,17 +146,17 @@ sudoers_lookup(pwflag)
|
|||||||
set_perms(PERM_RUNAS);
|
set_perms(PERM_RUNAS);
|
||||||
|
|
||||||
match = UNSPEC;
|
match = UNSPEC;
|
||||||
lh_foreach_rev(&userspecs, us) {
|
tq_foreach_rev(&userspecs, us) {
|
||||||
if (userlist_matches(sudo_user.pw, &us->users) != ALLOW)
|
if (userlist_matches(sudo_user.pw, &us->users) != ALLOW)
|
||||||
continue;
|
continue;
|
||||||
CLR(validated, FLAG_NO_USER);
|
CLR(validated, FLAG_NO_USER);
|
||||||
lh_foreach_rev(&us->privileges, priv) {
|
tq_foreach_rev(&us->privileges, priv) {
|
||||||
host_match = hostlist_matches(&priv->hostlist);
|
host_match = hostlist_matches(&priv->hostlist);
|
||||||
if (host_match == ALLOW)
|
if (host_match == ALLOW)
|
||||||
CLR(validated, FLAG_NO_HOST);
|
CLR(validated, FLAG_NO_HOST);
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
lh_foreach_rev(&priv->cmndlist, cs) {
|
tq_foreach_rev(&priv->cmndlist, cs) {
|
||||||
runas_match = runaslist_matches(&cs->runaslist);
|
runas_match = runaslist_matches(&cs->runaslist);
|
||||||
if (runas_match == ALLOW) {
|
if (runas_match == ALLOW) {
|
||||||
cmnd_match = cmnd_matches(cs->cmnd);
|
cmnd_match = cmnd_matches(cs->cmnd);
|
||||||
@@ -224,24 +224,24 @@ display_privs(v, pw)
|
|||||||
printf("User %s may run the following commands on this host:\n",
|
printf("User %s may run the following commands on this host:\n",
|
||||||
pw->pw_name);
|
pw->pw_name);
|
||||||
|
|
||||||
lh_foreach_fwd(&userspecs, us) {
|
tq_foreach_fwd(&userspecs, us) {
|
||||||
/* XXX - why only check the first privilege here? */
|
/* XXX - why only check the first privilege here? */
|
||||||
if (userlist_matches(pw, &us->users) != ALLOW ||
|
if (userlist_matches(pw, &us->users) != ALLOW ||
|
||||||
hostlist_matches(&us->privileges.first->hostlist) != ALLOW)
|
hostlist_matches(&us->privileges.first->hostlist) != ALLOW)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
lh_foreach_fwd(&us->privileges, priv) {
|
tq_foreach_fwd(&us->privileges, priv) {
|
||||||
tags.noexec = def_noexec;
|
tags.noexec = def_noexec;
|
||||||
tags.setenv = def_setenv;
|
tags.setenv = def_setenv;
|
||||||
tags.nopasswd = !def_authenticate;
|
tags.nopasswd = !def_authenticate;
|
||||||
lbuf_append(&lbuf, " ", NULL);
|
lbuf_append(&lbuf, " ", NULL);
|
||||||
lh_foreach_fwd(&priv->cmndlist, cs) {
|
tq_foreach_fwd(&priv->cmndlist, cs) {
|
||||||
if (cs != lh_first(&priv->cmndlist))
|
if (cs != tq_first(&priv->cmndlist))
|
||||||
lbuf_append(&lbuf, ", ", NULL);
|
lbuf_append(&lbuf, ", ", NULL);
|
||||||
lbuf_append(&lbuf, "(", NULL);
|
lbuf_append(&lbuf, "(", NULL);
|
||||||
if (!lh_empty(&cs->runaslist)) {
|
if (!tq_empty(&cs->runaslist)) {
|
||||||
lh_foreach_fwd(&cs->runaslist, m) {
|
tq_foreach_fwd(&cs->runaslist, m) {
|
||||||
if (m != lh_first(&cs->runaslist))
|
if (m != tq_first(&cs->runaslist))
|
||||||
lbuf_append(&lbuf, ", ", NULL);
|
lbuf_append(&lbuf, ", ", NULL);
|
||||||
print_member(&lbuf, m->name, m->type, m->negated,
|
print_member(&lbuf, m->name, m->type, m->negated,
|
||||||
RUNASALIAS);
|
RUNASALIAS);
|
||||||
@@ -294,7 +294,7 @@ display_defaults(pw)
|
|||||||
|
|
||||||
lbuf_init(&lbuf, NULL, 4, 0);
|
lbuf_init(&lbuf, NULL, 4, 0);
|
||||||
|
|
||||||
lh_foreach_fwd(&defaults, d) {
|
tq_foreach_fwd(&defaults, d) {
|
||||||
switch (d->type) {
|
switch (d->type) {
|
||||||
case DEFAULTS_HOST:
|
case DEFAULTS_HOST:
|
||||||
if (hostlist_matches(&d->binding) != ALLOW)
|
if (hostlist_matches(&d->binding) != ALLOW)
|
||||||
@@ -381,12 +381,12 @@ display_bound_defaults(dtype)
|
|||||||
}
|
}
|
||||||
lbuf_init(&lbuf, NULL, 4, 0);
|
lbuf_init(&lbuf, NULL, 4, 0);
|
||||||
printf("Per-%s Defaults entries:\n", dname);
|
printf("Per-%s Defaults entries:\n", dname);
|
||||||
lh_foreach_fwd(&defaults, d) {
|
tq_foreach_fwd(&defaults, d) {
|
||||||
if (d->type != dtype)
|
if (d->type != dtype)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (binding != lh_first(&d->binding)) {
|
if (binding != tq_first(&d->binding)) {
|
||||||
binding = lh_first(&d->binding);
|
binding = tq_first(&d->binding);
|
||||||
lbuf_append(&lbuf, " Defaults", dsep, NULL);
|
lbuf_append(&lbuf, " Defaults", dsep, NULL);
|
||||||
for (m = binding; m != NULL; m = m->next) {
|
for (m = binding; m != NULL; m = m->next) {
|
||||||
if (m != binding)
|
if (m != binding)
|
||||||
@@ -429,15 +429,15 @@ display_cmnd(v, pw)
|
|||||||
#endif
|
#endif
|
||||||
if (rval != 0 && !def_ignore_local_sudoers) {
|
if (rval != 0 && !def_ignore_local_sudoers) {
|
||||||
match = NULL;
|
match = NULL;
|
||||||
lh_foreach_rev(&userspecs, us) {
|
tq_foreach_rev(&userspecs, us) {
|
||||||
if (userlist_matches(pw, &us->users) != ALLOW)
|
if (userlist_matches(pw, &us->users) != ALLOW)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
lh_foreach_rev(&us->privileges, priv) {
|
tq_foreach_rev(&us->privileges, priv) {
|
||||||
host_match = hostlist_matches(&priv->hostlist);
|
host_match = hostlist_matches(&priv->hostlist);
|
||||||
if (host_match != ALLOW)
|
if (host_match != ALLOW)
|
||||||
continue;
|
continue;
|
||||||
lh_foreach_rev(&priv->cmndlist, cs) {
|
tq_foreach_rev(&priv->cmndlist, cs) {
|
||||||
runas_match = runaslist_matches(&cs->runaslist);
|
runas_match = runaslist_matches(&cs->runaslist);
|
||||||
if (runas_match == ALLOW) {
|
if (runas_match == ALLOW) {
|
||||||
cmnd_match = cmnd_matches(cs->cmnd);
|
cmnd_match = cmnd_matches(cs->cmnd);
|
||||||
@@ -489,8 +489,8 @@ print_member(lbuf, name, type, negated, alias_type)
|
|||||||
break;
|
break;
|
||||||
case ALIAS:
|
case ALIAS:
|
||||||
if ((a = find_alias(name, alias_type)) != NULL) {
|
if ((a = find_alias(name, alias_type)) != NULL) {
|
||||||
lh_foreach_fwd(&a->members, m) {
|
tq_foreach_fwd(&a->members, m) {
|
||||||
if (m != lh_first(&a->members))
|
if (m != tq_first(&a->members))
|
||||||
lbuf_append(lbuf, ", ", NULL);
|
lbuf_append(lbuf, ", ", NULL);
|
||||||
print_member(lbuf, m->name, m->type,
|
print_member(lbuf, m->name, m->type,
|
||||||
negated ? !m->negated : m->negated, alias_type);
|
negated ? !m->negated : m->negated, alias_type);
|
||||||
|
10
parse.h
10
parse.h
@@ -68,11 +68,11 @@ struct cmndtag {
|
|||||||
/*
|
/*
|
||||||
* Tail queue list head structure.
|
* Tail queue list head structure.
|
||||||
*/
|
*/
|
||||||
LH_DECLARE(defaults)
|
TQ_DECLARE(defaults)
|
||||||
LH_DECLARE(userspec)
|
TQ_DECLARE(userspec)
|
||||||
LH_DECLARE(member)
|
TQ_DECLARE(member)
|
||||||
LH_DECLARE(privilege)
|
TQ_DECLARE(privilege)
|
||||||
LH_DECLARE(cmndspec)
|
TQ_DECLARE(cmndspec)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure describing a user specification and list thereof.
|
* Structure describing a user specification and list thereof.
|
||||||
|
@@ -268,16 +268,16 @@ main(argc, argv)
|
|||||||
/* This loop must match the one in sudoers_lookup() */
|
/* This loop must match the one in sudoers_lookup() */
|
||||||
printf("\nEntries for user %s:\n", user_name);
|
printf("\nEntries for user %s:\n", user_name);
|
||||||
matched = UNSPEC;
|
matched = UNSPEC;
|
||||||
lh_foreach_rev(&userspecs, us) {
|
tq_foreach_rev(&userspecs, us) {
|
||||||
if (userlist_matches(sudo_user.pw, &us->users) != ALLOW)
|
if (userlist_matches(sudo_user.pw, &us->users) != ALLOW)
|
||||||
continue;
|
continue;
|
||||||
lh_foreach_rev(&us->privileges, priv) {
|
tq_foreach_rev(&us->privileges, priv) {
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
print_privilege(priv); /* XXX */
|
print_privilege(priv); /* XXX */
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if (hostlist_matches(&priv->hostlist) == ALLOW) {
|
if (hostlist_matches(&priv->hostlist) == ALLOW) {
|
||||||
puts("\thost matched");
|
puts("\thost matched");
|
||||||
lh_foreach_rev(&priv->cmndlist, cs) {
|
tq_foreach_rev(&priv->cmndlist, cs) {
|
||||||
if (runaslist_matches(&cs->runaslist) == ALLOW) {
|
if (runaslist_matches(&cs->runaslist) == ALLOW) {
|
||||||
puts("\trunas matched");
|
puts("\trunas matched");
|
||||||
rval = cmnd_matches(cs->cmnd);
|
rval = cmnd_matches(cs->cmnd);
|
||||||
@@ -385,7 +385,7 @@ print_defaults()
|
|||||||
struct defaults *d;
|
struct defaults *d;
|
||||||
struct member *m;
|
struct member *m;
|
||||||
|
|
||||||
lh_foreach_fwd(&defaults, d) {
|
tq_foreach_fwd(&defaults, d) {
|
||||||
(void) fputs("Defaults", stdout);
|
(void) fputs("Defaults", stdout);
|
||||||
switch (d->type) {
|
switch (d->type) {
|
||||||
case DEFAULTS_HOST:
|
case DEFAULTS_HOST:
|
||||||
@@ -401,8 +401,8 @@ print_defaults()
|
|||||||
putchar('!');
|
putchar('!');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lh_foreach_fwd(&d->binding, m) {
|
tq_foreach_fwd(&d->binding, m) {
|
||||||
if (m != lh_first(&d->binding))
|
if (m != tq_first(&d->binding))
|
||||||
putchar(',');
|
putchar(',');
|
||||||
print_member(m);
|
print_member(m);
|
||||||
}
|
}
|
||||||
@@ -436,8 +436,8 @@ print_alias(v1, v2)
|
|||||||
(void) printf("Runas_Alias\t%s = ", a->name);
|
(void) printf("Runas_Alias\t%s = ", a->name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lh_foreach_fwd(&a->members, m) {
|
tq_foreach_fwd(&a->members, m) {
|
||||||
if (m != lh_first(&a->members))
|
if (m != tq_first(&a->members))
|
||||||
fputs(", ", stdout);
|
fputs(", ", stdout);
|
||||||
if (m->type == COMMAND) {
|
if (m->type == COMMAND) {
|
||||||
c = (struct sudo_command *) m->name;
|
c = (struct sudo_command *) m->name;
|
||||||
@@ -462,20 +462,20 @@ print_privilege(priv)
|
|||||||
for (p = priv; p != NULL; p = p->next) {
|
for (p = priv; p != NULL; p = p->next) {
|
||||||
if (p != priv)
|
if (p != priv)
|
||||||
fputs(" : ", stdout);
|
fputs(" : ", stdout);
|
||||||
lh_foreach_fwd(&p->hostlist, m) {
|
tq_foreach_fwd(&p->hostlist, m) {
|
||||||
if (m != lh_first(&p->hostlist))
|
if (m != tq_first(&p->hostlist))
|
||||||
fputs(", ", stdout);
|
fputs(", ", stdout);
|
||||||
print_member(m);
|
print_member(m);
|
||||||
}
|
}
|
||||||
fputs(" = ", stdout);
|
fputs(" = ", stdout);
|
||||||
tags.nopasswd = tags.noexec = UNSPEC;
|
tags.nopasswd = tags.noexec = UNSPEC;
|
||||||
lh_foreach_fwd(&p->cmndlist, cs) {
|
tq_foreach_fwd(&p->cmndlist, cs) {
|
||||||
if (cs != lh_first(&p->cmndlist))
|
if (cs != tq_first(&p->cmndlist))
|
||||||
fputs(", ", stdout);
|
fputs(", ", stdout);
|
||||||
if (!lh_empty(&cs->runaslist)) {
|
if (!tq_empty(&cs->runaslist)) {
|
||||||
fputs("(", stdout);
|
fputs("(", stdout);
|
||||||
lh_foreach_fwd(&cs->runaslist, m) {
|
tq_foreach_fwd(&cs->runaslist, m) {
|
||||||
if (m != lh_first(&cs->runaslist))
|
if (m != tq_first(&cs->runaslist))
|
||||||
fputs(", ", stdout);
|
fputs(", ", stdout);
|
||||||
print_member(m);
|
print_member(m);
|
||||||
}
|
}
|
||||||
@@ -497,9 +497,9 @@ print_userspecs()
|
|||||||
struct member *m;
|
struct member *m;
|
||||||
struct userspec *us;
|
struct userspec *us;
|
||||||
|
|
||||||
lh_foreach_fwd(&userspecs, us) {
|
tq_foreach_fwd(&userspecs, us) {
|
||||||
lh_foreach_fwd(&us->users, m) {
|
tq_foreach_fwd(&us->users, m) {
|
||||||
if (m != lh_first(&us->users))
|
if (m != tq_first(&us->users))
|
||||||
fputs(", ", stdout);
|
fputs(", ", stdout);
|
||||||
print_member(m);
|
print_member(m);
|
||||||
}
|
}
|
||||||
|
40
visudo.c
40
visudo.c
@@ -213,8 +213,8 @@ main(argc, argv)
|
|||||||
setup_signals();
|
setup_signals();
|
||||||
|
|
||||||
/* Edit the sudoers file(s) */
|
/* Edit the sudoers file(s) */
|
||||||
lh_foreach_fwd(&sudoerslist, sp) {
|
tq_foreach_fwd(&sudoerslist, sp) {
|
||||||
if (sp != lh_first(&sudoerslist)) {
|
if (sp != tq_first(&sudoerslist)) {
|
||||||
printf("press return to edit %s: ", sp->path);
|
printf("press return to edit %s: ", sp->path);
|
||||||
while ((ch = getchar()) != EOF && ch != '\n')
|
while ((ch = getchar()) != EOF && ch != '\n')
|
||||||
continue;
|
continue;
|
||||||
@@ -226,7 +226,7 @@ main(argc, argv)
|
|||||||
reparse_sudoers(editor, args, strict, quiet);
|
reparse_sudoers(editor, args, strict, quiet);
|
||||||
|
|
||||||
/* Install the sudoers temp files. */
|
/* Install the sudoers temp files. */
|
||||||
lh_foreach_fwd(&sudoerslist, sp) {
|
tq_foreach_fwd(&sudoerslist, sp) {
|
||||||
if (!sp->modified)
|
if (!sp->modified)
|
||||||
(void) unlink(sp->tpath);
|
(void) unlink(sp->tpath);
|
||||||
else
|
else
|
||||||
@@ -401,8 +401,8 @@ reparse_sudoers(editor, args, strict, quiet)
|
|||||||
* Parse the edited sudoers files and do sanity checking
|
* Parse the edited sudoers files and do sanity checking
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
sp = lh_first(&sudoerslist);
|
sp = tq_first(&sudoerslist);
|
||||||
last = lh_last(&sudoerslist);
|
last = tq_last(&sudoerslist);
|
||||||
fp = fopen(sp->tpath, "r+");
|
fp = fopen(sp->tpath, "r+");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
errorx(1, "can't re-open temporary file (%s), %s unchanged.",
|
errorx(1, "can't re-open temporary file (%s), %s unchanged.",
|
||||||
@@ -438,7 +438,7 @@ reparse_sudoers(editor, args, strict, quiet)
|
|||||||
}
|
}
|
||||||
if (parse_error) {
|
if (parse_error) {
|
||||||
/* Edit file with the parse error */
|
/* Edit file with the parse error */
|
||||||
lh_foreach_fwd(&sudoerslist, sp) {
|
tq_foreach_fwd(&sudoerslist, sp) {
|
||||||
if (errorfile == NULL || strcmp(sp->path, errorfile) == 0) {
|
if (errorfile == NULL || strcmp(sp->path, errorfile) == 0) {
|
||||||
edit_sudoers(sp, editor, args, errorlineno);
|
edit_sudoers(sp, editor, args, errorlineno);
|
||||||
break;
|
break;
|
||||||
@@ -725,7 +725,7 @@ open_sudoers(path, keepopen)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
/* Check for existing entry */
|
/* Check for existing entry */
|
||||||
lh_foreach_fwd(&sudoerslist, entry) {
|
tq_foreach_fwd(&sudoerslist, entry) {
|
||||||
if (strcmp(path, entry->path) == 0)
|
if (strcmp(path, entry->path) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -903,8 +903,8 @@ check_aliases(strict)
|
|||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
/* Forward check. */
|
/* Forward check. */
|
||||||
lh_foreach_fwd(&userspecs, us) {
|
tq_foreach_fwd(&userspecs, us) {
|
||||||
lh_foreach_fwd(&us->users, m) {
|
tq_foreach_fwd(&us->users, m) {
|
||||||
if (m->type == USERALIAS) {
|
if (m->type == USERALIAS) {
|
||||||
if (find_alias(m->name, m->type) == NULL) {
|
if (find_alias(m->name, m->type) == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -914,8 +914,8 @@ check_aliases(strict)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lh_foreach_fwd(&us->privileges, priv) {
|
tq_foreach_fwd(&us->privileges, priv) {
|
||||||
lh_foreach_fwd(&priv->hostlist, m) {
|
tq_foreach_fwd(&priv->hostlist, m) {
|
||||||
if (m->type == HOSTALIAS) {
|
if (m->type == HOSTALIAS) {
|
||||||
if (find_alias(m->name, m->type) == NULL) {
|
if (find_alias(m->name, m->type) == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -925,8 +925,8 @@ check_aliases(strict)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lh_foreach_fwd(&priv->cmndlist, cs) {
|
tq_foreach_fwd(&priv->cmndlist, cs) {
|
||||||
lh_foreach_fwd(&cs->runaslist, m) {
|
tq_foreach_fwd(&cs->runaslist, m) {
|
||||||
if (m->type == RUNASALIAS) {
|
if (m->type == RUNASALIAS) {
|
||||||
if (find_alias(m->name, m->type) == NULL) {
|
if (find_alias(m->name, m->type) == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -949,18 +949,18 @@ check_aliases(strict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Reverse check (destructive) */
|
/* Reverse check (destructive) */
|
||||||
lh_foreach_fwd(&userspecs, us) {
|
tq_foreach_fwd(&userspecs, us) {
|
||||||
lh_foreach_fwd(&us->users, m) {
|
tq_foreach_fwd(&us->users, m) {
|
||||||
if (m->type == USERALIAS)
|
if (m->type == USERALIAS)
|
||||||
(void) alias_remove(m->name, m->type);
|
(void) alias_remove(m->name, m->type);
|
||||||
}
|
}
|
||||||
lh_foreach_fwd(&us->privileges, priv) {
|
tq_foreach_fwd(&us->privileges, priv) {
|
||||||
lh_foreach_fwd(&priv->hostlist, m) {
|
tq_foreach_fwd(&priv->hostlist, m) {
|
||||||
if (m->type == HOSTALIAS)
|
if (m->type == HOSTALIAS)
|
||||||
(void) alias_remove(m->name, m->type);
|
(void) alias_remove(m->name, m->type);
|
||||||
}
|
}
|
||||||
lh_foreach_fwd(&priv->cmndlist, cs) {
|
tq_foreach_fwd(&priv->cmndlist, cs) {
|
||||||
lh_foreach_fwd(&cs->runaslist, m) {
|
tq_foreach_fwd(&cs->runaslist, m) {
|
||||||
if (m->type == RUNASALIAS)
|
if (m->type == RUNASALIAS)
|
||||||
(void) alias_remove(m->name, m->type);
|
(void) alias_remove(m->name, m->type);
|
||||||
}
|
}
|
||||||
@@ -1000,7 +1000,7 @@ cleanup(gotsignal)
|
|||||||
{
|
{
|
||||||
struct sudoersfile *sp;
|
struct sudoersfile *sp;
|
||||||
|
|
||||||
lh_foreach_fwd(&sudoerslist, sp) {
|
tq_foreach_fwd(&sudoerslist, sp) {
|
||||||
if (sp->tpath != NULL)
|
if (sp->tpath != NULL)
|
||||||
(void) unlink(sp->tpath);
|
(void) unlink(sp->tpath);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user