1c5c4113dSnw141292 /* 2c5c4113dSnw141292 * CDDL HEADER START 3c5c4113dSnw141292 * 4c5c4113dSnw141292 * The contents of this file are subject to the terms of the 5c5c4113dSnw141292 * Common Development and Distribution License (the "License"). 6c5c4113dSnw141292 * You may not use this file except in compliance with the License. 7c5c4113dSnw141292 * 8c5c4113dSnw141292 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9c5c4113dSnw141292 * or http://www.opensolaris.org/os/licensing. 10c5c4113dSnw141292 * See the License for the specific language governing permissions 11c5c4113dSnw141292 * and limitations under the License. 12c5c4113dSnw141292 * 13c5c4113dSnw141292 * When distributing Covered Code, include this CDDL HEADER in each 14c5c4113dSnw141292 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15c5c4113dSnw141292 * If applicable, add the following below this CDDL HEADER, with the 16c5c4113dSnw141292 * fields enclosed by brackets "[]" replaced with your own identifying 17c5c4113dSnw141292 * information: Portions Copyright [yyyy] [name of copyright owner] 18c5c4113dSnw141292 * 19c5c4113dSnw141292 * CDDL HEADER END 20c5c4113dSnw141292 */ 21c5c4113dSnw141292 /* 227a8a68f5SJulian Pullen * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23c5c4113dSnw141292 * Use is subject to license terms. 24c5c4113dSnw141292 */ 25c5c4113dSnw141292 26c5c4113dSnw141292 /* 27c5c4113dSnw141292 * Initialization routines 28c5c4113dSnw141292 */ 29c5c4113dSnw141292 30c5c4113dSnw141292 #include "idmapd.h" 31c5c4113dSnw141292 #include <signal.h> 32c5c4113dSnw141292 #include <thread.h> 33c5c4113dSnw141292 #include <string.h> 34c5c4113dSnw141292 #include <errno.h> 35c5c4113dSnw141292 #include <assert.h> 36c5c4113dSnw141292 #include <unistd.h> 37c5c4113dSnw141292 #include <sys/types.h> 38c5c4113dSnw141292 #include <sys/stat.h> 398edda628Sbaban #include <rpcsvc/daemon_utils.h> 40c5c4113dSnw141292 41c5c4113dSnw141292 42c5c4113dSnw141292 int 434edd44c5Sjp151216 init_mapping_system() 444edd44c5Sjp151216 { 458edda628Sbaban int rc = 0; 468edda628Sbaban 47c5c4113dSnw141292 if (rwlock_init(&_idmapdstate.rwlk_cfg, USYNC_THREAD, NULL) != 0) 48c5c4113dSnw141292 return (-1); 49e8c27ec8Sbaban if ((rc = load_config()) < 0) 50e8c27ec8Sbaban return (rc); 518edda628Sbaban 528edda628Sbaban (void) setegid(DAEMON_GID); 538edda628Sbaban (void) seteuid(DAEMON_UID); 54c5c4113dSnw141292 if (init_dbs() < 0) { 558edda628Sbaban rc = -1; 56c5c4113dSnw141292 fini_mapping_system(); 57c5c4113dSnw141292 } 588edda628Sbaban (void) seteuid(0); 598edda628Sbaban (void) setegid(0); 608edda628Sbaban 618edda628Sbaban return (rc); 62c5c4113dSnw141292 } 63c5c4113dSnw141292 64c5c4113dSnw141292 void 654edd44c5Sjp151216 fini_mapping_system() 664edd44c5Sjp151216 { 67c5c4113dSnw141292 fini_dbs(); 68c5c4113dSnw141292 } 69c5c4113dSnw141292 70c5c4113dSnw141292 int 714edd44c5Sjp151216 load_config() 724edd44c5Sjp151216 { 73e3c2d6aaSnw141292 int rc; 74c5c4113dSnw141292 if ((_idmapdstate.cfg = idmap_cfg_init()) == NULL) { 75349d5d8fSnw141292 degrade_svc(0, "failed to initialize config"); 76c5c4113dSnw141292 return (-1); 77c5c4113dSnw141292 } 78c8e26105Sjp151216 79e3f2c991SKeyur Desai rc = idmap_cfg_upgrade(_idmapdstate.cfg); 80e3f2c991SKeyur Desai if (rc != 0) { 81e3f2c991SKeyur Desai degrade_svc(0, "fatal error while upgrading configuration"); 82e3f2c991SKeyur Desai return (rc); 83e3f2c991SKeyur Desai } 84e3f2c991SKeyur Desai 85349d5d8fSnw141292 rc = idmap_cfg_load(_idmapdstate.cfg, 0); 86e3c2d6aaSnw141292 if (rc < -1) { 87e3c2d6aaSnw141292 /* Total failure */ 88349d5d8fSnw141292 degrade_svc(0, "fatal error while loading configuration"); 89e8c27ec8Sbaban return (rc); 90c5c4113dSnw141292 } 91c8e26105Sjp151216 92e3c2d6aaSnw141292 if (rc != 0) 93e3c2d6aaSnw141292 /* Partial failure */ 9471590c90Snw141292 idmapdlog(LOG_ERR, "Various errors occurred while loading " 9571590c90Snw141292 "the configuration; check the logs"); 96e3c2d6aaSnw141292 970dcc7149Snw141292 if ((rc = idmap_cfg_start_updates()) < 0) { 980dcc7149Snw141292 /* Total failure */ 99349d5d8fSnw141292 degrade_svc(0, "could not start config updater"); 1000dcc7149Snw141292 return (rc); 1010dcc7149Snw141292 } 102e3c2d6aaSnw141292 10371590c90Snw141292 idmapdlog(LOG_DEBUG, "Initial configuration loaded"); 104e3c2d6aaSnw141292 105c5c4113dSnw141292 return (0); 106c5c4113dSnw141292 } 107c5c4113dSnw141292 108c8e26105Sjp151216 109349d5d8fSnw141292 void 110e3f2c991SKeyur Desai reload_gcs() 1114edd44c5Sjp151216 { 1124d61c878SJulian Pullen int i, j; 113e3f2c991SKeyur Desai adutils_ad_t **new_gcs; 114e3f2c991SKeyur Desai adutils_ad_t **old_gcs; 115e3f2c991SKeyur Desai int new_num_gcs; 116e3f2c991SKeyur Desai int old_num_gcs; 117c8e26105Sjp151216 idmap_pg_config_t *pgcfg = &_idmapdstate.cfg->pgcfg; 1184d61c878SJulian Pullen idmap_trustedforest_t *trustfor = pgcfg->trusted_forests; 1194d61c878SJulian Pullen int num_trustfor = pgcfg->num_trusted_forests; 1204d61c878SJulian Pullen ad_disc_domainsinforest_t *domain_in_forest; 121c8e26105Sjp151216 122349d5d8fSnw141292 if (pgcfg->global_catalog == NULL || 123349d5d8fSnw141292 pgcfg->global_catalog[0].host[0] == '\0') { 124349d5d8fSnw141292 /* 125349d5d8fSnw141292 * No GCs. Continue to use the previous AD config in case 126349d5d8fSnw141292 * that's still good but auto-discovery had a transient failure. 127349d5d8fSnw141292 * If that stops working we'll go into degraded mode anyways 128349d5d8fSnw141292 * when it does. 129349d5d8fSnw141292 */ 130349d5d8fSnw141292 degrade_svc(0, 131349d5d8fSnw141292 "Global Catalog servers not configured/discoverable"); 132349d5d8fSnw141292 return; 133c8e26105Sjp151216 } 134c8e26105Sjp151216 135e3f2c991SKeyur Desai old_gcs = _idmapdstate.gcs; 136e3f2c991SKeyur Desai old_num_gcs = _idmapdstate.num_gcs; 137c8e26105Sjp151216 138e3f2c991SKeyur Desai new_num_gcs = 1 + num_trustfor; 139e3f2c991SKeyur Desai new_gcs = calloc(new_num_gcs, sizeof (adutils_ad_t *)); 140e3f2c991SKeyur Desai if (new_gcs == NULL) { 1414d61c878SJulian Pullen degrade_svc(0, "could not allocate AD context array " 1424d61c878SJulian Pullen "(out of memory)"); 1434d61c878SJulian Pullen return; 1444d61c878SJulian Pullen } 1454d61c878SJulian Pullen 146e3f2c991SKeyur Desai if (adutils_ad_alloc(&new_gcs[0], NULL, ADUTILS_AD_GLOBAL_CATALOG) != 147e3f2c991SKeyur Desai ADUTILS_SUCCESS) { 148e3f2c991SKeyur Desai free(new_gcs); 1494d61c878SJulian Pullen degrade_svc(0, "could not initialize AD context " 1504d61c878SJulian Pullen "(out of memory)"); 151349d5d8fSnw141292 return; 152c8e26105Sjp151216 } 153c8e26105Sjp151216 154c8e26105Sjp151216 for (i = 0; pgcfg->global_catalog[i].host[0] != '\0'; i++) { 155e3f2c991SKeyur Desai if (idmap_add_ds(new_gcs[0], 156c8e26105Sjp151216 pgcfg->global_catalog[i].host, 157c8e26105Sjp151216 pgcfg->global_catalog[i].port) != 0) { 158e3f2c991SKeyur Desai adutils_ad_free(&new_gcs[0]); 159e3f2c991SKeyur Desai free(new_gcs); 1604d61c878SJulian Pullen degrade_svc(0, "could not set AD hosts " 1614d61c878SJulian Pullen "(out of memory)"); 162349d5d8fSnw141292 return; 163c8e26105Sjp151216 } 164c8e26105Sjp151216 } 165c8e26105Sjp151216 1664d61c878SJulian Pullen if (pgcfg->domains_in_forest != NULL) { 1674d61c878SJulian Pullen for (i = 0; pgcfg->domains_in_forest[i].domain[0] != '\0'; 1684d61c878SJulian Pullen i++) { 169e3f2c991SKeyur Desai if (adutils_add_domain(new_gcs[0], 1704d61c878SJulian Pullen pgcfg->domains_in_forest[i].domain, 1714d61c878SJulian Pullen pgcfg->domains_in_forest[i].sid) != 0) { 172e3f2c991SKeyur Desai adutils_ad_free(&new_gcs[0]); 173e3f2c991SKeyur Desai free(new_gcs); 1744d61c878SJulian Pullen degrade_svc(0, "could not set AD domains " 1754d61c878SJulian Pullen "(out of memory)"); 1764d61c878SJulian Pullen return; 1774d61c878SJulian Pullen } 1784d61c878SJulian Pullen } 1794d61c878SJulian Pullen } 180c8e26105Sjp151216 1814d61c878SJulian Pullen for (i = 0; i < num_trustfor; i++) { 182e3f2c991SKeyur Desai if (adutils_ad_alloc(&new_gcs[i + 1], NULL, 1834d61c878SJulian Pullen ADUTILS_AD_GLOBAL_CATALOG) != ADUTILS_SUCCESS) { 1844d61c878SJulian Pullen degrade_svc(0, "could not initialize trusted AD " 1854d61c878SJulian Pullen "context (out of memory)"); 186e3f2c991SKeyur Desai new_num_gcs = i + 1; 1874d61c878SJulian Pullen goto out; 1884d61c878SJulian Pullen } 1894d61c878SJulian Pullen for (j = 0; trustfor[i].global_catalog[j].host[0] != '\0'; 1904d61c878SJulian Pullen j++) { 191e3f2c991SKeyur Desai if (idmap_add_ds(new_gcs[i + 1], 1924d61c878SJulian Pullen trustfor[i].global_catalog[j].host, 1934d61c878SJulian Pullen trustfor[i].global_catalog[j].port) != 0) { 194e3f2c991SKeyur Desai adutils_ad_free(&new_gcs[i + 1]); 1954d61c878SJulian Pullen degrade_svc(0, "could not set trusted " 1964d61c878SJulian Pullen "AD hosts (out of memory)"); 197e3f2c991SKeyur Desai new_num_gcs = i + 1; 1984d61c878SJulian Pullen goto out; 1994d61c878SJulian Pullen } 2004d61c878SJulian Pullen } 2014d61c878SJulian Pullen for (j = 0; trustfor[i].domains_in_forest[j].domain[0] != '\0'; 2024d61c878SJulian Pullen j++) { 2034d61c878SJulian Pullen domain_in_forest = &trustfor[i].domains_in_forest[j]; 2044d61c878SJulian Pullen /* Only add domains which are marked */ 2054d61c878SJulian Pullen if (domain_in_forest->trusted) { 206e3f2c991SKeyur Desai if (adutils_add_domain(new_gcs[i + 1], 2074d61c878SJulian Pullen domain_in_forest->domain, 2084d61c878SJulian Pullen domain_in_forest->sid) != 0) { 209e3f2c991SKeyur Desai adutils_ad_free(&new_gcs[i + 1]); 2104d61c878SJulian Pullen degrade_svc(0, "could not set trusted " 2114d61c878SJulian Pullen "AD domains (out of memory)"); 212e3f2c991SKeyur Desai new_num_gcs = i + 1; 2134d61c878SJulian Pullen goto out; 2144d61c878SJulian Pullen } 2154d61c878SJulian Pullen } 2164d61c878SJulian Pullen } 2174d61c878SJulian Pullen } 2184d61c878SJulian Pullen 2194d61c878SJulian Pullen out: 220e3f2c991SKeyur Desai _idmapdstate.gcs = new_gcs; 221e3f2c991SKeyur Desai _idmapdstate.num_gcs = new_num_gcs; 2224d61c878SJulian Pullen 2234d61c878SJulian Pullen 224e3f2c991SKeyur Desai if (old_gcs != NULL) { 225e3f2c991SKeyur Desai for (i = 0; i < old_num_gcs; i++) 226e3f2c991SKeyur Desai adutils_ad_free(&old_gcs[i]); 227e3f2c991SKeyur Desai free(old_gcs); 2284d61c878SJulian Pullen } 229c8e26105Sjp151216 } 230c8e26105Sjp151216 231e3f2c991SKeyur Desai /* 232e3f2c991SKeyur Desai * NEEDSWORK: This should load entries for domain servers for all known 233e3f2c991SKeyur Desai * domains - the joined domain, other domains in the forest, and trusted 234e3f2c991SKeyur Desai * domains in other forests. However, we don't yet discover any DCs other 235e3f2c991SKeyur Desai * than the DCs for the joined domain. 236e3f2c991SKeyur Desai */ 237e3f2c991SKeyur Desai static 238e3f2c991SKeyur Desai void 239e3f2c991SKeyur Desai reload_dcs(void) 240e3f2c991SKeyur Desai { 241e3f2c991SKeyur Desai int i; 242e3f2c991SKeyur Desai adutils_ad_t **new_dcs; 243e3f2c991SKeyur Desai adutils_ad_t **old_dcs; 244e3f2c991SKeyur Desai int new_num_dcs; 245e3f2c991SKeyur Desai int old_num_dcs; 246e3f2c991SKeyur Desai idmap_pg_config_t *pgcfg = &_idmapdstate.cfg->pgcfg; 247e3f2c991SKeyur Desai 248e3f2c991SKeyur Desai if (pgcfg->domain_controller == NULL || 249e3f2c991SKeyur Desai pgcfg->domain_controller[0].host[0] == '\0') { 250e3f2c991SKeyur Desai /* 251e3f2c991SKeyur Desai * No DCs. Continue to use the previous AD config in case 252e3f2c991SKeyur Desai * that's still good but auto-discovery had a transient failure. 253e3f2c991SKeyur Desai * If that stops working we'll go into degraded mode anyways 254e3f2c991SKeyur Desai * when it does. 255e3f2c991SKeyur Desai */ 256e3f2c991SKeyur Desai degrade_svc(0, 257e3f2c991SKeyur Desai "Domain controller servers not configured/discoverable"); 258e3f2c991SKeyur Desai return; 259e3f2c991SKeyur Desai } 260e3f2c991SKeyur Desai 261e3f2c991SKeyur Desai old_dcs = _idmapdstate.dcs; 262e3f2c991SKeyur Desai old_num_dcs = _idmapdstate.num_dcs; 263e3f2c991SKeyur Desai 264e3f2c991SKeyur Desai new_num_dcs = 1; 265e3f2c991SKeyur Desai new_dcs = calloc(new_num_dcs, sizeof (adutils_ad_t *)); 266e3f2c991SKeyur Desai if (new_dcs == NULL) 267e3f2c991SKeyur Desai goto nomem; 268e3f2c991SKeyur Desai 269e3f2c991SKeyur Desai if (adutils_ad_alloc(&new_dcs[0], pgcfg->domain_name, 270e3f2c991SKeyur Desai ADUTILS_AD_DATA) != ADUTILS_SUCCESS) 271e3f2c991SKeyur Desai goto nomem; 272e3f2c991SKeyur Desai 273e3f2c991SKeyur Desai for (i = 0; pgcfg->domain_controller[i].host[0] != '\0'; i++) { 274e3f2c991SKeyur Desai if (idmap_add_ds(new_dcs[0], 275e3f2c991SKeyur Desai pgcfg->domain_controller[i].host, 276e3f2c991SKeyur Desai pgcfg->domain_controller[i].port) != 0) 277e3f2c991SKeyur Desai goto nomem; 278e3f2c991SKeyur Desai } 279e3f2c991SKeyur Desai 280*46cf8a39SJordan Brown /* 281*46cf8a39SJordan Brown * NEEDSWORK: All we need here is to add the domain and SID for 282*46cf8a39SJordan Brown * this DC to the list of domains supported by this entry. Isn't 283*46cf8a39SJordan Brown * there an easier way to find the SID than to walk through the list 284*46cf8a39SJordan Brown * of all of the domains in the forest? 285*46cf8a39SJordan Brown */ 286*46cf8a39SJordan Brown ad_disc_domainsinforest_t *dif = pgcfg->domains_in_forest; 287*46cf8a39SJordan Brown if (dif != NULL) { 288*46cf8a39SJordan Brown for (; dif->domain[0] != '\0'; dif++) { 289*46cf8a39SJordan Brown if (domain_eq(pgcfg->domain_name, dif->domain)) { 290*46cf8a39SJordan Brown if (adutils_add_domain(new_dcs[0], 291*46cf8a39SJordan Brown dif->domain, dif->sid) != 0) 292e3f2c991SKeyur Desai goto nomem; 293e3f2c991SKeyur Desai break; 294e3f2c991SKeyur Desai } 295e3f2c991SKeyur Desai } 296*46cf8a39SJordan Brown } 297e3f2c991SKeyur Desai 298e3f2c991SKeyur Desai _idmapdstate.dcs = new_dcs; 299e3f2c991SKeyur Desai _idmapdstate.num_dcs = new_num_dcs; 300e3f2c991SKeyur Desai 301e3f2c991SKeyur Desai if (old_dcs != NULL) { 302e3f2c991SKeyur Desai for (i = 0; i < old_num_dcs; i++) 303e3f2c991SKeyur Desai adutils_ad_free(&old_dcs[i]); 304e3f2c991SKeyur Desai free(old_dcs); 305e3f2c991SKeyur Desai } 306e3f2c991SKeyur Desai 307e3f2c991SKeyur Desai return; 308e3f2c991SKeyur Desai 309e3f2c991SKeyur Desai nomem: 310e3f2c991SKeyur Desai degrade_svc(0, "out of memory"); 311e3f2c991SKeyur Desai 312e3f2c991SKeyur Desai if (new_dcs != NULL) { 313e3f2c991SKeyur Desai if (new_dcs[0] != NULL) 314e3f2c991SKeyur Desai adutils_ad_free(&new_dcs[0]); 315e3f2c991SKeyur Desai free(new_dcs); 316e3f2c991SKeyur Desai } 317e3f2c991SKeyur Desai } 318e3f2c991SKeyur Desai 319e3f2c991SKeyur Desai 320e3f2c991SKeyur Desai void 321e3f2c991SKeyur Desai reload_ad(void) 322e3f2c991SKeyur Desai { 323e3f2c991SKeyur Desai reload_gcs(); 324e3f2c991SKeyur Desai reload_dcs(); 325e3f2c991SKeyur Desai } 326c8e26105Sjp151216 327c5c4113dSnw141292 void 3284edd44c5Sjp151216 print_idmapdstate() 3294edd44c5Sjp151216 { 3304d61c878SJulian Pullen int i, j; 331e8c27ec8Sbaban idmap_pg_config_t *pgcfg; 3324d61c878SJulian Pullen idmap_trustedforest_t *tf; 333c8e26105Sjp151216 334c5c4113dSnw141292 RDLOCK_CONFIG(); 335c5c4113dSnw141292 336c8e26105Sjp151216 if (_idmapdstate.cfg == NULL) { 33771590c90Snw141292 idmapdlog(LOG_INFO, "Null configuration"); 338c8e26105Sjp151216 UNLOCK_CONFIG(); 339c8e26105Sjp151216 return; 340c5c4113dSnw141292 } 341c8e26105Sjp151216 342e8c27ec8Sbaban pgcfg = &_idmapdstate.cfg->pgcfg; 343e8c27ec8Sbaban 34471590c90Snw141292 idmapdlog(LOG_DEBUG, "list_size_limit=%llu", pgcfg->list_size_limit); 34571590c90Snw141292 idmapdlog(LOG_DEBUG, "default_domain=%s", 346c8e26105Sjp151216 CHECK_NULL(pgcfg->default_domain)); 34771590c90Snw141292 idmapdlog(LOG_DEBUG, "domain_name=%s", CHECK_NULL(pgcfg->domain_name)); 34871590c90Snw141292 idmapdlog(LOG_DEBUG, "machine_sid=%s", CHECK_NULL(pgcfg->machine_sid)); 349c8e26105Sjp151216 if (pgcfg->domain_controller == NULL || 350c8e26105Sjp151216 pgcfg->domain_controller[0].host[0] == '\0') { 35171590c90Snw141292 idmapdlog(LOG_DEBUG, "No domain controllers known"); 352c8e26105Sjp151216 } else { 353c8e26105Sjp151216 for (i = 0; pgcfg->domain_controller[i].host[0] != '\0'; i++) 35471590c90Snw141292 idmapdlog(LOG_DEBUG, "domain_controller=%s port=%d", 35571590c90Snw141292 pgcfg->domain_controller[i].host, 356c8e26105Sjp151216 pgcfg->domain_controller[i].port); 357c8e26105Sjp151216 } 35871590c90Snw141292 idmapdlog(LOG_DEBUG, "forest_name=%s", CHECK_NULL(pgcfg->forest_name)); 35971590c90Snw141292 idmapdlog(LOG_DEBUG, "site_name=%s", CHECK_NULL(pgcfg->site_name)); 360c8e26105Sjp151216 if (pgcfg->global_catalog == NULL || 361c8e26105Sjp151216 pgcfg->global_catalog[0].host[0] == '\0') { 36271590c90Snw141292 idmapdlog(LOG_DEBUG, "No global catalog servers known"); 363c8e26105Sjp151216 } else { 364c8e26105Sjp151216 for (i = 0; pgcfg->global_catalog[i].host[0] != '\0'; i++) 36571590c90Snw141292 idmapdlog(LOG_DEBUG, "global_catalog=%s port=%d", 366c8e26105Sjp151216 pgcfg->global_catalog[i].host, 367c8e26105Sjp151216 pgcfg->global_catalog[i].port); 368c8e26105Sjp151216 } 3694d61c878SJulian Pullen if (pgcfg->domains_in_forest == NULL || 3704d61c878SJulian Pullen pgcfg->domains_in_forest[0].domain[0] == '\0') { 3714d61c878SJulian Pullen idmapdlog(LOG_DEBUG, "No domains in forest %s known", 3724d61c878SJulian Pullen CHECK_NULL(pgcfg->forest_name)); 3734d61c878SJulian Pullen } else { 3744d61c878SJulian Pullen for (i = 0; pgcfg->domains_in_forest[i].domain[0] != '\0'; i++) 3754d61c878SJulian Pullen idmapdlog(LOG_DEBUG, "domains in forest %s = %s", 3764d61c878SJulian Pullen CHECK_NULL(pgcfg->forest_name), 3774d61c878SJulian Pullen pgcfg->domains_in_forest[i].domain); 3784d61c878SJulian Pullen } 3794d61c878SJulian Pullen if (pgcfg->trusted_domains == NULL || 3804d61c878SJulian Pullen pgcfg->trusted_domains[0].domain[0] == '\0') { 3814d61c878SJulian Pullen idmapdlog(LOG_DEBUG, "No trusted domains known"); 3824d61c878SJulian Pullen } else { 3834d61c878SJulian Pullen for (i = 0; pgcfg->trusted_domains[i].domain[0] != '\0'; i++) 3844d61c878SJulian Pullen idmapdlog(LOG_DEBUG, "trusted domain = %s", 3854d61c878SJulian Pullen pgcfg->trusted_domains[i].domain); 3864d61c878SJulian Pullen } 3874d61c878SJulian Pullen 3884d61c878SJulian Pullen for (i = 0; i < pgcfg->num_trusted_forests; i++) { 3894d61c878SJulian Pullen tf = &pgcfg->trusted_forests[i]; 3904d61c878SJulian Pullen for (j = 0; tf->global_catalog[j].host[0] != '\0'; j++) 3914d61c878SJulian Pullen idmapdlog(LOG_DEBUG, 3924d61c878SJulian Pullen "trusted forest %s global_catalog=%s port=%d", 3934d61c878SJulian Pullen tf->forest_name, 3944d61c878SJulian Pullen tf->global_catalog[j].host, 3954d61c878SJulian Pullen tf->global_catalog[j].port); 3964d61c878SJulian Pullen for (j = 0; tf->domains_in_forest[j].domain[0] != '\0'; j++) { 3974d61c878SJulian Pullen if (tf->domains_in_forest[j].trusted) { 3984d61c878SJulian Pullen idmapdlog(LOG_DEBUG, 3994d61c878SJulian Pullen "trusted forest %s domain=%s", 4004d61c878SJulian Pullen tf->forest_name, 4014d61c878SJulian Pullen tf->domains_in_forest[j].domain); 4024d61c878SJulian Pullen } 4034d61c878SJulian Pullen } 4044d61c878SJulian Pullen } 4054d61c878SJulian Pullen 406e3f2c991SKeyur Desai idmapdlog(LOG_DEBUG, "directory_based_mapping=%s", 407e3f2c991SKeyur Desai enum_lookup(pgcfg->directory_based_mapping, directory_mapping_map)); 40871590c90Snw141292 idmapdlog(LOG_DEBUG, "ad_unixuser_attr=%s", 409e8c27ec8Sbaban CHECK_NULL(pgcfg->ad_unixuser_attr)); 41071590c90Snw141292 idmapdlog(LOG_DEBUG, "ad_unixgroup_attr=%s", 411e8c27ec8Sbaban CHECK_NULL(pgcfg->ad_unixgroup_attr)); 41271590c90Snw141292 idmapdlog(LOG_DEBUG, "nldap_winname_attr=%s", 413e8c27ec8Sbaban CHECK_NULL(pgcfg->nldap_winname_attr)); 414c8e26105Sjp151216 415c5c4113dSnw141292 UNLOCK_CONFIG(); 416c5c4113dSnw141292 } 417c5c4113dSnw141292 418c5c4113dSnw141292 int 4194edd44c5Sjp151216 create_directory(const char *path, uid_t uid, gid_t gid) 4204edd44c5Sjp151216 { 421c5c4113dSnw141292 int rc; 422c5c4113dSnw141292 423c5c4113dSnw141292 if ((rc = mkdir(path, 0700)) < 0 && errno != EEXIST) { 42471590c90Snw141292 idmapdlog(LOG_ERR, "Error creating directory %s (%s)", 42571590c90Snw141292 path, strerror(errno)); 426c5c4113dSnw141292 return (-1); 427c5c4113dSnw141292 } 428c5c4113dSnw141292 429c5c4113dSnw141292 if (lchown(path, uid, gid) < 0) { 43071590c90Snw141292 idmapdlog(LOG_ERR, "Error creating directory %s (%s)", 43171590c90Snw141292 path, strerror(errno)); 432c5c4113dSnw141292 if (rc == 0) 433c5c4113dSnw141292 (void) rmdir(path); 434c5c4113dSnw141292 return (-1); 435c5c4113dSnw141292 } 436c5c4113dSnw141292 return (0); 437c5c4113dSnw141292 } 438