1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef __SHIM_H 27 #define __SHIM_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /* 34 * DESCRIPTION: Shim header information not relating to hooks 35 * 36 */ 37 38 /* 39 * Structure for holding all the information relating to one map. These will 40 * probably end up in shared memory so everyone can get at them. 41 * 42 * DBM pointers are non NULL only while the file is open. 43 */ 44 typedef struct { 45 /* These are used in all modes */ 46 DBM *entries; /* NIS entry DBM file */ 47 int hash_val; /* Hash of name (to save repeated rehashing) */ 48 49 /* 50 * Names. 51 * 52 * There is some duplication of information here but this enables these 53 * strings to be worked out once (when the map_ctrl is created) rather 54 * than many times as it is used. 55 */ 56 char *map_name; /* Name of map, unqualified */ 57 char *domain; /* Domain name */ 58 char *map_path; /* Full qualified path to map */ 59 60 /* These are used only in N2L mode */ 61 DBM *ttl; /* TTL DBM file */ 62 char *ttl_path; /* Full qualified path to TTL file */ 63 char *trad_map_path; /* Equivalent qualified traditional map name */ 64 datum key_data; /* See NOTE at top of shim.c */ 65 66 /* Open parameters (in case of reopen ) */ 67 mode_t open_mode; 68 int open_flags; 69 70 int magic; /* Check that this really is a map_ctrl */ 71 72 }map_ctrl; 73 #define MAP_MAGIC 0x09876543 74 75 /* 76 * Structure for holding unique map IDs. 77 * Used for locking purposes, in N2L mode only. 78 */ 79 typedef struct map_id_elt { 80 char *map_name; 81 int map_id; 82 struct map_id_elt *next; 83 } map_id_elt_t; 84 85 /* 86 * Success and failure codes the same as used by DBM 87 */ 88 typedef int suc_code; 89 #define SUCCESS 0 90 #define FAILURE -1 91 92 /* 93 * Extern defs for new DBM calls. Must have identical args to traditional 94 * version. 95 */ 96 extern void shim_dbm_close(DBM *db); 97 extern int shim_dbm_delete(DBM *db, datum key); 98 extern datum shim_dbm_fetch(DBM *db, datum key); 99 extern datum shim_dbm_fetch_noupdate(DBM *db, datum key); 100 extern datum shim_dbm_firstkey(DBM *db); 101 extern datum shim_dbm_nextkey(DBM *db); 102 extern DBM *shim_dbm_open(const char *file, int open_flags, 103 mode_t file_mode); 104 extern int shim_dbm_store(DBM *db, datum key, datum content, 105 int store_mode); 106 107 /* 108 * Other externs 109 */ 110 extern map_ctrl *get_map_ctrl(DBM *); 111 extern map_ctrl *create_map_ctrl(char *); 112 extern void free_map_ctrl(map_ctrl *); 113 extern map_ctrl *dup_map_ctrl(map_ctrl *); 114 extern void dump_map_ctrl(map_ctrl *); 115 extern suc_code map_ctrl_init(map_ctrl *map, char *name); 116 extern int lock_map_ctrl(map_ctrl *map); 117 extern int unlock_map_ctrl(map_ctrl *map); 118 extern int map_id_list_init(); 119 extern void get_list_max(map_id_elt_t ***list, int *max); 120 121 extern int try_lock_map_update(map_ctrl *map); 122 extern suc_code lock_map_update(map_ctrl *map); 123 extern suc_code unlock_map_update(map_ctrl *map); 124 extern bool_t init_update_lock_map(); 125 126 /* 127 * Globals 128 */ 129 extern bool_t yptol_mode; 130 extern bool_t yptol_newlock; 131 extern bool_t ypxfrd_flag; 132 extern int yp2ldap; 133 134 /* 135 * String extensions used in N2L 136 */ 137 138 /* Prefix used for N2L map names */ 139 #define NTOL_PREFIX "LDAP_" 140 141 /* Postfix used for TTL DBM files */ 142 #define TTL_POSTFIX "_TTL" 143 144 /* Postfix for temporary files */ 145 #define TEMP_POSTFIX "_TMP" 146 147 /* File separator character. If this is defined elsewhere can be removed */ 148 #define SEP_CHAR '/' 149 150 /* 151 * Special keys used in DBM files. No real NIS map can use these keys. 152 */ 153 #define MAP_EXPIRY_KEY "YP_EXPIRY_TIME" 154 #define MAP_OLD_MAP_DATE_KEY "YP_OLD_MAP_DATE_TIME" 155 156 /* Mmaped file used for update flags shared memory */ 157 #define SHM_FILE "/var/run/nis_shim" 158 159 /* used for map arrays reallocation purposes */ 160 #define ARRAY_CHUNK 10 161 162 #ifdef __cplusplus 163 } 164 #endif 165 166 #endif /* __SHIM_H */ 167