acl_common.c revision de122929e7c37df60cbea70616404e22d20e025b
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#if defined(_KERNEL)
#else
#include <errno.h>
#include <stdlib.h>
#include <strings.h>
#include <assert.h>
#endif
ace_t trivial_acl[] = {
};
void
{
else
else
pair[0].a_access_mask |=
else
}
/*
* ace_trivial:
* determine whether an ace_t acl is trivial
*
* Trivialness implys that the acl is composed of only
* owner, group, everyone entries. ACL can't
* have read_acl denied, and write_owner/write_acl/write_attributes
* can only be owner@ entry.
*/
int
{
int i;
int owner_seen = 0;
int group_seen = 0;
int everyone_seen = 0;
for (i = 0; i != aclcnt; i++) {
case ACE_OWNER:
if (group_seen || everyone_seen)
return (1);
owner_seen++;
break;
if (everyone_seen || owner_seen == 0)
return (1);
group_seen++;
break;
case ACE_EVERYONE:
if (owner_seen == 0 || group_seen == 0)
return (1);
break;
default:
return (1);
}
return (1);
/*
* Special check for some special bits
*
* Don't allow anybody to deny reading basic
* attributes or a files ACL.
*/
if ((acep[i].a_access_mask &
return (1);
/*
* Allow on owner@ to allow
*/
return (1);
}
return (1);
return (0);
}
/*
* Generic shellsort, from K&R (1st ed, p 58.), somewhat modified.
* n = # objs in the array
* s = size of each obj (must be multiples of a word size)
* f = ptr to function to compare two objs
* returns (-1 = less than, 0 = equal, 1 = greater than
*/
void
{
int g, i, j, ii;
unsigned int tmp;
/* No work to do */
if (v == NULL || n <= 1)
return;
/* Sanity check on arguments */
ASSERT(s > 0);
for (g = n / 2; g > 0; g /= 2) {
for (i = g; i < n; i++) {
for (j = i - g; j >= 0 &&
(*f)(v + j * s, v + (j + g) * s) == 1;
j -= g) {
p1 = (void *)(v + j * s);
p2 = (void *)(v + (j + g) * s);
}
}
}
}
}
/*
* Compare two acls, all fields. Returns:
* -1 (less than)
* 0 (equal)
* +1 (greater than)
*/
int
cmp2acls(void *a, void *b)
{
/* Compare types */
return (-1);
return (1);
/* Equal types; compare id's */
return (-1);
return (1);
/* Equal ids; compare perms */
return (-1);
return (1);
/* Totally equal */
return (0);
}