zfs_deleg.c revision e7437265dc2a4920c197ed4337665539d358b22c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#if defined(_KERNEL)
#else
#include <stdio.h>
#include <unistd.h>
#include <strings.h>
#include <libnvpair.h>
#include <ctype.h>
#endif
#include <sys/dsl_deleg.h>
#include "zfs_deleg.h"
#include "zfs_namecheck.h"
/*
* permission table
*/
char *zfs_deleg_perm_tab[] = {
};
int
zfs_deleg_type(char *name)
{
return (name[0]);
}
static int
zfs_valid_permission_name(char *perm)
{
int i;
for (i = 0; zfs_deleg_perm_tab[i] != NULL; i++) {
return (0);
}
}
static int
zfs_validate_who(char *who)
{
int error = 0;
char *p;
switch (zfs_deleg_type(who)) {
case ZFS_DELEG_USER:
case ZFS_DELEG_GROUP:
case ZFS_DELEG_USER_SETS:
case ZFS_DELEG_GROUP_SETS:
error = -1;
break;
}
for (p = &who[3]; p && *p; p++)
if (!isdigit(*p)) {
error = -1;
}
break;
case ZFS_DELEG_NAMED_SET:
case ZFS_DELEG_NAMED_SET_SETS:
break;
case ZFS_DELEG_CREATE:
case ZFS_DELEG_CREATE_SETS:
case ZFS_DELEG_EVERYONE:
case ZFS_DELEG_EVERYONE_SETS:
error = -1;
break;
default:
error = -1;
}
return (error);
}
static int
zfs_validate_iflags(char *who)
{
switch (zfs_deleg_type(who)) {
case ZFS_DELEG_NAMED_SET:
case ZFS_DELEG_NAMED_SET_SETS:
case ZFS_DELEG_CREATE:
case ZFS_DELEG_CREATE_SETS:
return (-1);
break;
default:
return (-1);
break;
}
return (0);
}
int
{
int error;
return (-1);
return (-1);
do {
return (-1);
return (-1);
return (-1);
continue;
return (-1);
}
do {
if (error) {
return (-1);
}
return (0);
}
/*
* Construct the base attribute name. The base attribute names
* are the "key" to locate the jump objects which contain the actual
* permissions. The base attribute names are encoded based on
* type of entry and whether it is a local or descendent permission.
*
* Arguments:
* attr - attribute name return string, attribute is assumed to be
* ZFS_MAX_DELEG_NAME long.
* type - type of entry to construct
* inheritchr - inheritance type (local,descendent, or NA for create and
* permission set definitions
*/
void
{
int len = ZFS_MAX_DELEG_NAME;
switch (type) {
case ZFS_DELEG_USER:
case ZFS_DELEG_GROUP:
case ZFS_DELEG_USER_SETS:
case ZFS_DELEG_GROUP_SETS:
break;
case ZFS_DELEG_NAMED_SET_SETS:
case ZFS_DELEG_NAMED_SET:
ZFS_DELEG_FIELD_SEP_CHR, (char *)data);
break;
case ZFS_DELEG_CREATE:
case ZFS_DELEG_CREATE_SETS:
break;
default:
}
}