xref: /onnv-gate/usr/src/lib/libnisdb/yptol/shim.h (revision 2189:bbaf8c7f3afd)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*2189Ssdussud  * Common Development and Distribution License (the "License").
6*2189Ssdussud  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*2189Ssdussud  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	__SHIM_H
270Sstevel@tonic-gate #define	__SHIM_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate  * DESCRIPTION: Shim header information not relating to hooks
370Sstevel@tonic-gate  *
380Sstevel@tonic-gate  */
390Sstevel@tonic-gate 
400Sstevel@tonic-gate /*
410Sstevel@tonic-gate  * Structure for holding all the information relating to one map. These will
420Sstevel@tonic-gate  * probably end up in shared memory so everyone can get at them.
430Sstevel@tonic-gate  *
440Sstevel@tonic-gate  * DBM pointers are non NULL only while the file is open.
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate typedef struct {
470Sstevel@tonic-gate 	/* These are used in all modes */
480Sstevel@tonic-gate 	DBM	*entries;	/* NIS entry DBM file */
490Sstevel@tonic-gate 	int	hash_val;	/* Hash of name (to save repeated rehashing) */
500Sstevel@tonic-gate 
510Sstevel@tonic-gate 	/*
520Sstevel@tonic-gate 	 * Names.
530Sstevel@tonic-gate 	 *
540Sstevel@tonic-gate 	 * There is some duplication of information here but this enables these
550Sstevel@tonic-gate 	 * strings to be worked out once (when the map_ctrl is created) rather
560Sstevel@tonic-gate 	 * than many times as it is used.
570Sstevel@tonic-gate 	 */
580Sstevel@tonic-gate 	char	*map_name;	/* Name of map, unqualified */
590Sstevel@tonic-gate 	char	*domain;	/* Domain name */
600Sstevel@tonic-gate 	char 	*map_path;	/* Full qualified path to map */
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 	/* These are used only in N2L mode */
630Sstevel@tonic-gate 	DBM	*ttl;		/* TTL DBM file */
640Sstevel@tonic-gate 	char	*ttl_path;	/* Full qualified path to TTL file */
650Sstevel@tonic-gate 	char	*trad_map_path;	/* Equivalent qualified traditional map name */
660Sstevel@tonic-gate 	datum	key_data;	/* See NOTE at top of shim.c */
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	/* Open parameters (in case of reopen ) */
690Sstevel@tonic-gate 	mode_t	open_mode;
700Sstevel@tonic-gate 	int	open_flags;
710Sstevel@tonic-gate 
720Sstevel@tonic-gate 	int	magic;		/* Check that this really is a map_ctrl */
730Sstevel@tonic-gate 
740Sstevel@tonic-gate }map_ctrl;
750Sstevel@tonic-gate #define	MAP_MAGIC	0x09876543
760Sstevel@tonic-gate 
770Sstevel@tonic-gate /*
78*2189Ssdussud  * Structure for holding unique map IDs.
79*2189Ssdussud  * Used for locking purposes, in N2L mode only.
80*2189Ssdussud  */
81*2189Ssdussud typedef struct map_id_elt {
82*2189Ssdussud 	char *map_name;
83*2189Ssdussud 	int map_id;
84*2189Ssdussud 	struct map_id_elt *next;
85*2189Ssdussud } map_id_elt_t;
86*2189Ssdussud 
87*2189Ssdussud /*
880Sstevel@tonic-gate  * Success and failure codes the same as used by DBM
890Sstevel@tonic-gate  */
900Sstevel@tonic-gate typedef int suc_code;
910Sstevel@tonic-gate #define	SUCCESS 0
920Sstevel@tonic-gate #define	FAILURE -1
930Sstevel@tonic-gate 
940Sstevel@tonic-gate /*
950Sstevel@tonic-gate  * Extern defs for new DBM calls. Must have identical args to traditional
960Sstevel@tonic-gate  * version.
970Sstevel@tonic-gate  */
980Sstevel@tonic-gate extern void 	shim_dbm_close(DBM *db);
990Sstevel@tonic-gate extern int 	shim_dbm_delete(DBM *db, datum key);
1000Sstevel@tonic-gate extern datum 	shim_dbm_fetch(DBM *db, datum key);
1010Sstevel@tonic-gate extern datum 	shim_dbm_fetch_noupdate(DBM *db, datum key);
1020Sstevel@tonic-gate extern datum	shim_dbm_firstkey(DBM *db);
1030Sstevel@tonic-gate extern datum 	shim_dbm_nextkey(DBM *db);
1040Sstevel@tonic-gate extern DBM 	*shim_dbm_open(const  char  *file,  int  open_flags,
1050Sstevel@tonic-gate 				mode_t file_mode);
1060Sstevel@tonic-gate extern int  	shim_dbm_store(DBM  *db,  datum  key,  datum  content,
1070Sstevel@tonic-gate 				int store_mode);
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate /*
1100Sstevel@tonic-gate  * Other externs
1110Sstevel@tonic-gate  */
1120Sstevel@tonic-gate extern map_ctrl *get_map_ctrl(DBM *);
1130Sstevel@tonic-gate extern map_ctrl *create_map_ctrl(char *);
1140Sstevel@tonic-gate extern void 	free_map_ctrl(map_ctrl *);
1150Sstevel@tonic-gate extern map_ctrl *dup_map_ctrl(map_ctrl *);
1160Sstevel@tonic-gate extern void 	dump_map_ctrl(map_ctrl *);
1170Sstevel@tonic-gate extern suc_code map_ctrl_init(map_ctrl *map, char *name);
1180Sstevel@tonic-gate extern int	lock_map_ctrl(map_ctrl *map);
1190Sstevel@tonic-gate extern int	unlock_map_ctrl(map_ctrl *map);
120*2189Ssdussud extern int	map_id_list_init();
121*2189Ssdussud extern void	get_list_max(map_id_elt_t ***list, int *max);
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate extern int	try_lock_map_update(map_ctrl *map);
1240Sstevel@tonic-gate extern suc_code lock_map_update(map_ctrl *map);
1250Sstevel@tonic-gate extern suc_code unlock_map_update(map_ctrl *map);
1260Sstevel@tonic-gate extern bool_t init_update_lock_map();
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate /*
1290Sstevel@tonic-gate  * Globals
1300Sstevel@tonic-gate  */
1310Sstevel@tonic-gate extern bool_t yptol_mode;
132*2189Ssdussud extern bool_t yptol_newlock;
1330Sstevel@tonic-gate extern bool_t ypxfrd_flag;
1340Sstevel@tonic-gate extern int yp2ldap;
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate /*
1370Sstevel@tonic-gate  * String extensions used in N2L
1380Sstevel@tonic-gate  */
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate /* Prefix used for N2L map names */
1410Sstevel@tonic-gate #define	NTOL_PREFIX "LDAP_"
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate /* Postfix used for TTL DBM files */
1440Sstevel@tonic-gate #define	TTL_POSTFIX "_TTL"
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate /* Postfix for temporary files */
1470Sstevel@tonic-gate #define	TEMP_POSTFIX "_TMP"
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate /* File separator character. If this is defined elsewhere can be removed */
1500Sstevel@tonic-gate #define	SEP_CHAR '/'
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate /*
1530Sstevel@tonic-gate  * Special keys used in DBM files. No real NIS map can use these keys.
1540Sstevel@tonic-gate  */
1550Sstevel@tonic-gate #define	MAP_EXPIRY_KEY "YP_EXPIRY_TIME"
1560Sstevel@tonic-gate #define	MAP_OLD_MAP_DATE_KEY "YP_OLD_MAP_DATE_TIME"
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate /* Mmaped file used for update flags shared memory */
1590Sstevel@tonic-gate #define	SHM_FILE "/var/run/nis_shim"
1600Sstevel@tonic-gate 
161*2189Ssdussud /* used for map arrays reallocation purposes */
162*2189Ssdussud #define	ARRAY_CHUNK	10
163*2189Ssdussud 
1640Sstevel@tonic-gate #ifdef	__cplusplus
1650Sstevel@tonic-gate }
1660Sstevel@tonic-gate #endif
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate #endif	/* __SHIM_H */
169