init.c revision e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* 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>
static const char *me = "idmapd";
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
load_config() {
int rc;
degrade_svc();
return (-1);
}
if (rc < -1) {
/* Total failure */
degrade_svc();
"configuration", me);
return (rc);
}
if (rc != 0)
/* Partial failure */
"the configuration; check the logs", me);
degrade_svc();
"%s: Global catalog server is not configured; AD lookup "
"will fail until one or more global catalog server names "
"are configured or discovered; auto-discovery will begin "
"shortly", me);
} else {
restore_svc();
}
(void) reload_ad();
me);
return (0);
}
int
reload_ad() {
int i;
else
return (-1);
}
IDMAP_AD_GLOBAL_CATALOG) != 0) {
degrade_svc();
return (-1);
}
if (idmap_add_ds(new,
idmap_ad_free(&new);
degrade_svc();
"%s: could not initialize AD DS context", me);
return (-1);
}
}
idmap_ad_free(&old);
return (0);
}
void
int i;
return;
}
} else {
}
} else {
me,
}
}
int
int rc;
"%s: Error creating directory %s (%s)",
return (-1);
}
"%s: Error creating directory %s (%s)",
if (rc == 0)
return (-1);
}
return (0);
}