5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <acl_common.h>
29 extern
int yyinteractive
;
36 struct acl_perm_type acl_perm
;
43 %token USER_TOK USER_SID_TOK GROUP_TOK GROUP_SID_TOK MASK_TOK OTHER_TOK
44 %token OWNERAT_TOK GROUPAT_TOK EVERYONEAT_TOK DEFAULT_USER_TOK
45 %token DEFAULT_GROUP_TOK DEFAULT_MASK_TOK DEFAULT_OTHER_TOK
46 %token COLON COMMA NL SLASH
47 %token
<str
> ID IDNAME PERM_TOK INHERIT_TOK SID
48 %token
<val
> ERROR ACE_PERM ACE_INHERIT ENTRY_TYPE ACCESS_TYPE
51 %type
<acl_perm
> perms perm aclent_perm ace_perms
55 %type
<val
> iflags verbose_iflag compact_iflag access_type entry_type
67 /* This seems illegal, but the old aclfromtext() allows it */
84 yyacl
= acl_alloc
(ACE_T
);
87 return
(EACL_MEM_ERROR
);
92 if
($$
->acl_type
== ACLENT_T
) {
93 acl_error
(dgettext
(TEXT_DOMAIN
,
94 "Cannot have POSIX draft ACL entries"
95 " with NFSv4/ZFS ACL entries.\n"));
99 return
(EACL_DIFF_TYPE
);
102 $$
->acl_aclp
= realloc
($$
->acl_aclp
,
103 ($$
->acl_entry_size
* ($$
->acl_cnt
+ 1)));
104 if
($$
->acl_aclp
== NULL
) {
107 return
(EACL_MEM_ERROR
);
110 acep
[$$
->acl_cnt
] = $1;
119 yyacl
= acl_alloc
(ACLENT_T
);
122 return
(EACL_MEM_ERROR
);
127 if
($$
->acl_type
== ACE_T
) {
128 acl_error
(dgettext
(TEXT_DOMAIN
,
129 "Cannot have NFSv4/ZFS ACL entries"
130 " with POSIX draft ACL entries.\n"));
134 return
(EACL_DIFF_TYPE
);
137 $$
->acl_aclp
= realloc
($$
->acl_aclp
,
138 ($$
->acl_entry_size
* ($$
->acl_cnt
+1)));
139 if
($$
->acl_aclp
== NULL
) {
142 return
(EACL_MEM_ERROR
);
144 aclent
= $$
->acl_aclp
;
145 aclent
[$$
->acl_cnt
] = $1;
150 ace: entry_type idname ace_perms access_type
156 error = get_id
($1, $2, &id
);
158 bad_entry_type
($1, $2);
160 return
(EACL_INVALID_USER_GROUP
);
164 $$.a_flags
= ace_entry_type
($1);
165 error = ace_perm_mask
(&$3, &$$.a_access_mask
);
173 | entry_type idname ace_perms access_type COLON id
179 acl_error
(dgettext
(TEXT_DOMAIN
,
180 "Extra fields on the end of "
181 "ACL specification.\n"));
183 return
(EACL_UNKNOWN_DATA
);
185 error = get_id
($1, $2, &id
);
187 $$.a_who
= get_id_nofail
($1, $6);
191 $$.a_flags
= ace_entry_type
($1);
192 error = ace_perm_mask
(&$3, &$$.a_access_mask
);
199 | entry_type idname ace_perms iflags access_type
204 error = get_id
($1, $2, &id
);
206 bad_entry_type
($1, $2);
208 return
(EACL_INVALID_USER_GROUP
);
212 $$.a_flags
= ace_entry_type
($1);
213 error = ace_perm_mask
(&$3, &$$.a_access_mask
);
221 | entry_type idname ace_perms iflags access_type COLON id
227 acl_error
(dgettext
(TEXT_DOMAIN
,
228 "Extra fields on the end of "
229 "ACL specification.\n"));
231 return
(EACL_UNKNOWN_DATA
);
233 error = get_id
($1, $2, &id
);
235 $$.a_who
= get_id_nofail
($1, $7);
240 $$.a_flags
= ace_entry_type
($1);
241 error = ace_perm_mask
(&$3, &$$.a_access_mask
);
250 | entry_type ace_perms access_type
255 $$.a_flags
= ace_entry_type
($1);
256 error = ace_perm_mask
(&$2, &$$.a_access_mask
);
263 | entry_type ace_perms access_type COLON id
267 acl_error
(dgettext
(TEXT_DOMAIN
,
268 "Extra fields on the end of "
269 "ACL specification.\n"));
270 return
(EACL_UNKNOWN_DATA
);
273 return
(EACL_ENTRY_ERROR
);
275 | entry_type ace_perms iflags access_type
280 $$.a_flags
= ace_entry_type
($1);
281 error = ace_perm_mask
(&$2, &$$.a_access_mask
);
290 | entry_type ace_perms iflags access_type COLON id
294 acl_error
(dgettext
(TEXT_DOMAIN
,
295 "Extra fields on the end of "
296 "ACL specification.\n"));
297 return
(EACL_UNKNOWN_DATA
);
299 return
(EACL_ENTRY_ERROR
);
302 aclent: entry_type idname aclent_perm
/* user or group */
307 error = get_id
($1, $2, &id
);
309 bad_entry_type
($1, $2);
311 return
(EACL_INVALID_USER_GROUP
);
314 error = compute_aclent_perms
($3.perm_str
, &$$.a_perm
);
316 acl_error
(dgettext
(TEXT_DOMAIN
,
317 "Invalid permission(s) '%s' specified.\n"),
323 error = aclent_entry_type
($1, 0, &$$.a_type
);
326 dgettext
(TEXT_DOMAIN
,
327 "Invalid ACL entry type '%s' specified.\n"), $1);
332 | entry_type COLON aclent_perm
/* owner group other */
336 error = compute_aclent_perms
($3.perm_str
, &$$.a_perm
);
338 acl_error
(dgettext
(TEXT_DOMAIN
,
339 "Invalid permission(s) '%s' specified.\n"),
345 error = aclent_entry_type
($1, 1, &$$.a_type
);
348 dgettext
(TEXT_DOMAIN
,
349 "Invalid ACL entry type '%s' specified.\n"), $1);
354 | entry_type COLON aclent_perm COLON id
358 acl_error
(dgettext
(TEXT_DOMAIN
,
359 "Extra fields on the end of ACL specification.\n"));
360 return
(EACL_UNKNOWN_DATA
);
362 return
(EACL_ENTRY_ERROR
);
364 | entry_type idname aclent_perm COLON id
/* user or group */
370 acl_error
(dgettext
(TEXT_DOMAIN
,
371 "Extra fields on the end of ACL specification.\n"));
373 return
(EACL_UNKNOWN_DATA
);
375 error = compute_aclent_perms
($3.perm_str
, &$$.a_perm
);
377 acl_error
(dgettext
(TEXT_DOMAIN
,
378 "Invalid permission(s) '%s' specified.\n"),
383 error = get_id
($1, $2, &id
);
385 $$.a_id
= get_id_nofail
($1, $5);
389 error = aclent_entry_type
($1, 0, &$$.a_type
);
392 dgettext
(TEXT_DOMAIN
,
393 "Invalid ACL entry type '%s' specified.\n"), $1);
398 | entry_type aclent_perm
/* mask entry */
402 error = compute_aclent_perms
($2.perm_str
, &$$.a_perm
);
404 acl_error
(dgettext
(TEXT_DOMAIN
,
405 "Invalid permission(s) '%s' specified.\n"),
411 error = aclent_entry_type
($1, 0, &$$.a_type
);
414 dgettext
(TEXT_DOMAIN
,
415 "Invalid ACL entry type specified %d.\n"),
421 | entry_type aclent_perm COLON id
425 acl_error
(dgettext
(TEXT_DOMAIN
,
426 "Extra fields on the end of ACL specification.\n"));
427 return
(EACL_UNKNOWN_DATA
);
429 return
(EACL_ENTRY_ERROR
);
432 iflags: compact_iflag COLON
{$$
= $1;}
433 | verbose_iflag COLON
{$$
= $1;}
436 compact_iflag
: INHERIT_TOK
441 error = compute_ace_inherit
($1, &iflags
);
443 acl_error
(dgettext
(TEXT_DOMAIN
,
444 "Invalid inheritance flags '%s' specified.\n"), $1);
450 | INHERIT_TOK SLASH verbose_iflag
452 acl_error
(dgettext
(TEXT_DOMAIN
,
453 "Can't mix compact inherit flags with"
454 " verbose inheritance flags.\n"));
456 return
(EACL_INHERIT_ERROR
);
459 verbose_iflag: ACE_INHERIT
{$$ |
= $1;}
460 | ACE_INHERIT SLASH verbose_iflag
{$$
= $1 |
$3;}
461 | ACE_INHERIT SLASH compact_iflag
463 acl_error
(dgettext
(TEXT_DOMAIN
,
464 "Can't mix verbose inherit flags with"
465 " compact inheritance flags.\n"));
467 return
(EACL_INHERIT_ERROR
);
469 | ACE_INHERIT SLASH ACCESS_TYPE
471 acl_error
(dgettext
(TEXT_DOMAIN
,
472 "Inheritance flags can't be mixed with access type.\n"));
474 return
(EACL_INHERIT_ERROR
);
476 | ACE_INHERIT SLASH ERROR
482 aclent_perm: PERM_TOK
484 $$.perm_style
= PERM_TYPE_UNKNOWN
;
490 acl_error
(dgettext
(TEXT_DOMAIN
,
491 "ACL entry permissions are incorrectly specified.\n"));
496 access_type: ACCESS_TYPE
{$$
= $1;}
507 acl_error
(dgettext
(TEXT_DOMAIN
,
508 "Invalid uid/gid specified.\nThe field"
509 " should be a numeric value.\n"));
511 return
(EACL_UNKNOWN_DATA
);
519 ace_perms: perm
{$$
= $1;}
520 | aclent_perm COLON
{$$
= $1;}
527 perm: perms COLON
{$$
= $1;}
528 | COLON
{$$.perm_style
= PERM_TYPE_EMPTY
;}
532 $$.perm_style
= PERM_TYPE_ACE
;
535 | ACE_PERM SLASH perms
537 $$.perm_style
= PERM_TYPE_ACE
;
538 $$.perm_val
= $1 |
$3.perm_val
;
540 | ACE_PERM SLASH aclent_perm
543 acl_error
(dgettext
(TEXT_DOMAIN
,
544 "Can't mix verbose permissions with"
545 " compact permission.\n"));
547 return
(EACL_PERM_MASK_ERROR
);
550 | ACE_PERM SLASH ERROR
557 idname: IDNAME
{$$
= $1;}
559 entry_type: ENTRY_TYPE
{$$
= $1;}
568 bad_entry_type
(int toketype
, char *str
)
572 case DEFAULT_USER_TOK
:
573 acl_error
(dgettext
(TEXT_DOMAIN
,
574 "Invalid user %s specified.\n"), str
);
578 case DEFAULT_GROUP_TOK
:
579 acl_error
(dgettext
(TEXT_DOMAIN
,
580 "Invalid group %s specified.\n"), str
);
584 acl_error
(dgettext
(TEXT_DOMAIN
,
585 "Invalid user SID %s specified.\n"), str
);
589 acl_error
(dgettext
(TEXT_DOMAIN
,
590 "Invalid group SID %s specified.\n"), str
);