FreeBSD/sys/kern/subr_acl_posix1e.c
/*
 * Perform a syntactic check of the ACL, sufficient to allow an implementing
 * filesystem to determine if it should accept this and rely on the POSIX.1e
 * ACL properties.
 */
Perform a syntactic check of the ACL, sufficient to allow an implementing
filesystem to determine if it should accept this and rely on the POSIX.1e
ACL properties.
Perform a syntactic check of the ACL sufficient to allow an implementing filesystem to determine if it should accept this and rely on the POSIX . 1e ACL properties .
int
acl_posix1e_check(struct acl *acl)
{
	int num_acl_user_obj, num_acl_user, num_acl_group_obj, num_acl_group;
	int num_acl_mask, num_acl_other, i;
	num_acl_user_obj = num_acl_user = num_acl_group_obj = num_acl_group =
	    num_acl_mask = num_acl_other = 0;
	if (acl->acl_cnt > ACL_MAX_ENTRIES)
		return (EINVAL);
	for (i = 0; i < acl->acl_cnt; i++) {
		switch(acl->acl_entry[i].ae_tag) {
		case ACL_USER_OBJ:
			acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; 
			if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID)
				return (EINVAL);
			num_acl_user_obj++;
			break;
		case ACL_GROUP_OBJ:
			acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; 
			if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID)
				return (EINVAL);
			num_acl_group_obj++;
			break;
		case ACL_USER:
			if (acl->acl_entry[i].ae_id == ACL_UNDEFINED_ID)
				return (EINVAL);
			num_acl_user++;
			break;
		case ACL_GROUP:
			if (acl->acl_entry[i].ae_id == ACL_UNDEFINED_ID)
				return (EINVAL);
			num_acl_group++;
			break;
		case ACL_OTHER:
			acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; 
			if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID)
				return (EINVAL);
			num_acl_other++;
			break;
		case ACL_MASK:
			acl->acl_entry[i].ae_id = ACL_UNDEFINED_ID; 
			if (acl->acl_entry[i].ae_id != ACL_UNDEFINED_ID)
				return (EINVAL);
			num_acl_mask++;
			break;
		default:
			return (EINVAL);
		}
		if ((acl->acl_entry[i].ae_perm | ACL_PERM_BITS) !=
		    ACL_PERM_BITS)
			return (EINVAL);
	}
	if ((num_acl_user_obj != 1) || (num_acl_group_obj != 1) ||
	    (num_acl_other != 1) || (num_acl_mask != 0 && num_acl_mask != 1))
		return (EINVAL);
	if (((num_acl_group != 0) || (num_acl_user != 0)) &&
	    (num_acl_mask != 1))
		return (EINVAL);
	return (0);
}
int acl_posix1e_check ( struct acl * acl ) { int num_acl_user_obj , num_acl_user , num_acl_group_obj , num_acl_group ; int num_acl_mask , num_acl_other , i ; num_acl_user_obj = num_acl_user = num_acl_group_obj = num_acl_group = num_acl_mask = num_acl_other = 0 ; if ( acl -> acl_cnt > ACL_MAX_ENTRIES ) return ( EINVAL ) ; for ( i = 0 ; i < acl -> acl_cnt ; i ++ ) { switch ( acl -> acl_entry [ i ] . ae_tag ) { case ACL_USER_OBJ : acl -> acl_entry [ i ] . ae_id = ACL_UNDEFINED_ID ; if ( acl -> acl_entry [ i ] . ae_id != ACL_UNDEFINED_ID ) return ( EINVAL ) ; num_acl_user_obj ++ ; break ; case ACL_GROUP_OBJ : acl -> acl_entry [ i ] . ae_id = ACL_UNDEFINED_ID ; if ( acl -> acl_entry [ i ] . ae_id != ACL_UNDEFINED_ID ) return ( EINVAL ) ; num_acl_group_obj ++ ; break ; case ACL_USER : if ( acl -> acl_entry [ i ] . ae_id == ACL_UNDEFINED_ID ) return ( EINVAL ) ; num_acl_user ++ ; break ; case ACL_GROUP : if ( acl -> acl_entry [ i ] . ae_id == ACL_UNDEFINED_ID ) return ( EINVAL ) ; num_acl_group ++ ; break ; case ACL_OTHER : acl -> acl_entry [ i ] . ae_id = ACL_UNDEFINED_ID ; if ( acl -> acl_entry [ i ] . ae_id != ACL_UNDEFINED_ID ) return ( EINVAL ) ; num_acl_other ++ ; break ; case ACL_MASK : acl -> acl_entry [ i ] . ae_id = ACL_UNDEFINED_ID ; if ( acl -> acl_entry [ i ] . ae_id != ACL_UNDEFINED_ID ) return ( EINVAL ) ; num_acl_mask ++ ; break ; default : return ( EINVAL ) ; } if ( ( acl -> acl_entry [ i ] . ae_perm | ACL_PERM_BITS ) != ACL_PERM_BITS ) return ( EINVAL ) ; } if ( ( num_acl_user_obj != 1 ) || ( num_acl_group_obj != 1 ) || ( num_acl_other != 1 ) || ( num_acl_mask != 0 && num_acl_mask != 1 ) ) return ( EINVAL ) ; if ( ( ( num_acl_group != 0 ) || ( num_acl_user != 0 ) ) && ( num_acl_mask != 1 ) ) return ( EINVAL ) ; return ( 0 ) ; }
Perform a syntactic check of the ACL, sufficient to allow an implementing
 filesystem to determine if it should accept this and rely on the POSIX.1e
 ACL properties.
Perform a syntactic check of the ACL sufficient to allow an implementing filesystem to determine if it should accept this and rely on the POSIX . 1e ACL properties .
/*
	 * Verify that the number of entries does not exceed the maximum
	 * defined for acl_t.
	 *
	 * Verify that the correct number of various sorts of ae_tags are
	 * present:
	 *   Exactly one ACL_USER_OBJ
	 *   Exactly one ACL_GROUP_OBJ
	 *   Exactly one ACL_OTHER
	 *   If any ACL_USER or ACL_GROUP entries appear, then exactly one
	 *   ACL_MASK entry must also appear.
	 *
	 * Verify that all ae_perm entries are in ACL_PERM_BITS.
	 *
	 * Verify all ae_tag entries are understood by this implementation.
	 *
	 * Note: Does not check for uniqueness of qualifier (ae_id) field.
	 */ /*
		 * Check for a valid tag.
		 */ /* XXX */ /* XXX */ /* XXX */ /* XXX */ /*
		 * Check for valid perm entries.
		 */