dsl_deleg.c revision bc9014e6a81272073b9854d9f65dd59e18d18c35
/*
* 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 (c) 2011, 2014 by Delphix. All rights reserved.
*/
/*
* DSL permissions are stored in a two level zap attribute
* mechanism. The first level identifies the "class" of
* entry. The class is identified by the first 2 letters of
* the attribute. The second letter "l" or "d" identifies whether
* it is a local or descendent permission. The first letter
* identifies the type of entry.
*
* ul$<id> identifies permissions granted locally for this userid.
* ud$<id> identifies permissions granted on descendent datasets for
* this userid.
* Ul$<id> identifies permission sets granted locally for this userid.
* Ud$<id> identifies permission sets granted on descendent datasets for
* this userid.
* gl$<id> identifies permissions granted locally for this groupid.
* gd$<id> identifies permissions granted on descendent datasets for
* this groupid.
* Gl$<id> identifies permission sets granted locally for this groupid.
* Gd$<id> identifies permission sets granted on descendent datasets for
* this groupid.
* el$ identifies permissions granted locally for everyone.
* ed$ identifies permissions granted on descendent datasets
* for everyone.
* El$ identifies permission sets granted locally for everyone.
* Ed$ identifies permission sets granted to descendent datasets for
* everyone.
* c-$ identifies permission to create at dataset creation time.
* C-$ identifies permission sets to grant locally at dataset creation
* time.
* s-$@<name> permissions defined in specified set @<name>
* S-$@<name> Sets defined in named set @<name>
*
* Each of the above entities points to another zap attribute that contains one
* attribute for each allowed permission, such as create, destroy,...
* All of the "upper" case class types will specify permission set names
* rather than permissions.
*
* Basically it looks something like this:
* ul$12 -> ZAP OBJ -> permissions...
*
* The ZAP OBJ is referred to as the jump object.
*/
#include <sys/dmu_objset.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_prop.h>
#include <sys/dsl_synctask.h>
#include <sys/dsl_deleg.h>
#include "zfs_deleg.h"
/*
* Validate that user is allowed to delegate specified permissions.
*
* In order to delegate "create" you must have "create"
* and "allow".
*/
int
{
int error;
return (error);
return (error);
}
}
return (0);
}
/*
* Validate that user is allowed to unallow specified permissions. They
* must have the 'allow' permission, and even then can only unallow
* perms for their uid.
*/
int
{
int error;
char idstr[32];
return (error);
if (type != ZFS_DELEG_USER &&
}
return (0);
}
typedef struct dsl_deleg_arg {
const char *dda_name;
static void
{
if (zapobj == 0) {
}
}
uint64_t n = 0;
}
}
}
static void
{
if (zapobj == 0) {
return;
}
1, &jumpobj) == 0) {
}
continue;
}
continue;
uint64_t n = 0;
}
}
}
}
static int
{
int error;
}
if (error == 0)
return (error);
}
int
{
/* nvp must already have been verified to be valid */
}
/*
* Find all 'allow' permissions from a given point and then continue
* traversing up to the root.
*
* This function constructs an nvlist of nvlists.
* each setpoint is an nvlist composed of an nvlist of an nvlist
* permissions.
*
* The nvlist will look like this.
*
* { source fsname -> { whokeys { permissions,...}, ...}}
*
* The fsname nvpairs will be arranged in a bottom up order. For example,
* if we have the following structure a/b/c then the nvpairs for the fsnames
* will be ordered a/b/c, a/b, a.
*/
int
{
dsl_pool_t *dp;
int error;
if (error != 0)
return (error);
if (error != 0) {
return (error);
}
uint64_t n;
char source[MAXNAMELEN];
continue;
sp_nvp = fnvlist_alloc();
zap_cursor_advance(&basezc)) {
perms_nvp = fnvlist_alloc();
zap_cursor_advance(&zc)) {
}
}
}
return (0);
}
/*
* Routines for dsl_deleg_access() -- access checking.
*/
typedef struct perm_set {
char p_setname[ZFS_MAX_DELEG_NAME];
} perm_set_t;
static int
{
int val;
if (val == 0)
return (0);
}
/*
* Determine whether a specified permission exists.
*
* First the base attribute has to be retrieved. i.e. ul$12
* Once the base object has been retrieved the actual permission
* is lookup up in the zap object the base object points to.
*
* Return 0 if permission exists, ENOENT if there is no whokey, EPERM if
* there is no perm in that jumpobj.
*/
static int
{
int error;
char whokey[ZFS_MAX_DELEG_NAME];
if (error == 0) {
}
return (error);
}
/*
*/
static int
{
int ngids;
int i;
/* check for user */
return (0);
/* check for users primary group */
return (0);
/* check for everyone entry */
id = -1;
return (0);
/* check each supplemental group user is a member of */
for (i = 0; i != ngids; i++) {
return (0);
}
}
/*
* Iterate over the sets specified in the specified zapobj
* and load them into the permsets avl tree.
*/
static int
{
int error;
char whokey[ZFS_MAX_DELEG_NAME];
if (error != 0)
return (error);
zap_cursor_advance(&zc)) {
} else {
}
}
return (0);
}
/*
* Load all permissions user based on cred belongs to.
*/
static void
{
int ngids, i;
for (i = 0; i != ngids; i++) {
}
}
/*
* Check if user has requested permission.
*/
int
{
dsl_pool_t *dp;
void *cookie;
int error;
char checkflag;
if (ds->ds_is_snapshot) {
/*
* Snapshots are treated as descendents only,
* local permissions do not apply.
*/
} else {
}
/*
* If not in global zone then make sure
* the zoned property is set
*/
if (!INGLOBALZONE(curproc)) {
if (dsl_prop_get_dd(dd,
break;
if (!zoned)
break;
}
if (zapobj == 0)
continue;
continue;
/* See if this set directly grants this permission */
if (error == 0)
goto success;
/* See if this set includes other sets */
if (error == 0)
}
/*
* If we expanded any sets, that will define more sets,
* which we need to check.
*/
if (expanded)
goto again;
if (error == 0)
goto success;
}
return (error);
}
int
{
dsl_pool_t *dp;
int error;
if (error != 0)
return (error);
if (error == 0) {
}
return (error);
}
/*
* Other routines.
*/
static void
{
char whokey[ZFS_MAX_DELEG_NAME];
return;
if (zapobj == 0) {
}
ZFS_DELEG_LOCAL, &uid);
}
zap_cursor_advance(&zc)) {
}
}
/*
* set all create time permission on new dataset.
*/
void
{
return;
if (pzapobj == 0)
continue;
}
}
int
{
if (zapobj == 0)
return (0);
zap_cursor_advance(&zc)) {
}
return (0);
}
{
}