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 2011 Nexenta Systems, Inc. All rights reserved.
24 */
25
26 /*
27 * Database related utility routines
28 */
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <errno.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <rpc/rpc.h>
37 #include <sys/sid.h>
38 #include <time.h>
39 #include <pwd.h>
40 #include <grp.h>
41 #include <pthread.h>
42 #include <assert.h>
43 #include <sys/u8_textprep.h>
4197 int i;
4198 int found_ad = 0;
4199
4200 RDLOCK_CONFIG();
4201 if (_idmapdstate.num_gcs > 0) {
4202 for (i = 0; i < _idmapdstate.num_gcs && !found_ad; i++) {
4203 retries = 0;
4204 retry:
4205 retcode = idmap_lookup_batch_start(
4206 _idmapdstate.gcs[i],
4207 1,
4208 _idmapdstate.cfg->pgcfg.directory_based_mapping,
4209 _idmapdstate.cfg->pgcfg.default_domain,
4210 &qs);
4211 if (retcode != IDMAP_SUCCESS) {
4212 if (retcode == IDMAP_ERR_RETRIABLE_NET_ERR &&
4213 retries++ < ADUTILS_DEF_NUM_RETRIES)
4214 goto retry;
4215 degrade_svc(1, "failed to create request for "
4216 "AD lookup by winname");
4217 return (retcode);
4218 }
4219
4220 restore_svc();
4221
4222 if (state != NULL && i == 0) {
4223 /*
4224 * Directory based name mapping is only
4225 * performed within the joined forest (i == 0).
4226 * We don't trust other "trusted" forests to
4227 * provide DS-based name mapping information
4228 * because AD's definition of "cross-forest
4229 * trust" does not encompass this sort of
4230 * behavior.
4231 */
4232 idmap_lookup_batch_set_unixattr(qs,
4233 state->ad_unixuser_attr,
4234 state->ad_unixgroup_attr);
4235 }
4236
|
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 2016 Nexenta Systems, Inc. All rights reserved.
24 */
25
26 /*
27 * Database related utility routines
28 */
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <errno.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <rpc/rpc.h>
37 #include <sys/sid.h>
38 #include <time.h>
39 #include <pwd.h>
40 #include <grp.h>
41 #include <pthread.h>
42 #include <assert.h>
43 #include <sys/u8_textprep.h>
4197 int i;
4198 int found_ad = 0;
4199
4200 RDLOCK_CONFIG();
4201 if (_idmapdstate.num_gcs > 0) {
4202 for (i = 0; i < _idmapdstate.num_gcs && !found_ad; i++) {
4203 retries = 0;
4204 retry:
4205 retcode = idmap_lookup_batch_start(
4206 _idmapdstate.gcs[i],
4207 1,
4208 _idmapdstate.cfg->pgcfg.directory_based_mapping,
4209 _idmapdstate.cfg->pgcfg.default_domain,
4210 &qs);
4211 if (retcode != IDMAP_SUCCESS) {
4212 if (retcode == IDMAP_ERR_RETRIABLE_NET_ERR &&
4213 retries++ < ADUTILS_DEF_NUM_RETRIES)
4214 goto retry;
4215 degrade_svc(1, "failed to create request for "
4216 "AD lookup by winname");
4217 UNLOCK_CONFIG();
4218 return (retcode);
4219 }
4220
4221 restore_svc();
4222
4223 if (state != NULL && i == 0) {
4224 /*
4225 * Directory based name mapping is only
4226 * performed within the joined forest (i == 0).
4227 * We don't trust other "trusted" forests to
4228 * provide DS-based name mapping information
4229 * because AD's definition of "cross-forest
4230 * trust" does not encompass this sort of
4231 * behavior.
4232 */
4233 idmap_lookup_batch_set_unixattr(qs,
4234 state->ad_unixuser_attr,
4235 state->ad_unixgroup_attr);
4236 }
4237
|