xref: /freebsd/sys/contrib/openzfs/include/sys/dsl_deleg.h (revision dd32d6b29d49838c99d38ba30846ade210b2e6f7)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or https://opensource.org/licenses/CDDL-1.0.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright (c) 2013, 2015 by Delphix. All rights reserved.
25  */
26 
27 #ifndef	_SYS_DSL_DELEG_H
28 #define	_SYS_DSL_DELEG_H
29 
30 #include <sys/dmu.h>
31 #include <sys/dsl_pool.h>
32 #include <sys/zfs_context.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #define	ZFS_DELEG_PERM_NONE		""
39 #define	ZFS_DELEG_PERM_CREATE		"create"
40 #define	ZFS_DELEG_PERM_DESTROY		"destroy"
41 #define	ZFS_DELEG_PERM_SNAPSHOT		"snapshot"
42 #define	ZFS_DELEG_PERM_ROLLBACK		"rollback"
43 #define	ZFS_DELEG_PERM_CLONE		"clone"
44 #define	ZFS_DELEG_PERM_PROMOTE		"promote"
45 #define	ZFS_DELEG_PERM_RENAME		"rename"
46 #define	ZFS_DELEG_PERM_MOUNT		"mount"
47 #define	ZFS_DELEG_PERM_SHARE		"share"
48 #define	ZFS_DELEG_PERM_SEND		"send"
49 #define	ZFS_DELEG_PERM_SEND_RAW		"send:raw"
50 #define	ZFS_DELEG_PERM_RECEIVE		"receive"
51 #define	ZFS_DELEG_PERM_RECEIVE_APPEND	"receive:append"
52 #define	ZFS_DELEG_PERM_ALLOW		"allow"
53 #define	ZFS_DELEG_PERM_USERPROP		"userprop"
54 #define	ZFS_DELEG_PERM_VSCAN		"vscan"
55 #define	ZFS_DELEG_PERM_USERQUOTA	"userquota"
56 #define	ZFS_DELEG_PERM_GROUPQUOTA	"groupquota"
57 #define	ZFS_DELEG_PERM_USEROBJQUOTA	"userobjquota"
58 #define	ZFS_DELEG_PERM_GROUPOBJQUOTA	"groupobjquota"
59 #define	ZFS_DELEG_PERM_USERUSED		"userused"
60 #define	ZFS_DELEG_PERM_GROUPUSED	"groupused"
61 #define	ZFS_DELEG_PERM_USEROBJUSED	"userobjused"
62 #define	ZFS_DELEG_PERM_GROUPOBJUSED	"groupobjused"
63 #define	ZFS_DELEG_PERM_HOLD		"hold"
64 #define	ZFS_DELEG_PERM_RELEASE		"release"
65 #define	ZFS_DELEG_PERM_DIFF		"diff"
66 #define	ZFS_DELEG_PERM_BOOKMARK		"bookmark"
67 #define	ZFS_DELEG_PERM_LOAD_KEY		"load-key"
68 #define	ZFS_DELEG_PERM_CHANGE_KEY	"change-key"
69 #define	ZFS_DELEG_PERM_PROJECTUSED	"projectused"
70 #define	ZFS_DELEG_PERM_PROJECTQUOTA	"projectquota"
71 #define	ZFS_DELEG_PERM_PROJECTOBJUSED	"projectobjused"
72 #define	ZFS_DELEG_PERM_PROJECTOBJQUOTA	"projectobjquota"
73 
74 /*
75  * Note: the names of properties that are marked delegatable are also
76  * valid delegated permissions
77  */
78 
79 int dsl_deleg_get(const char *ddname, nvlist_t **nvp);
80 int dsl_deleg_set(const char *ddname, nvlist_t *nvp, boolean_t unset);
81 int dsl_deleg_access(const char *ddname, const char *perm, cred_t *cr);
82 int dsl_deleg_access_impl(struct dsl_dataset *ds, const char *perm, cred_t *cr);
83 void dsl_deleg_set_create_perms(dsl_dir_t *dd, dmu_tx_t *tx, cred_t *cr);
84 int dsl_deleg_can_allow(char *ddname, nvlist_t *nvp, cred_t *cr);
85 int dsl_deleg_can_unallow(char *ddname, nvlist_t *nvp, cred_t *cr);
86 int dsl_deleg_destroy(objset_t *os, uint64_t zapobj, dmu_tx_t *tx);
87 boolean_t dsl_delegation_on(objset_t *os);
88 
89 #ifdef	__cplusplus
90 }
91 #endif
92 
93 #endif	/* _SYS_DSL_DELEG_H */
94