Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

587 lines
15 KiB

  1. #ifndef lint
  2. static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
  3. #endif
  4. #define YYBYACC 1
  5. #define YYMAJOR 1
  6. #define YYMINOR 9
  7. #define yyclearin (yychar=(-1))
  8. #define yyerrok (yyerrflag=0)
  9. #define YYRECOVERING (yyerrflag!=0)
  10. #define YYPREFIX "yy"
  11. /*++
  12. Copyright (c) 2000 Microsoft Corporation
  13. Module Name:
  14. adl.y/adlparser.cpp
  15. Abstract:
  16. YACC parser definition for the ADL language
  17. AdlParser::ParseAdl() function
  18. Author:
  19. t-eugenz - August 2000
  20. Environment:
  21. User mode only.
  22. Revision History:
  23. Created - August 2000
  24. --*/
  25. #include "pch.h"
  26. #include "adl.h"
  27. /**/
  28. /* YACC generates some long->short automatic conversion, disable the warning*/
  29. /**/
  30. #pragma warning(disable : 4242)
  31. /**/
  32. /* ISSUE-2000/08/28-t-eugenz*/
  33. /* This is a private netlib function. */
  34. /**/
  35. extern "C" NET_API_STATUS
  36. NetpwNameValidate(
  37. IN LPTSTR Name,
  38. IN DWORD NameType,
  39. IN DWORD Flags
  40. );
  41. /**/
  42. /* Name types for I_NetName* and I_NetListCanonicalize*/
  43. /**/
  44. #define NAMETYPE_USER 1
  45. #define NAMETYPE_PASSWORD 2
  46. #define NAMETYPE_GROUP 3
  47. #define NAMETYPE_COMPUTER 4
  48. #define NAMETYPE_EVENT 5
  49. #define NAMETYPE_DOMAIN 6
  50. #define NAMETYPE_SERVICE 7
  51. #define NAMETYPE_NET 8
  52. #define NAMETYPE_SHARE 9
  53. #define NAMETYPE_MESSAGE 10
  54. #define NAMETYPE_MESSAGEDEST 11
  55. #define NAMETYPE_SHAREPASSWORD 12
  56. #define NAMETYPE_WORKGROUP 13
  57. /**/
  58. /* Validate various tokens, with error handling*/
  59. /* have to cast away const, since NetpNameValidate takes a non-const for some*/
  60. /* reason*/
  61. /**/
  62. #define VALIDATE_USERNAME(TOK) \
  63. if( NetpwNameValidate( \
  64. (WCHAR *)(TOK)->GetValue(), \
  65. NAMETYPE_USER, \
  66. 0) != ERROR_SUCCESS) \
  67. { \
  68. this->SetErrorToken( TOK ); \
  69. throw AdlStatement::ERROR_INVALID_USERNAME; \
  70. }
  71. #define VALIDATE_DOMAIN(TOK) \
  72. if( NetpwNameValidate( \
  73. (WCHAR *)(TOK)->GetValue(), \
  74. NAMETYPE_DOMAIN, \
  75. 0) != ERROR_SUCCESS) \
  76. { \
  77. this->SetErrorToken( TOK ); \
  78. throw AdlStatement::ERROR_INVALID_DOMAIN; \
  79. }
  80. #define VALIDATE_PERMISSION(TOK) \
  81. { \
  82. for(DWORD i = 0;; i++) \
  83. { \
  84. if( (_pControl->pPermissions)[i].str == NULL ) \
  85. { \
  86. this->SetErrorToken( TOK ); \
  87. throw AdlStatement::ERROR_UNKNOWN_PERMISSION; \
  88. } \
  89. if(!_wcsicmp(TOK->GetValue(), \
  90. (_pControl->pPermissions)[i].str)) \
  91. { \
  92. break; \
  93. } \
  94. } \
  95. }
  96. /**/
  97. /* YACC value type*/
  98. /**/
  99. #define YYSTYPE AdlToken *
  100. /**/
  101. /* YACC error handler: raise an exception*/
  102. /**/
  103. void yyerror(char *szErr)
  104. {
  105. throw AdlStatement::ERROR_NOT_IN_LANGUAGE;
  106. }
  107. #define TK_ERROR 257
  108. #define TK_IDENT 258
  109. #define TK_AT 259
  110. #define TK_SLASH 260
  111. #define TK_PERIOD 261
  112. #define TK_COMMA 262
  113. #define TK_OPENPAREN 263
  114. #define TK_CLOSEPAREN 264
  115. #define TK_SEMICOLON 265
  116. #define TK_EXCEPT 266
  117. #define TK_ON 267
  118. #define TK_ALLOWED 268
  119. #define TK_AND 269
  120. #define TK_AS 270
  121. #define TK_THIS_OBJECT 271
  122. #define TK_CONTAINERS 272
  123. #define TK_OBJECTS 273
  124. #define TK_CONTAINERS_OBJECTS 274
  125. #define TK_NO_PROPAGATE 275
  126. #define TK_LANG_ENGLISH 276
  127. #define TK_LANG_REVERSE 277
  128. #define YYERRCODE 256
  129. short yylhs[] = { -1,
  130. 0, 0, 1, 1, 3, 3, 2, 2, 8, 8,
  131. 4, 4, 4, 5, 5, 5, 6, 6, 6, 10,
  132. 7, 7, 7, 9, 9, 13, 13, 13, 14, 14,
  133. 12, 12, 12, 12, 12, 11, 11, 11, 11, 11,
  134. 11, 11,
  135. };
  136. short yylen[] = { 2,
  137. 2, 2, 1, 2, 10, 6, 1, 2, 10, 6,
  138. 1, 3, 3, 1, 3, 3, 1, 3, 3, 1,
  139. 1, 3, 3, 1, 3, 3, 3, 1, 1, 3,
  140. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  141. 1, 1,
  142. };
  143. short yydefred[] = { 0,
  144. 0, 0, 0, 42, 36, 40, 41, 37, 38, 39,
  145. 0, 3, 0, 11, 0, 0, 0, 0, 0, 0,
  146. 7, 4, 0, 0, 0, 0, 0, 0, 0, 0,
  147. 0, 8, 0, 12, 0, 0, 17, 20, 13, 29,
  148. 0, 25, 27, 30, 0, 14, 0, 0, 0, 0,
  149. 0, 0, 0, 0, 0, 0, 19, 31, 32, 33,
  150. 34, 35, 0, 21, 18, 15, 0, 16, 0, 0,
  151. 0, 6, 0, 0, 10, 0, 23, 22, 0, 0,
  152. 0, 0, 0, 5, 9,
  153. };
  154. short yydgoto[] = { 3,
  155. 11, 19, 12, 13, 45, 36, 63, 21, 14, 37,
  156. 15, 64, 16, 17,
  157. };
  158. short yysindex[] = { -222,
  159. -238, -210, 0, 0, 0, 0, 0, 0, 0, 0,
  160. -238, 0, -184, 0, -249, -257, -136, -248, -210, -254,
  161. 0, 0, -238, -240, -238, -238, -238, -238, -238, -238,
  162. -238, 0, -238, 0, -238, -179, 0, 0, 0, 0,
  163. -227, 0, 0, 0, -224, 0, -176, -220, -238, -152,
  164. -238, -238, -238, -238, -152, -216, 0, 0, 0, 0,
  165. 0, 0, -173, 0, 0, 0, -168, 0, -167, -238,
  166. -152, 0, -152, -238, 0, -163, 0, 0, -159, -152,
  167. -152, -153, -151, 0, 0,
  168. };
  169. short yyrindex[] = { 0,
  170. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  171. 41, 0, 0, 0, -199, -187, 0, 0, 80, 0,
  172. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  173. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  174. -196, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  175. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  176. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  177. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  178. 0, 0, 0, 0, 0,
  179. };
  180. short yygindex[] = { 0,
  181. 0, 0, 76, -2, 62, -31, -44, 86, -19, -28,
  182. -24, -49, 79, 88,
  183. };
  184. #define YYTABLESIZE 125
  185. short yytable[] = { 20,
  186. 38, 47, 40, 34, 43, 44, 39, 23, 38, 27,
  187. 69, 46, 28, 33, 26, 46, 20, 31, 4, 5,
  188. 57, 77, 65, 78, 38, 35, 38, 6, 7, 8,
  189. 9, 10, 66, 30, 68, 82, 83, 52, 76, 53,
  190. 1, 52, 79, 56, 54, 38, 4, 5, 54, 38,
  191. 67, 70, 18, 1, 2, 6, 7, 8, 9, 10,
  192. 29, 29, 28, 28, 28, 26, 26, 26, 28, 28,
  193. 28, 26, 26, 26, 24, 24, 24, 23, 24, 2,
  194. 24, 24, 49, 25, 26, 49, 22, 50, 71, 51,
  195. 55, 72, 51, 23, 71, 73, 48, 75, 49, 74,
  196. 26, 73, 49, 80, 32, 51, 42, 81, 71, 51,
  197. 71, 84, 0, 85, 41, 73, 0, 73, 58, 59,
  198. 60, 61, 62, 29, 30,
  199. };
  200. short yycheck[] = { 2,
  201. 25, 33, 27, 23, 29, 30, 26, 262, 33, 259,
  202. 55, 31, 270, 268, 269, 35, 19, 266, 257, 258,
  203. 49, 71, 51, 73, 49, 266, 51, 266, 267, 268,
  204. 269, 270, 52, 261, 54, 80, 81, 262, 70, 264,
  205. 0, 262, 74, 264, 269, 70, 257, 258, 269, 74,
  206. 53, 268, 263, 276, 277, 266, 267, 268, 269, 270,
  207. 260, 261, 262, 263, 264, 262, 263, 264, 268, 269,
  208. 270, 268, 269, 270, 262, 263, 264, 262, 263, 0,
  209. 268, 269, 262, 268, 269, 262, 11, 267, 262, 269,
  210. 267, 265, 269, 262, 262, 269, 35, 265, 262, 268,
  211. 269, 269, 262, 267, 19, 269, 28, 267, 262, 269,
  212. 262, 265, -1, 265, 27, 269, -1, 269, 271, 272,
  213. 273, 274, 275, 260, 261,
  214. };
  215. #define YYFINAL 3
  216. #ifndef YYDEBUG
  217. #define YYDEBUG 0
  218. #endif
  219. #define YYMAXTOKEN 277
  220. #ifndef YYSTYPE
  221. typedef int YYSTYPE;
  222. #endif
  223. #ifdef YYSTACKSIZE
  224. #undef YYMAXDEPTH
  225. #define YYMAXDEPTH YYSTACKSIZE
  226. #else
  227. #ifdef YYMAXDEPTH
  228. #define YYSTACKSIZE YYMAXDEPTH
  229. #else
  230. #define YYSTACKSIZE 500
  231. #define YYMAXDEPTH 500
  232. #endif
  233. #endif
  234. #define yystacksize YYSTACKSIZE
  235. #define YYABORT goto yyabort
  236. #define YYREJECT goto yyabort
  237. #define YYACCEPT goto yyaccept
  238. #define YYERROR goto yyerrlab
  239. int
  240. AdlStatement::ParseAdl(const WCHAR *szInput)
  241. {
  242. register int yym, yyn, yystate;
  243. int yydebug = 0;
  244. int yynerrs;
  245. int yyerrflag;
  246. int yychar;
  247. short *yyssp;
  248. YYSTYPE *yyvsp;
  249. YYSTYPE yyval;
  250. YYSTYPE yylval;
  251. short yyss[YYSTACKSIZE];
  252. YYSTYPE yyvs[YYSTACKSIZE];
  253. AdlLexer Lexer(szInput, this, _pControl->pLang);
  254. yynerrs = 0;
  255. yyerrflag = 0;
  256. yychar = (-1);
  257. yyssp = yyss;
  258. yyvsp = yyvs;
  259. *yyssp = yystate = 0;
  260. yyloop:
  261. if (yyn = yydefred[yystate]) goto yyreduce;
  262. if (yychar < 0)
  263. {
  264. if ((yychar = Lexer.NextToken(&yylval)) < 0) yychar = 0;
  265. }
  266. if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
  267. yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  268. {
  269. if (yyssp >= yyss + yystacksize - 1)
  270. {
  271. goto yyoverflow;
  272. }
  273. *++yyssp = yystate = yytable[yyn];
  274. *++yyvsp = yylval;
  275. yychar = (-1);
  276. if (yyerrflag > 0) --yyerrflag;
  277. goto yyloop;
  278. }
  279. if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
  280. yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  281. {
  282. yyn = yytable[yyn];
  283. goto yyreduce;
  284. }
  285. if (yyerrflag) goto yyinrecovery;
  286. #ifdef lint
  287. goto yynewerror;
  288. #endif
  289. yyerror("syntax error");
  290. #ifdef lint
  291. goto yyerrlab;
  292. #endif
  293. yyinrecovery:
  294. if (yyerrflag < 3)
  295. {
  296. yyerrflag = 3;
  297. for (;;)
  298. {
  299. if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
  300. yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
  301. {
  302. if (yyssp >= yyss + yystacksize - 1)
  303. {
  304. goto yyoverflow;
  305. }
  306. *++yyssp = yystate = yytable[yyn];
  307. *++yyvsp = yylval;
  308. goto yyloop;
  309. }
  310. else
  311. {
  312. if (yyssp <= yyss) goto yyabort;
  313. --yyssp;
  314. --yyvsp;
  315. }
  316. }
  317. }
  318. else
  319. {
  320. if (yychar == 0) goto yyabort;
  321. yychar = (-1);
  322. goto yyloop;
  323. }
  324. yyreduce:
  325. yym = yylen[yyn];
  326. yyval = yyvsp[1-yym];
  327. switch (yyn)
  328. {
  329. case 1:
  330. {
  331. /**/
  332. /* At the end of all ADL_STATEMENT's*/
  333. /* pop the extra AdlTree that was pushed*/
  334. /* on when the last ADL_STATEMENT*/
  335. /* was completed*/
  336. /**/
  337. this->PopEmpty();
  338. }
  339. break;
  340. case 2:
  341. {
  342. /**/
  343. /* At the end of all ADL_STATEMENT's*/
  344. /* pop the extra AdlTree that was pushed*/
  345. /* on when the last ADL_STATEMENT*/
  346. /* was completed*/
  347. /**/
  348. this->PopEmpty();
  349. }
  350. break;
  351. case 5:
  352. {
  353. this->Next();
  354. }
  355. break;
  356. case 6:
  357. {
  358. this->Next();
  359. }
  360. break;
  361. case 9:
  362. {
  363. this->Next();
  364. }
  365. break;
  366. case 10:
  367. {
  368. this->Next();
  369. }
  370. break;
  371. case 11:
  372. {
  373. this->Cur()->AddPrincipal( yyvsp[0] );
  374. }
  375. break;
  376. case 12:
  377. {
  378. this->Cur()->AddPrincipal( yyvsp[0] );
  379. }
  380. break;
  381. case 13:
  382. {
  383. this->Cur()->AddPrincipal( yyvsp[0] );
  384. }
  385. break;
  386. case 14:
  387. {
  388. this->Cur()->AddExPrincipal( yyvsp[0] );
  389. }
  390. break;
  391. case 15:
  392. {
  393. this->Cur()->AddExPrincipal( yyvsp[0] );
  394. }
  395. break;
  396. case 16:
  397. {
  398. this->Cur()->AddExPrincipal( yyvsp[0] );
  399. }
  400. break;
  401. case 17:
  402. {
  403. this->Cur()->AddPermission( yyvsp[0] );
  404. }
  405. break;
  406. case 18:
  407. {
  408. this->Cur()->AddPermission( yyvsp[0] );
  409. }
  410. break;
  411. case 19:
  412. {
  413. this->Cur()->AddPermission( yyvsp[0] );
  414. }
  415. break;
  416. case 20:
  417. {
  418. VALIDATE_PERMISSION(yyvsp[0]);
  419. }
  420. break;
  421. case 25:
  422. {
  423. /**/
  424. /* For now, impersonation is not supported*/
  425. /**/
  426. throw AdlStatement::ERROR_IMPERSONATION_UNSUPPORTED;
  427. }
  428. break;
  429. case 26:
  430. {
  431. VALIDATE_USERNAME(yyvsp[-2]);
  432. VALIDATE_DOMAIN(yyvsp[0]);
  433. AdlToken *newTok = new AdlToken(yyvsp[-2]->GetValue(),
  434. yyvsp[0]->GetValue(),
  435. yyvsp[-2]->GetStart(),
  436. yyvsp[0]->GetEnd());
  437. this->AddToken(newTok);
  438. yyval = newTok;
  439. }
  440. break;
  441. case 27:
  442. {
  443. VALIDATE_USERNAME(yyvsp[0]);
  444. VALIDATE_DOMAIN(yyvsp[-2]);
  445. AdlToken *newTok = new AdlToken(yyvsp[0]->GetValue(),
  446. yyvsp[-2]->GetValue(),
  447. yyvsp[-2]->GetStart(),
  448. yyvsp[0]->GetEnd());
  449. this->AddToken(newTok);
  450. yyval = newTok;
  451. }
  452. break;
  453. case 28:
  454. {
  455. VALIDATE_USERNAME(yyvsp[0]);
  456. yyval = yyvsp[0];
  457. }
  458. break;
  459. case 30:
  460. {
  461. /**/
  462. /* Concatenate into single domain string*/
  463. /**/
  464. wstring newStr;
  465. newStr.append(yyvsp[-2]->GetValue());
  466. newStr.append(yyvsp[-1]->GetValue());
  467. newStr.append(yyvsp[0]->GetValue());
  468. AdlToken *newTok = new AdlToken(newStr.c_str(),
  469. yyvsp[-2]->GetStart(),
  470. yyvsp[-2]->GetEnd());
  471. this->AddToken(newTok);
  472. yyval = newTok;
  473. }
  474. break;
  475. case 31:
  476. {
  477. this->Cur()->UnsetFlags(INHERIT_ONLY_ACE);
  478. }
  479. break;
  480. case 32:
  481. {
  482. this->Cur()->SetFlags(CONTAINER_INHERIT_ACE);
  483. }
  484. break;
  485. case 33:
  486. {
  487. this->Cur()->SetFlags(OBJECT_INHERIT_ACE);
  488. }
  489. break;
  490. case 34:
  491. {
  492. this->Cur()->SetFlags(CONTAINER_INHERIT_ACE);
  493. this->Cur()->SetFlags(OBJECT_INHERIT_ACE);
  494. }
  495. break;
  496. case 35:
  497. {
  498. this->Cur()->SetFlags(NO_PROPAGATE_INHERIT_ACE);
  499. }
  500. break;
  501. case 42:
  502. {
  503. /**/
  504. /* This should never happen*/
  505. /**/
  506. throw AdlStatement::ERROR_FATAL_LEXER_ERROR;
  507. }
  508. break;
  509. }
  510. yyssp -= yym;
  511. yystate = *yyssp;
  512. yyvsp -= yym;
  513. yym = yylhs[yyn];
  514. if (yystate == 0 && yym == 0)
  515. {
  516. yystate = YYFINAL;
  517. *++yyssp = YYFINAL;
  518. *++yyvsp = yyval;
  519. if (yychar < 0)
  520. {
  521. if ((yychar = Lexer.NextToken(&yylval)) < 0) yychar = 0;
  522. }
  523. if (yychar == 0) goto yyaccept;
  524. goto yyloop;
  525. }
  526. if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
  527. yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
  528. yystate = yytable[yyn];
  529. else
  530. yystate = yydgoto[yym];
  531. if (yyssp >= yyss + yystacksize - 1)
  532. {
  533. goto yyoverflow;
  534. }
  535. *++yyssp = yystate;
  536. *++yyvsp = yyval;
  537. goto yyloop;
  538. yyoverflow:
  539. yyerror("yacc stack overflow");
  540. yyabort:
  541. return (1);
  542. yyaccept:
  543. return (0);
  544. }