FreeBSD/sys/kern/subr_acl_posix1e.c
/*
 * Utility function to generate a file mode given a complete POSIX.1e access
 * ACL.  Note that if the ACL is improperly formed, this may result in a
 * panic.
 */
Utility function to generate a file mode given a complete POSIX.1e access
ACL.  Note that if the ACL is improperly formed, this may result in a
panic.
Utility function to generate a file mode given a complete POSIX . 1e access ACL . Note that if the ACL is improperly formed this may result in a panic .
mode_t
acl_posix1e_acl_to_mode(struct acl *acl)
{
	struct acl_entry *acl_mask, *acl_user_obj, *acl_group_obj, *acl_other;
	int i;
	acl_user_obj = acl_group_obj = acl_other = acl_mask = NULL;
	for (i = 0; i < acl->acl_cnt; i++) {
		switch (acl->acl_entry[i].ae_tag) {
		case ACL_USER_OBJ:
			acl_user_obj = &acl->acl_entry[i];
			break;
		case ACL_GROUP_OBJ:
			acl_group_obj = &acl->acl_entry[i];
			break;
		case ACL_OTHER:
			acl_other = &acl->acl_entry[i];
			break;
		case ACL_MASK:
			acl_mask = &acl->acl_entry[i];
			break;
		case ACL_USER:
		case ACL_GROUP:
			break;
		default:
			panic("acl_posix1e_acl_to_mode: bad ae_tag");
		}
	}
	if (acl_user_obj == NULL || acl_group_obj == NULL || acl_other == NULL)
		panic("acl_posix1e_acl_to_mode: missing base ae_tags");
	if (acl_mask != NULL)
		return (acl_posix1e_perms_to_mode(acl_user_obj, acl_mask,
		    acl_other));
	else
		return (acl_posix1e_perms_to_mode(acl_user_obj, acl_group_obj,
		    acl_other));
}
mode_t acl_posix1e_acl_to_mode ( struct acl * acl ) { struct acl_entry * acl_mask , * acl_user_obj , * acl_group_obj , * acl_other ; int i ; acl_user_obj = acl_group_obj = acl_other = acl_mask = NULL ; for ( i = 0 ; i < acl -> acl_cnt ; i ++ ) { switch ( acl -> acl_entry [ i ] . ae_tag ) { case ACL_USER_OBJ : acl_user_obj = & acl -> acl_entry [ i ] ; break ; case ACL_GROUP_OBJ : acl_group_obj = & acl -> acl_entry [ i ] ; break ; case ACL_OTHER : acl_other = & acl -> acl_entry [ i ] ; break ; case ACL_MASK : acl_mask = & acl -> acl_entry [ i ] ; break ; case ACL_USER : case ACL_GROUP : break ; default : panic ( " " ) ; } } if ( acl_user_obj == NULL || acl_group_obj == NULL || acl_other == NULL ) panic ( " " ) ; if ( acl_mask != NULL ) return ( acl_posix1e_perms_to_mode ( acl_user_obj , acl_mask , acl_other ) ) ; else return ( acl_posix1e_perms_to_mode ( acl_user_obj , acl_group_obj , acl_other ) ) ; }
Utility function to generate a file mode given a complete POSIX.1e access
 ACL.
Utility function to generate a file mode given a complete POSIX . 1e access ACL .
/*
	 * Find the ACL entries relevant to a POSIX permission mode.
	 */ /*
	 * POSIX.1e specifies that if there is an ACL_MASK entry, we replace
	 * the mode "group" bits with its permissions.  If there isn't, we
	 * use the ACL_GROUP_OBJ permissions.
	 */