2 * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
5 * Redistribution and use in source and binary forms are permitted only
6 * as authorized by the OpenLDAP Public License. A copy of this
7 * license is available at http://www.OpenLDAP.org/license.html or
8 * in file LICENSE in the top-level directory of the distribution.
11 * Copyright (c) 1991, 1992, 1993
12 * Regents of the University of Michigan. All rights reserved.
14 * Redistribution and use in source and binary forms are permitted
15 * provided that this notice is preserved and that due credit is given
16 * to the University of Michigan at Ann Arbor. The name of the University
17 * may not be used to endorse or promote products derived from this
18 * software without specific prior written permission. This software
19 * is provided ``as is'' without express or implied warranty.
22 #define MAX_VALUES 1000
24 /*****************************************************************************
26 ** Limits which ud imposes. Also subject to change.
28 *****************************************************************************/
31 * Names are parsed somewhat like 'awk' parses them. This is the
32 * maximum number of components we store away.
34 * The isnamesepartor() macro should return TRUE if x is equal to one of the
35 * characters that delimits name fields. The ignorechar() macro should
36 * return TRUE if it is equal to a character that should be ignored when
39 #define MAX_NAME_COMPS 8
40 #define isnamesepartor(x) (isspace((unsigned char) (x)))
41 #define isignorechar(x) (((x) == '.') || ((x) == '_'))
44 * Quite often a search will turn up more than one match. When it does we
45 * print out a list of the matches, and ask the user to select the one that
46 * s/he wants. This defines how many we will save and show.
48 #define MAX_NUM_NAMES 128
51 * When a user displays a group, we will automatically print out this many
52 * members and subscribers. If the number is greater than this, we will
53 * prompt the user before printing them.
55 #define TOO_MANY_TO_PRINT 16
58 * This is the default size of a tty if we can't figure out the actual size.
60 #define DEFAULT_TTY_HEIGHT 24
61 #define DEFAULT_TTY_WIDTH 80
64 * The number of attributes we know about must be less than this number.
65 * Don't add lots of attributes to the list in globals.c without checking
70 /*****************************************************************************
72 ** No user servicable parts beyond this point.
74 *****************************************************************************/
77 * Generic buffer sizes.
79 #define SMALL_BUF_SIZE 16
80 #define MED_BUF_SIZE 128
81 #define LARGE_BUF_SIZE 512
84 * Used to specify the operation in x_group().
90 * Authentication method we will be using.
93 #define UD_AUTH_METHOD LDAP_AUTH_KRBV4
95 #define UD_AUTH_METHOD LDAP_AUTH_SIMPLE
99 * TRUE and FALSE - just in case we need them.
109 #define UD_NOT_BOUND 0 /* bound only as the default defined above */
110 #define UD_BOUND 1 /* bound as an actual Directory entity */
115 #define D_TRACE 0x0001
116 #define D_FIND 0x0002
117 #define D_GROUPS 0x0004
118 #define D_MODIFY 0x0008
119 #define D_PARSE 0x0010
120 #define D_PRINT 0x0020
121 #define D_AUTHENTICAT 0x0040
122 #define D_INITIALIZE 0x0080
125 * Used in the flags field of an attribute structure.
127 #define ATTR_FLAG_NONE 0x0000
128 #define ATTR_FLAG_PERSON 0x0001
129 #define ATTR_FLAG_GROUP 0x0002
130 #define ATTR_FLAG_PERSON_MOD 0x0010
131 #define ATTR_FLAG_GROUP_MOD 0x0020
132 #define ATTR_FLAG_MAY_EDIT 0x0040
133 #define ATTR_FLAG_SEARCH 0x0100
134 #define ATTR_FLAG_READ 0x0200
135 #define ATTR_FLAG_IS_A_DATE 0x0800
136 #define ATTR_FLAG_IS_A_DN 0x1000
137 #define ATTR_FLAG_IS_A_URL 0x2000
138 #define ATTR_FLAG_IS_A_BOOL 0x4000
139 #define ATTR_FLAG_IS_MULTILINE 0x8000
144 * These are the structures we use when parsing an answer we get from the LDAP
150 void (*mod_func) LDAP_P(( char *who, int attr_idx ));
151 unsigned short flags;
152 int number_of_values;
158 int subscriber_count;
161 struct attribute attrs[MAX_ATTRS];
171 extern struct attribute attrlist[];/* complete list of attrs */
173 extern char copyright[];
174 extern char *default_bind_object;
175 extern char *bound_dn;
176 extern char *group_base;
177 extern char *search_base; /* search base */
179 extern int verbose; /* verbose mode flag */
181 extern int bind_status;
182 extern LDAP *ld; /* our ldap descriptor */
183 extern LDAPFiltDesc *lfdp; /* LDAP filter descriptor */
185 extern int debug; /* debug flag */
188 extern struct entry Entry;
191 extern char Version[];
199 int auth LDAP_P(( char *who, int implicit ));
200 #if defined(HAVE_KERBEROS) && defined(_AC_KRB_H)
201 int krbgetpass LDAP_P(( char *u, char *in, char *re, char *pw, C_Block key ));
202 void destroy_tickets LDAP_P(( void ));
206 void edit LDAP_P(( char *who ));
209 int vrfy LDAP_P(( char *dn ));
210 LDAPMessage *find LDAP_P(( char *who, int quiet ));
211 int pick_one LDAP_P(( int i ));
212 void print_list LDAP_P(( LDAPMessage *list, char **names, int *matches ));
213 int find_all_subscribers LDAP_P(( char **sub, char *group ));
214 char *fetch_boolean_value LDAP_P(( char *who, struct attribute attr ));
219 void add_group LDAP_P(( char *name ));
220 void remove_group LDAP_P(( char *name ));
221 void x_group LDAP_P(( int action, char *name ));
222 void bulk_load LDAP_P(( char *group ));
223 void purge_group LDAP_P(( char *group ));
224 void tidy_up LDAP_P(( void ));
225 void mod_addrDN LDAP_P(( char *group, int offset ));
226 int my_ldap_modify_s LDAP_P(( LDAP *ldap, char *group, LDAPMod **mods ));
227 void list_groups LDAP_P(( char *who ));
228 void list_memberships LDAP_P(( char *who ));
231 void print_help LDAP_P(( char *s ));
237 void do_commands LDAP_P(( void )) LDAP_GCCATTR((noreturn));
238 void status LDAP_P(( void ));
239 void change_base LDAP_P(( int type, char **base, char *s ));
240 void initialize_client LDAP_P(( void ));
241 RETSIGTYPE attn LDAP_P(( int sig ));
242 #if !defined(NO_TERMCAP) && defined(TIOCGWINSZ)
243 RETSIGTYPE chwinsz LDAP_P(( int sig ));
247 void modify LDAP_P(( char *who ));
248 void change_field LDAP_P(( char *who, int attr_idx ));
249 char *get_value LDAP_P(( char *id, char *prompt ));
250 void set_boolean LDAP_P(( char *who, int attr_idx ));
252 void set_updates LDAP_P(( char *who, int dummy ));
254 void print_mod_list LDAP_P(( int group ));
255 int perform_action LDAP_P(( char *choice, char *dn, int group ));
256 void mod_perror LDAP_P(( LDAP *ld ));
259 void parse_answer LDAP_P(( LDAPMessage *s ));
260 void add_value LDAP_P(( struct attribute *attr, LDAPMessage *ep, char *ap ));
261 void print_an_entry LDAP_P(( void ));
262 void print_values LDAP_P(( struct attribute A ));
263 void print_DN LDAP_P(( struct attribute A ));
264 void clear_entry LDAP_P(( void ));
265 int attr_to_index LDAP_P(( char *s ));
266 void initialize_attribute_strings LDAP_P(( void ));
267 void print_URL LDAP_P(( struct attribute A ));
268 void print_one_URL LDAP_P(( char *s, int l_lead, char *tag, int u_lead ));
270 /* in string_to_key.c: */
271 #if defined(HAVE_KERBEROS) && !defined(openbsd) && defined(_AC_KRB_H)
272 #if defined(HAVE_AFS_KERBEROS) || !defined(HAVE_KERBEROS_V)
273 void des_string_to_key LDAP_P(( char *str, des_cblock *key ));
275 #if defined(HAVE_AFS_KERBEROS)
276 void ka_StringToKey LDAP_P(( char *str, char *cell, des_cblock *key ));
281 void printbase LDAP_P(( char *lead, char *s ));
282 void fetch_buffer LDAP_P(( char *buffer, int length, FILE *where ));
283 void fatal LDAP_P(( char *s )) LDAP_GCCATTR((noreturn));
284 int isgroup LDAP_P(( void ));
285 void format LDAP_P(( char *str, int width, int lead ));
286 void format2 LDAP_P(( char *s, char *ft, char *t, int fi, int i, int w ));
287 char *strip_ignore_chars LDAP_P(( char *cp ));
288 char *code_to_str LDAP_P(( int i ));
289 char *friendly_name LDAP_P(( char *s ));
291 int isauniqname LDAP_P(( char *s ));
293 int isadn LDAP_P(( char *s ));
294 char *my_ldap_dn2ufn LDAP_P(( char *s ));
295 int isaurl LDAP_P(( char *s ));
296 int isadate LDAP_P(( char *s ));
297 void *Malloc LDAP_P(( unsigned int size ));
298 void Free LDAP_P(( void *ptr ));
299 char *nextstr LDAP_P(( char *s ));
300 void free_mod_struct LDAP_P(( LDAPMod *modp ));
301 void StrFreeDup LDAP_P(( char **ptr, char *new_value ));
302 int confirm_action LDAP_P(( char *msg ));