xref: /titanic_51/usr/src/lib/libsec/common/acl.y (revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0)
15a5eeccaSmarks %{
25a5eeccaSmarks /*
35a5eeccaSmarks  * CDDL HEADER START
45a5eeccaSmarks  *
55a5eeccaSmarks  * The contents of this file are subject to the terms of the
694d2b9abSmarks  * Common Development and Distribution License (the "License").
794d2b9abSmarks  * You may not use this file except in compliance with the License.
85a5eeccaSmarks  *
95a5eeccaSmarks  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
105a5eeccaSmarks  * or http://www.opensolaris.org/os/licensing.
115a5eeccaSmarks  * See the License for the specific language governing permissions
125a5eeccaSmarks  * and limitations under the License.
135a5eeccaSmarks  *
145a5eeccaSmarks  * When distributing Covered Code, include this CDDL HEADER in each
155a5eeccaSmarks  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
165a5eeccaSmarks  * If applicable, add the following below this CDDL HEADER, with the
175a5eeccaSmarks  * fields enclosed by brackets "[]" replaced with your own identifying
185a5eeccaSmarks  * information: Portions Copyright [yyyy] [name of copyright owner]
195a5eeccaSmarks  *
205a5eeccaSmarks  * CDDL HEADER END
215a5eeccaSmarks  *
22*da6c28aaSamw  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
235a5eeccaSmarks  * Use is subject to license terms.
245a5eeccaSmarks  */
255a5eeccaSmarks 
265a5eeccaSmarks #pragma	ident	"%Z%%M%	%I%	%E% SMI"
275a5eeccaSmarks 
28*da6c28aaSamw #include <acl_common.h>
295a5eeccaSmarks #include <aclutils.h>
305a5eeccaSmarks 
315a5eeccaSmarks extern int yyinteractive;
325a5eeccaSmarks extern acl_t *yyacl;
335a5eeccaSmarks %}
345a5eeccaSmarks 
355a5eeccaSmarks 
365a5eeccaSmarks %union {
375a5eeccaSmarks 	char *str;
385a5eeccaSmarks 	int val;
395a5eeccaSmarks 	struct acl_perm_type acl_perm;
405a5eeccaSmarks 	ace_t ace;
415a5eeccaSmarks 	aclent_t aclent;
425a5eeccaSmarks 	acl_t *acl;
435a5eeccaSmarks }
445a5eeccaSmarks 
455a5eeccaSmarks 
465a5eeccaSmarks %token USER_TOK GROUP_TOK MASK_TOK OTHER_TOK OWNERAT_TOK
475a5eeccaSmarks %token GROUPAT_TOK EVERYONEAT_TOK DEFAULT_USER_TOK DEFAULT_GROUP_TOK
485a5eeccaSmarks %token DEFAULT_MASK_TOK DEFAULT_OTHER_TOK COLON COMMA NL SLASH
495a5eeccaSmarks %token <str> IDNAME PERM_TOK INHERIT_TOK
505a5eeccaSmarks %token <val> ID ERROR ACE_PERM ACE_INHERIT ENTRY_TYPE ACCESS_TYPE
515a5eeccaSmarks 
525a5eeccaSmarks %type <str> idname
535a5eeccaSmarks %type <acl_perm> perms perm aclent_perm ace_perms
545a5eeccaSmarks %type <acl> acl_entry
555a5eeccaSmarks %type <ace> ace
565a5eeccaSmarks %type <aclent> aclent
575a5eeccaSmarks %type <val> iflags verbose_iflag compact_iflag access_type id entry_type
585a5eeccaSmarks 
595a5eeccaSmarks %left ERROR COLON
605a5eeccaSmarks 
615a5eeccaSmarks %%
625a5eeccaSmarks 
635a5eeccaSmarks acl:	acl_entry NL
645a5eeccaSmarks 	{
655a5eeccaSmarks 		yyacl = $1;
665a5eeccaSmarks 		return (0);
675a5eeccaSmarks 	}
685a5eeccaSmarks 
695a5eeccaSmarks 	/* This seems illegal, but the old aclfromtext() allows it */
705a5eeccaSmarks 	| acl_entry COMMA NL
715a5eeccaSmarks 	{
725a5eeccaSmarks 		yyacl = $1;
735a5eeccaSmarks 		return (0);
745a5eeccaSmarks 	}
755a5eeccaSmarks 	| acl_entry COMMA acl
765a5eeccaSmarks 	{
775a5eeccaSmarks 		yyacl = $1;
785a5eeccaSmarks 		return (0);
795a5eeccaSmarks 	}
805a5eeccaSmarks 
815a5eeccaSmarks acl_entry: ace
825a5eeccaSmarks 	{
835a5eeccaSmarks 		ace_t *acep;
845a5eeccaSmarks 
855a5eeccaSmarks 		if (yyacl == NULL) {
865a5eeccaSmarks 			yyacl = acl_alloc(ACE_T);
875a5eeccaSmarks 			if (yyacl == NULL)
885a5eeccaSmarks 				return (EACL_MEM_ERROR);
895a5eeccaSmarks 		}
905a5eeccaSmarks 
915a5eeccaSmarks 		$$ = yyacl;
925a5eeccaSmarks 		if ($$->acl_type == ACLENT_T) {
935b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
945b233e2dSmarks 			    "Cannot have POSIX draft ACL entries"
9594d2b9abSmarks 			    " with NFSv4/ZFS ACL entries.\n"));
965a5eeccaSmarks 			acl_free(yyacl);
975a5eeccaSmarks 			yyacl = NULL;
985a5eeccaSmarks 			return (EACL_DIFF_TYPE);
995a5eeccaSmarks 		}
1005a5eeccaSmarks 
1015a5eeccaSmarks 		$$->acl_aclp = realloc($$->acl_aclp,
1025a5eeccaSmarks 		    ($$->acl_entry_size * ($$->acl_cnt + 1)));
1035a5eeccaSmarks 		if ($$->acl_aclp == NULL) {
1045a5eeccaSmarks 			free (yyacl);
1055a5eeccaSmarks 			return (EACL_MEM_ERROR);
1065a5eeccaSmarks 		}
1075a5eeccaSmarks 		acep = $$->acl_aclp;
1085a5eeccaSmarks 		acep[$$->acl_cnt] = $1;
1095a5eeccaSmarks 		$$->acl_cnt++;
1105a5eeccaSmarks 	}
1115a5eeccaSmarks 	| aclent
1125a5eeccaSmarks 	{
1135a5eeccaSmarks 		aclent_t *aclent;
1145a5eeccaSmarks 
1155a5eeccaSmarks 		if (yyacl == NULL) {
1165a5eeccaSmarks 			yyacl = acl_alloc(ACLENT_T);
1175a5eeccaSmarks 			if (yyacl == NULL)
1185a5eeccaSmarks 				return (EACL_MEM_ERROR);
1195a5eeccaSmarks 		}
1205a5eeccaSmarks 
1215a5eeccaSmarks 		$$ = yyacl;
1225a5eeccaSmarks 		if ($$->acl_type == ACE_T) {
1235b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
1245b233e2dSmarks 			    "Cannot have NFSv4/ZFS ACL entries"
12594d2b9abSmarks 			    " with POSIX draft ACL entries.\n"));
1265a5eeccaSmarks 			acl_free(yyacl);
1275a5eeccaSmarks 			yyacl = NULL;
1285a5eeccaSmarks 			return (EACL_DIFF_TYPE);
1295a5eeccaSmarks 		}
1305a5eeccaSmarks 
1315a5eeccaSmarks 		$$->acl_aclp = realloc($$->acl_aclp,
1325a5eeccaSmarks 		    ($$->acl_entry_size  * ($$->acl_cnt +1)));
1335a5eeccaSmarks 		if ($$->acl_aclp == NULL) {
1345a5eeccaSmarks 			free (yyacl);
1355a5eeccaSmarks 			return (EACL_MEM_ERROR);
1365a5eeccaSmarks 		}
1375a5eeccaSmarks 		aclent = $$->acl_aclp;
1385a5eeccaSmarks 		aclent[$$->acl_cnt] = $1;
1395a5eeccaSmarks 		$$->acl_cnt++;
1405a5eeccaSmarks 	}
1415a5eeccaSmarks 
1425a5eeccaSmarks ace:	entry_type idname ace_perms access_type
1435a5eeccaSmarks 	{
1445a5eeccaSmarks 		int error;
1455a5eeccaSmarks 		int id;
1465a5eeccaSmarks 		int mask;
1475a5eeccaSmarks 
1485a5eeccaSmarks 		error = get_id($1, $2, &id);
1495a5eeccaSmarks 		if (error) {
1505b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
1515b233e2dSmarks 			    "Invalid user %s specified.\n"), $2);
1525a5eeccaSmarks 			free($2);
1535a5eeccaSmarks 			return (EACL_INVALID_USER_GROUP);
1545a5eeccaSmarks 		}
1555a5eeccaSmarks 
1565a5eeccaSmarks 		$$.a_who = id;
1575a5eeccaSmarks 		$$.a_flags = ace_entry_type($1);
1585a5eeccaSmarks 		free($2);
1595a5eeccaSmarks 		error = ace_perm_mask(&$3, &$$.a_access_mask);
1605a5eeccaSmarks 		if (error)
1615a5eeccaSmarks 			return (error);
1625a5eeccaSmarks 		$$.a_type = $4;
1635a5eeccaSmarks 
1645a5eeccaSmarks 	}
1655a5eeccaSmarks 	| entry_type idname ace_perms access_type COLON id
1665a5eeccaSmarks 	{
1675a5eeccaSmarks 		int error;
1685a5eeccaSmarks 		int id;
1695a5eeccaSmarks 
1705a5eeccaSmarks 		if (yyinteractive) {
1715b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
1725b233e2dSmarks 			    "Extra fields on the end of "
17394d2b9abSmarks 			    "ACL specification.\n"));
1745a5eeccaSmarks 			return (EACL_UNKNOWN_DATA);
1755a5eeccaSmarks 		}
1765a5eeccaSmarks 		error = get_id($1, $2, &id);
1775a5eeccaSmarks 		if (error) {
1785a5eeccaSmarks 			$$.a_who = $6;
1795a5eeccaSmarks 		} else {
1805a5eeccaSmarks 			$$.a_who = id;
1815a5eeccaSmarks 		}
1825a5eeccaSmarks 		$$.a_flags = ace_entry_type($1);
1835a5eeccaSmarks 		free($2);
1845a5eeccaSmarks 		error = ace_perm_mask(&$3, &$$.a_access_mask);
1855a5eeccaSmarks 		if (error)
1865a5eeccaSmarks 			return (error);
1875a5eeccaSmarks 		$$.a_type = $4;
1885a5eeccaSmarks 	}
1895a5eeccaSmarks 	| entry_type idname ace_perms iflags access_type
1905a5eeccaSmarks 	{
1915a5eeccaSmarks 		int error;
1925a5eeccaSmarks 		int id;
1935a5eeccaSmarks 
1945a5eeccaSmarks 		error = get_id($1, $2, &id);
1955a5eeccaSmarks 		if (error) {
1965b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
1975b233e2dSmarks 			    "Invalid user %s specified.\n"), $2);
1985a5eeccaSmarks 			free($2);
1995a5eeccaSmarks 			return (EACL_INVALID_USER_GROUP);
2005a5eeccaSmarks 		}
2015a5eeccaSmarks 
2025a5eeccaSmarks 		$$.a_who = id;
2035a5eeccaSmarks 		$$.a_flags = ace_entry_type($1);
2045a5eeccaSmarks 		free($2);
2055a5eeccaSmarks 		error = ace_perm_mask(&$3, &$$.a_access_mask);
2065a5eeccaSmarks 		if (error)
2075a5eeccaSmarks 			return (error);
2085a5eeccaSmarks 		$$.a_type = $5;
2095a5eeccaSmarks 		$$.a_flags |= $4;
2105a5eeccaSmarks 	}
2115a5eeccaSmarks 	| entry_type idname ace_perms iflags access_type COLON id
2125a5eeccaSmarks 	{
2135a5eeccaSmarks 		int error;
2145a5eeccaSmarks 		int  id;
2155a5eeccaSmarks 
2165a5eeccaSmarks 		if (yyinteractive) {
2175b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
2185b233e2dSmarks 			    "Extra fields on the end of "
21994d2b9abSmarks 			    "ACL specification.\n"));
2205a5eeccaSmarks 			return (EACL_UNKNOWN_DATA);
2215a5eeccaSmarks 		}
2225a5eeccaSmarks 		error = get_id($1, $2, &id);
2235a5eeccaSmarks 		if (error) {
2245a5eeccaSmarks 			$$.a_who = $7;
2255a5eeccaSmarks 		} else {
2265a5eeccaSmarks 			$$.a_who = id;
2275a5eeccaSmarks 		}
2285a5eeccaSmarks 
2295a5eeccaSmarks 		$$.a_flags = ace_entry_type($1);
2305a5eeccaSmarks 		free($2);
2315a5eeccaSmarks 		error = ace_perm_mask(&$3, &$$.a_access_mask);
2325a5eeccaSmarks 		if (error)
2335a5eeccaSmarks 			return (error);
2345a5eeccaSmarks 
2355a5eeccaSmarks 		$$.a_type = $5;
2365a5eeccaSmarks 		$$.a_flags |= $4;
2375a5eeccaSmarks 	}
2385a5eeccaSmarks 	| entry_type ace_perms access_type
2395a5eeccaSmarks 	{
2405a5eeccaSmarks 		int error;
2415a5eeccaSmarks 
2425a5eeccaSmarks 		$$.a_who = -1;
2435a5eeccaSmarks 		$$.a_flags = ace_entry_type($1);
2445a5eeccaSmarks 		error = ace_perm_mask(&$2, &$$.a_access_mask);
2455a5eeccaSmarks 		if (error) {
2465a5eeccaSmarks 			return (error);
2475a5eeccaSmarks 		}
2485a5eeccaSmarks 		$$.a_type = $3;
2495a5eeccaSmarks 	}
2505a5eeccaSmarks 	| entry_type ace_perms access_type COLON id
2515a5eeccaSmarks 	{
2525a5eeccaSmarks 		if (yyinteractive) {
2535b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
2545b233e2dSmarks 			    "Extra fields on the end of "
25594d2b9abSmarks 			    "ACL specification.\n"));
2565a5eeccaSmarks 			return (EACL_UNKNOWN_DATA);
2575a5eeccaSmarks 		}
2585a5eeccaSmarks 
2595a5eeccaSmarks 		return (EACL_ENTRY_ERROR);
2605a5eeccaSmarks 	}
2615a5eeccaSmarks 	| entry_type ace_perms iflags access_type
2625a5eeccaSmarks 	{
2635a5eeccaSmarks 		int error;
2645a5eeccaSmarks 
2655a5eeccaSmarks 		$$.a_who = -1;
2665a5eeccaSmarks 		$$.a_flags = ace_entry_type($1);
2675a5eeccaSmarks 		error = ace_perm_mask(&$2, &$$.a_access_mask);
2685a5eeccaSmarks 		if (error)
2695a5eeccaSmarks 			return (error);
2705a5eeccaSmarks 		$$.a_type = $4;
2715a5eeccaSmarks 		$$.a_flags |= $3;
2725a5eeccaSmarks 
2735a5eeccaSmarks 	}
2745a5eeccaSmarks 	| entry_type ace_perms iflags access_type COLON id
2755a5eeccaSmarks 	{
2765a5eeccaSmarks 		if (yyinteractive) {
2775b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
2785b233e2dSmarks 			    "Extra fields on the end of "
27994d2b9abSmarks 			    "ACL specification.\n"));
2805a5eeccaSmarks 			return (EACL_UNKNOWN_DATA);
2815a5eeccaSmarks 		}
2825a5eeccaSmarks 		return (EACL_ENTRY_ERROR);
2835a5eeccaSmarks 	}
2845a5eeccaSmarks 
2855a5eeccaSmarks aclent: entry_type idname aclent_perm	/* user or group */
2865a5eeccaSmarks 	{
2875a5eeccaSmarks 		int error;
2885a5eeccaSmarks 		int id;
2895a5eeccaSmarks 
2905a5eeccaSmarks 		error = get_id($1, $2, &id);
2915a5eeccaSmarks 		if (error) {
2925b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
2935b233e2dSmarks 			    "Invalid user '%s' specified.\n"), $2);
2945a5eeccaSmarks 			free($2);
2955a5eeccaSmarks 			return (EACL_INVALID_USER_GROUP);
2965a5eeccaSmarks 		}
2975a5eeccaSmarks 
2985a5eeccaSmarks 		error = compute_aclent_perms($3.perm_str, &$$.a_perm);
2995a5eeccaSmarks 		if (error) {
3005a5eeccaSmarks 			free($2);
3015b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
30294d2b9abSmarks 			    "Invalid permission(s) '%s' specified.\n"),
3035a5eeccaSmarks 			    $3.perm_str);
3045a5eeccaSmarks 			return (error);
3055a5eeccaSmarks 		}
3065a5eeccaSmarks 		$$.a_id = id;
3075a5eeccaSmarks 		error = aclent_entry_type($1, 0, &$$.a_type);
3085a5eeccaSmarks 		free($2);
3095a5eeccaSmarks 		if (error) {
3105a5eeccaSmarks 			acl_error(
3115b233e2dSmarks 			    dgettext(TEXT_DOMAIN,
3125b233e2dSmarks 			    "Invalid ACL entry type '%s' specified.\n"), $1);
3135a5eeccaSmarks 			return (error);
3145a5eeccaSmarks 		}
3155a5eeccaSmarks 	}
3165a5eeccaSmarks 	| entry_type COLON aclent_perm		/* owner group other */
3175a5eeccaSmarks 	{
3185a5eeccaSmarks 		int error;
3195a5eeccaSmarks 
3205a5eeccaSmarks 		error = compute_aclent_perms($3.perm_str, &$$.a_perm);
3215a5eeccaSmarks 		if (error) {
3225b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
32394d2b9abSmarks 			    "Invalid permission(s) '%s' specified.\n"),
3245a5eeccaSmarks 			    $3.perm_str);
3255a5eeccaSmarks 			return (error);
3265a5eeccaSmarks 		}
3275a5eeccaSmarks 		$$.a_id = -1;
3285a5eeccaSmarks 		error = aclent_entry_type($1, 1, &$$.a_type);
3295a5eeccaSmarks 		if (error) {
3305a5eeccaSmarks 			acl_error(
3315b233e2dSmarks 			    dgettext(TEXT_DOMAIN,
3325b233e2dSmarks 			    "Invalid ACL entry type '%s' specified.\n"), $1);
3335a5eeccaSmarks 			return (error);
3345a5eeccaSmarks 		}
3355a5eeccaSmarks 	}
3365a5eeccaSmarks 	| entry_type COLON aclent_perm COLON id
3375a5eeccaSmarks 	{
3385a5eeccaSmarks 		if (yyinteractive) {
3395b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
3405b233e2dSmarks 			    "Extra fields on the end of ACL specification.\n"));
3415a5eeccaSmarks 			return (EACL_UNKNOWN_DATA);
3425a5eeccaSmarks 		}
3435a5eeccaSmarks 		return (EACL_ENTRY_ERROR);
3445a5eeccaSmarks 	}
3455a5eeccaSmarks 	| entry_type idname aclent_perm COLON id 	/* user or group */
3465a5eeccaSmarks 	{
3475a5eeccaSmarks 		int error;
3485a5eeccaSmarks 		int id;
3495a5eeccaSmarks 
3505a5eeccaSmarks 		if (yyinteractive) {
3515b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
3525b233e2dSmarks 			    "Extra fields on the end of ACL specification.\n"));
3535a5eeccaSmarks 			return (EACL_UNKNOWN_DATA);
3545a5eeccaSmarks 		}
3555a5eeccaSmarks 		error = compute_aclent_perms($3.perm_str, &$$.a_perm);
3565a5eeccaSmarks 		if (error) {
3575a5eeccaSmarks 			free($2);
3585b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
35994d2b9abSmarks 			    "Invalid permission(s) '%s' specified.\n"),
3605a5eeccaSmarks 			    $3.perm_str);
3615a5eeccaSmarks 			return (error);
3625a5eeccaSmarks 		}
3635a5eeccaSmarks 		error = get_id($1, $2, &id);
3645a5eeccaSmarks 		if (error)
3655a5eeccaSmarks 			$$.a_id = $5;
3665a5eeccaSmarks 		else
3675a5eeccaSmarks 			$$.a_id = id;
3685a5eeccaSmarks 
3695a5eeccaSmarks 		error = aclent_entry_type($1, 0, &$$.a_type);
3705a5eeccaSmarks 		free($2);
3715a5eeccaSmarks 		if (error) {
3725a5eeccaSmarks 			acl_error(
3735b233e2dSmarks 			    dgettext(TEXT_DOMAIN,
3745b233e2dSmarks 			    "Invalid ACL entry type '%s' specified.\n"), $1);
3755a5eeccaSmarks 			return (error);
3765a5eeccaSmarks 		}
3775a5eeccaSmarks 	}
3785a5eeccaSmarks 	| entry_type aclent_perm  /* mask entry */
3795a5eeccaSmarks 	{
3805a5eeccaSmarks 		int error;
3815a5eeccaSmarks 
3825a5eeccaSmarks 		error = compute_aclent_perms($2.perm_str, &$$.a_perm);
3835a5eeccaSmarks 		if (error) {
3845b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
38594d2b9abSmarks 			    "Invalid permission(s) '%s' specified.\n"),
3865a5eeccaSmarks 			    $2.perm_str);
3875a5eeccaSmarks 			return (error);
3885a5eeccaSmarks 		}
3895a5eeccaSmarks 		$$.a_id = -1;
3905a5eeccaSmarks 		error = aclent_entry_type($1, 0, &$$.a_type);
3915a5eeccaSmarks 		if (error) {
3925a5eeccaSmarks 			acl_error(
3935b233e2dSmarks 			    dgettext(TEXT_DOMAIN,
3945b233e2dSmarks 			    "Invalid ACL entry type specified %d.\n"),
3955a5eeccaSmarks 			    error);
3965a5eeccaSmarks 			return (error);
3975a5eeccaSmarks 		}
3985a5eeccaSmarks 	}
3995a5eeccaSmarks 	| entry_type aclent_perm COLON id
4005a5eeccaSmarks 	{
4015a5eeccaSmarks 		if (yyinteractive) {
4025b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
4035b233e2dSmarks 			    "Extra fields on the end of ACL specification.\n"));
4045a5eeccaSmarks 			return (EACL_UNKNOWN_DATA);
4055a5eeccaSmarks 		}
4065a5eeccaSmarks 		return (EACL_ENTRY_ERROR);
4075a5eeccaSmarks 	}
4085a5eeccaSmarks 
4095a5eeccaSmarks iflags: compact_iflag COLON {$$ = $1;}
4105a5eeccaSmarks 	| verbose_iflag COLON {$$ = $1;}
4115a5eeccaSmarks 	| COLON {$$ = 0;}
4125a5eeccaSmarks 
4135a5eeccaSmarks compact_iflag : INHERIT_TOK
4145a5eeccaSmarks 	{
4155a5eeccaSmarks 		int error;
4165a5eeccaSmarks 		uint32_t iflags;
4175a5eeccaSmarks 
4185a5eeccaSmarks 		error = compute_ace_inherit($1, &iflags);
4195a5eeccaSmarks 		if (error) {
4205b233e2dSmarks 			acl_error(dgettext(TEXT_DOMAIN,
4215b233e2dSmarks 			    "Invalid inheritance flags '%s' specified.\n"), $1);
4225a5eeccaSmarks 			free($1);
4235a5eeccaSmarks 			return (error);
4245a5eeccaSmarks 		}
4255a5eeccaSmarks 		$$ = iflags;
4265a5eeccaSmarks 	}
4275a5eeccaSmarks 	| INHERIT_TOK SLASH verbose_iflag
4285a5eeccaSmarks 	{
4295b233e2dSmarks 		acl_error(dgettext(TEXT_DOMAIN,
4305b233e2dSmarks 		    "Can't mix compact inherit flags with"
43194d2b9abSmarks 		    " verbose inheritance flags.\n"));
4325a5eeccaSmarks 		return (EACL_INHERIT_ERROR);
4335a5eeccaSmarks 	}
4345a5eeccaSmarks 
4355a5eeccaSmarks verbose_iflag: ACE_INHERIT	{$$ |= $1;}
4365a5eeccaSmarks 	| ACE_INHERIT SLASH verbose_iflag {$$ = $1 | $3;}
4375a5eeccaSmarks 	| ACE_INHERIT SLASH compact_iflag
4385a5eeccaSmarks 	{
4395b233e2dSmarks 		acl_error(dgettext(TEXT_DOMAIN,
4405b233e2dSmarks 		    "Can't mix verbose inherit flags with"
44194d2b9abSmarks 		    " compact inheritance flags.\n"));
44294d2b9abSmarks 		return (EACL_INHERIT_ERROR);
44394d2b9abSmarks 	}
44494d2b9abSmarks 	| ACE_INHERIT SLASH ACCESS_TYPE
44594d2b9abSmarks 	{
4465b233e2dSmarks 		acl_error(dgettext(TEXT_DOMAIN,
4475b233e2dSmarks 		    "Inheritance flags can't be mixed with access type.\n"));
4485a5eeccaSmarks 		return (EACL_INHERIT_ERROR);
4495a5eeccaSmarks 	}
4505a5eeccaSmarks 	| ACE_INHERIT SLASH ERROR {return ($3);}
4515a5eeccaSmarks 
4525a5eeccaSmarks aclent_perm: PERM_TOK
4535a5eeccaSmarks 	{
4545a5eeccaSmarks 		$$.perm_style = PERM_TYPE_UNKNOWN;
4555a5eeccaSmarks 		$$.perm_str = $1;
4565a5eeccaSmarks 		$$.perm_val = 0;
4575a5eeccaSmarks 	}
4585a5eeccaSmarks 	| PERM_TOK ERROR
4595a5eeccaSmarks 	{
4605b233e2dSmarks 		acl_error(dgettext(TEXT_DOMAIN,
4615b233e2dSmarks 		    "ACL entry permissions are incorrectly specified.\n"));
4625a5eeccaSmarks 		return ($2);
4635a5eeccaSmarks 	}
4645a5eeccaSmarks 
4655a5eeccaSmarks access_type: ACCESS_TYPE {$$ = $1;}
4665a5eeccaSmarks 	| ERROR {return ($1);}
4675a5eeccaSmarks 
4685a5eeccaSmarks id: ID {$$ = $1;}
46994d2b9abSmarks   	| COLON
47094d2b9abSmarks 	{
4715b233e2dSmarks 		acl_error(dgettext(TEXT_DOMAIN,
4725b233e2dSmarks 		    "Invalid uid/gid specified.\nThe field"
47394d2b9abSmarks 		    " should be a numeric value.\n"));
47494d2b9abSmarks 		return (EACL_UNKNOWN_DATA);
47594d2b9abSmarks 	}
4765a5eeccaSmarks 	| ERROR {return ($1);}
4775a5eeccaSmarks 
4785a5eeccaSmarks ace_perms: perm {$$ = $1;}
4795a5eeccaSmarks 	| aclent_perm COLON {$$ = $1;}
4805a5eeccaSmarks 	| ERROR {return ($1);}
4815a5eeccaSmarks 
4825a5eeccaSmarks perm: perms COLON {$$ = $1;}
4835a5eeccaSmarks     	| COLON {$$.perm_style = PERM_TYPE_EMPTY;}
4845a5eeccaSmarks 
4855a5eeccaSmarks perms: ACE_PERM
4865a5eeccaSmarks      	{
4875a5eeccaSmarks 		$$.perm_style = PERM_TYPE_ACE;
4885a5eeccaSmarks 		$$.perm_val |= $1;
4895a5eeccaSmarks 	}
4905a5eeccaSmarks 	| ACE_PERM SLASH perms
4915a5eeccaSmarks 	{
4925a5eeccaSmarks 		$$.perm_style = PERM_TYPE_ACE;
4935a5eeccaSmarks 		$$.perm_val = $1 | $3.perm_val;
4945a5eeccaSmarks 	}
4955a5eeccaSmarks 	| ACE_PERM SLASH aclent_perm
4965a5eeccaSmarks 	{
4975a5eeccaSmarks 
4985b233e2dSmarks 		acl_error(dgettext(TEXT_DOMAIN,
4995b233e2dSmarks 		   "Can't mix verbose permissions with"
50094d2b9abSmarks 		    " compact permission.\n"));
5015a5eeccaSmarks 		return (EACL_PERM_MASK_ERROR);
5025a5eeccaSmarks 
5035a5eeccaSmarks 	}
50494d2b9abSmarks 	| ACE_PERM SLASH ERROR {return ($3);}
50594d2b9abSmarks 
5065a5eeccaSmarks 
5075a5eeccaSmarks idname: IDNAME {$$ = $1;}
5085a5eeccaSmarks 
5095a5eeccaSmarks entry_type: ENTRY_TYPE {$$ = $1;}
5105a5eeccaSmarks 	| ERROR {return ($1);}
511