Exemplo n.º 1
0
int
acl_cmp(acl_t acl1, acl_t acl2)
{
	acl_obj *acl1_obj_p = ext2int(acl, acl1),
	        *acl2_obj_p = ext2int(acl, acl2);
	acl_entry_obj *p1_obj_p, *p2_obj_p;
	if (!acl1_obj_p || !acl2_obj_p)
		return -1;
	if (acl1_obj_p->aused != acl2_obj_p->aused)
		return 1;
	p2_obj_p = acl2_obj_p->anext;
	FOREACH_ACL_ENTRY(p1_obj_p, acl1_obj_p) {
		if (p1_obj_p->etag != p2_obj_p->etag)
			return 1;
		if (!permset_obj_equal(p1_obj_p->eperm,p2_obj_p->eperm))
			return 1;
		switch(p1_obj_p->etag) {
			case ACL_USER:
			case ACL_GROUP:
				if (qualifier_obj_id(p1_obj_p->eid) !=
				    qualifier_obj_id(p2_obj_p->eid))
					return 1;
				
		}
		p2_obj_p = p2_obj_p->enext;
	}
	return 0;
}
Exemplo n.º 2
0
/*
  Take an ACL entry form its current place in the entry ring,
  and insert it at its proper place. Entries that are not valid
  (yet) are not reordered.
*/
int
__acl_reorder_entry_obj_p(acl_entry_obj *entry_obj_p)
{
	acl_obj *acl_obj_p = entry_obj_p->econtainer;
	acl_entry_obj *here_obj_p;

	if (acl_obj_p->aused <= 1)
		return 0;
	switch(entry_obj_p->etag) {
		case ACL_UNDEFINED_TAG:
			return 1;
		case ACL_USER:
		case ACL_GROUP:
			if (qualifier_obj_id(entry_obj_p->eid) ==
			    ACL_UNDEFINED_ID)
				return 1;
	}

	/* Remove entry from ring */
	entry_obj_p->eprev->enext = entry_obj_p->enext;
	entry_obj_p->enext->eprev = entry_obj_p->eprev;

	/* Search for next greater entry */
	FOREACH_ACL_ENTRY(here_obj_p, acl_obj_p) {
		if (__acl_entry_p_compare(here_obj_p, entry_obj_p) > 0)
			break;
	}
	
	/* Re-insert entry into ring */
	entry_obj_p->eprev = here_obj_p->eprev;
	entry_obj_p->enext = here_obj_p;
	entry_obj_p->eprev->enext = entry_obj_p;
	entry_obj_p->enext->eprev = entry_obj_p;

	return 0;
}