Exemplo n.º 1
0
int
remove_by_number(uint entry_number, acl_t *prev_acl, const char *filename)
{
	acl_entry_t	entry;
	acl_t		acl_new;
	acl_tag_t	tag;
	int		carried_error, entry_id;
	uint		i;

	carried_error = 0;

	acl_new = acl_dup(*prev_acl);
	if (acl_new == NULL)
		err(1, "%s: acl_dup() failed", filename);

	tag = ACL_UNDEFINED_TAG;

	/*
	 * Find out whether we're removing the mask entry,
	 * to behave the same as the routine above.
	 *
	 * XXX: Is this loop actually needed?
	 */
	entry_id = ACL_FIRST_ENTRY;
	i = 0;
	while (acl_get_entry(acl_new, entry_id, &entry) == 1) {
		entry_id = ACL_NEXT_ENTRY;
		if (i != entry_number)
			continue;
		if (acl_get_tag_type(entry, &tag) == -1)
			err(1, "%s: acl_get_tag_type() failed", filename);
		if (tag == ACL_MASK)
			have_mask++;
	}

	if (acl_delete_entry_np(acl_new, entry_number) == -1) {
		carried_error++;
		warn("%s: acl_delete_entry_np() failed", filename);
	}

	acl_free(*prev_acl);
	*prev_acl = acl_new;

	if (carried_error)
		return (-1);

	return (0);
}
Exemplo n.º 2
0
/* remove an ACL */
static int
windows_acl_remove(struct windows_acl_info *w, const char *path)
{
	acl_t acl;

	if ((acl = acl_get_file(path, ACL_TYPE_NFS4)) == NULL)
		err(EX_OSERR, "%s: acl_get_filed() failed", path);

	/* remove the entry by index */
    if (acl_delete_entry_np(acl, w->index) < 0)
		err(EX_OSERR, "%s: acl_delete_entry() failed", path);

	/* write out the acl to the file */
	if (acl_set_file(path, ACL_TYPE_NFS4, acl) < 0)
		warn("%s: acl_set_file() failed", path);

	acl_free(acl);
	return (0);
}