xref: /netbsd-src/external/bsd/openldap/dist/servers/slapd/slapcommon.h (revision b7b7574d3bf8eeb51a1fa3977b59142ec6434a55)
1 /*	$NetBSD: slapcommon.h,v 1.1.1.4 2014/05/28 09:58:48 tron Exp $	*/
2 
3 /* slapcommon.h - common definitions for the slap tools */
4 /* $OpenLDAP$ */
5 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
6  *
7  * Copyright 1998-2014 The OpenLDAP Foundation.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted only as authorized by the OpenLDAP
12  * Public License.
13  *
14  * A copy of this license is available in the file LICENSE in the
15  * top-level directory of the distribution or, alternatively, at
16  * <http://www.OpenLDAP.org/license.html>.
17  */
18 
19 #ifndef SLAPCOMMON_H_
20 #define SLAPCOMMON_H_ 1
21 
22 #define SLAPD_TOOLS 1
23 #include "slap.h"
24 
25 enum slaptool {
26 	SLAPADD=1,	/* LDIF -> database tool */
27 	SLAPCAT,	/* database -> LDIF tool */
28 	SLAPDN,		/* DN check w/ syntax tool */
29 	SLAPINDEX,	/* database index tool */
30 	SLAPPASSWD,	/* password generation tool */
31 	SLAPSCHEMA,	/* schema checking tool */
32 	SLAPTEST,	/* slapd.conf test tool */
33 	SLAPAUTH,	/* test authz-regexp and authc/authz stuff */
34 	SLAPACL,	/* test acl */
35 	SLAPLAST
36 };
37 
38 typedef struct tool_vars {
39 	Backend *tv_be;
40 	int tv_dbnum;
41 	int tv_verbose;
42 	int tv_quiet;
43 	int tv_update_ctxcsn;
44 	int tv_continuemode;
45 	int tv_nosubordinates;
46 	int tv_dryrun;
47 	unsigned long tv_jumpline;
48 	struct berval tv_sub_ndn;
49 	int tv_scope;
50 	Filter *tv_filter;
51 	struct LDIFFP	*tv_ldiffp;
52 	struct berval tv_baseDN;
53 	struct berval tv_authcDN;
54 	struct berval tv_authzDN;
55 	struct berval tv_authcID;
56 	struct berval tv_authzID;
57 	struct berval tv_mech;
58 	char	*tv_realm;
59 	struct berval tv_listener_url;
60 	struct berval tv_peer_domain;
61 	struct berval tv_peer_name;
62 	struct berval tv_sock_name;
63 	slap_ssf_t tv_ssf;
64 	slap_ssf_t tv_transport_ssf;
65 	slap_ssf_t tv_tls_ssf;
66 	slap_ssf_t tv_sasl_ssf;
67 	unsigned tv_dn_mode;
68 	unsigned int tv_csnsid;
69 	ber_len_t tv_ldif_wrap;
70 	char tv_maxcsnbuf[ LDAP_PVT_CSNSTR_BUFSIZE * ( SLAP_SYNC_SID_MAX + 1 ) ];
71 	struct berval tv_maxcsn[ SLAP_SYNC_SID_MAX + 1 ];
72 } tool_vars;
73 
74 extern tool_vars tool_globals;
75 
76 #define	be tool_globals.tv_be
77 #define	dbnum tool_globals.tv_dbnum
78 #define verbose tool_globals.tv_verbose
79 #define quiet tool_globals.tv_quiet
80 #define jumpline tool_globals.tv_jumpline
81 #define update_ctxcsn tool_globals.tv_update_ctxcsn
82 #define continuemode tool_globals.tv_continuemode
83 #define nosubordinates tool_globals.tv_nosubordinates
84 #define dryrun tool_globals.tv_dryrun
85 #define sub_ndn tool_globals.tv_sub_ndn
86 #define scope tool_globals.tv_scope
87 #define filter tool_globals.tv_filter
88 #define ldiffp tool_globals.tv_ldiffp
89 #define baseDN tool_globals.tv_baseDN
90 #define authcDN tool_globals.tv_authcDN
91 #define authzDN tool_globals.tv_authzDN
92 #define authcID tool_globals.tv_authcID
93 #define authzID tool_globals.tv_authzID
94 #define mech tool_globals.tv_mech
95 #define realm tool_globals.tv_realm
96 #define listener_url tool_globals.tv_listener_url
97 #define peer_domain tool_globals.tv_peer_domain
98 #define peer_name tool_globals.tv_peer_name
99 #define sock_name tool_globals.tv_sock_name
100 #define ssf tool_globals.tv_ssf
101 #define transport_ssf tool_globals.tv_transport_ssf
102 #define tls_ssf tool_globals.tv_tls_ssf
103 #define sasl_ssf tool_globals.tv_sasl_ssf
104 #define dn_mode tool_globals.tv_dn_mode
105 #define csnsid tool_globals.tv_csnsid
106 #define ldif_wrap tool_globals.tv_ldif_wrap
107 #define maxcsn tool_globals.tv_maxcsn
108 #define maxcsnbuf tool_globals.tv_maxcsnbuf
109 
110 #define SLAP_TOOL_LDAPDN_PRETTY		SLAP_LDAPDN_PRETTY
111 #define SLAP_TOOL_LDAPDN_NORMAL		(SLAP_LDAPDN_PRETTY << 1)
112 
113 void slap_tool_init LDAP_P((
114 	const char* name,
115 	int tool,
116 	int argc, char **argv ));
117 
118 int slap_tool_destroy LDAP_P((void));
119 
120 int slap_tool_update_ctxcsn LDAP_P((
121 	const char *progname,
122 	unsigned long sid,
123 	struct berval *bvtext ));
124 
125 unsigned long slap_tool_update_ctxcsn_check LDAP_P((
126 	const char *progname,
127 	Entry *e ));
128 
129 int slap_tool_update_ctxcsn_init LDAP_P((void));
130 
131 int slap_tool_entry_check LDAP_P((
132 	const char *progname,
133 	Operation *op,
134 	Entry *e,
135 	int lineno,
136 	const char **text,
137 	char *textbuf,
138 	size_t textlen ));
139 
140 #endif /* SLAPCOMMON_H_ */
141