1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
2001-01-21 01:49:05 +08:00
|
|
|
/*
|
2002-01-05 05:17:25 +08:00
|
|
|
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
|
2001-01-21 01:49:05 +08:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
1998-08-09 08:43:13 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1996 Regents of the University of Michigan.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that this notice is preserved and that due credit is given
|
|
|
|
* to the University of Michigan at Ann Arbor. The name of the University
|
|
|
|
* may not be used to endorse or promote products derived from this
|
|
|
|
* software without specific prior written permission. This software
|
|
|
|
* is provided ``as is'' without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ldap_op.c - routines to perform LDAP operations
|
|
|
|
*/
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <stdio.h>
|
1999-06-03 08:37:44 +08:00
|
|
|
|
|
|
|
#include <ac/stdlib.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
|
|
|
#include <ac/errno.h>
|
|
|
|
#include <ac/string.h>
|
1998-11-05 15:31:40 +08:00
|
|
|
#include <ac/ctype.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
#include <ac/time.h>
|
1999-06-03 08:37:44 +08:00
|
|
|
#include <ac/unistd.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <ldap.h>
|
2000-08-18 00:30:37 +08:00
|
|
|
#include "lutil_ldap.h"
|
1998-08-09 08:43:13 +08:00
|
|
|
#include "slurp.h"
|
|
|
|
|
|
|
|
/* Forward references */
|
1998-10-25 09:41:42 +08:00
|
|
|
static struct berval **make_singlevalued_berval LDAP_P(( char *, int ));
|
|
|
|
static int op_ldap_add LDAP_P(( Ri *, Re *, char ** ));
|
|
|
|
static int op_ldap_modify LDAP_P(( Ri *, Re *, char ** ));
|
|
|
|
static int op_ldap_delete LDAP_P(( Ri *, Re *, char ** ));
|
|
|
|
static int op_ldap_modrdn LDAP_P(( Ri *, Re *, char ** ));
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
static LDAPMod *alloc_ldapmod LDAP_P(( void ));
|
1998-10-25 09:41:42 +08:00
|
|
|
static void free_ldapmod LDAP_P(( LDAPMod * ));
|
|
|
|
static void free_ldmarr LDAP_P(( LDAPMod ** ));
|
|
|
|
static int getmodtype LDAP_P(( char * ));
|
|
|
|
static void dump_ldm_array LDAP_P(( LDAPMod ** ));
|
|
|
|
static int do_bind LDAP_P(( Ri *, int * ));
|
|
|
|
static int do_unbind LDAP_P(( Ri * ));
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine the type of ldap operation being performed and call the
|
|
|
|
* appropriate routine.
|
2001-09-27 11:13:28 +08:00
|
|
|
* - If successful, returns DO_LDAP_OK
|
1998-08-09 08:43:13 +08:00
|
|
|
* - If a retryable error occurs, ERR_DO_LDAP_RETRYABLE is returned.
|
|
|
|
* The caller should wait a while and retry the operation.
|
|
|
|
* - If a fatal error occurs, ERR_DO_LDAP_FATAL is returned. The caller
|
|
|
|
* should reject the operation and continue with the next replication
|
|
|
|
* entry.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
do_ldap(
|
2001-09-27 11:13:28 +08:00
|
|
|
Ri *ri,
|
|
|
|
Re *re,
|
|
|
|
char **errmsg
|
1998-08-09 08:43:13 +08:00
|
|
|
)
|
|
|
|
{
|
2001-09-27 11:13:28 +08:00
|
|
|
int retry = 2;
|
|
|
|
*errmsg = NULL;
|
|
|
|
|
|
|
|
do {
|
|
|
|
int lderr;
|
|
|
|
if ( ri->ri_ldp == NULL ) {
|
|
|
|
lderr = do_bind( ri, &lderr );
|
|
|
|
|
|
|
|
if ( lderr != BIND_OK ) {
|
|
|
|
return DO_LDAP_ERR_RETRYABLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( re->re_changetype ) {
|
|
|
|
case T_ADDCT:
|
|
|
|
lderr = op_ldap_add( ri, re, errmsg );
|
|
|
|
if ( lderr != LDAP_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_ldap: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: ldap_add_s failed adding \"%s\": %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
*errmsg ? *errmsg : ldap_err2string( lderr ),
|
|
|
|
re->re_dn, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2001-09-27 11:13:28 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: ldap_add_s failed adding \"%s\": %s\n",
|
|
|
|
*errmsg ? *errmsg : ldap_err2string( lderr ),
|
|
|
|
re->re_dn, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2001-09-27 11:13:28 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_MODIFYCT:
|
|
|
|
lderr = op_ldap_modify( ri, re, errmsg );
|
|
|
|
if ( lderr != LDAP_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_ldap: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: ldap_modify_s failed modifying \"%s\": %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
*errmsg ? *errmsg : ldap_err2string( lderr ),
|
|
|
|
re->re_dn, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2001-09-27 11:13:28 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: ldap_modify_s failed modifying \"%s\": %s\n",
|
|
|
|
*errmsg ? *errmsg : ldap_err2string( lderr ),
|
|
|
|
re->re_dn, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2001-09-27 11:13:28 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_DELETECT:
|
|
|
|
lderr = op_ldap_delete( ri, re, errmsg );
|
|
|
|
if ( lderr != LDAP_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_ldap: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: ldap_delete_s failed deleting \"%s\": %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
*errmsg ? *errmsg : ldap_err2string( lderr ),
|
|
|
|
re->re_dn, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2001-09-27 11:13:28 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: ldap_delete_s failed deleting \"%s\": %s\n",
|
|
|
|
*errmsg ? *errmsg : ldap_err2string( lderr ),
|
|
|
|
re->re_dn, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2001-09-27 11:13:28 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_MODRDNCT:
|
|
|
|
lderr = op_ldap_modrdn( ri, re, errmsg );
|
|
|
|
if ( lderr != LDAP_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_ldap: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: ldap_modrdn_s failed modifying %s: %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
*errmsg ? *errmsg : ldap_err2string( lderr ),
|
|
|
|
re->re_dn, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2001-09-27 11:13:28 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: ldap_modrdn_s failed modifying %s: %s\n",
|
|
|
|
*errmsg ? *errmsg : ldap_err2string( lderr ),
|
|
|
|
re->re_dn, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2001-09-27 11:13:28 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_ldap: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: bad op \"%d\", dn = \"%s\"\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
re->re_changetype, re->re_dn, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2001-09-27 11:13:28 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: do_ldap: bad op \"%d\", dn = \"%s\"\n",
|
|
|
|
re->re_changetype, re->re_dn, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2001-09-27 11:13:28 +08:00
|
|
|
return DO_LDAP_ERR_FATAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Analyze return code. If ok, just return. If LDAP_SERVER_DOWN,
|
|
|
|
* we may have been idle long enough that the remote slapd timed
|
|
|
|
* us out. Rebind and try again.
|
|
|
|
*/
|
|
|
|
switch( lderr ) {
|
|
|
|
case LDAP_SUCCESS:
|
|
|
|
return DO_LDAP_OK;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DO_LDAP_ERR_FATAL;
|
|
|
|
|
|
|
|
case LDAP_SERVER_DOWN: /* server went down */
|
|
|
|
(void) do_unbind( ri );
|
|
|
|
retry--;
|
|
|
|
}
|
|
|
|
} while ( retry > 0 );
|
|
|
|
|
|
|
|
return DO_LDAP_ERR_RETRYABLE;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform an ldap add operation.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
op_ldap_add(
|
|
|
|
Ri *ri,
|
|
|
|
Re *re,
|
|
|
|
char **errmsg
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Mi *mi;
|
|
|
|
int nattrs, rc = 0, i;
|
|
|
|
LDAPMod *ldm, **ldmarr;
|
|
|
|
int lderr = 0;
|
|
|
|
|
|
|
|
nattrs = i = 0;
|
|
|
|
ldmarr = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Construct a null-terminated array of LDAPMod structs.
|
|
|
|
*/
|
|
|
|
mi = re->re_mods;
|
|
|
|
while ( mi[ i ].mi_type != NULL ) {
|
|
|
|
ldm = alloc_ldapmod();
|
|
|
|
ldmarr = ( LDAPMod ** ) ch_realloc( ldmarr,
|
|
|
|
( nattrs + 2 ) * sizeof( LDAPMod * ));
|
|
|
|
ldmarr[ nattrs ] = ldm;
|
|
|
|
ldm->mod_op = LDAP_MOD_BVALUES;
|
|
|
|
ldm->mod_type = mi[ i ].mi_type;
|
|
|
|
ldm->mod_bvalues =
|
|
|
|
make_singlevalued_berval( mi[ i ].mi_val, mi[ i ].mi_len );
|
|
|
|
i++;
|
|
|
|
nattrs++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ldmarr != NULL ) {
|
|
|
|
ldmarr[ nattrs ] = NULL;
|
|
|
|
|
|
|
|
/* Perform the operation */
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ARGS,
|
2002-04-16 02:59:20 +08:00
|
|
|
"op_ldap_add: replica %s:%d - add dn \"%s\"\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, re->re_dn );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS, "replica %s:%d - add dn \"%s\"\n",
|
|
|
|
ri->ri_hostname, ri->ri_port, re->re_dn );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
rc = ldap_add_s( ri->ri_ldp, re->re_dn, ldmarr );
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
ldap_get_option( ri->ri_ldp, LDAP_OPT_ERROR_NUMBER, &lderr);
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
} else {
|
|
|
|
*errmsg = "No modifications to do";
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"op_ldap_add: Error: no mods to do (%s)!\n", re->re_dn, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
1999-04-03 11:39:16 +08:00
|
|
|
"Error: op_ldap_add: no mods to do (%s)!\n", re->re_dn, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
free_ldmarr( ldmarr );
|
|
|
|
return( lderr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform an ldap modify operation.
|
|
|
|
*/
|
|
|
|
#define AWAITING_OP -1
|
|
|
|
static int
|
|
|
|
op_ldap_modify(
|
|
|
|
Ri *ri,
|
|
|
|
Re *re,
|
|
|
|
char **errmsg
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Mi *mi;
|
|
|
|
int state; /* This code is a simple-minded state machine */
|
|
|
|
int nvals; /* Number of values we're modifying */
|
|
|
|
int nops; /* Number of LDAPMod structs in ldmarr */
|
2002-04-08 17:43:22 +08:00
|
|
|
LDAPMod *ldm = NULL, **ldmarr;
|
1998-08-09 08:43:13 +08:00
|
|
|
int i, len;
|
|
|
|
char *type, *value;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
state = AWAITING_OP;
|
|
|
|
nvals = 0;
|
|
|
|
nops = 0;
|
|
|
|
ldmarr = NULL;
|
|
|
|
|
|
|
|
if ( re->re_mods == NULL ) {
|
|
|
|
*errmsg = "No arguments given";
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"op_ldap_modify: Error: no arguments\n" , 0, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "Error: op_ldap_modify: no arguments\n",
|
|
|
|
0, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Construct a null-terminated array of LDAPMod structs.
|
|
|
|
*/
|
|
|
|
for ( mi = re->re_mods, i = 0; mi[ i ].mi_type != NULL; i++ ) {
|
|
|
|
type = mi[ i ].mi_type;
|
|
|
|
value = mi[ i ].mi_val;
|
|
|
|
len = mi[ i ].mi_len;
|
|
|
|
switch ( getmodtype( type )) {
|
|
|
|
case T_MODSEP:
|
|
|
|
state = T_MODSEP; /* Got a separator line "-\n" */
|
|
|
|
continue;
|
|
|
|
case T_MODOPADD:
|
|
|
|
state = T_MODOPADD;
|
|
|
|
ldmarr = ( LDAPMod ** )
|
|
|
|
ch_realloc(ldmarr, (( nops + 2 ) * ( sizeof( LDAPMod * ))));
|
|
|
|
ldmarr[ nops ] = ldm = alloc_ldapmod();
|
|
|
|
ldm->mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES;
|
|
|
|
ldm->mod_type = value;
|
|
|
|
nvals = 0;
|
|
|
|
nops++;
|
|
|
|
break;
|
|
|
|
case T_MODOPREPLACE:
|
|
|
|
state = T_MODOPREPLACE;
|
|
|
|
ldmarr = ( LDAPMod ** )
|
|
|
|
ch_realloc(ldmarr, (( nops + 2 ) * ( sizeof( LDAPMod * ))));
|
|
|
|
ldmarr[ nops ] = ldm = alloc_ldapmod();
|
|
|
|
ldm->mod_op = LDAP_MOD_REPLACE | LDAP_MOD_BVALUES;
|
|
|
|
ldm->mod_type = value;
|
|
|
|
nvals = 0;
|
|
|
|
nops++;
|
|
|
|
break;
|
|
|
|
case T_MODOPDELETE:
|
|
|
|
state = T_MODOPDELETE;
|
|
|
|
ldmarr = ( LDAPMod ** )
|
|
|
|
ch_realloc(ldmarr, (( nops + 2 ) * ( sizeof( LDAPMod * ))));
|
|
|
|
ldmarr[ nops ] = ldm = alloc_ldapmod();
|
|
|
|
ldm->mod_op = LDAP_MOD_DELETE | LDAP_MOD_BVALUES;
|
|
|
|
ldm->mod_type = value;
|
|
|
|
nvals = 0;
|
|
|
|
nops++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if ( state == AWAITING_OP ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"op_ldap_modify: Error: unknown mod type \"%s\"\n", type, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: op_ldap_modify: unknown mod type \"%s\"\n",
|
|
|
|
type, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-04-08 17:43:22 +08:00
|
|
|
assert( ldm );
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
/*
|
|
|
|
* We should have an attribute: value pair here.
|
|
|
|
* Construct the mod_bvalues part of the ldapmod struct.
|
|
|
|
*/
|
|
|
|
if ( strcasecmp( type, ldm->mod_type )) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
2002-04-16 02:59:20 +08:00
|
|
|
"op_ldap_modify: Error: "
|
|
|
|
"malformed modify op, %s: %s (expecting \"%s\")\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
type, value, ldm->mod_type );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: malformed modify op, %s: %s (expecting %s:)\n",
|
|
|
|
type, value, ldm->mod_type );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ldm->mod_bvalues = ( struct berval ** )
|
|
|
|
ch_realloc( ldm->mod_bvalues,
|
|
|
|
( nvals + 2 ) * sizeof( struct berval * ));
|
|
|
|
ldm->mod_bvalues[ nvals + 1 ] = NULL;
|
|
|
|
ldm->mod_bvalues[ nvals ] = ( struct berval * )
|
|
|
|
ch_malloc( sizeof( struct berval ));
|
|
|
|
ldm->mod_bvalues[ nvals ]->bv_val = value;
|
|
|
|
ldm->mod_bvalues[ nvals ]->bv_len = len;
|
|
|
|
nvals++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ldmarr[ nops ] = NULL;
|
|
|
|
|
|
|
|
if ( nops > 0 ) {
|
|
|
|
/* Actually perform the LDAP operation */
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
2002-04-16 02:59:20 +08:00
|
|
|
"op_ldap_modify: replica %s:%d - modify dn \"%s\"\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, re->re_dn );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS, "replica %s:%d - modify dn \"%s\"\n",
|
|
|
|
ri->ri_hostname, ri->ri_port, re->re_dn );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
rc = ldap_modify_s( ri->ri_ldp, re->re_dn, ldmarr );
|
|
|
|
}
|
|
|
|
free_ldmarr( ldmarr );
|
|
|
|
return( rc );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform an ldap delete operation.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
op_ldap_delete(
|
|
|
|
Ri *ri,
|
|
|
|
Re *re,
|
|
|
|
char **errmsg
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ARGS,
|
2002-04-16 02:59:20 +08:00
|
|
|
"op_ldap_delete: replica %s:%d - delete dn \"%s\"\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, re->re_dn );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS, "replica %s:%d - delete dn \"%s\"\n",
|
|
|
|
ri->ri_hostname, ri->ri_port, re->re_dn );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
rc = ldap_delete_s( ri->ri_ldp, re->re_dn );
|
|
|
|
|
|
|
|
return( rc );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform an ldap modrdn operation.
|
|
|
|
*/
|
1999-07-30 05:25:39 +08:00
|
|
|
#define GOT_NEWRDN 0x1
|
|
|
|
#define GOT_DELOLDRDN 0x2
|
|
|
|
#define GOT_NEWSUP 0x4
|
|
|
|
|
|
|
|
#define GOT_MODDN_REQ (GOT_NEWRDN|GOT_DELOLDRDN)
|
|
|
|
#define GOT_ALL_MODDN(f) (((f) & GOT_MODDN_REQ) == GOT_MODDN_REQ)
|
1998-08-09 08:43:13 +08:00
|
|
|
static int
|
|
|
|
op_ldap_modrdn(
|
|
|
|
Ri *ri,
|
|
|
|
Re *re,
|
|
|
|
char **errmsg
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
Mi *mi;
|
|
|
|
int i;
|
1998-11-04 09:41:00 +08:00
|
|
|
int lderr = 0;
|
1998-08-09 08:43:13 +08:00
|
|
|
int state = 0;
|
|
|
|
int drdnflag = -1;
|
2002-04-08 17:43:22 +08:00
|
|
|
char *newrdn = NULL;
|
1999-07-30 05:25:39 +08:00
|
|
|
char *newsup = NULL;
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
if ( re->re_mods == NULL ) {
|
|
|
|
*errmsg = "No arguments given";
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"op_ldap_modrdn: Error: no arguments\n" , 0, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "Error: op_ldap_modrdn: no arguments\n",
|
|
|
|
0, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the arguments: should see newrdn: and deleteoldrdn: args.
|
|
|
|
*/
|
|
|
|
for ( mi = re->re_mods, i = 0; mi[ i ].mi_type != NULL; i++ ) {
|
|
|
|
if ( !strcmp( mi[ i ].mi_type, T_NEWRDNSTR )) {
|
1999-07-30 05:25:39 +08:00
|
|
|
if( state & GOT_NEWRDN ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
2002-04-16 02:59:20 +08:00
|
|
|
"op_ldap_modrdn: Error: multiple newrdn arg \"%s\"\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
mi[ i ].mi_val, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1999-07-30 05:25:39 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: op_ldap_modrdn: multiple newrdn arg \"%s\"\n",
|
|
|
|
mi[ i ].mi_val, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1999-07-30 05:25:39 +08:00
|
|
|
*errmsg = "Multiple newrdn argument";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
newrdn = mi[ i ].mi_val;
|
|
|
|
state |= GOT_NEWRDN;
|
1999-07-30 05:25:39 +08:00
|
|
|
|
|
|
|
} else if ( !strcmp( mi[ i ].mi_type, T_DELOLDRDNSTR )) {
|
|
|
|
if( state & GOT_DELOLDRDN ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
2002-04-16 02:59:20 +08:00
|
|
|
"op_ldap_modrdn: Error: multiple deleteoldrdn arg \"%s\"\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
mi[ i ].mi_val, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1999-07-30 05:25:39 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: op_ldap_modrdn: multiple deleteoldrdn arg \"%s\"\n",
|
|
|
|
mi[ i ].mi_val, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1999-07-30 05:25:39 +08:00
|
|
|
*errmsg = "Multiple newrdn argument";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
state |= GOT_DELOLDRDN;
|
1998-08-09 08:43:13 +08:00
|
|
|
if ( !strcmp( mi[ i ].mi_val, "0" )) {
|
|
|
|
drdnflag = 0;
|
|
|
|
} else if ( !strcmp( mi[ i ].mi_val, "1" )) {
|
|
|
|
drdnflag = 1;
|
|
|
|
} else {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
2002-04-16 02:59:20 +08:00
|
|
|
"op_ldap_modrdn: Error: bad deleteoldrdn arg \"%s\"\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
mi[ i ].mi_val, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: op_ldap_modrdn: bad deleteoldrdn arg \"%s\"\n",
|
|
|
|
mi[ i ].mi_val, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
*errmsg = "Incorrect argument to deleteoldrdn";
|
|
|
|
return -1;
|
|
|
|
}
|
1999-07-30 05:25:39 +08:00
|
|
|
|
|
|
|
} else if ( !strcmp( mi[ i ].mi_type, T_NEWSUPSTR )) {
|
|
|
|
if( state & GOT_NEWSUP ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
2002-04-16 02:59:20 +08:00
|
|
|
"op_ldap_modrdn: Error: multiple newsuperior arg \"%s\"\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
mi[ i ].mi_val, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1999-07-30 05:25:39 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: op_ldap_modrdn: multiple newsuperior arg \"%s\"\n",
|
|
|
|
mi[ i ].mi_val, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-06-26 09:23:00 +08:00
|
|
|
*errmsg = "Multiple newsuperior argument";
|
1999-07-30 05:25:39 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2001-10-10 02:12:22 +08:00
|
|
|
newsup = mi[ i ].mi_val;
|
1999-07-30 05:25:39 +08:00
|
|
|
state |= GOT_NEWSUP;
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
} else {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
2002-04-16 02:59:20 +08:00
|
|
|
"op_ldap_modrdn: Error: bad type \"%s\"\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
mi[ i ].mi_type, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "Error: op_ldap_modrdn: bad type \"%s\"\n",
|
|
|
|
mi[ i ].mi_type, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
*errmsg = "Bad value in replication log entry";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Punt if we don't have all the args.
|
|
|
|
*/
|
2000-09-16 08:26:24 +08:00
|
|
|
if ( !GOT_ALL_MODDN(state) ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"op_ldap_modrdn: Error: missing arguments\n" , 0, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "Error: op_ldap_modrdn: missing arguments\n",
|
|
|
|
0, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
*errmsg = "Missing argument: requires \"newrdn\" and \"deleteoldrdn\"";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef LDAP_DEBUG
|
|
|
|
if ( ldap_debug & LDAP_DEBUG_ARGS ) {
|
|
|
|
char buf[ 256 ];
|
|
|
|
char *buf2;
|
2002-04-26 03:23:37 +08:00
|
|
|
int buf2len = strlen( re->re_dn ) + strlen( mi->mi_val ) + 11;
|
|
|
|
|
|
|
|
snprintf( buf, sizeof(buf), "%s:%d", ri->ri_hostname, ri->ri_port );
|
|
|
|
|
|
|
|
buf2 = (char *) ch_malloc( buf2len );
|
|
|
|
snprintf( buf2, buf2len, "(\"%s\" -> \"%s\")", re->re_dn, mi->mi_val );
|
|
|
|
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ARGS,
|
2002-04-16 02:59:20 +08:00
|
|
|
"op_ldap_modrdn: replica %s - modify rdn %s (flag: %d)\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
buf, buf2, drdnflag );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
|
|
|
"replica %s - modify rdn %s (flag: %d)\n",
|
|
|
|
buf, buf2, drdnflag );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
free( buf2 );
|
|
|
|
}
|
|
|
|
#endif /* LDAP_DEBUG */
|
|
|
|
|
2002-04-08 17:43:22 +08:00
|
|
|
assert( newrdn );
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
/* Do the modrdn */
|
2001-10-10 02:12:22 +08:00
|
|
|
rc = ldap_rename2_s( ri->ri_ldp, re->re_dn, newrdn, newsup, drdnflag );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-11-04 09:41:00 +08:00
|
|
|
ldap_get_option( ri->ri_ldp, LDAP_OPT_ERROR_NUMBER, &lderr);
|
|
|
|
return( lderr );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate and initialize an ldapmod struct.
|
|
|
|
*/
|
|
|
|
static LDAPMod *
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
alloc_ldapmod( void )
|
1998-08-09 08:43:13 +08:00
|
|
|
{
|
|
|
|
LDAPMod *ldm;
|
|
|
|
|
|
|
|
ldm = ( struct ldapmod * ) ch_malloc( sizeof ( struct ldapmod ));
|
|
|
|
ldm->mod_type = NULL;
|
|
|
|
ldm->mod_bvalues = ( struct berval ** ) NULL;
|
|
|
|
return( ldm );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free an ldapmod struct associated mod_bvalues. NOTE - it is assumed
|
|
|
|
* that mod_bvalues and mod_type contain pointers to the same block of memory
|
|
|
|
* pointed to by the repl struct. Therefore, it's not freed here.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
free_ldapmod(
|
|
|
|
LDAPMod *ldm )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ( ldm == NULL ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( ldm->mod_bvalues != NULL ) {
|
|
|
|
for ( i = 0; ldm->mod_bvalues[ i ] != NULL; i++ ) {
|
|
|
|
free( ldm->mod_bvalues[ i ] );
|
|
|
|
}
|
|
|
|
free( ldm->mod_bvalues );
|
|
|
|
}
|
|
|
|
free( ldm );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free an an array of LDAPMod pointers and the LDAPMod structs they point
|
|
|
|
* to.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
free_ldmarr(
|
|
|
|
LDAPMod **ldmarr )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for ( i = 0; ldmarr[ i ] != NULL; i++ ) {
|
|
|
|
free_ldapmod( ldmarr[ i ] );
|
|
|
|
}
|
|
|
|
free( ldmarr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a berval with a single value.
|
|
|
|
*/
|
|
|
|
static struct berval **
|
|
|
|
make_singlevalued_berval(
|
|
|
|
char *value,
|
|
|
|
int len )
|
|
|
|
{
|
|
|
|
struct berval **p;
|
|
|
|
|
|
|
|
p = ( struct berval ** ) ch_malloc( 2 * sizeof( struct berval * ));
|
|
|
|
p[ 0 ] = ( struct berval * ) ch_malloc( sizeof( struct berval ));
|
|
|
|
p[ 1 ] = NULL;
|
|
|
|
p[ 0 ]->bv_val = value;
|
|
|
|
p[ 0 ]->bv_len = len;
|
|
|
|
return( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a modification type (string), return an enumerated type.
|
|
|
|
* Avoids ugly copy in op_ldap_modify - lets us use a switch statement
|
|
|
|
* there.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
getmodtype(
|
|
|
|
char *type )
|
|
|
|
{
|
|
|
|
if ( !strcmp( type, T_MODSEPSTR )) {
|
|
|
|
return( T_MODSEP );
|
|
|
|
}
|
|
|
|
if ( !strcmp( type, T_MODOPADDSTR )) {
|
|
|
|
return( T_MODOPADD );
|
|
|
|
}
|
|
|
|
if ( !strcmp( type, T_MODOPREPLACESTR )) {
|
|
|
|
return( T_MODOPREPLACE );
|
|
|
|
}
|
|
|
|
if ( !strcmp( type, T_MODOPDELETESTR )) {
|
|
|
|
return( T_MODOPDELETE );
|
|
|
|
}
|
|
|
|
return( T_ERR );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform an LDAP unbind operation. If replica is NULL, or the
|
|
|
|
* repl_ldp is NULL, just return LDAP_SUCCESS. Otherwise, unbind,
|
|
|
|
* set the ldp to NULL, and return the result of the unbind call.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
do_unbind(
|
|
|
|
Ri *ri
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int rc = LDAP_SUCCESS;
|
|
|
|
|
|
|
|
if (( ri != NULL ) && ( ri->ri_ldp != NULL )) {
|
|
|
|
rc = ldap_unbind( ri->ri_ldp );
|
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
2002-04-16 02:59:20 +08:00
|
|
|
"do_unbind: ldap_unbind failed for %s:%d: %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, ldap_err2string( rc ) );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: do_unbind: ldap_unbind failed for %s:%d: %s\n",
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, ldap_err2string( rc ) );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
ri->ri_ldp = NULL;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform an LDAP bind operation to the replication site given
|
|
|
|
* by replica. If replica->repl_ldp is non-NULL, then we unbind
|
|
|
|
* from the replica before rebinding. It should be safe to call
|
|
|
|
* this to re-connect if the replica's connection goes away
|
|
|
|
* for some reason.
|
|
|
|
*
|
|
|
|
* Returns 0 on success, -1 if an LDAP error occurred, and a return
|
|
|
|
* code > 0 if some other error occurred, e.g. invalid bind method.
|
|
|
|
* If an LDAP error occurs, the LDAP error is returned in lderr.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
do_bind(
|
|
|
|
Ri *ri,
|
|
|
|
int *lderr
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int ldrc;
|
|
|
|
|
|
|
|
*lderr = 0;
|
|
|
|
|
|
|
|
if ( ri == NULL ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_bind: null ri ptr\n" , 0, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "Error: do_bind: null ri ptr\n", 0, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
return( BIND_ERR_BADRI );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ri->ri_ldp != NULL ) {
|
|
|
|
ldrc = ldap_unbind( ri->ri_ldp );
|
|
|
|
if ( ldrc != LDAP_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"do_bind: ldap_unbind failed: %s\n", ldap_err2string( ldrc ), 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: do_bind: ldap_unbind failed: %s\n",
|
|
|
|
ldap_err2string( ldrc ), 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
ri->ri_ldp = NULL;
|
|
|
|
}
|
|
|
|
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ARGS,
|
2002-04-16 02:59:20 +08:00
|
|
|
"do_bind: Initializing session to %s:%d\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1999-06-14 05:49:35 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS, "Initializing session to %s:%d\n",
|
1998-08-09 08:43:13 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-06-26 06:45:28 +08:00
|
|
|
|
1999-06-14 05:49:35 +08:00
|
|
|
ri->ri_ldp = ldap_init( ri->ri_hostname, ri->ri_port );
|
1998-08-09 08:43:13 +08:00
|
|
|
if ( ri->ri_ldp == NULL ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
2002-04-16 02:59:20 +08:00
|
|
|
"do_bind: ldap_init (%s, %d) failed: %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, sys_errlist[ errno ] );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2000-06-26 06:45:28 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "Error: ldap_init(%s, %d) failed: %s\n",
|
|
|
|
ri->ri_hostname, ri->ri_port, sys_errlist[ errno ] );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-06-26 06:45:28 +08:00
|
|
|
return( BIND_ERR_OPEN );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
2000-06-26 06:45:28 +08:00
|
|
|
{ /* set version 3 */
|
|
|
|
int err, version = 3;
|
|
|
|
err = ldap_set_option(ri->ri_ldp,
|
|
|
|
LDAP_OPT_PROTOCOL_VERSION, &version);
|
|
|
|
|
|
|
|
if( err != LDAP_OPT_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_bind: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: ldap_set_option(%s, LDAP_OPT_VERSION, 3) failed!\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2000-06-26 06:45:28 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: ldap_set_option(%s, LDAP_OPT_VERSION, 3) failed!\n",
|
|
|
|
ri->ri_hostname, NULL, NULL );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-06-26 06:45:28 +08:00
|
|
|
|
|
|
|
ldap_unbind( ri->ri_ldp );
|
|
|
|
ri->ri_ldp = NULL;
|
|
|
|
return BIND_ERR_VERSION;
|
|
|
|
}
|
|
|
|
}
|
1998-11-07 04:40:47 +08:00
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
/*
|
|
|
|
* Set ldap library options to (1) not follow referrals, and
|
|
|
|
* (2) restart the select() system call.
|
|
|
|
*/
|
2000-06-26 06:45:28 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
err = ldap_set_option(ri->ri_ldp, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
|
|
|
|
|
|
|
|
if( err != LDAP_OPT_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_bind: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: ldap_set_option(%s, REFERRALS, OFF) failed!\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2000-06-26 06:45:28 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: ldap_set_option(%s,REFERRALS, OFF) failed!\n",
|
|
|
|
ri->ri_hostname, NULL, NULL );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-06-26 06:45:28 +08:00
|
|
|
ldap_unbind( ri->ri_ldp );
|
|
|
|
ri->ri_ldp = NULL;
|
|
|
|
return BIND_ERR_REFERRALS;
|
|
|
|
}
|
|
|
|
}
|
1998-11-04 09:41:00 +08:00
|
|
|
ldap_set_option(ri->ri_ldp, LDAP_OPT_RESTART, LDAP_OPT_ON);
|
1998-08-09 08:43:13 +08:00
|
|
|
|
2000-09-16 07:41:07 +08:00
|
|
|
if( ri->ri_tls ) {
|
|
|
|
int err;
|
|
|
|
err = ldap_start_tls_s(ri->ri_ldp, NULL, NULL);
|
|
|
|
|
|
|
|
if( err != LDAP_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_bind: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"%s: ldap_start_tls failed: %s (%d)\n",
|
|
|
|
ri->ri_tls == TLS_CRITICAL ? "Error" : "Warning",
|
2002-07-12 04:33:24 +08:00
|
|
|
ldap_err2string( err ), err );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2000-09-16 07:41:07 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"%s: ldap_start_tls failed: %s (%d)\n",
|
2002-01-13 01:46:27 +08:00
|
|
|
ri->ri_tls == TLS_CRITICAL ? "Error" : "Warning",
|
2000-09-16 07:41:07 +08:00
|
|
|
ldap_err2string( err ), err );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-09-16 07:41:07 +08:00
|
|
|
|
2002-01-13 01:46:27 +08:00
|
|
|
if( ri->ri_tls == TLS_CRITICAL ) {
|
2000-09-16 07:41:07 +08:00
|
|
|
ldap_unbind( ri->ri_ldp );
|
|
|
|
ri->ri_ldp = NULL;
|
|
|
|
return BIND_ERR_TLS_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
switch ( ri->ri_bind_method ) {
|
|
|
|
case AUTH_SIMPLE:
|
|
|
|
/*
|
|
|
|
* Bind with a plaintext password.
|
|
|
|
*/
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ARGS,
|
2002-04-16 02:59:20 +08:00
|
|
|
"do_bind: bind to %s:%d as %s (simple)\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, ri->ri_bind_dn );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS, "bind to %s:%d as %s (simple)\n",
|
|
|
|
ri->ri_hostname, ri->ri_port, ri->ri_bind_dn );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
ldrc = ldap_simple_bind_s( ri->ri_ldp, ri->ri_bind_dn,
|
|
|
|
ri->ri_password );
|
|
|
|
if ( ldrc != LDAP_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_bind: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: ldap_simple_bind_s for %s:%d failed: %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, ldap_err2string( ldrc ) );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: ldap_simple_bind_s for %s:%d failed: %s\n",
|
|
|
|
ri->ri_hostname, ri->ri_port, ldap_err2string( ldrc ));
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
*lderr = ldrc;
|
2000-06-26 06:45:28 +08:00
|
|
|
ldap_unbind( ri->ri_ldp );
|
|
|
|
ri->ri_ldp = NULL;
|
1998-08-09 08:43:13 +08:00
|
|
|
return( BIND_ERR_SIMPLE_FAILED );
|
|
|
|
}
|
|
|
|
break;
|
2000-08-18 00:30:37 +08:00
|
|
|
|
|
|
|
case AUTH_SASL:
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ARGS,
|
2002-04-16 02:59:20 +08:00
|
|
|
"do_bind: bind to %s as %s via %s (SASL)\n",
|
2002-06-23 05:27:38 +08:00
|
|
|
ri->ri_hostname,
|
|
|
|
ri->ri_authcId ? ri->ri_authcId : "-",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_saslmech );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2000-08-18 00:30:37 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS, "bind to %s as %s via %s (SASL)\n",
|
2002-06-23 05:27:38 +08:00
|
|
|
ri->ri_hostname,
|
|
|
|
ri->ri_authcId ? ri->ri_authcId : "-",
|
|
|
|
ri->ri_saslmech );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-08-18 00:30:37 +08:00
|
|
|
|
2000-08-20 02:47:32 +08:00
|
|
|
#ifdef HAVE_CYRUS_SASL
|
2000-09-16 07:41:07 +08:00
|
|
|
if( ri->ri_secprops != NULL ) {
|
|
|
|
int err;
|
|
|
|
err = ldap_set_option(ri->ri_ldp, LDAP_OPT_X_SASL_SECPROPS,
|
|
|
|
ri->ri_secprops);
|
|
|
|
|
|
|
|
if( err != LDAP_OPT_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_bind: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: ldap_set_option(%s,SECPROPS,\"%s\") failed!\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_secprops, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2000-09-16 07:41:07 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: ldap_set_option(%s,SECPROPS,\"%s\") failed!\n",
|
|
|
|
ri->ri_hostname, ri->ri_secprops, NULL );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-09-16 07:41:07 +08:00
|
|
|
ldap_unbind( ri->ri_ldp );
|
|
|
|
ri->ri_ldp = NULL;
|
|
|
|
return BIND_ERR_SASL_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-13 01:46:27 +08:00
|
|
|
{
|
|
|
|
char *passwd = ri->ri_password ? ber_strdup( ri->ri_password ) : NULL;
|
|
|
|
void *defaults = lutil_sasl_defaults( ri->ri_ldp, ri->ri_saslmech,
|
|
|
|
ri->ri_realm, ri->ri_authcId, passwd, ri->ri_authzId );
|
|
|
|
|
|
|
|
ldrc = ldap_sasl_interactive_bind_s( ri->ri_ldp, ri->ri_bind_dn,
|
|
|
|
ri->ri_saslmech, NULL, NULL,
|
|
|
|
LDAP_SASL_QUIET, lutil_sasl_interact, defaults );
|
|
|
|
if ( ldrc != LDAP_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_bind: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: LDAP SASL for %s:%d failed: %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, ldap_err2string( ldrc ) );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2002-01-13 01:46:27 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "Error: LDAP SASL for %s:%d failed: %s\n",
|
|
|
|
ri->ri_hostname, ri->ri_port, ldap_err2string( ldrc ));
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2002-01-13 01:46:27 +08:00
|
|
|
*lderr = ldrc;
|
|
|
|
ldap_unbind( ri->ri_ldp );
|
|
|
|
ri->ri_ldp = NULL;
|
|
|
|
return( BIND_ERR_SASL_FAILED );
|
|
|
|
}
|
|
|
|
|
|
|
|
ber_memfree( passwd );
|
|
|
|
ber_memfree( defaults );
|
2000-08-18 00:30:37 +08:00
|
|
|
}
|
|
|
|
break;
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_bind: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: do_bind: SASL not supported %s:%d\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, ri->ri_port, 0 );
|
2000-08-20 02:47:32 +08:00
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: do_bind: SASL not supported %s:%d\n",
|
|
|
|
ri->ri_hostname, ri->ri_port, NULL );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-08-20 02:47:32 +08:00
|
|
|
ldap_unbind( ri->ri_ldp );
|
|
|
|
ri->ri_ldp = NULL;
|
|
|
|
return( BIND_ERR_BAD_ATYPE );
|
|
|
|
#endif
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
default:
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_bind: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Error: do_bind: unknown auth type \"%d\" for %s:%d\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_bind_method, ri->ri_hostname, ri->ri_port );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Error: do_bind: unknown auth type \"%d\" for %s:%d\n",
|
|
|
|
ri->ri_bind_method, ri->ri_hostname, ri->ri_port );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-06-26 06:45:28 +08:00
|
|
|
ldap_unbind( ri->ri_ldp );
|
|
|
|
ri->ri_ldp = NULL;
|
1998-08-09 08:43:13 +08:00
|
|
|
return( BIND_ERR_BAD_ATYPE );
|
|
|
|
}
|
2000-06-26 06:45:28 +08:00
|
|
|
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
LDAPControl c;
|
|
|
|
LDAPControl *ctrls[2];
|
|
|
|
ctrls[0] = &c;
|
|
|
|
ctrls[1] = NULL;
|
|
|
|
|
|
|
|
c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
|
|
|
c.ldctl_value.bv_val = NULL;
|
|
|
|
c.ldctl_value.bv_len = 0;
|
2001-10-10 02:53:22 +08:00
|
|
|
c.ldctl_iscritical = 0;
|
2000-06-26 06:45:28 +08:00
|
|
|
|
|
|
|
err = ldap_set_option(ri->ri_ldp, LDAP_OPT_SERVER_CONTROLS, &ctrls);
|
|
|
|
|
|
|
|
if( err != LDAP_OPT_SUCCESS ) {
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR, "do_bind: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"ldap_set_option(%s, SERVER_CONTROLS, ManageDSAit) failed!\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
ri->ri_hostname, 0, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
2001-10-10 02:53:22 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "Error: "
|
|
|
|
"ldap_set_option(%s, SERVER_CONTROLS, ManageDSAit) failed!\n",
|
2000-06-26 06:45:28 +08:00
|
|
|
ri->ri_hostname, NULL, NULL );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
2000-06-26 06:45:28 +08:00
|
|
|
ldap_unbind( ri->ri_ldp );
|
|
|
|
ri->ri_ldp = NULL;
|
|
|
|
return BIND_ERR_MANAGEDSAIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( BIND_OK );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For debugging. Print the contents of an ldmarr array.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dump_ldm_array(
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
LDAPMod **ldmarr
|
|
|
|
)
|
1998-08-09 08:43:13 +08:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
LDAPMod *ldm;
|
|
|
|
struct berval *b;
|
|
|
|
char *msgbuf;
|
|
|
|
|
|
|
|
for ( i = 0; ldmarr[ i ] != NULL; i++ ) {
|
|
|
|
ldm = ldmarr[ i ];
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, INFO, "dump_ldm_array: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Trace (%ld): *** ldmarr[ %d ] contents:\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
(long) getpid(), i, 0 );
|
|
|
|
LDAP_LOG ( OPERATION, INFO, "dump_ldm_array: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Trace (%ld): *** ldm->mod_op: %d\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
(long) getpid(), ldm->mod_op, 0 );
|
|
|
|
LDAP_LOG ( OPERATION, INFO, "dump_ldm_array: "
|
2002-04-16 02:59:20 +08:00
|
|
|
"Trace (%ld): *** ldm->mod_type: %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
(long) getpid(), ldm->mod_type, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
"Trace (%ld): *** ldmarr[ %d ] contents:\n",
|
|
|
|
(long) getpid(), i, 0 );
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
"Trace (%ld): *** ldm->mod_op: %d\n",
|
|
|
|
(long) getpid(), ldm->mod_op, 0 );
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
"Trace (%ld): *** ldm->mod_type: %s\n",
|
|
|
|
(long) getpid(), ldm->mod_type, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
if ( ldm->mod_bvalues != NULL ) {
|
|
|
|
for ( j = 0; ( b = ldm->mod_bvalues[ j ] ) != NULL; j++ ) {
|
|
|
|
msgbuf = ch_malloc( b->bv_len + 512 );
|
1998-11-05 15:31:40 +08:00
|
|
|
sprintf( msgbuf, "***** bv[ %d ] len = %ld, val = <%s>",
|
1998-08-09 08:43:13 +08:00
|
|
|
j, b->bv_len, b->bv_val );
|
2002-04-16 02:59:20 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, INFO, "dump_ldm_array: "
|
|
|
|
"Trace (%ld):%s\n", (long) getpid(), msgbuf, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
"Trace (%ld):%s\n", (long) getpid(), msgbuf, 0 );
|
2002-04-16 02:59:20 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
free( msgbuf );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|