3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2011 by Delphix. All rights reserved.
24 */
25
26 /*
27 * DSL permissions are stored in a two level zap attribute
28 * mechanism. The first level identifies the "class" of
29 * entry. The class is identified by the first 2 letters of
30 * the attribute. The second letter "l" or "d" identifies whether
31 * it is a local or descendent permission. The first letter
32 * identifies the type of entry.
33 *
34 * ul$<id> identifies permissions granted locally for this userid.
35 * ud$<id> identifies permissions granted on descendent datasets for
36 * this userid.
37 * Ul$<id> identifies permission sets granted locally for this userid.
38 * Ud$<id> identifies permission sets granted on descendent datasets for
39 * this userid.
40 * gl$<id> identifies permissions granted locally for this groupid.
41 * gd$<id> identifies permissions granted on descendent datasets for
42 * this groupid.
43 * Gl$<id> identifies permission sets granted locally for this groupid.
154 nvlist_t *nvp = arg2;
155 objset_t *mos = dd->dd_pool->dp_meta_objset;
156 nvpair_t *whopair = NULL;
157 uint64_t zapobj = dd->dd_phys->dd_deleg_zapobj;
158
159 if (zapobj == 0) {
160 dmu_buf_will_dirty(dd->dd_dbuf, tx);
161 zapobj = dd->dd_phys->dd_deleg_zapobj = zap_create(mos,
162 DMU_OT_DSL_PERMS, DMU_OT_NONE, 0, tx);
163 }
164
165 while (whopair = nvlist_next_nvpair(nvp, whopair)) {
166 const char *whokey = nvpair_name(whopair);
167 nvlist_t *perms;
168 nvpair_t *permpair = NULL;
169 uint64_t jumpobj;
170
171 VERIFY(nvpair_value_nvlist(whopair, &perms) == 0);
172
173 if (zap_lookup(mos, zapobj, whokey, 8, 1, &jumpobj) != 0) {
174 jumpobj = zap_create(mos, DMU_OT_DSL_PERMS,
175 DMU_OT_NONE, 0, tx);
176 VERIFY(zap_update(mos, zapobj,
177 whokey, 8, 1, &jumpobj, tx) == 0);
178 }
179
180 while (permpair = nvlist_next_nvpair(perms, permpair)) {
181 const char *perm = nvpair_name(permpair);
182 uint64_t n = 0;
183
184 VERIFY(zap_update(mos, jumpobj,
185 perm, 8, 1, &n, tx) == 0);
186 spa_history_log_internal(LOG_DS_PERM_UPDATE,
187 dd->dd_pool->dp_spa, tx,
188 "%s %s dataset = %llu", whokey, perm,
189 dd->dd_phys->dd_head_dataset_obj);
190 }
191 }
192 }
193
194 static void
195 dsl_deleg_unset_sync(void *arg1, void *arg2, dmu_tx_t *tx)
196 {
197 dsl_dir_t *dd = arg1;
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012 by Delphix. All rights reserved.
24 */
25
26 /*
27 * DSL permissions are stored in a two level zap attribute
28 * mechanism. The first level identifies the "class" of
29 * entry. The class is identified by the first 2 letters of
30 * the attribute. The second letter "l" or "d" identifies whether
31 * it is a local or descendent permission. The first letter
32 * identifies the type of entry.
33 *
34 * ul$<id> identifies permissions granted locally for this userid.
35 * ud$<id> identifies permissions granted on descendent datasets for
36 * this userid.
37 * Ul$<id> identifies permission sets granted locally for this userid.
38 * Ud$<id> identifies permission sets granted on descendent datasets for
39 * this userid.
40 * gl$<id> identifies permissions granted locally for this groupid.
41 * gd$<id> identifies permissions granted on descendent datasets for
42 * this groupid.
43 * Gl$<id> identifies permission sets granted locally for this groupid.
154 nvlist_t *nvp = arg2;
155 objset_t *mos = dd->dd_pool->dp_meta_objset;
156 nvpair_t *whopair = NULL;
157 uint64_t zapobj = dd->dd_phys->dd_deleg_zapobj;
158
159 if (zapobj == 0) {
160 dmu_buf_will_dirty(dd->dd_dbuf, tx);
161 zapobj = dd->dd_phys->dd_deleg_zapobj = zap_create(mos,
162 DMU_OT_DSL_PERMS, DMU_OT_NONE, 0, tx);
163 }
164
165 while (whopair = nvlist_next_nvpair(nvp, whopair)) {
166 const char *whokey = nvpair_name(whopair);
167 nvlist_t *perms;
168 nvpair_t *permpair = NULL;
169 uint64_t jumpobj;
170
171 VERIFY(nvpair_value_nvlist(whopair, &perms) == 0);
172
173 if (zap_lookup(mos, zapobj, whokey, 8, 1, &jumpobj) != 0) {
174 jumpobj = zap_create_link(mos, DMU_OT_DSL_PERMS,
175 zapobj, whokey, tx);
176 }
177
178 while (permpair = nvlist_next_nvpair(perms, permpair)) {
179 const char *perm = nvpair_name(permpair);
180 uint64_t n = 0;
181
182 VERIFY(zap_update(mos, jumpobj,
183 perm, 8, 1, &n, tx) == 0);
184 spa_history_log_internal(LOG_DS_PERM_UPDATE,
185 dd->dd_pool->dp_spa, tx,
186 "%s %s dataset = %llu", whokey, perm,
187 dd->dd_phys->dd_head_dataset_obj);
188 }
189 }
190 }
191
192 static void
193 dsl_deleg_unset_sync(void *arg1, void *arg2, dmu_tx_t *tx)
194 {
195 dsl_dir_t *dd = arg1;
|