idmapd.h revision 48cd229b73530d4ff90bcaca099aec95e2126239
/*
* 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 2011 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _IDMAPD_H
#define _IDMAPD_H
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <synch.h>
#include <thread.h>
#include <libintl.h>
#include <strings.h>
#include <syslog.h>
#include <inttypes.h>
#include <rpcsvc/idmap_prot.h>
#include "adutils.h"
#include "idmap_priv.h"
#include "idmap_config.h"
#include "libadutils.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum idmap_namemap_mode {
IDMAP_NM_NONE = 0,
/*
* Debugging output.
*
* There are some number of areas - configuration, mapping, discovery, et
* cetera - and for each area there is a verbosity level controlled through
* control allowing you to turn on all debugging output with one setting.
*
* A typical debugging output sequence would look like
*
* if (DBG(CONFIG, 2)) {
* idmapdlog(LOG_DEBUG,
* "some message about config at verbosity 2");
* }
*/
enum idmapd_debug {
IDMAPD_DEBUG_ALL = 0,
IDMAPD_DEBUG_CONFIG = 1,
IDMAPD_DEBUG_MAPPING = 2,
IDMAPD_DEBUG_DISC = 3,
IDMAPD_DEBUG_DNS = 4,
IDMAPD_DEBUG_LDAP = 5,
IDMAPD_DEBUG_MAX = 5
};
/*
* Global state of idmapd daemon.
*/
typedef struct idmapd_state {
int new_eph_db; /* was the ephem ID db [re-]created? */
int num_gcs;
adutils_ad_t **gcs;
int num_dcs;
adutils_ad_t **dcs;
extern idmapd_state_t _idmapdstate;
#define RDLOCK_CONFIG() \
#define WRLOCK_CONFIG() \
#define UNLOCK_CONFIG() \
typedef struct hashentry {
} hashentry_t;
typedef struct lookup_state {
int ad_nqueries;
int nldap_nqueries;
int directory_based_mapping; /* enum */
char *ad_unixuser_attr;
char *ad_unixgroup_attr;
char *nldap_winname_attr;
char *defdom;
#define NLDAP_OR_MIXED(nm) \
#define AD_OR_MIXED(nm) \
#define PID_UID_OR_UNKNOWN(pidtype) \
#define PID_GID_OR_UNKNOWN(pidtype) \
typedef struct list_cb_data {
void *result;
int flag;
typedef struct msg_table {
const char *msg;
} msg_table_t;
/*
* Data structure to store well-known SIDs and
* associated mappings (if any)
*/
typedef struct wksids_table {
const char *sidprefix;
const char *domain;
const char *winname;
int is_wuser;
int is_user;
int direction;
/*
* The following flags are used by idmapd while processing a
* given mapping request. Note that idmapd uses multiple passes to
* process the request and the flags are used to pass information
* about the state of the request between these passes.
*/
/* Initial state. Done. Reset all flags. Remaining passes can be skipped */
#define _IDMAP_F_DONE 0x00000000
/* Set when subsequent passes are required */
#define _IDMAP_F_NOTDONE 0x00000001
/* Don't update name_cache. (e.g. set when winname,SID found in name_cache) */
#define _IDMAP_F_DONT_UPDATE_NAMECACHE 0x00000002
/* Batch this request for AD lookup */
#define _IDMAP_F_LOOKUP_AD 0x00000004
/* Batch this request for nldap directory lookup */
#define _IDMAP_F_LOOKUP_NLDAP 0x00000008
/*
* Expired ephemeral mapping found in cache when processing sid2uid request.
* Use it if the given SID cannot be mapped by name
*/
#define _IDMAP_F_EXP_EPH_UID 0x00000010
/* Same as above. Used for sid2gid request */
#define _IDMAP_F_EXP_EPH_GID 0x00000020
/* This request is not valid for the current forest */
#define _IDMAP_F_LOOKUP_OTHER_AD 0x00000040
/*
* Check if we are done. If so, subsequent passes can be skipped
* when processing a given mapping request.
*/
#define ARE_WE_DONE(f) ((f & _IDMAP_F_NOTDONE) == 0)
#define SIZE_INCR 5
#define MAX_TRIES 5
#define IDMAP_DBDIR "/var/idmap"
#define IDMAP_CACHEDIR "/var/run/idmap"
#define IS_ID_NONE(id) \
#define IS_ID_POSIX(id) \
/*
* Local RID ranges
*/
#define LOCALRID_UID_MIN 1000U
#define LOCALRID_GID_MAX UINT32_MAX
/*
* Tracing.
*
* The tracing mechanism is intended to help the administrator understand
* why their mapping configuration is doing what it is. Each interesting
* decision point during the mapping process calls TRACE() with the current
* request and response and a printf-style message. The message, plus
* data from the request and the response, is logged to the service log
* (if IDMAP_REQ_FLG_TRACE was set in the request. The primary consumer
* is the "-V" option to "idmap show".
*
* TRACING(req) says whether tracing is appropriate for the request, and
* is used to determine and record whether any request in a batch requested
* tracing, to control whether later code loops over the batch to do tracing
* for any of the requests.
*
* TRACE(req, res, fmt, ...) generates a trace entry if appropriate.
*/
typedef int (*list_svc_cb)(void *, int, char **, char **);
extern void idmapdlog(int, const char *, ...);
extern int init_mapping_system();
extern void fini_mapping_system();
extern void print_idmapdstate();
extern int load_config();
extern void reload_ad();
extern void idmap_init_tsd_key(void);
extern void degrade_svc(int, const char *);
extern void restore_svc(void);
extern int init_dbs();
extern void fini_dbs();
extern char *tolower_u8(const char *);
uint64_t, int, list_svc_cb, void *);
idmap_mapping *, idmap_id_res *);
idmap_mapping *, idmap_id_res *);
idmap_mapping *, idmap_id_res *, int);
idmap_mapping *, idmap_id_res *, int);
idmap_mapping *, idmap_id_res *);
idmap_mapping *, idmap_id_res *);
idmap_mapping *, int);
idmap_mapping *);
extern void cleanup_lookup_state(lookup_state_t *);
idmap_mapping_batch *, idmap_ids_res *);
int, char **, char **, char **,
idmap_rid_t *, idmap_id_type *,
idmap_mapping *, int);
extern idmap_retcode lookup_wksids_name2sid(const char *, const char *,
char **, char **, char **, idmap_rid_t *,
idmap_id_type *);
#ifdef __cplusplus
}
#endif
#endif /* _IDMAPD_H */