/*
* 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 2014 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Initialization routines
*/
#include "idmapd.h"
#include <signal.h>
#include <thread.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <rpcsvc/daemon_utils.h>
int
{
int rc = 0;
if ((rc = load_config()) < 0)
return (rc);
(void) setegid(DAEMON_GID);
(void) seteuid(DAEMON_UID);
if (init_dbs() < 0) {
rc = -1;
}
(void) seteuid(0);
(void) setegid(0);
return (rc);
}
void
{
fini_dbs();
}
int
{
int rc;
degrade_svc(0, "failed to initialize config");
return (-1);
}
if (rc != 0) {
degrade_svc(0, "fatal error while upgrading configuration");
return (rc);
}
if (rc < -1) {
/* Total failure */
degrade_svc(0, "fatal error while loading configuration");
return (rc);
}
if (rc != 0)
/* Partial failure */
"the configuration; check the logs");
if ((rc = idmap_cfg_start_updates()) < 0) {
/* Total failure */
degrade_svc(0, "could not start config updater");
return (rc);
}
return (0);
}
void
{
int i, j;
int new_num_gcs;
/*
* ADS disabled, or no domain name specified.
* Not using adutils. (but still can use lsa)
*/
new_num_gcs = 0;
goto out;
}
/*
* No GCs. Continue to use the previous AD config in case
* that's still good but auto-discovery had a transient failure.
* If that stops working we'll go into degraded mode anyways
* when it does.
*/
"Global Catalog servers not configured/discoverable");
return;
}
degrade_svc(0, "could not allocate AD context array "
"(out of memory)");
return;
}
degrade_svc(0, "could not initialize AD context "
"(out of memory)");
return;
}
if (idmap_add_ds(new_gcs[0],
adutils_ad_free(&new_gcs[0]);
degrade_svc(0, "could not set AD hosts "
"(out of memory)");
return;
}
}
i++) {
if (adutils_add_domain(new_gcs[0],
adutils_ad_free(&new_gcs[0]);
degrade_svc(0, "could not set AD domains "
"(out of memory)");
return;
}
}
}
for (i = 0; i < num_trustfor; i++) {
degrade_svc(0, "could not initialize trusted AD "
"context (out of memory)");
new_num_gcs = i + 1;
goto out;
}
j++) {
degrade_svc(0, "could not set trusted "
"AD hosts (out of memory)");
new_num_gcs = i + 1;
goto out;
}
}
j++) {
/* Only add domains which are marked */
if (domain_in_forest->trusted) {
domain_in_forest->sid) != 0) {
degrade_svc(0, "could not set trusted "
"AD domains (out of memory)");
new_num_gcs = i + 1;
goto out;
}
}
}
}
out:
for (i = 0; i < old_num_gcs; i++)
adutils_ad_free(&old_gcs[i]);
}
}
/*
* NEEDSWORK: This should load entries for domain servers for all known
* domains - the joined domain, other domains in the forest, and trusted
* domains in other forests. However, we don't yet discover any DCs other
* than the DCs for the joined domain.
*/
static
void
reload_dcs(void)
{
int i;
int new_num_dcs;
/*
* ADS disabled, or no domain name specified.
* Not using adutils. (but still can use lsa)
*/
new_num_dcs = 0;
goto out;
}
/*
* No DCs. Continue to use the previous AD config in case
* that's still good but auto-discovery had a transient failure.
* If that stops working we'll go into degraded mode anyways
* when it does.
*/
"Domain controller servers not configured/discoverable");
return;
}
new_num_dcs = 1;
goto nomem;
goto nomem;
if (idmap_add_ds(new_dcs[0],
goto nomem;
}
/*
* NEEDSWORK: All we need here is to add the domain and SID for
* this DC to the list of domains supported by this entry. Isn't
* there an easier way to find the SID than to walk through the list
* of all of the domains in the forest?
*/
if (adutils_add_domain(new_dcs[0],
goto nomem;
break;
}
}
}
out:
for (i = 0; i < old_num_dcs; i++)
adutils_ad_free(&old_dcs[i]);
}
return;
degrade_svc(0, "out of memory");
adutils_ad_free(&new_dcs[0]);
}
}
void
reload_ad(void)
{
reload_gcs();
reload_dcs();
}
void
print_idmapdstate(void)
{
int i, j;
return;
}
} else {
}
} else {
}
} else {
}
} else {
}
for (i = 0; i < pgcfg->num_trusted_forests; i++) {
"trusted forest %s global_catalog=%s port=%d",
"trusted forest %s domain=%s",
}
}
}
}
int
{
int rc;
return (-1);
}
if (rc == 0)
return (-1);
}
return (0);
}