ruby-ldap 0.9.19 → 0.9.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -7
- data/ChangeLog +4 -0
- data/NOTES +6 -0
- data/conn.c +3 -0
- data/ldap.c +3 -0
- data/rbldap.h +2 -2
- data/test/bind-ldaps.rb +1 -1
- data/test/bind-ssl.rb +1 -1
- data/test/bind.rb +1 -1
- data/test/compare.rb +1 -1
- data/test/ext.rb +9 -9
- data/test/modrdn.rb +2 -2
- data/test/moz_cert.rb +15 -15
- data/test/search.rb +2 -2
- data/test/search2.rb +2 -2
- data/test/search3.rb +1 -1
- data/test/setup.rb +3 -3
- data/test/tc_conn.rb +0 -1
- data/test/tc_ldif.rb +4 -4
- data/test/tc_search.rb +18 -18
- metadata +33 -51
- data/test/openldap_tests/progs/ldif-filter.c +0 -256
- data/test/openldap_tests/progs/slapd-addel.c +0 -435
- data/test/openldap_tests/progs/slapd-auth.c +0 -335
- data/test/openldap_tests/progs/slapd-bind.c +0 -609
- data/test/openldap_tests/progs/slapd-common.c +0 -300
- data/test/openldap_tests/progs/slapd-common.h +0 -44
- data/test/openldap_tests/progs/slapd-modify.c +0 -318
- data/test/openldap_tests/progs/slapd-modrdn.c +0 -310
- data/test/openldap_tests/progs/slapd-mtread.c +0 -837
- data/test/openldap_tests/progs/slapd-read.c +0 -568
- data/test/openldap_tests/progs/slapd-search.c +0 -618
- data/test/openldap_tests/progs/slapd-tester.c +0 -1197
@@ -1,300 +0,0 @@
|
|
1
|
-
/* $OpenLDAP$ */
|
2
|
-
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
3
|
-
*
|
4
|
-
* Copyright 1999-2016 The OpenLDAP Foundation.
|
5
|
-
* All rights reserved.
|
6
|
-
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
* modification, are permitted only as authorized by the OpenLDAP
|
9
|
-
* Public License.
|
10
|
-
*
|
11
|
-
* A copy of this license is available in file LICENSE in the
|
12
|
-
* top-level directory of the distribution or, alternatively, at
|
13
|
-
* <http://www.OpenLDAP.org/license.html>.
|
14
|
-
*/
|
15
|
-
/* ACKNOWLEDGEMENTS:
|
16
|
-
* This work was initially developed by Howard Chu for inclusion
|
17
|
-
* in OpenLDAP Software.
|
18
|
-
*/
|
19
|
-
|
20
|
-
#include "portable.h"
|
21
|
-
|
22
|
-
#include <stdio.h>
|
23
|
-
|
24
|
-
#include "ac/stdlib.h"
|
25
|
-
#include "ac/unistd.h"
|
26
|
-
#include "ac/string.h"
|
27
|
-
#include "ac/errno.h"
|
28
|
-
|
29
|
-
#include "ldap.h"
|
30
|
-
|
31
|
-
#include "ldap_pvt.h"
|
32
|
-
#include "slapd-common.h"
|
33
|
-
|
34
|
-
/* global vars */
|
35
|
-
pid_t pid;
|
36
|
-
|
37
|
-
/* static vars */
|
38
|
-
static char progname[ BUFSIZ ];
|
39
|
-
tester_t progtype;
|
40
|
-
|
41
|
-
/*
|
42
|
-
* ignore_count[] is indexed by result code:
|
43
|
-
* negative for OpenLDAP client-side errors, positive for protocol codes.
|
44
|
-
*/
|
45
|
-
#define TESTER_CLIENT_FIRST LDAP_REFERRAL_LIMIT_EXCEEDED /* negative */
|
46
|
-
#define TESTER_SERVER_LAST LDAP_OTHER
|
47
|
-
static int ignore_base [ -TESTER_CLIENT_FIRST + TESTER_SERVER_LAST + 1 ];
|
48
|
-
#define ignore_count (ignore_base - TESTER_CLIENT_FIRST)
|
49
|
-
|
50
|
-
static const struct {
|
51
|
-
const char *name;
|
52
|
-
int err;
|
53
|
-
} ignore_str2err[] = {
|
54
|
-
{ "OPERATIONS_ERROR", LDAP_OPERATIONS_ERROR },
|
55
|
-
{ "PROTOCOL_ERROR", LDAP_PROTOCOL_ERROR },
|
56
|
-
{ "TIMELIMIT_EXCEEDED", LDAP_TIMELIMIT_EXCEEDED },
|
57
|
-
{ "SIZELIMIT_EXCEEDED", LDAP_SIZELIMIT_EXCEEDED },
|
58
|
-
{ "COMPARE_FALSE", LDAP_COMPARE_FALSE },
|
59
|
-
{ "COMPARE_TRUE", LDAP_COMPARE_TRUE },
|
60
|
-
{ "AUTH_METHOD_NOT_SUPPORTED", LDAP_AUTH_METHOD_NOT_SUPPORTED },
|
61
|
-
{ "STRONG_AUTH_NOT_SUPPORTED", LDAP_STRONG_AUTH_NOT_SUPPORTED },
|
62
|
-
{ "STRONG_AUTH_REQUIRED", LDAP_STRONG_AUTH_REQUIRED },
|
63
|
-
{ "STRONGER_AUTH_REQUIRED", LDAP_STRONGER_AUTH_REQUIRED },
|
64
|
-
{ "PARTIAL_RESULTS", LDAP_PARTIAL_RESULTS },
|
65
|
-
|
66
|
-
{ "REFERRAL", LDAP_REFERRAL },
|
67
|
-
{ "ADMINLIMIT_EXCEEDED", LDAP_ADMINLIMIT_EXCEEDED },
|
68
|
-
{ "UNAVAILABLE_CRITICAL_EXTENSION", LDAP_UNAVAILABLE_CRITICAL_EXTENSION },
|
69
|
-
{ "CONFIDENTIALITY_REQUIRED", LDAP_CONFIDENTIALITY_REQUIRED },
|
70
|
-
{ "SASL_BIND_IN_PROGRESS", LDAP_SASL_BIND_IN_PROGRESS },
|
71
|
-
|
72
|
-
{ "NO_SUCH_ATTRIBUTE", LDAP_NO_SUCH_ATTRIBUTE },
|
73
|
-
{ "UNDEFINED_TYPE", LDAP_UNDEFINED_TYPE },
|
74
|
-
{ "INAPPROPRIATE_MATCHING", LDAP_INAPPROPRIATE_MATCHING },
|
75
|
-
{ "CONSTRAINT_VIOLATION", LDAP_CONSTRAINT_VIOLATION },
|
76
|
-
{ "TYPE_OR_VALUE_EXISTS", LDAP_TYPE_OR_VALUE_EXISTS },
|
77
|
-
{ "INVALID_SYNTAX", LDAP_INVALID_SYNTAX },
|
78
|
-
|
79
|
-
{ "NO_SUCH_OBJECT", LDAP_NO_SUCH_OBJECT },
|
80
|
-
{ "ALIAS_PROBLEM", LDAP_ALIAS_PROBLEM },
|
81
|
-
{ "INVALID_DN_SYNTAX", LDAP_INVALID_DN_SYNTAX },
|
82
|
-
{ "IS_LEAF", LDAP_IS_LEAF },
|
83
|
-
{ "ALIAS_DEREF_PROBLEM", LDAP_ALIAS_DEREF_PROBLEM },
|
84
|
-
|
85
|
-
/* obsolete */
|
86
|
-
{ "PROXY_AUTHZ_FAILURE", LDAP_X_PROXY_AUTHZ_FAILURE },
|
87
|
-
{ "INAPPROPRIATE_AUTH", LDAP_INAPPROPRIATE_AUTH },
|
88
|
-
{ "INVALID_CREDENTIALS", LDAP_INVALID_CREDENTIALS },
|
89
|
-
{ "INSUFFICIENT_ACCESS", LDAP_INSUFFICIENT_ACCESS },
|
90
|
-
|
91
|
-
{ "BUSY", LDAP_BUSY },
|
92
|
-
{ "UNAVAILABLE", LDAP_UNAVAILABLE },
|
93
|
-
{ "UNWILLING_TO_PERFORM", LDAP_UNWILLING_TO_PERFORM },
|
94
|
-
{ "LOOP_DETECT", LDAP_LOOP_DETECT },
|
95
|
-
|
96
|
-
{ "NAMING_VIOLATION", LDAP_NAMING_VIOLATION },
|
97
|
-
{ "OBJECT_CLASS_VIOLATION", LDAP_OBJECT_CLASS_VIOLATION },
|
98
|
-
{ "NOT_ALLOWED_ON_NONLEAF", LDAP_NOT_ALLOWED_ON_NONLEAF },
|
99
|
-
{ "NOT_ALLOWED_ON_RDN", LDAP_NOT_ALLOWED_ON_RDN },
|
100
|
-
{ "ALREADY_EXISTS", LDAP_ALREADY_EXISTS },
|
101
|
-
{ "NO_OBJECT_CLASS_MODS", LDAP_NO_OBJECT_CLASS_MODS },
|
102
|
-
{ "RESULTS_TOO_LARGE", LDAP_RESULTS_TOO_LARGE },
|
103
|
-
{ "AFFECTS_MULTIPLE_DSAS", LDAP_AFFECTS_MULTIPLE_DSAS },
|
104
|
-
|
105
|
-
{ "OTHER", LDAP_OTHER },
|
106
|
-
|
107
|
-
{ "SERVER_DOWN", LDAP_SERVER_DOWN },
|
108
|
-
{ "LOCAL_ERROR", LDAP_LOCAL_ERROR },
|
109
|
-
{ "ENCODING_ERROR", LDAP_ENCODING_ERROR },
|
110
|
-
{ "DECODING_ERROR", LDAP_DECODING_ERROR },
|
111
|
-
{ "TIMEOUT", LDAP_TIMEOUT },
|
112
|
-
{ "AUTH_UNKNOWN", LDAP_AUTH_UNKNOWN },
|
113
|
-
{ "FILTER_ERROR", LDAP_FILTER_ERROR },
|
114
|
-
{ "USER_CANCELLED", LDAP_USER_CANCELLED },
|
115
|
-
{ "PARAM_ERROR", LDAP_PARAM_ERROR },
|
116
|
-
{ "NO_MEMORY", LDAP_NO_MEMORY },
|
117
|
-
{ "CONNECT_ERROR", LDAP_CONNECT_ERROR },
|
118
|
-
{ "NOT_SUPPORTED", LDAP_NOT_SUPPORTED },
|
119
|
-
{ "CONTROL_NOT_FOUND", LDAP_CONTROL_NOT_FOUND },
|
120
|
-
{ "NO_RESULTS_RETURNED", LDAP_NO_RESULTS_RETURNED },
|
121
|
-
{ "MORE_RESULTS_TO_RETURN", LDAP_MORE_RESULTS_TO_RETURN },
|
122
|
-
{ "CLIENT_LOOP", LDAP_CLIENT_LOOP },
|
123
|
-
{ "REFERRAL_LIMIT_EXCEEDED", LDAP_REFERRAL_LIMIT_EXCEEDED },
|
124
|
-
|
125
|
-
{ NULL }
|
126
|
-
};
|
127
|
-
|
128
|
-
#define UNKNOWN_ERR (1234567890)
|
129
|
-
|
130
|
-
static int
|
131
|
-
tester_ignore_str2err( const char *err )
|
132
|
-
{
|
133
|
-
int i, ignore = 1;
|
134
|
-
|
135
|
-
if ( strcmp( err, "ALL" ) == 0 ) {
|
136
|
-
for ( i = 0; ignore_str2err[ i ].name != NULL; i++ ) {
|
137
|
-
ignore_count[ ignore_str2err[ i ].err ] = 1;
|
138
|
-
}
|
139
|
-
ignore_count[ LDAP_SUCCESS ] = 0;
|
140
|
-
|
141
|
-
return 0;
|
142
|
-
}
|
143
|
-
|
144
|
-
if ( err[ 0 ] == '!' ) {
|
145
|
-
ignore = 0;
|
146
|
-
err++;
|
147
|
-
|
148
|
-
} else if ( err[ 0 ] == '*' ) {
|
149
|
-
ignore = -1;
|
150
|
-
err++;
|
151
|
-
}
|
152
|
-
|
153
|
-
for ( i = 0; ignore_str2err[ i ].name != NULL; i++ ) {
|
154
|
-
if ( strcmp( err, ignore_str2err[ i ].name ) == 0 ) {
|
155
|
-
int err = ignore_str2err[ i ].err;
|
156
|
-
|
157
|
-
if ( err != LDAP_SUCCESS ) {
|
158
|
-
ignore_count[ err ] = ignore;
|
159
|
-
}
|
160
|
-
|
161
|
-
return err;
|
162
|
-
}
|
163
|
-
}
|
164
|
-
|
165
|
-
return UNKNOWN_ERR;
|
166
|
-
}
|
167
|
-
|
168
|
-
int
|
169
|
-
tester_ignore_str2errlist( const char *err )
|
170
|
-
{
|
171
|
-
int i;
|
172
|
-
char **errs = ldap_str2charray( err, "," );
|
173
|
-
|
174
|
-
for ( i = 0; errs[ i ] != NULL; i++ ) {
|
175
|
-
/* TODO: allow <err>:<prog> to ignore <err> only when <prog> */
|
176
|
-
(void)tester_ignore_str2err( errs[ i ] );
|
177
|
-
}
|
178
|
-
|
179
|
-
ldap_charray_free( errs );
|
180
|
-
|
181
|
-
return 0;
|
182
|
-
}
|
183
|
-
|
184
|
-
int
|
185
|
-
tester_ignore_err( int err )
|
186
|
-
{
|
187
|
-
int rc = 1;
|
188
|
-
|
189
|
-
if ( err && TESTER_CLIENT_FIRST <= err && err <= TESTER_SERVER_LAST ) {
|
190
|
-
rc = ignore_count[ err ];
|
191
|
-
if ( rc != 0 ) {
|
192
|
-
ignore_count[ err ] = rc + (rc > 0 ? 1 : -1);
|
193
|
-
}
|
194
|
-
}
|
195
|
-
|
196
|
-
/* SUCCESS is always "ignored" */
|
197
|
-
return rc;
|
198
|
-
}
|
199
|
-
|
200
|
-
void
|
201
|
-
tester_init( const char *pname, tester_t ptype )
|
202
|
-
{
|
203
|
-
pid = getpid();
|
204
|
-
srand( pid );
|
205
|
-
snprintf( progname, sizeof( progname ), "%s PID=%d", pname, pid );
|
206
|
-
progtype = ptype;
|
207
|
-
}
|
208
|
-
|
209
|
-
char *
|
210
|
-
tester_uri( char *uri, char *host, int port )
|
211
|
-
{
|
212
|
-
static char uribuf[ BUFSIZ ];
|
213
|
-
|
214
|
-
if ( uri != NULL ) {
|
215
|
-
return uri;
|
216
|
-
}
|
217
|
-
|
218
|
-
snprintf( uribuf, sizeof( uribuf ), "ldap://%s:%d", host, port );
|
219
|
-
|
220
|
-
return uribuf;
|
221
|
-
}
|
222
|
-
|
223
|
-
void
|
224
|
-
tester_ldap_error( LDAP *ld, const char *fname, const char *msg )
|
225
|
-
{
|
226
|
-
int err;
|
227
|
-
char *text = NULL;
|
228
|
-
LDAPControl **ctrls = NULL;
|
229
|
-
|
230
|
-
ldap_get_option( ld, LDAP_OPT_RESULT_CODE, (void *)&err );
|
231
|
-
if ( err != LDAP_SUCCESS ) {
|
232
|
-
ldap_get_option( ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, (void *)&text );
|
233
|
-
}
|
234
|
-
|
235
|
-
fprintf( stderr, "%s: %s: %s (%d) %s %s\n",
|
236
|
-
progname, fname, ldap_err2string( err ), err,
|
237
|
-
text == NULL ? "" : text,
|
238
|
-
msg ? msg : "" );
|
239
|
-
|
240
|
-
if ( text ) {
|
241
|
-
ldap_memfree( text );
|
242
|
-
text = NULL;
|
243
|
-
}
|
244
|
-
|
245
|
-
ldap_get_option( ld, LDAP_OPT_MATCHED_DN, (void *)&text );
|
246
|
-
if ( text != NULL ) {
|
247
|
-
if ( text[ 0 ] != '\0' ) {
|
248
|
-
fprintf( stderr, "\tmatched: %s\n", text );
|
249
|
-
}
|
250
|
-
ldap_memfree( text );
|
251
|
-
text = NULL;
|
252
|
-
}
|
253
|
-
|
254
|
-
ldap_get_option( ld, LDAP_OPT_SERVER_CONTROLS, (void *)&ctrls );
|
255
|
-
if ( ctrls != NULL ) {
|
256
|
-
int i;
|
257
|
-
|
258
|
-
fprintf( stderr, "\tcontrols:\n" );
|
259
|
-
for ( i = 0; ctrls[ i ] != NULL; i++ ) {
|
260
|
-
fprintf( stderr, "\t\t%s\n", ctrls[ i ]->ldctl_oid );
|
261
|
-
}
|
262
|
-
ldap_controls_free( ctrls );
|
263
|
-
ctrls = NULL;
|
264
|
-
}
|
265
|
-
|
266
|
-
if ( err == LDAP_REFERRAL ) {
|
267
|
-
char **refs = NULL;
|
268
|
-
|
269
|
-
ldap_get_option( ld, LDAP_OPT_REFERRAL_URLS, (void *)&refs );
|
270
|
-
|
271
|
-
if ( refs ) {
|
272
|
-
int i;
|
273
|
-
|
274
|
-
fprintf( stderr, "\treferral:\n" );
|
275
|
-
for ( i = 0; refs[ i ] != NULL; i++ ) {
|
276
|
-
fprintf( stderr, "\t\t%s\n", refs[ i ] );
|
277
|
-
}
|
278
|
-
|
279
|
-
ber_memvfree( (void **)refs );
|
280
|
-
}
|
281
|
-
}
|
282
|
-
}
|
283
|
-
|
284
|
-
void
|
285
|
-
tester_perror( const char *fname, const char *msg )
|
286
|
-
{
|
287
|
-
int save_errno = errno;
|
288
|
-
char buf[ BUFSIZ ];
|
289
|
-
|
290
|
-
fprintf( stderr, "%s: %s: (%d) %s %s\n",
|
291
|
-
progname, fname, save_errno,
|
292
|
-
AC_STRERROR_R( save_errno, buf, sizeof( buf ) ),
|
293
|
-
msg ? msg : "" );
|
294
|
-
}
|
295
|
-
|
296
|
-
void
|
297
|
-
tester_error( const char *msg )
|
298
|
-
{
|
299
|
-
fprintf( stderr, "%s: %s\n", progname, msg );
|
300
|
-
}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
/* $OpenLDAP$ */
|
2
|
-
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
3
|
-
*
|
4
|
-
* Copyright 1999-2016 The OpenLDAP Foundation.
|
5
|
-
* All rights reserved.
|
6
|
-
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
* modification, are permitted only as authorized by the OpenLDAP
|
9
|
-
* Public License.
|
10
|
-
*
|
11
|
-
* A copy of this license is available in file LICENSE in the
|
12
|
-
* top-level directory of the distribution or, alternatively, at
|
13
|
-
* <http://www.OpenLDAP.org/license.html>.
|
14
|
-
*/
|
15
|
-
/* ACKNOWLEDGEMENTS:
|
16
|
-
* This work was initially developed by Howard Chu for inclusion
|
17
|
-
* in OpenLDAP Software.
|
18
|
-
*/
|
19
|
-
|
20
|
-
#ifndef SLAPD_COMMON_H
|
21
|
-
#define SLAPD_COMMON_H
|
22
|
-
|
23
|
-
typedef enum {
|
24
|
-
TESTER_TESTER,
|
25
|
-
TESTER_ADDEL,
|
26
|
-
TESTER_BIND,
|
27
|
-
TESTER_MODIFY,
|
28
|
-
TESTER_MODRDN,
|
29
|
-
TESTER_READ,
|
30
|
-
TESTER_SEARCH,
|
31
|
-
TESTER_LAST
|
32
|
-
} tester_t;
|
33
|
-
|
34
|
-
extern void tester_init( const char *pname, tester_t ptype );
|
35
|
-
extern char * tester_uri( char *uri, char *host, int port );
|
36
|
-
extern void tester_error( const char *msg );
|
37
|
-
extern void tester_perror( const char *fname, const char *msg );
|
38
|
-
extern void tester_ldap_error( LDAP *ld, const char *fname, const char *msg );
|
39
|
-
extern int tester_ignore_str2errlist( const char *err );
|
40
|
-
extern int tester_ignore_err( int err );
|
41
|
-
|
42
|
-
extern pid_t pid;
|
43
|
-
|
44
|
-
#endif /* SLAPD_COMMON_H */
|
@@ -1,318 +0,0 @@
|
|
1
|
-
/* $OpenLDAP$ */
|
2
|
-
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
3
|
-
*
|
4
|
-
* Copyright 1999-2016 The OpenLDAP Foundation.
|
5
|
-
* All rights reserved.
|
6
|
-
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
* modification, are permitted only as authorized by the OpenLDAP
|
9
|
-
* Public License.
|
10
|
-
*
|
11
|
-
* A copy of this license is available in file LICENSE in the
|
12
|
-
* top-level directory of the distribution or, alternatively, at
|
13
|
-
* <http://www.OpenLDAP.org/license.html>.
|
14
|
-
*/
|
15
|
-
|
16
|
-
#include "portable.h"
|
17
|
-
|
18
|
-
#include <stdio.h>
|
19
|
-
|
20
|
-
#include "ac/stdlib.h"
|
21
|
-
|
22
|
-
#include "ac/ctype.h"
|
23
|
-
#include "ac/param.h"
|
24
|
-
#include "ac/socket.h"
|
25
|
-
#include "ac/string.h"
|
26
|
-
#include "ac/unistd.h"
|
27
|
-
#include "ac/wait.h"
|
28
|
-
|
29
|
-
#include "ldap.h"
|
30
|
-
#include "lutil.h"
|
31
|
-
|
32
|
-
#include "slapd-common.h"
|
33
|
-
|
34
|
-
#define LOOPS 100
|
35
|
-
#define RETRIES 0
|
36
|
-
|
37
|
-
static void
|
38
|
-
do_modify( char *uri, char *manager, struct berval *passwd,
|
39
|
-
char *entry, char *attr, char *value, int maxloop,
|
40
|
-
int maxretries, int delay, int friendly, int chaserefs );
|
41
|
-
|
42
|
-
|
43
|
-
static void
|
44
|
-
usage( char *name )
|
45
|
-
{
|
46
|
-
fprintf( stderr,
|
47
|
-
"usage: %s "
|
48
|
-
"-H <uri> | ([-h <host>] -p <port>) "
|
49
|
-
"-D <manager> "
|
50
|
-
"-w <passwd> "
|
51
|
-
"-e <entry> "
|
52
|
-
"[-i <ignore>] "
|
53
|
-
"[-l <loops>] "
|
54
|
-
"[-L <outerloops>] "
|
55
|
-
"[-r <maxretries>] "
|
56
|
-
"[-t <delay>] "
|
57
|
-
"[-F] "
|
58
|
-
"[-C]\n",
|
59
|
-
name );
|
60
|
-
exit( EXIT_FAILURE );
|
61
|
-
}
|
62
|
-
|
63
|
-
int
|
64
|
-
main( int argc, char **argv )
|
65
|
-
{
|
66
|
-
int i;
|
67
|
-
char *uri = NULL;
|
68
|
-
char *host = "localhost";
|
69
|
-
int port = -1;
|
70
|
-
char *manager = NULL;
|
71
|
-
struct berval passwd = { 0, NULL };
|
72
|
-
char *entry = NULL;
|
73
|
-
char *ava = NULL;
|
74
|
-
char *value = NULL;
|
75
|
-
int loops = LOOPS;
|
76
|
-
int outerloops = 1;
|
77
|
-
int retries = RETRIES;
|
78
|
-
int delay = 0;
|
79
|
-
int friendly = 0;
|
80
|
-
int chaserefs = 0;
|
81
|
-
|
82
|
-
tester_init( "slapd-modify", TESTER_MODIFY );
|
83
|
-
|
84
|
-
while ( ( i = getopt( argc, argv, "a:CD:e:FH:h:i:L:l:p:r:t:w:" ) ) != EOF )
|
85
|
-
{
|
86
|
-
switch ( i ) {
|
87
|
-
case 'C':
|
88
|
-
chaserefs++;
|
89
|
-
break;
|
90
|
-
|
91
|
-
case 'F':
|
92
|
-
friendly++;
|
93
|
-
break;
|
94
|
-
|
95
|
-
case 'H': /* the server uri */
|
96
|
-
uri = strdup( optarg );
|
97
|
-
break;
|
98
|
-
|
99
|
-
case 'h': /* the servers host */
|
100
|
-
host = strdup( optarg );
|
101
|
-
break;
|
102
|
-
|
103
|
-
case 'i':
|
104
|
-
/* ignored (!) by now */
|
105
|
-
break;
|
106
|
-
|
107
|
-
case 'p': /* the servers port */
|
108
|
-
if ( lutil_atoi( &port, optarg ) != 0 ) {
|
109
|
-
usage( argv[0] );
|
110
|
-
}
|
111
|
-
break;
|
112
|
-
|
113
|
-
case 'D': /* the servers manager */
|
114
|
-
manager = strdup( optarg );
|
115
|
-
break;
|
116
|
-
|
117
|
-
case 'w': /* the server managers password */
|
118
|
-
passwd.bv_val = strdup( optarg );
|
119
|
-
passwd.bv_len = strlen( optarg );
|
120
|
-
memset( optarg, '*', passwd.bv_len );
|
121
|
-
break;
|
122
|
-
|
123
|
-
case 'e': /* entry to modify */
|
124
|
-
entry = strdup( optarg );
|
125
|
-
break;
|
126
|
-
|
127
|
-
case 'a':
|
128
|
-
ava = strdup( optarg );
|
129
|
-
break;
|
130
|
-
|
131
|
-
case 'l': /* the number of loops */
|
132
|
-
if ( lutil_atoi( &loops, optarg ) != 0 ) {
|
133
|
-
usage( argv[0] );
|
134
|
-
}
|
135
|
-
break;
|
136
|
-
|
137
|
-
case 'L': /* the number of outerloops */
|
138
|
-
if ( lutil_atoi( &outerloops, optarg ) != 0 ) {
|
139
|
-
usage( argv[0] );
|
140
|
-
}
|
141
|
-
break;
|
142
|
-
|
143
|
-
case 'r': /* number of retries */
|
144
|
-
if ( lutil_atoi( &retries, optarg ) != 0 ) {
|
145
|
-
usage( argv[0] );
|
146
|
-
}
|
147
|
-
break;
|
148
|
-
|
149
|
-
case 't': /* delay in seconds */
|
150
|
-
if ( lutil_atoi( &delay, optarg ) != 0 ) {
|
151
|
-
usage( argv[0] );
|
152
|
-
}
|
153
|
-
break;
|
154
|
-
|
155
|
-
default:
|
156
|
-
usage( argv[0] );
|
157
|
-
break;
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
if (( entry == NULL ) || ( ava == NULL ) || ( port == -1 && uri == NULL ))
|
162
|
-
usage( argv[0] );
|
163
|
-
|
164
|
-
if ( *entry == '\0' ) {
|
165
|
-
|
166
|
-
fprintf( stderr, "%s: invalid EMPTY entry DN.\n",
|
167
|
-
argv[0] );
|
168
|
-
exit( EXIT_FAILURE );
|
169
|
-
|
170
|
-
}
|
171
|
-
if ( *ava == '\0' ) {
|
172
|
-
fprintf( stderr, "%s: invalid EMPTY AVA.\n",
|
173
|
-
argv[0] );
|
174
|
-
exit( EXIT_FAILURE );
|
175
|
-
}
|
176
|
-
|
177
|
-
if ( !( value = strchr( ava, ':' ))) {
|
178
|
-
fprintf( stderr, "%s: invalid AVA.\n",
|
179
|
-
argv[0] );
|
180
|
-
exit( EXIT_FAILURE );
|
181
|
-
}
|
182
|
-
*value++ = '\0';
|
183
|
-
while ( *value && isspace( (unsigned char) *value ))
|
184
|
-
value++;
|
185
|
-
|
186
|
-
uri = tester_uri( uri, host, port );
|
187
|
-
|
188
|
-
for ( i = 0; i < outerloops; i++ ) {
|
189
|
-
do_modify( uri, manager, &passwd, entry, ava, value,
|
190
|
-
loops, retries, delay, friendly, chaserefs );
|
191
|
-
}
|
192
|
-
|
193
|
-
exit( EXIT_SUCCESS );
|
194
|
-
}
|
195
|
-
|
196
|
-
|
197
|
-
static void
|
198
|
-
do_modify( char *uri, char *manager,
|
199
|
-
struct berval *passwd, char *entry, char* attr, char* value,
|
200
|
-
int maxloop, int maxretries, int delay, int friendly, int chaserefs )
|
201
|
-
{
|
202
|
-
LDAP *ld = NULL;
|
203
|
-
int i = 0, do_retry = maxretries;
|
204
|
-
int rc = LDAP_SUCCESS;
|
205
|
-
|
206
|
-
struct ldapmod mod;
|
207
|
-
struct ldapmod *mods[2];
|
208
|
-
char *values[2];
|
209
|
-
int version = LDAP_VERSION3;
|
210
|
-
|
211
|
-
values[0] = value;
|
212
|
-
values[1] = NULL;
|
213
|
-
mod.mod_op = LDAP_MOD_ADD;
|
214
|
-
mod.mod_type = attr;
|
215
|
-
mod.mod_values = values;
|
216
|
-
mods[0] = &mod;
|
217
|
-
mods[1] = NULL;
|
218
|
-
|
219
|
-
retry:;
|
220
|
-
ldap_initialize( &ld, uri );
|
221
|
-
if ( ld == NULL ) {
|
222
|
-
tester_perror( "ldap_initialize", NULL );
|
223
|
-
exit( EXIT_FAILURE );
|
224
|
-
}
|
225
|
-
|
226
|
-
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
227
|
-
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
228
|
-
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
|
229
|
-
|
230
|
-
if ( do_retry == maxretries ) {
|
231
|
-
fprintf( stderr, "PID=%ld - Modify(%d): entry=\"%s\".\n",
|
232
|
-
(long) pid, maxloop, entry );
|
233
|
-
}
|
234
|
-
|
235
|
-
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
|
236
|
-
if ( rc != LDAP_SUCCESS ) {
|
237
|
-
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
|
238
|
-
switch ( rc ) {
|
239
|
-
case LDAP_BUSY:
|
240
|
-
case LDAP_UNAVAILABLE:
|
241
|
-
if ( do_retry > 0 ) {
|
242
|
-
do_retry--;
|
243
|
-
if ( delay > 0 ) {
|
244
|
-
sleep( delay );
|
245
|
-
}
|
246
|
-
goto retry;
|
247
|
-
}
|
248
|
-
/* fallthru */
|
249
|
-
default:
|
250
|
-
break;
|
251
|
-
}
|
252
|
-
exit( EXIT_FAILURE );
|
253
|
-
}
|
254
|
-
|
255
|
-
for ( ; i < maxloop; i++ ) {
|
256
|
-
mod.mod_op = LDAP_MOD_ADD;
|
257
|
-
rc = ldap_modify_ext_s( ld, entry, mods, NULL, NULL );
|
258
|
-
if ( rc != LDAP_SUCCESS ) {
|
259
|
-
tester_ldap_error( ld, "ldap_modify_ext_s", NULL );
|
260
|
-
switch ( rc ) {
|
261
|
-
case LDAP_TYPE_OR_VALUE_EXISTS:
|
262
|
-
/* NOTE: this likely means
|
263
|
-
* the second modify failed
|
264
|
-
* during the previous round... */
|
265
|
-
if ( !friendly ) {
|
266
|
-
goto done;
|
267
|
-
}
|
268
|
-
break;
|
269
|
-
|
270
|
-
case LDAP_BUSY:
|
271
|
-
case LDAP_UNAVAILABLE:
|
272
|
-
if ( do_retry > 0 ) {
|
273
|
-
do_retry--;
|
274
|
-
goto retry;
|
275
|
-
}
|
276
|
-
/* fall thru */
|
277
|
-
|
278
|
-
default:
|
279
|
-
goto done;
|
280
|
-
}
|
281
|
-
}
|
282
|
-
|
283
|
-
mod.mod_op = LDAP_MOD_DELETE;
|
284
|
-
rc = ldap_modify_ext_s( ld, entry, mods, NULL, NULL );
|
285
|
-
if ( rc != LDAP_SUCCESS ) {
|
286
|
-
tester_ldap_error( ld, "ldap_modify_ext_s", NULL );
|
287
|
-
switch ( rc ) {
|
288
|
-
case LDAP_NO_SUCH_ATTRIBUTE:
|
289
|
-
/* NOTE: this likely means
|
290
|
-
* the first modify failed
|
291
|
-
* during the previous round... */
|
292
|
-
if ( !friendly ) {
|
293
|
-
goto done;
|
294
|
-
}
|
295
|
-
break;
|
296
|
-
|
297
|
-
case LDAP_BUSY:
|
298
|
-
case LDAP_UNAVAILABLE:
|
299
|
-
if ( do_retry > 0 ) {
|
300
|
-
do_retry--;
|
301
|
-
goto retry;
|
302
|
-
}
|
303
|
-
/* fall thru */
|
304
|
-
|
305
|
-
default:
|
306
|
-
goto done;
|
307
|
-
}
|
308
|
-
}
|
309
|
-
|
310
|
-
}
|
311
|
-
|
312
|
-
done:;
|
313
|
-
fprintf( stderr, " PID=%ld - Modify done (%d).\n", (long) pid, rc );
|
314
|
-
|
315
|
-
ldap_unbind_ext( ld, NULL, NULL );
|
316
|
-
}
|
317
|
-
|
318
|
-
|