mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-03 15:55:40 +00:00
Expand aliases in "sudo -l" mode
This commit is contained in:
52
parse.c
52
parse.c
@@ -59,6 +59,11 @@ static const char rcsid[] = "$Sudo$";
|
|||||||
*/
|
*/
|
||||||
extern struct userspec *userspecs;
|
extern struct userspec *userspecs;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local prototypes.
|
||||||
|
*/
|
||||||
|
static void print_member __P((char *, int, int, int));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the specified sudoers file.
|
* Parse the specified sudoers file.
|
||||||
*/
|
*/
|
||||||
@@ -211,7 +216,7 @@ display_privs(pw)
|
|||||||
for (m = runas; m != NULL; m = m->next) {
|
for (m = runas; m != NULL; m = m->next) {
|
||||||
if (m != runas)
|
if (m != runas)
|
||||||
fputs(", ", stdout);
|
fputs(", ", stdout);
|
||||||
print_member(m);
|
print_member(m->name, m->type, m->negated, RUNASALIAS);
|
||||||
}
|
}
|
||||||
fputs(") ", stdout);
|
fputs(") ", stdout);
|
||||||
}
|
}
|
||||||
@@ -221,7 +226,8 @@ display_privs(pw)
|
|||||||
printf("%sEXEC: ", cs->tags.noexec ? "NO" : "");
|
printf("%sEXEC: ", cs->tags.noexec ? "NO" : "");
|
||||||
if (cs->tags.nopasswd != UNSPEC && cs->tags.nopasswd != !def_authenticate)
|
if (cs->tags.nopasswd != UNSPEC && cs->tags.nopasswd != !def_authenticate)
|
||||||
printf("%sPASSWD: ", cs->tags.nopasswd ? "NO" : "");
|
printf("%sPASSWD: ", cs->tags.nopasswd ? "NO" : "");
|
||||||
print_member(cs->cmnd);
|
m = cs->cmnd;
|
||||||
|
print_member(m->name, m->type, m->negated, CMNDALIAS);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,21 +236,37 @@ display_privs(pw)
|
|||||||
/*
|
/*
|
||||||
* Print the contents of a struct member to stdout
|
* Print the contents of a struct member to stdout
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
print_member(m)
|
print_member(name, type, negated, alias_type)
|
||||||
struct member *m;
|
char *name;
|
||||||
|
int type, negated, alias_type;
|
||||||
{
|
{
|
||||||
|
struct alias *a;
|
||||||
|
struct member *m;
|
||||||
struct sudo_command *c;
|
struct sudo_command *c;
|
||||||
|
|
||||||
if (m->negated)
|
switch (type) {
|
||||||
printf("!");
|
case ALL:
|
||||||
if (m->name == NULL)
|
printf("%sALL", negated ? "!" : "");
|
||||||
printf("ALL");
|
break;
|
||||||
else if (m->type != COMMAND)
|
case COMMAND:
|
||||||
printf("%s", m->name);
|
c = (struct sudo_command *) name;
|
||||||
else {
|
printf("%s%s%s%s", negated ? "!" : "", c->cmnd, c->args ? " " : "",
|
||||||
c = (struct sudo_command *) m->name;
|
c->args ? c->args : "");
|
||||||
printf("%s%s%s", c->cmnd, c->args ? " " : "",
|
break;
|
||||||
c->args ? c->args : "");
|
case ALIAS:
|
||||||
|
if ((a = find_alias(name, alias_type)) != NULL) {
|
||||||
|
for (m = a->first_member; m != NULL; m = m->next) {
|
||||||
|
if (m != a->first_member)
|
||||||
|
fputs(", ", stdout);
|
||||||
|
print_member(m->name, m->type,
|
||||||
|
negated ? !m->negated : m->negated, alias_type);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
default:
|
||||||
|
printf("%s%s", negated ? "!" : "", name);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
parse.h
1
parse.h
@@ -169,6 +169,5 @@ int userpw_matches __P((char *, char *, struct passwd *));
|
|||||||
struct alias *find_alias __P((char *, int));
|
struct alias *find_alias __P((char *, int));
|
||||||
void alias_apply __P((int (*)(VOID *, VOID *), VOID *));
|
void alias_apply __P((int (*)(VOID *, VOID *), VOID *));
|
||||||
void init_parser __P((char *, int));
|
void init_parser __P((char *, int));
|
||||||
void print_member __P((struct member *m));
|
|
||||||
|
|
||||||
#endif /* _SUDO_PARSE_H */
|
#endif /* _SUDO_PARSE_H */
|
||||||
|
Reference in New Issue
Block a user