mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-30 13:58:05 +00:00
fix Runas_Alias stuff
Alias's in runas list now get expanded (but it is gross)
This commit is contained in:
55
parse.yacc
55
parse.yacc
@@ -323,6 +323,10 @@ runaslist : runasuser {
|
|||||||
|
|
||||||
runasuser : NAME {
|
runasuser : NAME {
|
||||||
$$ = (strcmp($1, runas_user) == 0);
|
$$ = (strcmp($1, runas_user) == 0);
|
||||||
|
if (printmatches == TRUE && in_alias == TRUE)
|
||||||
|
append($1, &ca_list[ca_list_len-1].entries,
|
||||||
|
&ca_list[ca_list_len-1].entries_len,
|
||||||
|
&ca_list[ca_list_len-1].entries_size, ',');
|
||||||
if (printmatches == TRUE && host_matches == TRUE &&
|
if (printmatches == TRUE && host_matches == TRUE &&
|
||||||
user_matches == TRUE)
|
user_matches == TRUE)
|
||||||
append($1, &cm_list[cm_list_len].runas,
|
append($1, &cm_list[cm_list_len].runas,
|
||||||
@@ -332,6 +336,10 @@ runasuser : NAME {
|
|||||||
}
|
}
|
||||||
| USERGROUP {
|
| USERGROUP {
|
||||||
$$ = usergr_matches($1, runas_user);
|
$$ = usergr_matches($1, runas_user);
|
||||||
|
if (printmatches == TRUE && in_alias == TRUE)
|
||||||
|
append($1, &ca_list[ca_list_len-1].entries,
|
||||||
|
&ca_list[ca_list_len-1].entries_len,
|
||||||
|
&ca_list[ca_list_len-1].entries_size, ',');
|
||||||
if (printmatches == TRUE && host_matches == TRUE &&
|
if (printmatches == TRUE && host_matches == TRUE &&
|
||||||
user_matches == TRUE) {
|
user_matches == TRUE) {
|
||||||
append("%", &cm_list[cm_list_len].runas,
|
append("%", &cm_list[cm_list_len].runas,
|
||||||
@@ -345,6 +353,10 @@ runasuser : NAME {
|
|||||||
}
|
}
|
||||||
| NETGROUP {
|
| NETGROUP {
|
||||||
$$ = netgr_matches($1, NULL, runas_user);
|
$$ = netgr_matches($1, NULL, runas_user);
|
||||||
|
if (printmatches == TRUE && in_alias == TRUE)
|
||||||
|
append($1, &ca_list[ca_list_len-1].entries,
|
||||||
|
&ca_list[ca_list_len-1].entries_len,
|
||||||
|
&ca_list[ca_list_len-1].entries_size, ',');
|
||||||
if (printmatches == TRUE && host_matches == TRUE &&
|
if (printmatches == TRUE && host_matches == TRUE &&
|
||||||
user_matches == TRUE) {
|
user_matches == TRUE) {
|
||||||
append("+", &cm_list[cm_list_len].runas,
|
append("+", &cm_list[cm_list_len].runas,
|
||||||
@@ -363,6 +375,10 @@ runasuser : NAME {
|
|||||||
$$ = TRUE;
|
$$ = TRUE;
|
||||||
else
|
else
|
||||||
$$ = FALSE;
|
$$ = FALSE;
|
||||||
|
if (printmatches == TRUE && in_alias == TRUE)
|
||||||
|
append($1, &ca_list[ca_list_len-1].entries,
|
||||||
|
&ca_list[ca_list_len-1].entries_len,
|
||||||
|
&ca_list[ca_list_len-1].entries_size, ',');
|
||||||
if (printmatches == TRUE && host_matches == TRUE &&
|
if (printmatches == TRUE && host_matches == TRUE &&
|
||||||
user_matches == TRUE)
|
user_matches == TRUE)
|
||||||
append($1, &cm_list[cm_list_len].runas,
|
append($1, &cm_list[cm_list_len].runas,
|
||||||
@@ -372,6 +388,10 @@ runasuser : NAME {
|
|||||||
}
|
}
|
||||||
| ALL {
|
| ALL {
|
||||||
$$ = TRUE;
|
$$ = TRUE;
|
||||||
|
if (printmatches == TRUE && in_alias == TRUE)
|
||||||
|
append("ALL", &ca_list[ca_list_len-1].entries,
|
||||||
|
&ca_list[ca_list_len-1].entries_len,
|
||||||
|
&ca_list[ca_list_len-1].entries_size, ',');
|
||||||
if (printmatches == TRUE && host_matches == TRUE &&
|
if (printmatches == TRUE && host_matches == TRUE &&
|
||||||
user_matches == TRUE)
|
user_matches == TRUE)
|
||||||
append("ALL", &cm_list[cm_list_len].runas,
|
append("ALL", &cm_list[cm_list_len].runas,
|
||||||
@@ -516,11 +536,27 @@ runasaliases : runasalias
|
|||||||
| runasaliases ':' runasalias
|
| runasaliases ':' runasalias
|
||||||
;
|
;
|
||||||
|
|
||||||
runasalias : ALIAS { push; } '=' runaslist {
|
runasalias : ALIAS {
|
||||||
if (add_alias($1, RUNAS_ALIAS) == FALSE)
|
push;
|
||||||
|
if (printmatches == TRUE) {
|
||||||
|
in_alias = TRUE;
|
||||||
|
/* Allocate space for ca_list if necesary. */
|
||||||
|
expand_ca_list();
|
||||||
|
if (!(ca_list[ca_list_len-1].alias = strdup($1))){
|
||||||
|
perror("malloc");
|
||||||
|
(void) fprintf(stderr,
|
||||||
|
"%s: cannot allocate memory!\n", Argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} '=' runaslist {
|
||||||
|
if ($4 > 0 && add_alias($1, RUNAS_ALIAS) == FALSE)
|
||||||
YYERROR;
|
YYERROR;
|
||||||
pop;
|
pop;
|
||||||
(void) free($1);
|
(void) free($1);
|
||||||
|
|
||||||
|
if (printmatches == TRUE)
|
||||||
|
in_alias = FALSE;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -770,12 +806,19 @@ void list_matches()
|
|||||||
(void) fputs(" ", stdout);
|
(void) fputs(" ", stdout);
|
||||||
if (cm_list[i].runas) {
|
if (cm_list[i].runas) {
|
||||||
(void) putchar('(');
|
(void) putchar('(');
|
||||||
if ((p = strtok(cm_list[i].runas, ":")))
|
p = strtok(cm_list[i].runas, ":");
|
||||||
(void) fputs(p, stdout);
|
do {
|
||||||
while ((p = strtok(NULL, ":"))) {
|
if (p != cm_list[i].runas)
|
||||||
(void) fputs(", ", stdout);
|
(void) fputs(", ", stdout);
|
||||||
|
|
||||||
|
/* XXX - this is disgusting! Make ca_list generic? */
|
||||||
|
key.alias = p;
|
||||||
|
if ((ca = (struct command_alias *) lfind((VOID *) &key,
|
||||||
|
(VOID *) &ca_list[0], &ca_list_len, sizeof(key), cmndaliascmp)))
|
||||||
|
(void) fputs(ca->entries, stdout);
|
||||||
|
else
|
||||||
(void) fputs(p, stdout);
|
(void) fputs(p, stdout);
|
||||||
}
|
} while ((p = strtok(NULL, ":")));
|
||||||
(void) fputs(") ", stdout);
|
(void) fputs(") ", stdout);
|
||||||
} else {
|
} else {
|
||||||
(void) fputs("(root) ", stdout);
|
(void) fputs("(root) ", stdout);
|
||||||
|
Reference in New Issue
Block a user