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
;
30 extern
int yylex(void);
37 struct acl_perm_type acl_perm
;
44 %token USER_TOK USER_SID_TOK GROUP_TOK GROUP_SID_TOK MASK_TOK OTHER_TOK
45 %token OWNERAT_TOK GROUPAT_TOK EVERYONEAT_TOK DEFAULT_USER_TOK
46 %token DEFAULT_GROUP_TOK DEFAULT_MASK_TOK DEFAULT_OTHER_TOK
47 %token COLON COMMA NL SLASH
48 %token
<str
> ID IDNAME PERM_TOK INHERIT_TOK SID
49 %token
<val
> ERROR ACE_PERM ACE_INHERIT ENTRY_TYPE ACCESS_TYPE
52 %type
<acl_perm
> perms perm aclent_perm ace_perms
56 %type
<val
> iflags verbose_iflag compact_iflag access_type entry_type
68 /* This seems illegal, but the old aclfromtext() allows it */
85 yyacl
= acl_alloc
(ACE_T
);
88 return
(EACL_MEM_ERROR
);
93 if
($$
->acl_type
== ACLENT_T
) {
94 acl_error
(dgettext
(TEXT_DOMAIN
,
95 "Cannot have POSIX draft ACL entries"
96 " with NFSv4/ZFS ACL entries.\n"));
100 return
(EACL_DIFF_TYPE
);
103 $$
->acl_aclp
= realloc
($$
->acl_aclp
,
104 ($$
->acl_entry_size
* ($$
->acl_cnt
+ 1)));
105 if
($$
->acl_aclp
== NULL
) {
108 return
(EACL_MEM_ERROR
);
111 acep
[$$
->acl_cnt
] = $1;
120 yyacl
= acl_alloc
(ACLENT_T
);
123 return
(EACL_MEM_ERROR
);
128 if
($$
->acl_type
== ACE_T
) {
129 acl_error
(dgettext
(TEXT_DOMAIN
,
130 "Cannot have NFSv4/ZFS ACL entries"
131 " with POSIX draft ACL entries.\n"));
135 return
(EACL_DIFF_TYPE
);
138 $$
->acl_aclp
= realloc
($$
->acl_aclp
,
139 ($$
->acl_entry_size
* ($$
->acl_cnt
+1)));
140 if
($$
->acl_aclp
== NULL
) {
143 return
(EACL_MEM_ERROR
);
145 aclent
= $$
->acl_aclp
;
146 aclent
[$$
->acl_cnt
] = $1;
151 ace: entry_type idname ace_perms access_type
157 error = get_id
($1, $2, &id
);
159 bad_entry_type
($1, $2);
161 return
(EACL_INVALID_USER_GROUP
);
165 $$.a_flags
= ace_entry_type
($1);
166 error = ace_perm_mask
(&$3, &$$.a_access_mask
);
174 | entry_type idname ace_perms access_type COLON id
180 acl_error
(dgettext
(TEXT_DOMAIN
,
181 "Extra fields on the end of "
182 "ACL specification.\n"));
184 return
(EACL_UNKNOWN_DATA
);
186 error = get_id
($1, $2, &id
);
188 $$.a_who
= get_id_nofail
($1, $6);
192 $$.a_flags
= ace_entry_type
($1);
193 error = ace_perm_mask
(&$3, &$$.a_access_mask
);
200 | entry_type idname ace_perms iflags access_type
205 error = get_id
($1, $2, &id
);
207 bad_entry_type
($1, $2);
209 return
(EACL_INVALID_USER_GROUP
);
213 $$.a_flags
= ace_entry_type
($1);
214 error = ace_perm_mask
(&$3, &$$.a_access_mask
);
222 | entry_type idname ace_perms iflags access_type COLON id
228 acl_error
(dgettext
(TEXT_DOMAIN
,
229 "Extra fields on the end of "
230 "ACL specification.\n"));
232 return
(EACL_UNKNOWN_DATA
);
234 error = get_id
($1, $2, &id
);
236 $$.a_who
= get_id_nofail
($1, $7);
241 $$.a_flags
= ace_entry_type
($1);
242 error = ace_perm_mask
(&$3, &$$.a_access_mask
);
251 | entry_type ace_perms access_type
256 $$.a_flags
= ace_entry_type
($1);
257 error = ace_perm_mask
(&$2, &$$.a_access_mask
);
264 | entry_type ace_perms access_type COLON id
268 acl_error
(dgettext
(TEXT_DOMAIN
,
269 "Extra fields on the end of "
270 "ACL specification.\n"));
271 return
(EACL_UNKNOWN_DATA
);
274 return
(EACL_ENTRY_ERROR
);
276 | entry_type ace_perms iflags access_type
281 $$.a_flags
= ace_entry_type
($1);
282 error = ace_perm_mask
(&$2, &$$.a_access_mask
);
291 | entry_type ace_perms iflags access_type COLON id
295 acl_error
(dgettext
(TEXT_DOMAIN
,
296 "Extra fields on the end of "
297 "ACL specification.\n"));
298 return
(EACL_UNKNOWN_DATA
);
300 return
(EACL_ENTRY_ERROR
);
303 aclent: entry_type idname aclent_perm
/* user or group */
308 error = get_id
($1, $2, &id
);
310 bad_entry_type
($1, $2);
312 return
(EACL_INVALID_USER_GROUP
);
315 error = compute_aclent_perms
($3.perm_str
, &$$.a_perm
);
317 acl_error
(dgettext
(TEXT_DOMAIN
,
318 "Invalid permission(s) '%s' specified.\n"),
324 error = aclent_entry_type
($1, 0, &$$.a_type
);
327 dgettext
(TEXT_DOMAIN
,
328 "Invalid ACL entry type '%s' specified.\n"), $1);
333 | entry_type COLON aclent_perm
/* owner group other */
337 error = compute_aclent_perms
($3.perm_str
, &$$.a_perm
);
339 acl_error
(dgettext
(TEXT_DOMAIN
,
340 "Invalid permission(s) '%s' specified.\n"),
346 error = aclent_entry_type
($1, 1, &$$.a_type
);
349 dgettext
(TEXT_DOMAIN
,
350 "Invalid ACL entry type '%s' specified.\n"), $1);
355 | entry_type COLON aclent_perm COLON id
359 acl_error
(dgettext
(TEXT_DOMAIN
,
360 "Extra fields on the end of ACL specification.\n"));
361 return
(EACL_UNKNOWN_DATA
);
363 return
(EACL_ENTRY_ERROR
);
365 | entry_type idname aclent_perm COLON id
/* user or group */
371 acl_error
(dgettext
(TEXT_DOMAIN
,
372 "Extra fields on the end of ACL specification.\n"));
374 return
(EACL_UNKNOWN_DATA
);
376 error = compute_aclent_perms
($3.perm_str
, &$$.a_perm
);
378 acl_error
(dgettext
(TEXT_DOMAIN
,
379 "Invalid permission(s) '%s' specified.\n"),
384 error = get_id
($1, $2, &id
);
386 $$.a_id
= get_id_nofail
($1, $5);
390 error = aclent_entry_type
($1, 0, &$$.a_type
);
393 dgettext
(TEXT_DOMAIN
,
394 "Invalid ACL entry type '%s' specified.\n"), $1);
399 | entry_type aclent_perm
/* mask entry */
403 error = compute_aclent_perms
($2.perm_str
, &$$.a_perm
);
405 acl_error
(dgettext
(TEXT_DOMAIN
,
406 "Invalid permission(s) '%s' specified.\n"),
412 error = aclent_entry_type
($1, 0, &$$.a_type
);
415 dgettext
(TEXT_DOMAIN
,
416 "Invalid ACL entry type specified %d.\n"),
422 | entry_type aclent_perm COLON id
426 acl_error
(dgettext
(TEXT_DOMAIN
,
427 "Extra fields on the end of ACL specification.\n"));
428 return
(EACL_UNKNOWN_DATA
);
430 return
(EACL_ENTRY_ERROR
);
433 iflags: compact_iflag COLON
{$$
= $1;}
434 | verbose_iflag COLON
{$$
= $1;}
437 compact_iflag
: INHERIT_TOK
442 error = compute_ace_inherit
($1, &iflags
);
444 acl_error
(dgettext
(TEXT_DOMAIN
,
445 "Invalid inheritance flags '%s' specified.\n"), $1);
451 | INHERIT_TOK SLASH verbose_iflag
453 acl_error
(dgettext
(TEXT_DOMAIN
,
454 "Can't mix compact inherit flags with"
455 " verbose inheritance flags.\n"));
457 return
(EACL_INHERIT_ERROR
);
460 verbose_iflag: ACE_INHERIT
{$$ |
= $1;}
461 | ACE_INHERIT SLASH verbose_iflag
{$$
= $1 |
$3;}
462 | ACE_INHERIT SLASH compact_iflag
464 acl_error
(dgettext
(TEXT_DOMAIN
,
465 "Can't mix verbose inherit flags with"
466 " compact inheritance flags.\n"));
468 return
(EACL_INHERIT_ERROR
);
470 | ACE_INHERIT SLASH ACCESS_TYPE
472 acl_error
(dgettext
(TEXT_DOMAIN
,
473 "Inheritance flags can't be mixed with access type.\n"));
475 return
(EACL_INHERIT_ERROR
);
477 | ACE_INHERIT SLASH ERROR
483 aclent_perm: PERM_TOK
485 $$.perm_style
= PERM_TYPE_UNKNOWN
;
491 acl_error
(dgettext
(TEXT_DOMAIN
,
492 "ACL entry permissions are incorrectly specified.\n"));
497 access_type: ACCESS_TYPE
{$$
= $1;}
508 acl_error
(dgettext
(TEXT_DOMAIN
,
509 "Invalid uid/gid specified.\nThe field"
510 " should be a numeric value.\n"));
512 return
(EACL_UNKNOWN_DATA
);
520 ace_perms: perm
{$$
= $1;}
521 | aclent_perm COLON
{$$
= $1;}
528 perm: perms COLON
{$$
= $1;}
529 | COLON
{$$.perm_style
= PERM_TYPE_EMPTY
;}
533 $$.perm_style
= PERM_TYPE_ACE
;
536 | ACE_PERM SLASH perms
538 $$.perm_style
= PERM_TYPE_ACE
;
539 $$.perm_val
= $1 |
$3.perm_val
;
541 | ACE_PERM SLASH aclent_perm
544 acl_error
(dgettext
(TEXT_DOMAIN
,
545 "Can't mix verbose permissions with"
546 " compact permission.\n"));
548 return
(EACL_PERM_MASK_ERROR
);
551 | ACE_PERM SLASH ERROR
558 idname: IDNAME
{$$
= $1;}
560 entry_type: ENTRY_TYPE
{$$
= $1;}
569 bad_entry_type
(int toketype
, char *str
)
573 case DEFAULT_USER_TOK
:
574 acl_error
(dgettext
(TEXT_DOMAIN
,
575 "Invalid user %s specified.\n"), str
);
579 case DEFAULT_GROUP_TOK
:
580 acl_error
(dgettext
(TEXT_DOMAIN
,
581 "Invalid group %s specified.\n"), str
);
585 acl_error
(dgettext
(TEXT_DOMAIN
,
586 "Invalid user SID %s specified.\n"), str
);
590 acl_error
(dgettext
(TEXT_DOMAIN
,
591 "Invalid group SID %s specified.\n"), str
);