aclcheck.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 (c) 1993-1997 by Sun Microsystems, Inc.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
/*
* aclcheck(): check validity of an ACL
* A valid ACL is defined as follows:
* There must be exactly one USER_OBJ, GROUP_OBJ, and OTHER_OBJ entry.
* If there are any USER entries, then the user id must be unique.
* If there are any GROUP entries, then the group id must be unique.
* If there are any GROUP or USER entries, there must be exactly one
* CLASS_OBJ entry.
* The same rules apply to default ACL entries.
*/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
struct entry {
int count;
};
struct entry_stat {
struct entry def_user_obj;
struct entry def_group_obj;
struct entry def_other_obj;
struct entry def_class_obj;
};
static void free_mem(struct entry_stat *);
int
{
struct entry_stat tally;
int cnt;
*which = -1;
case USER_OBJ:
/* check uniqueness */
return (USER_ERROR);
}
break;
case GROUP_OBJ:
/* check uniqueness */
return (GRP_ERROR);
}
break;
case OTHER_OBJ:
/* check uniqueness */
return (OTHER_ERROR);
}
break;
case CLASS_OBJ:
/* check uniqueness */
return (CLASS_ERROR);
}
break;
case USER:
case GROUP:
case DEF_USER:
case DEF_GROUP:
/* check duplicate */
} else {
}
if (cnt == 0) {
return (MEM_ERROR);
} else {
&tally) == -1) {
return (DUPLICATE_ERROR);
}
}
break;
case DEF_USER_OBJ:
/* check uniqueness */
return (USER_ERROR);
}
break;
case DEF_GROUP_OBJ:
/* check uniqueness */
return (GRP_ERROR);
}
break;
case DEF_OTHER_OBJ:
/* check uniqueness */
return (OTHER_ERROR);
}
break;
case DEF_CLASS_OBJ:
/* check uniqueness */
return (CLASS_ERROR);
}
break;
default:
return (ENTRY_ERROR);
}
}
/* If there are group or user entries, there must be one class entry */
return (MISS_ERROR);
}
/* same is true for default entries */
return (MISS_ERROR);
}
/* there must be exactly one user_obj, group_obj, and other_obj entry */
return (MISS_ERROR);
}
/* has default? same rules apply to default entries */
return (MISS_ERROR);
}
return (0);
}
static void
{
}
static int
{
int i;
for (i = 0; i < count; i++) {
return (-1);
}
}
return (0);
}