#define push \
if (top > MATCHSTACKSIZE) \
- yyerror("matching stack overflow\n"); \
+ yyerror("matching stack overflow"); \
else {\
match[top].user = -1; \
match[top].cmnd = -1; \
}
#define pop \
if (top == 0) \
- yyerror("matching stack underflow\n"); \
+ yyerror("matching stack underflow"); \
else \
top--;
{ ; }
| error COMMENT
{ yyerrok; }
- | NAME {
- push;
- user_matches = strcmp(user, $1) == 0;
- } privileges
- | ALIAS {
- push;
- user_matches = find_alias($1, USER) != 0;
- } privileges
- | ALL {
- push;
- user_matches = TRUE;
- } privileges
+ | { push; } user privileges {
+ while (top && user_matches != TRUE) {
+ pop;
+ }
+ }
| USERALIAS useraliases
{ ; }
| HOSTALIAS hostaliases
;
privilege : hostspec '=' opcmndlist {
- if (!user_matches) {
- pop;
- } else {
+ if (user_matches == TRUE) {
push;
user_matches = TRUE;
}
if (strcmp($1, host) == 0)
host_matches = TRUE;
#endif /* HAVE_STRCASECMP */
- }
+ }
;
fqdn : NAME '.' NAME {
if (strcmp($1, user) == 0)
user_matches = TRUE;
}
+ | ALIAS {
+ if (find_alias($1, USER))
+ user_matches = TRUE;
+ }
| ALL {
user_matches = TRUE;
}
{
size_t n;
- for (n = 0; n < naliases; n++)
- printf("%s\t%s\n", aliases[n].type == HOST ? "HOST" : "CMND",
- aliases[n].name);
+ for (n = 0; n < naliases; n++) {
+ switch (aliases[n].type) {
+ case HOST:
+ puts("HOST");
+ break;
+ case CMND:
+ puts("CMND");
+ break;
+
+ case USER:
+ puts("USER");
+ break;
+ }
+ printf("\t%s\n", aliases[n].name);
+ }
}
void