Beispiel #1
0
/*
 * acl_copy_entry() (23.4.4): copy the contents of ACL entry src_d to
 * ACL entry dest_d
 */
int
acl_copy_entry(acl_entry_t dest_d, acl_entry_t src_d)
{

    if (src_d == NULL || dest_d == NULL || src_d == dest_d) {
        errno = EINVAL;
        return (-1);
    }

    /*
     * Can we brand the new entry the same as the source entry?
     */
    if (!_entry_brand_may_be(dest_d, _entry_brand(src_d))) {
        errno = EINVAL;
        return (-1);
    }

    _entry_brand_as(dest_d, _entry_brand(src_d));

    dest_d->ae_tag = src_d->ae_tag;
    dest_d->ae_id = src_d->ae_id;
    dest_d->ae_perm = src_d->ae_perm;
    dest_d->ae_entry_type = src_d->ae_entry_type;
    dest_d->ae_flags = src_d->ae_flags;

    return (0);
}
Beispiel #2
0
int
acl_set_entry_type_np(acl_entry_t entry_d, acl_entry_type_t entry_type)
{

	if (entry_d == NULL) {
		errno = EINVAL;
		return (-1);
	}
	if (!_entry_brand_may_be(entry_d, ACL_BRAND_NFS4)) {
		errno = EINVAL;
		return (-1);
	}
	_entry_brand_as(entry_d, ACL_BRAND_NFS4);

	switch (entry_type) {
	case ACL_ENTRY_TYPE_ALLOW:
	case ACL_ENTRY_TYPE_DENY:
	case ACL_ENTRY_TYPE_AUDIT:
	case ACL_ENTRY_TYPE_ALARM:
		entry_d->ae_entry_type = entry_type;
		return (0);
	}

	errno = EINVAL;
	return (-1);
}
Beispiel #3
0
/*
 * acl_set_permset() (23.4.23): sets the permissions of ACL entry entry_d
 * with the permissions in permset_d
 */
int
acl_set_permset(acl_entry_t entry_d, acl_permset_t permset_d)
{

	if (!entry_d) {
		errno = EINVAL;
		return (-1);
	}

	if ((*permset_d & ACL_POSIX1E_BITS) != *permset_d) {
		if ((*permset_d & ACL_NFS4_PERM_BITS) != *permset_d) {
			errno = EINVAL;
			return (-1);
		}
		if (!_entry_brand_may_be(entry_d, ACL_BRAND_NFS4)) {
			errno = EINVAL;
			return (-1);
		}
		_entry_brand_as(entry_d, ACL_BRAND_NFS4);
	}

	entry_d->ae_perm = *permset_d;

	return (0);
}
Beispiel #4
0
/*
 * acl_set_tag_type() sets the tag type for ACL entry entry_d to the
 * value of tag_type
 */
int
acl_set_tag_type(acl_entry_t entry_d, acl_tag_t tag_type)
{

	if (entry_d == NULL) {
		errno = EINVAL;
		return (-1);
	}

	switch(tag_type) {
	case ACL_OTHER:
	case ACL_MASK:
		if (!_entry_brand_may_be(entry_d, ACL_BRAND_POSIX)) {
			errno = EINVAL;
			return (-1);
		}
		_entry_brand_as(entry_d, ACL_BRAND_POSIX);
		break;
	case ACL_EVERYONE:
		if (!_entry_brand_may_be(entry_d, ACL_BRAND_NFS4)) {
			errno = EINVAL;
			return (-1);
		}
		_entry_brand_as(entry_d, ACL_BRAND_NFS4);
		break;
	}

	switch(tag_type) {
	case ACL_USER_OBJ:
	case ACL_USER:
	case ACL_GROUP_OBJ:
	case ACL_GROUP:
	case ACL_MASK:
	case ACL_OTHER:
	case ACL_EVERYONE:
		entry_d->ae_tag = tag_type;
		return (0);
	}

	errno = EINVAL;
	return (-1);
}
Beispiel #5
0
int
acl_set_flagset_np(acl_entry_t entry_d, acl_flagset_t flagset_d)
{

	if (entry_d == NULL) {
		errno = EINVAL;
		return (-1);
	}

	if (!_entry_brand_may_be(entry_d, ACL_BRAND_NFS4)) {
		errno = EINVAL;
		return (-1);
	}

	_entry_brand_as(entry_d, ACL_BRAND_NFS4);

	if (_flag_is_invalid(*flagset_d))
		return (-1);

	entry_d->ae_flags = *flagset_d;

	return (0);
}