2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-01 06:45:10 +00:00
This commit is contained in:
Todd C. Miller
2002-11-28 23:43:35 +00:00
parent 5bf742d282
commit d26b608279

View File

@@ -594,7 +594,7 @@ short *yyss;
short *yysslim; short *yysslim;
YYSTYPE *yyvs; YYSTYPE *yyvs;
int yystacksize; int yystacksize;
#line 844 "parse.yacc" #line 854 "parse.yacc"
#define MOREALIASES (32) #define MOREALIASES (32)
aliasinfo *aliases = NULL; aliasinfo *aliases = NULL;
@@ -754,21 +754,21 @@ dumpaliases()
void void
list_matches() list_matches()
{ {
int i; size_t count;
char *p; char *p;
struct generic_alias *ga, key; struct generic_alias *ga, key;
(void) printf("User %s may run the following commands on this host:\n", (void) printf("User %s may run the following commands on this host:\n",
user_name); user_name);
for (i = 0; i < cm_list_len; i++) { for (count = 0; count < cm_list_len; count++) {
/* Print the runas list. */ /* Print the runas list. */
(void) fputs(" ", stdout); (void) fputs(" ", stdout);
if (cm_list[i].runas) { if (cm_list[count].runas) {
(void) putchar('('); (void) putchar('(');
p = strtok(cm_list[i].runas, ", "); p = strtok(cm_list[count].runas, ", ");
do { do {
if (p != cm_list[i].runas) if (p != cm_list[count].runas)
(void) fputs(", ", stdout); (void) fputs(", ", stdout);
key.alias = p; key.alias = p;
@@ -785,32 +785,32 @@ list_matches()
} }
/* Is a password required? */ /* Is a password required? */
if (cm_list[i].nopasswd == TRUE && def_flag(I_AUTHENTICATE)) if (cm_list[count].nopasswd == TRUE && def_flag(I_AUTHENTICATE))
(void) fputs("NOPASSWD: ", stdout); (void) fputs("NOPASSWD: ", stdout);
else if (cm_list[i].nopasswd == FALSE && !def_flag(I_AUTHENTICATE)) else if (cm_list[count].nopasswd == FALSE && !def_flag(I_AUTHENTICATE))
(void) fputs("PASSWD: ", stdout); (void) fputs("PASSWD: ", stdout);
/* Print the actual command or expanded Cmnd_Alias. */ /* Print the actual command or expanded Cmnd_Alias. */
key.alias = cm_list[i].cmnd; key.alias = cm_list[count].cmnd;
key.type = CMND_ALIAS; key.type = CMND_ALIAS;
if ((ga = (struct generic_alias *) lfind((VOID *) &key, if ((ga = (struct generic_alias *) lfind((VOID *) &key,
(VOID *) &ga_list[0], &ga_list_len, sizeof(key), genaliascmp))) (VOID *) &ga_list[0], &ga_list_len, sizeof(key), genaliascmp)))
(void) puts(ga->entries); (void) puts(ga->entries);
else else
(void) puts(cm_list[i].cmnd); (void) puts(cm_list[count].cmnd);
} }
/* Be nice and free up space now that we are done. */ /* Be nice and free up space now that we are done. */
for (i = 0; i < ga_list_len; i++) { for (count = 0; count < ga_list_len; count++) {
free(ga_list[i].alias); free(ga_list[count].alias);
free(ga_list[i].entries); free(ga_list[count].entries);
} }
free(ga_list); free(ga_list);
ga_list = NULL; ga_list = NULL;
for (i = 0; i < cm_list_len; i++) { for (count = 0; count < cm_list_len; count++) {
free(cm_list[i].runas); free(cm_list[count].runas);
free(cm_list[i].cmnd); free(cm_list[count].cmnd);
} }
free(cm_list); free(cm_list);
cm_list = NULL; cm_list = NULL;
@@ -1693,13 +1693,15 @@ case 62:
#line 707 "parse.yacc" #line 707 "parse.yacc"
{ {
if ((host_matches != -1 || pedantic) && if ((host_matches != -1 || pedantic) &&
!add_alias(yyvsp[-3].string, HOST_ALIAS, host_matches)) !add_alias(yyvsp[-3].string, HOST_ALIAS, host_matches)) {
yyerror(NULL);
YYERROR; YYERROR;
}
pop; pop;
} }
break; break;
case 67: case 67:
#line 723 "parse.yacc" #line 725 "parse.yacc"
{ {
push; push;
if (printmatches == TRUE) { if (printmatches == TRUE) {
@@ -1712,11 +1714,13 @@ case 67:
} }
break; break;
case 68: case 68:
#line 732 "parse.yacc" #line 734 "parse.yacc"
{ {
if ((cmnd_matches != -1 || pedantic) && if ((cmnd_matches != -1 || pedantic) &&
!add_alias(yyvsp[-3].string, CMND_ALIAS, cmnd_matches)) !add_alias(yyvsp[-3].string, CMND_ALIAS, cmnd_matches)) {
yyerror(NULL);
YYERROR; YYERROR;
}
pop; pop;
free(yyvsp[-3].string); free(yyvsp[-3].string);
@@ -1725,11 +1729,11 @@ case 68:
} }
break; break;
case 69: case 69:
#line 744 "parse.yacc" #line 748 "parse.yacc"
{ ; } { ; }
break; break;
case 73: case 73:
#line 752 "parse.yacc" #line 756 "parse.yacc"
{ {
if (printmatches == TRUE) { if (printmatches == TRUE) {
in_alias = TRUE; in_alias = TRUE;
@@ -1741,11 +1745,13 @@ case 73:
} }
break; break;
case 74: case 74:
#line 760 "parse.yacc" #line 764 "parse.yacc"
{ {
if ((yyvsp[0].BOOLEAN != -1 || pedantic) && if ((yyvsp[0].BOOLEAN != -1 || pedantic) &&
!add_alias(yyvsp[-3].string, RUNAS_ALIAS, yyvsp[0].BOOLEAN)) !add_alias(yyvsp[-3].string, RUNAS_ALIAS, yyvsp[0].BOOLEAN)) {
yyerror(NULL);
YYERROR; YYERROR;
}
free(yyvsp[-3].string); free(yyvsp[-3].string);
if (printmatches == TRUE) if (printmatches == TRUE)
@@ -1753,35 +1759,37 @@ case 74:
} }
break; break;
case 77: case 77:
#line 775 "parse.yacc" #line 781 "parse.yacc"
{ push; } { push; }
break; break;
case 78: case 78:
#line 775 "parse.yacc" #line 781 "parse.yacc"
{ {
if ((user_matches != -1 || pedantic) && if ((user_matches != -1 || pedantic) &&
!add_alias(yyvsp[-3].string, USER_ALIAS, user_matches)) !add_alias(yyvsp[-3].string, USER_ALIAS, user_matches)) {
yyerror(NULL);
YYERROR; YYERROR;
}
pop; pop;
free(yyvsp[-3].string); free(yyvsp[-3].string);
} }
break; break;
case 81: case 81:
#line 788 "parse.yacc" #line 796 "parse.yacc"
{ {
if (yyvsp[0].BOOLEAN != -1) if (yyvsp[0].BOOLEAN != -1)
user_matches = yyvsp[0].BOOLEAN; user_matches = yyvsp[0].BOOLEAN;
} }
break; break;
case 82: case 82:
#line 792 "parse.yacc" #line 800 "parse.yacc"
{ {
if (yyvsp[0].BOOLEAN != -1) if (yyvsp[0].BOOLEAN != -1)
user_matches = ! yyvsp[0].BOOLEAN; user_matches = ! yyvsp[0].BOOLEAN;
} }
break; break;
case 83: case 83:
#line 797 "parse.yacc" #line 805 "parse.yacc"
{ {
if (strcmp(yyvsp[0].string, user_name) == 0) if (strcmp(yyvsp[0].string, user_name) == 0)
yyval.BOOLEAN = TRUE; yyval.BOOLEAN = TRUE;
@@ -1791,7 +1799,7 @@ case 83:
} }
break; break;
case 84: case 84:
#line 804 "parse.yacc" #line 812 "parse.yacc"
{ {
if (usergr_matches(yyvsp[0].string, user_name)) if (usergr_matches(yyvsp[0].string, user_name))
yyval.BOOLEAN = TRUE; yyval.BOOLEAN = TRUE;
@@ -1801,7 +1809,7 @@ case 84:
} }
break; break;
case 85: case 85:
#line 811 "parse.yacc" #line 819 "parse.yacc"
{ {
if (netgr_matches(yyvsp[0].string, NULL, NULL, user_name)) if (netgr_matches(yyvsp[0].string, NULL, NULL, user_name))
yyval.BOOLEAN = TRUE; yyval.BOOLEAN = TRUE;
@@ -1811,7 +1819,7 @@ case 85:
} }
break; break;
case 86: case 86:
#line 818 "parse.yacc" #line 826 "parse.yacc"
{ {
aliasinfo *aip = find_alias(yyvsp[0].string, USER_ALIAS); aliasinfo *aip = find_alias(yyvsp[0].string, USER_ALIAS);
@@ -1825,8 +1833,10 @@ case 86:
(void) fprintf(stderr, (void) fprintf(stderr,
"%s: undeclared User_Alias `%s' referenced near line %d\n", "%s: undeclared User_Alias `%s' referenced near line %d\n",
(pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno); (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
if (pedantic > 1) if (pedantic > 1) {
yyerror(NULL);
YYERROR; YYERROR;
}
} }
yyval.BOOLEAN = -1; yyval.BOOLEAN = -1;
} }
@@ -1834,12 +1844,12 @@ case 86:
} }
break; break;
case 87: case 87:
#line 838 "parse.yacc" #line 848 "parse.yacc"
{ {
yyval.BOOLEAN = TRUE; yyval.BOOLEAN = TRUE;
} }
break; break;
#line 1834 "sudo.tab.c" #line 1844 "sudo.tab.c"
} }
yyssp -= yym; yyssp -= yym;
yystate = *yyssp; yystate = *yyssp;