Print this page
7029 want per-process exploit mitigation features (secflags)
7030 want basic address space layout randomization (aslr)
7031 noexec_user_stack should be a secflag
7032 want a means to forbid mappings around NULL.
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/zonecfg/zonecfg_grammar.y
+++ new/usr/src/cmd/zonecfg/zonecfg_grammar.y
1 1 %{
2 2 /*
3 3 * CDDL HEADER START
4 4 *
5 5 * The contents of this file are subject to the terms of the
6 6 * Common Development and Distribution License (the "License").
7 7 * You may not use this file except in compliance with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22
23 23 /*
24 24 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
25 25 */
26 26
27 27 /*
28 28 * This file defines zonecfg(1M)'s grammar.
29 29 *
30 30 * Reduction rules that consume TOKENs must invoke claim_token() immediately
31 31 * before freeing the TOKENs or adding them to data structures (e.g., cmd) that
32 32 * will be cleaned up when the parser finishes or encounters errors.
33 33 */
34 34
35 35 #include <stdio.h>
36 36 #include <strings.h>
37 37
38 38 #include "zonecfg.h"
39 39
40 40 static cmd_t *cmd = NULL; /* Command being processed */
41 41 static complex_property_ptr_t complex = NULL;
42 42 static list_property_ptr_t new_list = NULL, tmp_list, last,
43 43 list[MAX_EQ_PROP_PAIRS];
44 44 static property_value_t property[MAX_EQ_PROP_PAIRS];
45 45
46 46 extern boolean_t newline_terminated;
47 47 extern int num_prop_vals; /* # of property values */
48 48
49 49 /* yacc externals */
50 50 extern int yydebug;
51 51 extern void yyerror(char *s);
52 52
53 53 /*
54 54 * This function is used by the simple_prop_val reduction rules to set up
55 55 * a list_property_ptr_t and adjust the above global variables appropriately.
56 56 * Note that this function duplicates the specified string and makes
57 57 * the new list's lp_simple field point to the duplicate. This function does
58 58 * not free the original string.
59 59 *
60 60 * This function returns a pointer to the duplicated string or NULL if an error
61 61 * occurred. The simple_prop_val reduction rules that invoke this function
62 62 * should set $$ to the returned pointer.
63 63 */
64 64 static char *
65 65 simple_prop_val_func(const char *str)
66 66 {
67 67 char *retstr;
68 68
69 69 if ((new_list = alloc_list()) == NULL)
70 70 return (NULL);
71 71 if ((retstr = strdup(str)) == NULL) {
72 72 free_list(new_list);
73 73 return (NULL);
74 74 }
75 75 new_list->lp_simple = retstr;
76 76 new_list->lp_complex = NULL;
77 77 new_list->lp_next = NULL;
78 78 if (list[num_prop_vals] == NULL) {
79 79 list[num_prop_vals] = new_list;
80 80 } else {
81 81 for (tmp_list = list[num_prop_vals]; tmp_list != NULL;
82 82 tmp_list = tmp_list->lp_next)
83 83 last = tmp_list;
84 84 last->lp_next = new_list;
85 85 }
86 86 return (retstr);
87 87 }
88 88
89 89 /*
90 90 * This function is used by the complex_piece reduction rules to set up a
91 91 * complex_property_prt_t and adjust the above global variables appropriately.
92 92 * Note that this function duplicates the specified string and makes the new
93 93 * complex_property_ptr_t's cp_value field point to the duplicate. It also sets
94 94 * the complex_property_ptr_t's cp_type field to cp_type and its cp_next field
95 95 * to cp_next. This function does not free the original string.
96 96 *
97 97 * This function returns a pointer to the complex_property_t created for the
98 98 * complex_piece or NULL if an error occurred. The complex_piece reduction
99 99 * rules that invoke this function should set $$ to the returned pointer.
100 100 */
101 101 static complex_property_ptr_t
102 102 complex_piece_func(int cp_type, const char *str, complex_property_ptr_t cp_next)
103 103 {
104 104 complex_property_ptr_t retval;
105 105
106 106 if ((retval = alloc_complex()) == NULL)
107 107 return (NULL);
108 108 if ((retval->cp_value = strdup(str)) == NULL) {
109 109 free_complex(retval);
110 110 return (NULL);
111 111 }
112 112 retval->cp_type = cp_type;
113 113 retval->cp_next = cp_next;
114 114 complex = retval;
115 115 return (retval);
116 116 }
117 117
118 118
119 119 %}
120 120
121 121 %union {
122 122 int ival;
123 123 char *strval;
124 124 cmd_t *cmd;
125 125 complex_property_ptr_t complex;
126 126 list_property_ptr_t list;
127 127 }
↓ open down ↓ |
127 lines elided |
↑ open up ↑ |
128 128
129 129 %start commands
130 130
131 131 %token HELP CREATE EXPORT ADD DELETE REMOVE SELECT SET INFO CANCEL END VERIFY
132 132 %token COMMIT REVERT EXIT SEMICOLON TOKEN ZONENAME ZONEPATH AUTOBOOT POOL NET
133 133 %token FS ATTR DEVICE RCTL SPECIAL RAW DIR OPTIONS TYPE ADDRESS PHYSICAL
134 134 %token IPTYPE HOSTID FS_ALLOWED ALLOWED_ADDRESS
135 135 %token NAME MATCH PRIV LIMIT ACTION VALUE EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
136 136 %token OPEN_PAREN CLOSE_PAREN COMMA DATASET LIMITPRIV BOOTARGS BRAND PSET PCAP
137 137 %token MCAP NCPUS IMPORTANCE SHARES MAXLWPS MAXSHMMEM MAXSHMIDS MAXMSGIDS
138 -%token MAXSEMIDS LOCKED SWAP SCHED CLEAR DEFROUTER ADMIN USER AUTHS MAXPROCS
138 +%token MAXSEMIDS LOCKED SWAP SCHED CLEAR DEFROUTER ADMIN SECFLAGS USER AUTHS MAXPROCS
139 +%token DEFAULT UPPER LOWER
139 140
140 141 %type <strval> TOKEN EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
141 142 property_value OPEN_PAREN CLOSE_PAREN COMMA simple_prop_val
142 143 %type <complex> complex_piece complex_prop_val
143 144 %type <ival> resource_type NET FS DEVICE RCTL ATTR DATASET PSET PCAP MCAP
144 - ADMIN
145 + ADMIN SECFLAGS
145 146 %type <ival> property_name SPECIAL RAW DIR OPTIONS TYPE ADDRESS PHYSICAL NAME
146 147 MATCH ZONENAME ZONEPATH AUTOBOOT POOL LIMITPRIV BOOTARGS VALUE PRIV LIMIT
147 148 ACTION BRAND SCHED IPTYPE DEFROUTER HOSTID USER AUTHS FS_ALLOWED
148 - ALLOWED_ADDRESS
149 + ALLOWED_ADDRESS DEFAULT UPPER LOWER
149 150 %type <cmd> command
150 151 %type <cmd> add_command ADD
151 152 %type <cmd> cancel_command CANCEL
152 153 %type <cmd> commit_command COMMIT
153 154 %type <cmd> create_command CREATE
154 155 %type <cmd> delete_command DELETE
155 156 %type <cmd> end_command END
156 157 %type <cmd> exit_command EXIT
157 158 %type <cmd> export_command EXPORT
158 159 %type <cmd> help_command HELP
159 160 %type <cmd> info_command INFO
160 161 %type <cmd> remove_command REMOVE
161 162 %type <cmd> revert_command REVERT
162 163 %type <cmd> select_command SELECT
163 164 %type <cmd> set_command SET
164 165 %type <cmd> clear_command CLEAR
165 166 %type <cmd> verify_command VERIFY
166 167 %type <cmd> terminator
167 168
168 169 %%
169 170
170 171 /*
171 172 * NOTE: Each commands reduction rule must invoke assert_no_unclaimed_tokens()
172 173 * before it completes if it isn't processing an error. This ensures that
173 174 * reduction rules properly consume TOKENs.
174 175 */
175 176 commands: command terminator
176 177 {
177 178 if ($1 != NULL) {
178 179 if ($1->cmd_handler != NULL)
179 180 $1->cmd_handler($1);
180 181 free_cmd($1);
181 182 bzero(list, sizeof (list_property_t));
182 183 num_prop_vals = 0;
183 184 }
184 185 assert_no_unclaimed_tokens();
185 186 return (0);
186 187 }
187 188 | command error terminator
188 189 {
189 190 if ($1 != NULL) {
190 191 free_cmd($1);
191 192 bzero(list, sizeof (list_property_t));
192 193 num_prop_vals = 0;
193 194 }
194 195 if (YYRECOVERING())
195 196 YYABORT;
196 197 yyclearin;
197 198 yyerrok;
198 199 }
199 200 | error terminator
200 201 {
201 202 if (YYRECOVERING())
202 203 YYABORT;
203 204 yyclearin;
204 205 yyerrok;
205 206 }
206 207 | terminator
207 208 {
208 209 assert_no_unclaimed_tokens();
209 210 return (0);
210 211 }
211 212
212 213 command: add_command
213 214 | cancel_command
214 215 | clear_command
215 216 | create_command
216 217 | commit_command
217 218 | delete_command
218 219 | end_command
219 220 | exit_command
220 221 | export_command
221 222 | help_command
222 223 | info_command
223 224 | remove_command
224 225 | revert_command
225 226 | select_command
226 227 | set_command
227 228 | verify_command
228 229
229 230 terminator: '\n' { newline_terminated = B_TRUE; }
230 231 | ';' { newline_terminated = B_FALSE; }
231 232
232 233 add_command: ADD
233 234 {
234 235 short_usage(CMD_ADD);
235 236 (void) fputs("\n", stderr);
236 237 usage(B_FALSE, HELP_RES_PROPS);
237 238 YYERROR;
238 239 }
239 240 | ADD TOKEN
240 241 {
241 242 if (($$ = alloc_cmd()) == NULL)
242 243 YYERROR;
243 244 cmd = $$;
244 245 $$->cmd_handler = &add_func;
245 246 $$->cmd_argc = 1;
246 247 $$->cmd_argv[0] = claim_token($2);
247 248 $$->cmd_argv[1] = NULL;
248 249 }
249 250 | ADD resource_type
250 251 {
251 252 if (($$ = alloc_cmd()) == NULL)
252 253 YYERROR;
253 254 cmd = $$;
254 255 $$->cmd_handler = &add_func;
255 256 $$->cmd_argc = 0;
256 257 $$->cmd_res_type = $2;
257 258 $$->cmd_prop_nv_pairs = 0;
258 259 }
259 260 | ADD property_name property_value
260 261 {
261 262 if (($$ = alloc_cmd()) == NULL)
262 263 YYERROR;
263 264 cmd = $$;
264 265 $$->cmd_handler = &add_func;
265 266 $$->cmd_argc = 0;
266 267 $$->cmd_prop_nv_pairs = 1;
267 268 $$->cmd_prop_name[0] = $2;
268 269 $$->cmd_property_ptr[0] = &property[0];
269 270 }
270 271
271 272 cancel_command: CANCEL
272 273 {
273 274 if (($$ = alloc_cmd()) == NULL)
274 275 YYERROR;
275 276 cmd = $$;
276 277 $$->cmd_handler = &cancel_func;
277 278 $$->cmd_argc = 0;
278 279 $$->cmd_argv[0] = NULL;
279 280 }
280 281 | CANCEL TOKEN
281 282 {
282 283 if (($$ = alloc_cmd()) == NULL)
283 284 YYERROR;
284 285 cmd = $$;
285 286 $$->cmd_handler = &cancel_func;
286 287 $$->cmd_argc = 1;
287 288 $$->cmd_argv[0] = claim_token($2);
288 289 $$->cmd_argv[1] = NULL;
289 290 }
290 291
291 292 create_command: CREATE
292 293 {
293 294 if (($$ = alloc_cmd()) == NULL)
294 295 YYERROR;
295 296 cmd = $$;
296 297 $$->cmd_handler = &create_func;
297 298 $$->cmd_argc = 0;
298 299 $$->cmd_argv[0] = NULL;
299 300 }
300 301 | CREATE TOKEN
301 302 {
302 303 if (($$ = alloc_cmd()) == NULL)
303 304 YYERROR;
304 305 cmd = $$;
305 306 $$->cmd_handler = &create_func;
306 307 $$->cmd_argc = 1;
307 308 $$->cmd_argv[0] = claim_token($2);
308 309 $$->cmd_argv[1] = NULL;
309 310 }
310 311 | CREATE TOKEN TOKEN
311 312 {
312 313 if (($$ = alloc_cmd()) == NULL)
313 314 YYERROR;
314 315 cmd = $$;
315 316 $$->cmd_handler = &create_func;
316 317 $$->cmd_argc = 2;
317 318 $$->cmd_argv[0] = claim_token($2);
318 319 $$->cmd_argv[1] = claim_token($3);
319 320 $$->cmd_argv[2] = NULL;
320 321 }
321 322 | CREATE TOKEN TOKEN TOKEN
322 323 {
323 324 if (($$ = alloc_cmd()) == NULL)
324 325 YYERROR;
325 326 cmd = $$;
326 327 $$->cmd_handler = &create_func;
327 328 $$->cmd_argc = 3;
328 329 $$->cmd_argv[0] = claim_token($2);
329 330 $$->cmd_argv[1] = claim_token($3);
330 331 $$->cmd_argv[2] = claim_token($4);
331 332 $$->cmd_argv[3] = NULL;
332 333 }
333 334
334 335 commit_command: COMMIT
335 336 {
336 337 if (($$ = alloc_cmd()) == NULL)
337 338 YYERROR;
338 339 cmd = $$;
339 340 $$->cmd_handler = &commit_func;
340 341 $$->cmd_argc = 0;
341 342 $$->cmd_argv[0] = NULL;
342 343 }
343 344 | COMMIT TOKEN
344 345 {
345 346 if (($$ = alloc_cmd()) == NULL)
346 347 YYERROR;
347 348 cmd = $$;
348 349 $$->cmd_handler = &commit_func;
349 350 $$->cmd_argc = 1;
350 351 $$->cmd_argv[0] = claim_token($2);
351 352 $$->cmd_argv[1] = NULL;
352 353 }
353 354
354 355 delete_command: DELETE
355 356 {
356 357 if (($$ = alloc_cmd()) == NULL)
357 358 YYERROR;
358 359 cmd = $$;
359 360 $$->cmd_handler = &delete_func;
360 361 $$->cmd_argc = 0;
361 362 $$->cmd_argv[0] = NULL;
362 363 }
363 364 | DELETE TOKEN
364 365 {
365 366 if (($$ = alloc_cmd()) == NULL)
366 367 YYERROR;
367 368 cmd = $$;
368 369 $$->cmd_handler = &delete_func;
369 370 $$->cmd_argc = 1;
370 371 $$->cmd_argv[0] = claim_token($2);
371 372 $$->cmd_argv[1] = NULL;
372 373 }
373 374
374 375 end_command: END
375 376 {
376 377 if (($$ = alloc_cmd()) == NULL)
377 378 YYERROR;
378 379 cmd = $$;
379 380 $$->cmd_handler = &end_func;
380 381 $$->cmd_argc = 0;
381 382 $$->cmd_argv[0] = NULL;
382 383 }
383 384 | END TOKEN
384 385 {
385 386 if (($$ = alloc_cmd()) == NULL)
386 387 YYERROR;
387 388 cmd = $$;
388 389 $$->cmd_handler = &end_func;
389 390 $$->cmd_argc = 1;
390 391 $$->cmd_argv[0] = claim_token($2);
391 392 $$->cmd_argv[1] = NULL;
392 393 }
393 394
394 395 exit_command: EXIT
395 396 {
396 397 if (($$ = alloc_cmd()) == NULL)
397 398 YYERROR;
398 399 cmd = $$;
399 400 $$->cmd_handler = &exit_func;
400 401 $$->cmd_argc = 0;
401 402 $$->cmd_argv[0] = NULL;
402 403 }
403 404 | EXIT TOKEN
404 405 {
405 406 if (($$ = alloc_cmd()) == NULL)
406 407 YYERROR;
407 408 cmd = $$;
408 409 $$->cmd_handler = &exit_func;
409 410 $$->cmd_argc = 1;
410 411 $$->cmd_argv[0] = claim_token($2);
411 412 $$->cmd_argv[1] = NULL;
412 413 }
413 414
414 415 export_command: EXPORT
415 416 {
416 417 if (($$ = alloc_cmd()) == NULL)
417 418 YYERROR;
418 419 cmd = $$;
419 420 $$->cmd_handler = &export_func;
420 421 $$->cmd_argc = 0;
421 422 $$->cmd_argv[0] = NULL;
422 423 }
423 424 | EXPORT TOKEN
424 425 {
425 426 if (($$ = alloc_cmd()) == NULL)
426 427 YYERROR;
427 428 cmd = $$;
428 429 $$->cmd_handler = &export_func;
429 430 $$->cmd_argc = 1;
430 431 $$->cmd_argv[0] = claim_token($2);
431 432 $$->cmd_argv[1] = NULL;
432 433 }
433 434 | EXPORT TOKEN TOKEN
434 435 {
435 436 if (($$ = alloc_cmd()) == NULL)
436 437 YYERROR;
437 438 cmd = $$;
438 439 $$->cmd_handler = &export_func;
439 440 $$->cmd_argc = 2;
440 441 $$->cmd_argv[0] = claim_token($2);
441 442 $$->cmd_argv[1] = claim_token($3);
442 443 $$->cmd_argv[2] = NULL;
443 444 }
444 445
445 446 help_command: HELP
446 447 {
447 448 if (($$ = alloc_cmd()) == NULL)
448 449 YYERROR;
449 450 cmd = $$;
450 451 $$->cmd_handler = &help_func;
451 452 $$->cmd_argc = 0;
452 453 $$->cmd_argv[0] = NULL;
453 454 }
454 455 | HELP TOKEN
455 456 {
456 457 if (($$ = alloc_cmd()) == NULL)
457 458 YYERROR;
458 459 cmd = $$;
459 460 $$->cmd_handler = &help_func;
460 461 $$->cmd_argc = 1;
461 462 $$->cmd_argv[0] = claim_token($2);
462 463 $$->cmd_argv[1] = NULL;
463 464 }
464 465
465 466 info_command: INFO
466 467 {
467 468 if (($$ = alloc_cmd()) == NULL)
468 469 YYERROR;
469 470 cmd = $$;
470 471 $$->cmd_handler = &info_func;
471 472 $$->cmd_res_type = RT_UNKNOWN;
472 473 $$->cmd_prop_nv_pairs = 0;
473 474 }
474 475 | INFO TOKEN
475 476 {
476 477 short_usage(CMD_INFO);
477 478 (void) fputs("\n", stderr);
478 479 usage(B_FALSE, HELP_RES_PROPS);
479 480 free(claim_token($2));
480 481 YYERROR;
481 482 }
482 483 | INFO resource_type
483 484 {
484 485 if (($$ = alloc_cmd()) == NULL)
485 486 YYERROR;
486 487 cmd = $$;
487 488 $$->cmd_handler = &info_func;
488 489 $$->cmd_res_type = $2;
489 490 $$->cmd_prop_nv_pairs = 0;
490 491 }
491 492 | INFO ZONENAME
492 493 {
493 494 if (($$ = alloc_cmd()) == NULL)
494 495 YYERROR;
495 496 cmd = $$;
496 497 $$->cmd_handler = &info_func;
497 498 $$->cmd_res_type = RT_ZONENAME;
498 499 $$->cmd_prop_nv_pairs = 0;
499 500 }
500 501 | INFO ZONEPATH
501 502 {
502 503 if (($$ = alloc_cmd()) == NULL)
503 504 YYERROR;
504 505 cmd = $$;
505 506 $$->cmd_handler = &info_func;
506 507 $$->cmd_res_type = RT_ZONEPATH;
507 508 $$->cmd_prop_nv_pairs = 0;
508 509 }
509 510 | INFO BRAND
510 511 {
511 512 if (($$ = alloc_cmd()) == NULL)
512 513 YYERROR;
513 514 cmd = $$;
514 515 $$->cmd_handler = &info_func;
515 516 $$->cmd_res_type = RT_BRAND;
516 517 $$->cmd_prop_nv_pairs = 0;
517 518 }
518 519 | INFO AUTOBOOT
519 520 {
520 521 if (($$ = alloc_cmd()) == NULL)
521 522 YYERROR;
522 523 cmd = $$;
523 524 $$->cmd_handler = &info_func;
524 525 $$->cmd_res_type = RT_AUTOBOOT;
525 526 $$->cmd_prop_nv_pairs = 0;
526 527 }
527 528 | INFO IPTYPE
528 529 {
529 530 if (($$ = alloc_cmd()) == NULL)
530 531 YYERROR;
531 532 cmd = $$;
532 533 $$->cmd_handler = &info_func;
533 534 $$->cmd_res_type = RT_IPTYPE;
534 535 $$->cmd_prop_nv_pairs = 0;
535 536 }
536 537 | INFO POOL
537 538 {
538 539 if (($$ = alloc_cmd()) == NULL)
539 540 YYERROR;
540 541 cmd = $$;
541 542 $$->cmd_handler = &info_func;
542 543 $$->cmd_res_type = RT_POOL;
543 544 $$->cmd_prop_nv_pairs = 0;
544 545 }
545 546 | INFO LIMITPRIV
546 547 {
547 548 if (($$ = alloc_cmd()) == NULL)
548 549 YYERROR;
549 550 cmd = $$;
550 551 $$->cmd_handler = &info_func;
551 552 $$->cmd_res_type = RT_LIMITPRIV;
552 553 $$->cmd_prop_nv_pairs = 0;
553 554 }
554 555 | INFO BOOTARGS
555 556 {
556 557 if (($$ = alloc_cmd()) == NULL)
557 558 YYERROR;
558 559 cmd = $$;
559 560 $$->cmd_handler = &info_func;
560 561 $$->cmd_res_type = RT_BOOTARGS;
561 562 $$->cmd_prop_nv_pairs = 0;
562 563 }
563 564 | INFO SCHED
564 565 {
565 566 if (($$ = alloc_cmd()) == NULL)
566 567 YYERROR;
567 568 cmd = $$;
568 569 $$->cmd_handler = &info_func;
569 570 $$->cmd_res_type = RT_SCHED;
570 571 $$->cmd_prop_nv_pairs = 0;
571 572 }
572 573 | INFO SHARES
573 574 {
574 575 if (($$ = alloc_cmd()) == NULL)
575 576 YYERROR;
576 577 cmd = $$;
577 578 $$->cmd_handler = &info_func;
578 579 $$->cmd_res_type = RT_SHARES;
579 580 $$->cmd_prop_nv_pairs = 0;
580 581 }
581 582 | INFO MAXLWPS
582 583 {
583 584 if (($$ = alloc_cmd()) == NULL)
584 585 YYERROR;
585 586 cmd = $$;
586 587 $$->cmd_handler = &info_func;
587 588 $$->cmd_res_type = RT_MAXLWPS;
588 589 $$->cmd_prop_nv_pairs = 0;
589 590 }
590 591 | INFO MAXPROCS
591 592 {
592 593 if (($$ = alloc_cmd()) == NULL)
593 594 YYERROR;
594 595 cmd = $$;
595 596 $$->cmd_handler = &info_func;
596 597 $$->cmd_res_type = RT_MAXPROCS;
597 598 $$->cmd_prop_nv_pairs = 0;
598 599 }
599 600 | INFO MAXSHMMEM
600 601 {
601 602 if (($$ = alloc_cmd()) == NULL)
602 603 YYERROR;
603 604 cmd = $$;
604 605 $$->cmd_handler = &info_func;
605 606 $$->cmd_res_type = RT_MAXSHMMEM;
606 607 $$->cmd_prop_nv_pairs = 0;
607 608 }
608 609 | INFO MAXSHMIDS
609 610 {
610 611 if (($$ = alloc_cmd()) == NULL)
611 612 YYERROR;
612 613 cmd = $$;
613 614 $$->cmd_handler = &info_func;
614 615 $$->cmd_res_type = RT_MAXSHMIDS;
615 616 $$->cmd_prop_nv_pairs = 0;
616 617 }
617 618 | INFO MAXMSGIDS
618 619 {
619 620 if (($$ = alloc_cmd()) == NULL)
620 621 YYERROR;
621 622 cmd = $$;
622 623 $$->cmd_handler = &info_func;
623 624 $$->cmd_res_type = RT_MAXMSGIDS;
624 625 $$->cmd_prop_nv_pairs = 0;
625 626 }
626 627 | INFO MAXSEMIDS
627 628 {
628 629 if (($$ = alloc_cmd()) == NULL)
629 630 YYERROR;
630 631 cmd = $$;
631 632 $$->cmd_handler = &info_func;
632 633 $$->cmd_res_type = RT_MAXSEMIDS;
633 634 $$->cmd_prop_nv_pairs = 0;
634 635 }
635 636 | INFO HOSTID
636 637 {
637 638 if (($$ = alloc_cmd()) == NULL)
638 639 YYERROR;
639 640 cmd = $$;
640 641 $$->cmd_handler = &info_func;
641 642 $$->cmd_res_type = RT_HOSTID;
642 643 $$->cmd_prop_nv_pairs = 0;
643 644 }
644 645 | INFO FS_ALLOWED
645 646 {
646 647 if (($$ = alloc_cmd()) == NULL)
647 648 YYERROR;
648 649 cmd = $$;
649 650 $$->cmd_handler = &info_func;
650 651 $$->cmd_res_type = RT_FS_ALLOWED;
651 652 $$->cmd_prop_nv_pairs = 0;
652 653 }
653 654 | INFO resource_type property_name EQUAL property_value
654 655 {
655 656 if (($$ = alloc_cmd()) == NULL)
656 657 YYERROR;
657 658 cmd = $$;
658 659 $$->cmd_handler = &info_func;
659 660 $$->cmd_res_type = $2;
660 661 $$->cmd_prop_nv_pairs = 1;
661 662 $$->cmd_prop_name[0] = $3;
662 663 $$->cmd_property_ptr[0] = &property[0];
663 664 }
664 665 | INFO resource_type property_name EQUAL property_value property_name EQUAL property_value
665 666 {
666 667 if (($$ = alloc_cmd()) == NULL)
667 668 YYERROR;
668 669 cmd = $$;
669 670 $$->cmd_handler = &info_func;
670 671 $$->cmd_res_type = $2;
671 672 $$->cmd_prop_nv_pairs = 2;
672 673 $$->cmd_prop_name[0] = $3;
673 674 $$->cmd_property_ptr[0] = &property[0];
674 675 $$->cmd_prop_name[1] = $6;
675 676 $$->cmd_property_ptr[1] = &property[1];
676 677 }
677 678 | INFO resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
678 679 {
679 680 if (($$ = alloc_cmd()) == NULL)
680 681 YYERROR;
681 682 cmd = $$;
682 683 $$->cmd_handler = &info_func;
683 684 $$->cmd_res_type = $2;
684 685 $$->cmd_prop_nv_pairs = 3;
685 686 $$->cmd_prop_name[0] = $3;
686 687 $$->cmd_property_ptr[0] = &property[0];
687 688 $$->cmd_prop_name[1] = $6;
688 689 $$->cmd_property_ptr[1] = &property[1];
689 690 $$->cmd_prop_name[2] = $9;
690 691 $$->cmd_property_ptr[2] = &property[2];
691 692 }
692 693
693 694 remove_command: REMOVE
694 695 {
695 696 short_usage(CMD_REMOVE);
696 697 (void) fputs("\n", stderr);
697 698 usage(B_FALSE, HELP_RES_PROPS);
698 699 YYERROR;
699 700 }
700 701 | REMOVE TOKEN
701 702 {
702 703 short_usage(CMD_REMOVE);
703 704 (void) fputs("\n", stderr);
704 705 usage(B_FALSE, HELP_RES_PROPS);
705 706 free(claim_token($2));
706 707 YYERROR;
707 708 }
708 709 | REMOVE resource_type
709 710 {
710 711 if (($$ = alloc_cmd()) == NULL)
711 712 YYERROR;
712 713 cmd = $$;
713 714 $$->cmd_handler = &remove_func;
714 715 $$->cmd_res_type = $2;
715 716 }
716 717 | REMOVE TOKEN resource_type
717 718 {
718 719 if (($$ = alloc_cmd()) == NULL)
719 720 YYERROR;
720 721 cmd = $$;
721 722 $$->cmd_handler = &remove_func;
722 723 $$->cmd_res_type = $3;
723 724 $$->cmd_argc = 1;
724 725 $$->cmd_argv[0] = claim_token($2);
725 726 $$->cmd_argv[1] = NULL;
726 727 }
727 728 | REMOVE property_name property_value
728 729 {
729 730 if (($$ = alloc_cmd()) == NULL)
730 731 YYERROR;
731 732 cmd = $$;
732 733 $$->cmd_handler = &remove_func;
733 734 $$->cmd_prop_nv_pairs = 1;
734 735 $$->cmd_prop_name[0] = $2;
735 736 $$->cmd_property_ptr[0] = &property[0];
736 737 }
737 738 | REMOVE resource_type property_name EQUAL property_value
738 739 {
739 740 if (($$ = alloc_cmd()) == NULL)
740 741 YYERROR;
741 742 cmd = $$;
742 743 $$->cmd_handler = &remove_func;
743 744 $$->cmd_res_type = $2;
744 745 $$->cmd_prop_nv_pairs = 1;
745 746 $$->cmd_prop_name[0] = $3;
746 747 $$->cmd_property_ptr[0] = &property[0];
747 748 }
748 749 | REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value
749 750 {
750 751 if (($$ = alloc_cmd()) == NULL)
751 752 YYERROR;
752 753 cmd = $$;
753 754 $$->cmd_handler = &remove_func;
754 755 $$->cmd_res_type = $2;
755 756 $$->cmd_prop_nv_pairs = 2;
756 757 $$->cmd_prop_name[0] = $3;
757 758 $$->cmd_property_ptr[0] = &property[0];
758 759 $$->cmd_prop_name[1] = $6;
759 760 $$->cmd_property_ptr[1] = &property[1];
760 761 }
761 762 | REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
762 763 {
763 764 if (($$ = alloc_cmd()) == NULL)
764 765 YYERROR;
765 766 cmd = $$;
766 767 $$->cmd_handler = &remove_func;
767 768 $$->cmd_res_type = $2;
768 769 $$->cmd_prop_nv_pairs = 3;
769 770 $$->cmd_prop_name[0] = $3;
770 771 $$->cmd_property_ptr[0] = &property[0];
771 772 $$->cmd_prop_name[1] = $6;
772 773 $$->cmd_property_ptr[1] = &property[1];
773 774 $$->cmd_prop_name[2] = $9;
774 775 $$->cmd_property_ptr[2] = &property[2];
775 776 }
776 777
777 778 revert_command: REVERT
778 779 {
779 780 if (($$ = alloc_cmd()) == NULL)
780 781 YYERROR;
781 782 cmd = $$;
782 783 $$->cmd_handler = &revert_func;
783 784 $$->cmd_argc = 0;
784 785 $$->cmd_argv[0] = NULL;
785 786 }
786 787 | REVERT TOKEN
787 788 {
788 789 if (($$ = alloc_cmd()) == NULL)
789 790 YYERROR;
790 791 cmd = $$;
791 792 $$->cmd_handler = &revert_func;
792 793 $$->cmd_argc = 1;
793 794 $$->cmd_argv[0] = claim_token($2);
794 795 $$->cmd_argv[1] = NULL;
795 796 }
796 797
797 798 select_command: SELECT
798 799 {
799 800 short_usage(CMD_SELECT);
800 801 (void) fputs("\n", stderr);
801 802 usage(B_FALSE, HELP_RES_PROPS);
802 803 YYERROR;
803 804 }
804 805 | SELECT PSET
805 806 {
806 807 if (($$ = alloc_cmd()) == NULL)
807 808 YYERROR;
808 809 cmd = $$;
809 810 $$->cmd_handler = &select_func;
810 811 $$->cmd_res_type = RT_DCPU;
811 812 }
812 813 | SELECT PCAP
813 814 {
814 815 if (($$ = alloc_cmd()) == NULL)
815 816 YYERROR;
816 817 cmd = $$;
817 818 $$->cmd_handler = &select_func;
818 819 $$->cmd_res_type = RT_PCAP;
819 820 }
820 821 | SELECT MCAP
821 822 {
822 823 if (($$ = alloc_cmd()) == NULL)
823 824 YYERROR;
824 825 cmd = $$;
825 826 $$->cmd_handler = &select_func;
826 827 $$->cmd_res_type = RT_MCAP;
827 828 }
828 829 | SELECT resource_type
829 830 {
830 831 short_usage(CMD_SELECT);
831 832 YYERROR;
832 833 }
833 834 | SELECT resource_type property_name EQUAL property_value
834 835 {
835 836 if (($$ = alloc_cmd()) == NULL)
836 837 YYERROR;
837 838 cmd = $$;
838 839 $$->cmd_handler = &select_func;
839 840 $$->cmd_res_type = $2;
840 841 $$->cmd_prop_nv_pairs = 1;
841 842 $$->cmd_prop_name[0] = $3;
842 843 $$->cmd_property_ptr[0] = &property[0];
843 844 }
844 845 | SELECT resource_type property_name EQUAL property_value property_name EQUAL property_value
845 846 {
846 847 if (($$ = alloc_cmd()) == NULL)
847 848 YYERROR;
848 849 cmd = $$;
849 850 $$->cmd_handler = &select_func;
850 851 $$->cmd_res_type = $2;
851 852 $$->cmd_prop_nv_pairs = 2;
852 853 $$->cmd_prop_name[0] = $3;
853 854 $$->cmd_property_ptr[0] = &property[0];
854 855 $$->cmd_prop_name[1] = $6;
855 856 $$->cmd_property_ptr[1] = &property[1];
856 857 }
857 858 | SELECT resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
858 859 {
859 860 if (($$ = alloc_cmd()) == NULL)
860 861 YYERROR;
861 862 cmd = $$;
862 863 $$->cmd_handler = &select_func;
863 864 $$->cmd_res_type = $2;
864 865 $$->cmd_prop_nv_pairs = 3;
865 866 $$->cmd_prop_name[0] = $3;
866 867 $$->cmd_property_ptr[0] = &property[0];
867 868 $$->cmd_prop_name[1] = $6;
868 869 $$->cmd_property_ptr[1] = &property[1];
869 870 $$->cmd_prop_name[2] = $9;
870 871 $$->cmd_property_ptr[2] = &property[2];
871 872 }
872 873
873 874 set_command: SET
874 875 {
875 876 short_usage(CMD_SET);
876 877 (void) fputs("\n", stderr);
877 878 usage(B_FALSE, HELP_PROPS);
878 879 YYERROR;
879 880 }
880 881 | SET property_name EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
881 882 {
882 883 if (($$ = alloc_cmd()) == NULL)
883 884 YYERROR;
884 885 cmd = $$;
885 886 $$->cmd_handler = &set_func;
886 887 $$->cmd_prop_nv_pairs = 0;
887 888 $$->cmd_prop_name[0] = $2;
888 889 property[0].pv_type = PROP_VAL_LIST;
889 890 property[0].pv_list = NULL;
890 891 $$->cmd_property_ptr[0] = &property[0];
891 892 }
892 893 | SET property_name EQUAL property_value
893 894 {
894 895 if (($$ = alloc_cmd()) == NULL)
895 896 YYERROR;
896 897 cmd = $$;
897 898 $$->cmd_handler = &set_func;
898 899 $$->cmd_prop_nv_pairs = 1;
899 900 $$->cmd_prop_name[0] = $2;
900 901 $$->cmd_property_ptr[0] = &property[0];
901 902 }
902 903 | SET TOKEN ZONEPATH EQUAL property_value
903 904 {
904 905 if (($$ = alloc_cmd()) == NULL)
905 906 YYERROR;
906 907 cmd = $$;
907 908 $$->cmd_argc = 1;
908 909 $$->cmd_argv[0] = claim_token($2);
909 910 $$->cmd_argv[1] = NULL;
910 911 $$->cmd_handler = &set_func;
911 912 $$->cmd_prop_nv_pairs = 1;
912 913 $$->cmd_prop_name[0] = PT_ZONEPATH;
913 914 $$->cmd_property_ptr[0] = &property[0];
914 915 }
915 916
916 917 clear_command: CLEAR
917 918 {
918 919 short_usage(CMD_CLEAR);
919 920 (void) fputs("\n", stderr);
920 921 usage(B_FALSE, HELP_PROPS);
921 922 YYERROR;
922 923 }
923 924 | CLEAR property_name
924 925 {
925 926 if (($$ = alloc_cmd()) == NULL)
926 927 YYERROR;
927 928 cmd = $$;
928 929 $$->cmd_handler = &clear_func;
929 930 $$->cmd_res_type = $2;
930 931 }
931 932
932 933 verify_command: VERIFY
933 934 {
934 935 if (($$ = alloc_cmd()) == NULL)
935 936 YYERROR;
936 937 cmd = $$;
937 938 $$->cmd_handler = &verify_func;
938 939 $$->cmd_argc = 0;
939 940 $$->cmd_argv[0] = NULL;
940 941 }
941 942 | VERIFY TOKEN
942 943 {
943 944 if (($$ = alloc_cmd()) == NULL)
944 945 YYERROR;
945 946 cmd = $$;
946 947 $$->cmd_handler = &verify_func;
947 948 $$->cmd_argc = 1;
948 949 $$->cmd_argv[0] = claim_token($2);
949 950 $$->cmd_argv[1] = NULL;
950 951 }
951 952
↓ open down ↓ |
793 lines elided |
↑ open up ↑ |
952 953 resource_type: NET { $$ = RT_NET; }
953 954 | FS { $$ = RT_FS; }
954 955 | DEVICE { $$ = RT_DEVICE; }
955 956 | RCTL { $$ = RT_RCTL; }
956 957 | ATTR { $$ = RT_ATTR; }
957 958 | DATASET { $$ = RT_DATASET; }
958 959 | PSET { $$ = RT_DCPU; }
959 960 | PCAP { $$ = RT_PCAP; }
960 961 | MCAP { $$ = RT_MCAP; }
961 962 | ADMIN { $$ = RT_ADMIN; }
963 + | SECFLAGS { $$ = RT_SECFLAGS; }
962 964
963 965 property_name: SPECIAL { $$ = PT_SPECIAL; }
964 966 | RAW { $$ = PT_RAW; }
965 967 | DIR { $$ = PT_DIR; }
966 968 | TYPE { $$ = PT_TYPE; }
967 969 | OPTIONS { $$ = PT_OPTIONS; }
968 970 | ZONENAME { $$ = PT_ZONENAME; }
969 971 | ZONEPATH { $$ = PT_ZONEPATH; }
970 972 | AUTOBOOT { $$ = PT_AUTOBOOT; }
971 973 | IPTYPE { $$ = PT_IPTYPE; }
972 974 | POOL { $$ = PT_POOL; }
973 975 | LIMITPRIV { $$ = PT_LIMITPRIV; }
974 976 | BOOTARGS { $$ = PT_BOOTARGS; }
975 977 | ADDRESS { $$ = PT_ADDRESS; }
976 978 | ALLOWED_ADDRESS { $$ = PT_ALLOWED_ADDRESS; }
977 979 | PHYSICAL { $$ = PT_PHYSICAL; }
978 980 | DEFROUTER { $$ = PT_DEFROUTER; }
979 981 | NAME { $$ = PT_NAME; }
980 982 | VALUE { $$ = PT_VALUE; }
981 983 | MATCH { $$ = PT_MATCH; }
982 984 | PRIV { $$ = PT_PRIV; }
983 985 | LIMIT { $$ = PT_LIMIT; }
984 986 | ACTION { $$ = PT_ACTION; }
985 987 | BRAND { $$ = PT_BRAND; }
986 988 | NCPUS { $$ = PT_NCPUS; }
987 989 | LOCKED { $$ = PT_LOCKED; }
988 990 | SWAP { $$ = PT_SWAP; }
989 991 | IMPORTANCE { $$ = PT_IMPORTANCE; }
990 992 | SHARES { $$ = PT_SHARES; }
991 993 | MAXLWPS { $$ = PT_MAXLWPS; }
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
992 994 | MAXPROCS { $$ = PT_MAXPROCS; }
993 995 | MAXSHMMEM { $$ = PT_MAXSHMMEM; }
994 996 | MAXSHMIDS { $$ = PT_MAXSHMIDS; }
995 997 | MAXMSGIDS { $$ = PT_MAXMSGIDS; }
996 998 | MAXSEMIDS { $$ = PT_MAXSEMIDS; }
997 999 | SCHED { $$ = PT_SCHED; }
998 1000 | HOSTID { $$ = PT_HOSTID; }
999 1001 | USER { $$ = PT_USER; }
1000 1002 | AUTHS { $$ = PT_AUTHS; }
1001 1003 | FS_ALLOWED { $$ = PT_FS_ALLOWED; }
1004 + | DEFAULT { $$ = PT_DEFAULT; }
1005 + | UPPER { $$ = PT_UPPER; }
1006 + | LOWER { $$ = PT_LOWER; }
1002 1007
1003 1008 /*
1004 1009 * The grammar builds data structures from the bottom up. Thus various
1005 1010 * strings are lexed into TOKENs or commands or resource or property values.
1006 1011 * Below is where the resource and property values are built up into more
1007 1012 * complex data structures.
1008 1013 *
1009 1014 * There are three kinds of properties: simple (single valued), complex
1010 1015 * (one or more name=value pairs) and list (concatenation of one or more
1011 1016 * simple or complex properties).
1012 1017 *
1013 1018 * So the property structure has a type which is one of these, and the
1014 1019 * corresponding _simple, _complex or _list is set to the corresponding
1015 1020 * lower-level data structure.
1016 1021 */
1017 1022
1018 1023 property_value: simple_prop_val
1019 1024 {
1020 1025 property[num_prop_vals].pv_type = PROP_VAL_SIMPLE;
1021 1026 property[num_prop_vals].pv_simple = $1;
1022 1027 if (list[num_prop_vals] != NULL) {
1023 1028 free_outer_list(list[num_prop_vals]);
1024 1029 list[num_prop_vals] = NULL;
1025 1030 }
1026 1031 num_prop_vals++;
1027 1032 }
1028 1033 | complex_prop_val
1029 1034 {
1030 1035 property[num_prop_vals].pv_type = PROP_VAL_COMPLEX;
1031 1036 property[num_prop_vals].pv_complex = complex;
1032 1037 if (list[num_prop_vals] != NULL) {
1033 1038 free_outer_list(list[num_prop_vals]);
1034 1039 list[num_prop_vals] = NULL;
1035 1040 }
1036 1041 num_prop_vals++;
1037 1042 }
1038 1043 | list_prop_val
1039 1044 {
1040 1045 property[num_prop_vals].pv_type = PROP_VAL_LIST;
1041 1046 property[num_prop_vals].pv_list = list[num_prop_vals];
1042 1047 num_prop_vals++;
1043 1048 }
1044 1049
1045 1050 /*
1046 1051 * One level lower, lists are made up of simple or complex values, so
1047 1052 * simple_prop_val and complex_prop_val fill in a list structure and
1048 1053 * insert it into the linked list which is built up. And because
1049 1054 * complex properties can have multiple name=value pairs, we keep
1050 1055 * track of them in another linked list.
1051 1056 *
1052 1057 * The complex and list structures for the linked lists are allocated
1053 1058 * below, and freed by recursive functions which are ultimately called
1054 1059 * by free_cmd(), which is called from the top-most "commands" part of
1055 1060 * the grammar.
1056 1061 *
1057 1062 * NOTE: simple_prop_val and complex_piece need reduction rules for
1058 1063 * property_name and resource_type so that the parser will accept property names
1059 1064 * and resource type names as property values.
1060 1065 */
1061 1066
1062 1067 simple_prop_val: TOKEN
1063 1068 {
1064 1069 $$ = simple_prop_val_func($1);
1065 1070 free(claim_token($1));
1066 1071 if ($$ == NULL)
1067 1072 YYERROR;
1068 1073 }
1069 1074 | resource_type
1070 1075 {
1071 1076 if (($$ = simple_prop_val_func(res_types[$1])) == NULL)
1072 1077 YYERROR;
1073 1078 }
1074 1079 | property_name
1075 1080 {
1076 1081 if (($$ = simple_prop_val_func(prop_types[$1])) == NULL)
1077 1082 YYERROR;
1078 1083 }
1079 1084
1080 1085 complex_prop_val: OPEN_PAREN complex_piece CLOSE_PAREN
1081 1086 {
1082 1087 if ((new_list = alloc_list()) == NULL)
1083 1088 YYERROR;
1084 1089 new_list->lp_simple = NULL;
1085 1090 new_list->lp_complex = complex;
1086 1091 new_list->lp_next = NULL;
1087 1092 if (list[num_prop_vals] == NULL) {
1088 1093 list[num_prop_vals] = new_list;
1089 1094 } else {
1090 1095 for (tmp_list = list[num_prop_vals]; tmp_list != NULL;
1091 1096 tmp_list = tmp_list->lp_next)
1092 1097 last = tmp_list;
1093 1098 last->lp_next = new_list;
1094 1099 }
1095 1100 }
1096 1101
1097 1102 complex_piece: property_name EQUAL TOKEN
1098 1103 {
1099 1104 $$ = complex_piece_func($1, $3, NULL);
1100 1105 free(claim_token($3));
1101 1106 if ($$ == NULL)
1102 1107 YYERROR;
1103 1108 }
↓ open down ↓ |
92 lines elided |
↑ open up ↑ |
1104 1109 | property_name EQUAL resource_type
1105 1110 {
1106 1111 if (($$ = complex_piece_func($1, res_types[$3], NULL)) == NULL)
1107 1112 YYERROR;
1108 1113 }
1109 1114 | property_name EQUAL property_name
1110 1115 {
1111 1116 if (($$ = complex_piece_func($1, prop_types[$3], NULL)) == NULL)
1112 1117 YYERROR;
1113 1118 }
1114 - | property_name EQUAL TOKEN COMMA complex_piece
1119 + | property_name EQUAL TOKEN COMMA complex_piece
1115 1120 {
1116 1121 $$ = complex_piece_func($1, $3, complex);
1117 1122 free(claim_token($3));
1118 1123 if ($$ == NULL)
1119 1124 YYERROR;
1120 1125 }
1121 - | property_name EQUAL resource_type COMMA complex_piece
1126 + | property_name EQUAL resource_type COMMA complex_piece
1122 1127 {
1123 1128 if (($$ = complex_piece_func($1, res_types[$3], complex)) ==
1124 1129 NULL)
1125 1130 YYERROR;
1126 1131 }
1127 - | property_name EQUAL property_name COMMA complex_piece
1132 + | property_name EQUAL property_name COMMA complex_piece
1128 1133 {
1129 1134 if (($$ = complex_piece_func($1, prop_types[$3], complex)) ==
1130 1135 NULL)
1131 1136 YYERROR;
1132 1137 }
1133 1138
1134 1139 list_piece: simple_prop_val
1135 1140 | complex_prop_val
1136 1141 | simple_prop_val COMMA list_piece
1137 1142 | complex_prop_val COMMA list_piece
1138 1143
1139 1144 list_prop_val: OPEN_SQ_BRACKET list_piece CLOSE_SQ_BRACKET
1140 1145 %%
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX