|
|
1.1 ! root 1: ! 2: #include "y.tab.h" ! 3: #define YYCLEARIN yychar = -1000 ! 4: #define YYERROK yyerrflag = 0 ! 5: extern int yychar; ! 6: extern short yyerrflag; ! 7: #ifndef YYMAXDEPTH ! 8: #define YYMAXDEPTH 150 ! 9: #endif ! 10: YYSTYPE yyval, yylval; ! 11: ! 12: #line 176 "checkperms.y" ! 13: ! 14: ! 15: #include <stdio.h> ! 16: #include "checkperms.h" ! 17: #include "monitor.h" ! 18: ! 19: yyerror (s) ! 20: char *s; ! 21: { ! 22: fprintf (stderr, "line %d: %s, Token: %d\n", lineno, s, yychar); ! 23: } ! 24: #ifdef YYTNAMES ! 25: struct yytname yytnames[21] = ! 26: { ! 27: "$end", -1, ! 28: "error", -2, ! 29: "FOREACH", 256, ! 30: "PATHNAME", 257, ! 31: "STRING", 258, ! 32: "INDENT", 259, ! 33: "UNINDENT", 260, ! 34: "NL", 261, ! 35: "ERROR_TOKEN", 262, ! 36: "WARNING_TOKEN", 263, ! 37: "EXIST", 264, ! 38: "OWNER", 265, ! 39: "GROUP", 266, ! 40: "CHMOD_PERMISSION", 267, ! 41: "NUMBER", 268, ! 42: "FILE_TOKEN", 269, ! 43: "DIRECTORY", 270, ! 44: "PIPE", 271, ! 45: "CHARACTER_SPECIAL", 272, ! 46: "BLOCK_SPECIAL", 273, ! 47: NULL ! 48: } ; ! 49: #endif ! 50: unsigned yypdnt[33] = { ! 51: 00, 01, 01, 02, 02, 02, 02, 02, ! 52: 03, 06, 04, 011, 07, 07, 05, 05, ! 53: 012, 012, 013, 013, 013, 013, 013, 014, ! 54: 015, 015, 015, 015, 015, 016, 017, 010, ! 55: 020 ! 56: } ; ! 57: unsigned yypn[33] = { ! 58: 02, 01, 02, 01, 01, 02, 01, 02, ! 59: 03, 02, 03, 02, 03, 00, 03, 02, ! 60: 01, 01, 01, 01, 01, 01, 01, 01, ! 61: 01, 01, 01, 01, 01, 02, 02, 01, ! 62: 01 ! 63: } ; ! 64: unsigned yypgo[17] = { ! 65: 00, 00, 04, 012, 014, 016, 020, 022, ! 66: 026, 040, 042, 044, 046, 050, 052, 054, ! 67: 056 ! 68: } ; ! 69: unsigned yygo[48] = { ! 70: 046, 054, 0176030, 07, 07, 024, 054, 024, ! 71: 0176030, 010, 0176030, 011, 0176030, 012, 0176030, 013, ! 72: 0176030, 014, 027, 050, 0176030, 047, 03, 022, ! 73: 031, 051, 032, 052, 041, 053, 0176030, 021, ! 74: 0176030, 015, 0176030, 016, 0176030, 041, 0176030, 042, ! 75: 0176030, 043, 0176030, 044, 0176030, 045, 0176030, 00 ! 76: } ; ! 77: unsigned yypa[46] = { ! 78: 00, 014, 020, 020, 024, 026, 030, 032, ! 79: 050, 052, 054, 056, 062, 066, 072, 0116, ! 80: 0120, 0122, 0124, 0126, 0132, 0134, 0136, 0136, ! 81: 0142, 020, 020, 0144, 0146, 0150, 0152, 0154, ! 82: 0156, 0160, 0164, 0166, 0170, 0172, 00, 0174, ! 83: 0176, 0200, 0202, 0204, 0206, 0224 ! 84: } ; ! 85: unsigned yyact[150] = { ! 86: 02, 0400, 03, 0401, 04, 0405, 05, 0406, ! 87: 06, 0407, 01, 0176030, 017, 0405, 060000, 0176030, ! 88: 020, 0402, 060000, 0176030, 020006, 0176030, 020020, 0176030, ! 89: 020021, 0176030, 023, 0177777, 02, 0400, 03, 0401, ! 90: 04, 0405, 05, 0406, 06, 0407, 01, 0176030, ! 91: 020001, 0176030, 020003, 0176030, 020004, 0176030, 025, 0405, ! 92: 060000, 0176030, 026, 0405, 060000, 0176030, 027, 0405, ! 93: 060000, 0176030, 030, 0410, 031, 0411, 032, 0412, ! 94: 033, 0413, 034, 0415, 035, 0416, 036, 0417, ! 95: 037, 0420, 040, 0421, 060000, 0176030, 020007, 0176030, ! 96: 020037, 0176030, 020011, 0176030, 020013, 0176030, 040000, 0177777, ! 97: 060000, 0176030, 020002, 0176030, 020005, 0176030, 046, 0403, ! 98: 020015, 0176030, 020027, 0176030, 020026, 0176030, 020030, 0176030, ! 99: 020031, 0176030, 020032, 0176030, 020033, 0176030, 020034, 0176030, ! 100: 020, 0402, 020017, 0176030, 020022, 0176030, 020023, 0176030, ! 101: 020024, 0176030, 020025, 0176030, 020010, 0176030, 020012, 0176030, ! 102: 020035, 0176030, 020036, 0176030, 020016, 0176030, 02, 0400, ! 103: 03, 0401, 055, 0404, 04, 0405, 05, 0406, ! 104: 06, 0407, 01, 0176030, 020014, 0176030 ! 105: } ; ! 106: /* (-lgl ! 107: * COHERENT Version 3.0 ! 108: * Copyright (c) 1982, 1990 by Mark Williams Company. ! 109: * All rights reserved. May not be copied without permission. ! 110: -lgl) */ ! 111: #include "action.h" ! 112: #define YYNOCHAR (-1000) ! 113: #define yyerrok yyerrflag=0 ! 114: #define yyclearin yylval=YYNOCHAR ! 115: int yystack[YYMAXDEPTH]; ! 116: YYSTYPE yyvstack[YYMAXDEPTH], *yyv; ! 117: int yychar; ! 118: ! 119: #ifdef YYDEBUG ! 120: int yydebug = 1; /* No sir, not in the BSS */ ! 121: #include <stdio.h> ! 122: #endif ! 123: ! 124: short yyerrflag; ! 125: int *yys; ! 126: ! 127: yyparse() ! 128: { ! 129: register YYSTYPE *yypvt; ! 130: int act; ! 131: register unsigned *ip, yystate; ! 132: int pno; ! 133: yystate = 0; ! 134: yychar = YYNOCHAR; ! 135: yyv = &yyvstack[-1]; ! 136: yys = &yystack[-1]; ! 137: ! 138: stack: ! 139: if( ++yys >= &yystack[YYMAXDEPTH] ) { ! 140: write(2, "Stack overflow\n", 15); ! 141: exit(1); ! 142: } ! 143: *yys = yystate; ! 144: *++yyv = yyval; ! 145: #ifdef YYDEBUG ! 146: if( yydebug ) ! 147: fprintf(stdout, "Stack state %d, char %d\n", yystate, yychar); ! 148: #endif ! 149: ! 150: read: ! 151: ip = &yyact[yypa[yystate]]; ! 152: if( ip[1] != YYNOCHAR ) { ! 153: if( yychar == YYNOCHAR ) { ! 154: yychar = yylex(); ! 155: #ifdef YYDEBUG ! 156: if( yydebug ) ! 157: fprintf(stdout, "lex read char %d, val %d\n", yychar, yylval); ! 158: #endif ! 159: } ! 160: while (ip[1]!=YYNOCHAR) { ! 161: if (ip[1]==yychar) ! 162: break; ! 163: ip += 2; ! 164: } ! 165: } ! 166: act = ip[0]; ! 167: switch( act>>YYACTSH ) { ! 168: case YYSHIFTACT: ! 169: if( ip[1]==YYNOCHAR ) ! 170: goto YYerract; ! 171: if( yychar != -1 ) ! 172: yychar = YYNOCHAR; /* dont throw away EOF */ ! 173: yystate = act&YYAMASK; ! 174: yyval = yylval; ! 175: #ifdef YYDEBUG ! 176: if( yydebug ) ! 177: fprintf(stdout, "shift %d\n", yystate); ! 178: #endif ! 179: if( yyerrflag ) ! 180: --yyerrflag; ! 181: goto stack; ! 182: ! 183: case YYACCEPTACT: ! 184: #ifdef YYDEBUG ! 185: if( yydebug ) ! 186: fprintf(stdout, "accept\n"); ! 187: #endif ! 188: return(0); ! 189: ! 190: case YYERRACT: ! 191: YYerract: ! 192: switch (yyerrflag) { ! 193: case 0: ! 194: yyerror("Syntax error"); ! 195: ! 196: case 1: ! 197: case 2: ! 198: ! 199: yyerrflag = 3; ! 200: while( yys >= & yystack[0] ) { ! 201: ip = &yyact[yypa[*yys]]; ! 202: while( ip[1]!=YYNOCHAR ) ! 203: ip += 2; ! 204: if( (*ip&~YYAMASK) == (YYSHIFTACT<<YYACTSH) ) { ! 205: yystate = *ip&YYAMASK; ! 206: goto stack; ! 207: } ! 208: #ifdef YYDEBUG ! 209: if( yydebug ) ! 210: fprintf(stderr, "error recovery leaves state %d, uncovers %d\n", *yys, yys[-1]); ! 211: #endif ! 212: yys--; ! 213: yyv--; ! 214: } ! 215: #ifdef YYDEBUG ! 216: if( yydebug ) ! 217: fprintf(stderr, "no shift on error; abort\n"); ! 218: #endif ! 219: return(1); ! 220: ! 221: case 3: ! 222: #ifdef YYDEBUG ! 223: if( yydebug ) ! 224: fprintf(stderr, "Error recovery clobbers char %o\n", yychar); ! 225: #endif ! 226: if( yychar==YYEOFVAL ) ! 227: return(1); ! 228: yychar = YYNOCHAR; ! 229: goto read; ! 230: } ! 231: ! 232: case YYREDACT: ! 233: pno = act&YYAMASK; ! 234: #ifdef YYDEBUG ! 235: if( yydebug ) ! 236: fprintf(stdout, "reduce %d\n", pno); ! 237: #endif ! 238: yypvt = yyv; ! 239: yyv -= yypn[pno]; ! 240: yys -= yypn[pno]; ! 241: yyval = yyv[1]; ! 242: switch(pno) { ! 243: ! 244: case 7: { ! 245: ! 246: #line 21 "checkperms.y" ! 247: yyerrok;}break; ! 248: ! 249: case 8: { ! 250: ! 251: #line 25 "checkperms.y" ! 252: ! 253: /* Put lost character back into stdin. */ ! 254: my_ungetchar(delayed_char); ! 255: #ifdef DEBUG ! 256: printf("%d: finished foreach_block.\n", lineno); ! 257: #endif /* DEBUG */ ! 258: }break; ! 259: ! 260: case 9: { ! 261: ! 262: #line 34 "checkperms.y" ! 263: ! 264: if(host_looping) { ! 265: FATAL("%d: foreach can not nest.", ! 266: lineno); ! 267: } else { ! 268: #ifdef DEBUG ! 269: /* DEBUG */ printf("%d: Foreach identified\n", lineno); ! 270: #endif /* DEBUG */ ! 271: host_looping = TRUE; ! 272: current_host = first_host(yypvt[0]); ! 273: saving_to_monitor_file = TRUE; ! 274: reading_from_monitor_file = FALSE; ! 275: open_monitor_file(); /* Start saving input. */ ! 276: } /* if host_looping */ ! 277: }break; ! 278: ! 279: case 10: { ! 280: ! 281: #line 52 "checkperms.y" ! 282: ! 283: /* Once beyond the scope of a path_block, make sure ! 284: * that there is no current_path set. ! 285: */ ! 286: free(current_path); ! 287: current_path = NULL; ! 288: }break; ! 289: ! 290: case 11: { ! 291: ! 292: #line 61 "checkperms.y" ! 293: ! 294: if(host_looping) { ! 295: /* We need to build a whole pathname. */ ! 296: current_path = malloc(strlen(current_host)+ ! 297: strlen(yypvt[0]) + 1 ); ! 298: /* Insert the current host into the ! 299: * partial path provided. */ ! 300: sprintf(current_path, yypvt[0], current_host); ! 301: } else { ! 302: if(current_path != NULL) { ! 303: FATAL("%d: pathnames can not be nested.\n", ! 304: lineno); ! 305: } /* if there is a current path */ ! 306: copy_str(¤t_path, yypvt[0]); ! 307: } /* if in a loop of host names */ ! 308: ! 309: /* Now that we have a full pathname, we can build ! 310: * a stat structure for it. ! 311: */ ! 312: if (stat(current_path, ¤t_stat) == -1){ ! 313: #ifdef DEBUG ! 314: /* DEBUG */ printf("Can not stat %s.\n", current_path); ! 315: #endif /* DEBUG */ ! 316: it_exists = FALSE; ! 317: } /* if stat failed */ ! 318: else { ! 319: #ifdef DEBUG ! 320: /* DEBUG */ printf("Just stat ed %s.\n", current_path); ! 321: #endif /* DEBUG */ ! 322: it_exists = TRUE; ! 323: } /* else stat succeeded */ ! 324: sprintf(bigbuf, "Examining %s.\n", current_path); ! 325: REALLYVERBOSE(bigbuf); ! 326: }break; ! 327: ! 328: case 14: { ! 329: ! 330: #line 101 "checkperms.y" ! 331: ! 332: #ifdef DEBUG ! 333: /* DEBUG */ printf("%d: Message %d, Check %d, String: %s\n", ! 334: lineno, yypvt[-2], yypvt[-1], yypvt[0]); ! 335: #endif /* DEBUG */ ! 336: do_check(yypvt[-2], yypvt[-1], yypvt[0]); ! 337: }break; ! 338: ! 339: case 15: { ! 340: ! 341: #line 108 "checkperms.y" ! 342: ! 343: #ifdef DEBUG ! 344: /* DEBUG */ printf("%d: Message %d, Check %d\n", ! 345: lineno, yypvt[-1], yypvt[0]); ! 346: #endif ! 347: do_check(yypvt[-1], yypvt[0], NULL); ! 348: }break; ! 349: ! 350: case 16: { ! 351: ! 352: #line 119 "checkperms.y" ! 353: yyval = ERROR_TOKEN;}break; ! 354: ! 355: case 17: { ! 356: ! 357: #line 121 "checkperms.y" ! 358: yyval = WARNING_TOKEN;}break; ! 359: ! 360: case 18: { ! 361: ! 362: #line 126 "checkperms.y" ! 363: yyval=yypvt[0];}break; ! 364: ! 365: case 19: { ! 366: ! 367: #line 128 "checkperms.y" ! 368: yyval=yypvt[0];}break; ! 369: ! 370: case 20: { ! 371: ! 372: #line 130 "checkperms.y" ! 373: yyval=yypvt[0];}break; ! 374: ! 375: case 21: { ! 376: ! 377: #line 132 "checkperms.y" ! 378: yyval=yypvt[0];}break; ! 379: ! 380: case 22: { ! 381: ! 382: #line 133 "checkperms.y" ! 383: ! 384: yyval=CHMOD_PERMISSION; ! 385: }break; ! 386: ! 387: case 23: { ! 388: ! 389: #line 139 "checkperms.y" ! 390: yyval=EXIST;}break; ! 391: ! 392: case 24: { ! 393: ! 394: #line 143 "checkperms.y" ! 395: yyval=FILE_TOKEN;}break; ! 396: ! 397: case 25: { ! 398: ! 399: #line 145 "checkperms.y" ! 400: yyval=DIRECTORY;}break; ! 401: ! 402: case 26: { ! 403: ! 404: #line 147 "checkperms.y" ! 405: yyval=PIPE;}break; ! 406: ! 407: case 27: { ! 408: ! 409: #line 149 "checkperms.y" ! 410: yyval=CHARACTER_SPECIAL;}break; ! 411: ! 412: case 28: { ! 413: ! 414: #line 151 "checkperms.y" ! 415: yyval=BLOCK_SPECIAL;}break; ! 416: ! 417: case 29: { ! 418: ! 419: #line 154 "checkperms.y" ! 420: ! 421: yyval=OWNER; ! 422: copy_str(&id_string, yypvt[0]); ! 423: }break; ! 424: ! 425: case 30: { ! 426: ! 427: #line 160 "checkperms.y" ! 428: ! 429: yyval=GROUP; ! 430: copy_str(&id_string, yypvt[0]); ! 431: }break; ! 432: ! 433: case 31: { ! 434: ! 435: #line 166 "checkperms.y" ! 436: ! 437: yyval=ret_string; ! 438: ret_string = NULL; ! 439: }break; ! 440: ! 441: case 32: { ! 442: ! 443: #line 172 "checkperms.y" ! 444: ! 445: yyval = ret_number; ! 446: }break; ! 447: ! 448: } ! 449: ip = &yygo[ yypgo[yypdnt[pno]] ]; ! 450: while( *ip!=*yys && *ip!=YYNOCHAR ) ! 451: ip += 2; ! 452: yystate = ip[1]; ! 453: goto stack; ! 454: } ! 455: } ! 456: ! 457: ! 458: ! 459:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.