/*
* 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.
*/
#include <stdlib.h>
#include <libscf.h>
#include <string.h>
#include "nscd_switch.h"
#include "nscd_log.h"
#include "nscd_door.h"
extern int _whoami;
/*
* Service states monitored by nscd. Protected by
*/
/*
* init service state table
*/
{
int i;
sizeof (nscd_smf_state_t));
if (nscd_smf_service_state == NULL)
return (NSCD_NO_MEMORY);
for (i = 1; i < NSCD_NUM_SMF_FMRI; i++)
return (NSCD_SUCCESS);
}
static int
{
return (ret);
(void) rw_wrlock(&nscd_smf_service_state_lock);
(void) rw_unlock(&nscd_smf_service_state_lock);
return (ret);
}
/* ARGSUSED */
static void *
{
int i;
int st;
/*
* the forker nscd needs not monitor the state
* of the client services
*/
if (_whoami == NSCD_FORKER)
thr_exit(0);
/*CONSTCOND*/
while (1) {
/* skip the first service which is nscd */
for (i = 1; i < NSCD_NUM_SMF_FMRI; i++) {
st = query_smf_state(i);
if (st == NSCD_SVC_STATE_UNINITED)
break;
}
}
/* NOTREACHED */
/*LINTED E_FUNC_HAS_NO_RETURN_STMT*/
}
int errnum;
(me, "initializing the smf monitor\n");
/*
* start a thread to check the state of the client services
*/
return (NSCD_THREAD_CREATE_ERROR);
}
return (NSCD_SUCCESS);
}
int
{
int s;
char *n;
n = NSCD_NSW_SRC_NAME(srci);
/* the files, compat, and dns backends are always available */
if ((*n == 'f' || *n == 'c' || *n == 'd' || *n == 'a') &&
return (SCF_STATE_ONLINE);
}
/*
* for the printer database and user backend, treat the
* backend as a unsupported one, as nscd can not access
* the home directory of the user
*/
return (NSCD_SVC_STATE_UNSUPPORTED_SRC);
else
return (SCF_STATE_ONLINE);
}
/*
* Foreign backend is not supported by nscd unless
* the backend supports the nss2 interface (global
* symbol _nss_<backname name>_version is present),
* tell the switch engine to return NSS_TRYLOCAL
* if needed via rc NSCD_SVC_STATE_FOREIGN_SRC.
*/
if (srci >= _nscd_cfg_num_nsw_src)
return (NSCD_SVC_STATE_FOREIGN_SRC);
if (recheck == 1)
return (query_smf_state(srci));
(void) rw_rdlock(&nscd_smf_service_state_lock);
s = NSCD_SMF_SVC_STATE(srci);
(void) rw_unlock(&nscd_smf_service_state_lock);
/*
* if the state has been queried at least once but is
* still not online, query one more time
*/
if (s != NSCD_SVC_STATE_UNINITED && s < SCF_STATE_ONLINE)
s = query_smf_state(srci);
return (s);
}