init.c revision 4d61c878ad5fbf36c5338bef5994cc5fe88a589a
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* 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;
return (-1);
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 < -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_ads;
int old_num_ads;
/*
* 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.
*/
degrade_svc(0,
"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_ads[0],
adutils_ad_free(&new_ads[0]);
degrade_svc(0, "could not set AD hosts "
"(out of memory)");
return;
}
}
i++) {
if (adutils_add_domain(new_ads[0],
adutils_ad_free(&new_ads[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_ads = i + 1;
goto out;
}
j++) {
degrade_svc(0, "could not set trusted "
"AD hosts (out of memory)");
new_num_ads = 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_ads = i + 1;
goto out;
}
}
}
}
out:
for (i = 0; i < old_num_ads; i++)
adutils_ad_free(&old_ads[i]);
}
}
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);
}