nscd_switch.h revision bf1e3bee1b13b3a914f0dd817a04f6e0ce8e0691
/*
* 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.
*/
#ifndef _NSCD_SWITCH_H
#define _NSCD_SWITCH_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <nss_dbdefs.h>
#include <thread.h>
#include <libscf.h>
#define __NSS_PRIVATE_INTERFACE
#include "nsswitch_priv.h"
#include "nscd_db.h"
#include "nscd_config.h"
/*
* max. length of e.g. "passwd: files ldap"
*/
#define MAX_NSSWITCH_CONFIG_STRING_SZ 256
/*
* max. length of the name of a NSS database
*/
#define MAX_NSSWITCH_CONFIG_DB_NAME_SZ 256
/*
* nscd_nsw_config_t is an abstraction of the configuration
* for a NSS database
*/
typedef struct {
char *db_name;
char *nsw_cfg_str;
struct __nsw_switchconfig_v1 *nsw_config;
int max_src;
int *src_idx; /* ptr to array of */
/* src index */
int nobase; /* not shared */
/*
* nscd_be_info_t is an abstraction of a NSS backend
*/
typedef struct {
void *finder_priv;
/*
* nscd_state_ctrl_t is used to control a nscd_nsw_state pool
*/
typedef struct {
int max;
int allocated;
int free;
int waiter;
struct nscd_nsw_state *first;
/*
* nscd_nsw_state_base_t represents the nscd_nsw_state pool
* for a NSS database
*/
typedef struct nscd_nsw_state_base {
int dbi; /* which database? */
int used_by_thr;
/*
* nscd_nsw_state_t is an abstraction of all the data needed
* to do lookup of NSS database (e.g. "passwd" or "hosts")
*/
typedef struct nscd_nsw_state {
int dbi; /* which database? */
int max_src; /* is == config->num_lookups */
int getent; /* used by getent */
struct __nsw_switchconfig_v1 *config;
struct nscd_nsw_state *next;
/*
* nscd_getent_ctx_base_t represents the nscd_getent_ctx_base_t pool
* for a NSS database
*/
typedef struct nscd_getent_ctx_base {
int dbi; /* which database? */
int deattached; /* not associated with */
/* current config */
int max_getent_ctx;
int num_getent_ctx;
int num_waiter;
struct nscd_getent_context *first;
/*
* nscd_getent_context_t is an abstraction of all the data needed
* to enumerate a NSS database (e.g. "passwd" or "hosts")
*/
typedef struct nscd_getent_context {
int dbi;
int n_src; /* >=max_src: end of sequence */
struct nscd_getent_context *next;
/*
* nscd_smf_state_t is used to keep track of the state of the smf
* service associated with a NSS source (e.g. "passwd" or "hosts")
*/
typedef struct {
char *src_name;
int src_state;
/*
* nscd_smf_state_t is used to keep track of the state of the smf
* service associated with a NSS source (e.g. "passwd" or "hosts")
*/
typedef struct {
int dbi; /* database index */
/*
* index of the database of which the switch policy
* should be used
*/
int cfgdbi;
/*
* index of the pseudo database that the NSS backend
* does search on
*/
int compati;
/*
* ptr to ptr to the siwtch config structure
*/
/*
* frontend params passed to nss_search or nss_*ent
*/
struct nss_db_params p;
/*
* set to 1 if database is "hosts", else 2 if "ipnodes"
*/
/*
* set to 1 if require privilege to look up the database
*/
/*
* additional info returned by the switch engine
*/
typedef struct {
void *pbuf; /* ptr to packed buffer */
int srci; /* last source searched */
int errnum; /* errno from the backend */
int noarg; /* if set, backend does not use the arg structure */
int fallback; /* if set, may need to fall back to main nscd */
/*
* - p0 cookie: returned by nscd to indicate
* the start of the enumeration position
* the current enumeration position
*/
#define NSCD_P0_COOKIE_SEQNUM -1
typedef struct {
typedef struct {
/*
* static tables or global data defined in other files
*/
extern int _nscd_cfg_num_nsw_src;
extern int _nscd_cfg_num_nsw_src_all;
extern int _nscd_cfg_num_nsw_db;
extern int _nscd_cfg_num_nsw_db_all;
extern int _nscd_cfg_num_smf_services;
extern nscd_cfg_id_t _nscd_cfg_nsw_src[];
extern nscd_cfg_id_t *_nscd_cfg_nsw_src_all;
extern nscd_cfg_id_t _nscd_cfg_nsw_db[];
extern nss_db_initf_t nscd_nss_db_initf[];
extern nscd_cfg_id_t _nscd_cfg_smf_services[];
extern nscd_smf_state_t *nscd_smf_service_state;
extern nscd_db_t ***nscd_src_backend_db;
extern nscd_nsw_config_t ***nscd_nsw_config;
extern nscd_nsw_state_base_t **nscd_nsw_state_base;
extern nscd_getent_ctx_base_t **nscd_getent_ctx_base;
extern nscd_cfg_switch_t *nscd_switch_cfg;
extern nscd_cfg_stat_switch_t *nscd_switch_stats;
#define NSCD_NUM_DB _nscd_cfg_num_nsw_db_all
#define NSCD_SW_CFG_G nscd_switch_cfg_g
#define NSCD_SW_CFG(i) nscd_switch_cfg[i]
#define NSCD_SW_STATS_G nscd_switch_stats_g
#define NSCD_SW_STATS(i) nscd_switch_stats[i]
/*
* special service states used by the switch engine
*/
#define NSCD_SVC_STATE_UNINITED -1
#define NSCD_SVC_STATE_UNKNOWN_SRC -2
/*
* prototypes
*/
void
nscd_nsw_state_t *s);
void
nscd_nsw_state_t *s);
int dbi,
int compat_basei,
int lock);
int dbi,
int lock);
void
const char *fmri,
#endif
int index,
int dbi,
int compat_basei,
const char *dbn,
const char *cfgstr,
void *swcfgv1,
void
void
void
void
void
struct __nsw_switchconfig_v1 *
const char *name,
char *linep,
enum __nsw_parse_err *errp);
int
struct __nsw_switchconfig_v1 *conf);
int
void
void
void
void
void
#ifdef __cplusplus
}
#endif
#endif /* _NSCD_SWITCH_H */