--- /dev/null
+/* extended.c - bdb backend extended routines */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/string.h>
+
+#include "back-bdb.h"
+#include "external.h"
+
+static struct exop {
+ char *oid;
+ BI_op_extended *extended;
+} exop_table[] = {
+ { LDAP_EXOP_MODIFY_PASSWD, bdb_exop_passwd },
+ { NULL, NULL }
+};
+
+int
+bdb_extended(
+ Backend *be,
+ Connection *conn,
+ Operation *op,
+ const char *reqoid,
+ struct berval *reqdata,
+ char **rspoid,
+ struct berval **rspdata,
+ LDAPControl *** rspctrls,
+ const char** text,
+ BerVarray *refs
+)
+{
+ int i;
+
+ for( i=0; exop_table[i].oid != NULL; i++ ) {
+ if( strcmp( exop_table[i].oid, reqoid ) == 0 ) {
+ return (exop_table[i].extended)(
+ be, conn, op,
+ reqoid, reqdata,
+ rspoid, rspdata, rspctrls,
+ text, refs );
+ }
+ }
+
+ *text = "not supported within naming context";
+ return LDAP_UNWILLING_TO_PERFORM;
+}
+
0, 0, 0 );
#endif
- rc = LDAP_OPERATIONS_ERROR;
+ rc = LDAP_OTHER;
goto return_results;
}
"bdb_modrdn: can't figure out type(s)/values(s) "
"of newrdn\n", 0, 0, 0 );
#endif
- rc = LDAP_OPERATIONS_ERROR;
+ rc = LDAP_INVALID_DN_SYNTAX;
text = "unknown type(s) used in RDN";
goto return_results;
}
if( dn.bv_len == 0 ) {
*text = "No password is associated with the Root DSE";
- rc = LDAP_OPERATIONS_ERROR;
+ rc = LDAP_UNWILLING_TO_PERFORM;
goto done;
}
return( -1 );
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "Operations error", NULL, NULL );
return( -1 );
}
return( -1 );
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "Operations error", NULL, NULL );
return( -1 );
}
case REWRITE_REGEXEC_ERR:
send_ldap_result( conn, op,
- LDAP_OPERATIONS_ERROR,
+ LDAP_OTHER,
NULL, "Operations error",
NULL, NULL );
return( NULL );
/* Err could be -1 in case a duplicate ldapconn is inserted */
if ( err != 0 ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "internal server error", NULL, NULL );
/* better destroy the ldapconn struct? */
return( NULL );
case LDAP_SERVER_DOWN:
return LDAP_UNAVAILABLE;
case LDAP_LOCAL_ERROR:
- return LDAP_OPERATIONS_ERROR;
+ return LDAP_OTHER;
case LDAP_ENCODING_ERROR:
case LDAP_DECODING_ERROR:
return LDAP_PROTOCOL_ERROR;
case LDAP_AUTH_UNKNOWN:
return LDAP_AUTH_METHOD_NOT_SUPPORTED;
case LDAP_FILTER_ERROR:
- return LDAP_OPERATIONS_ERROR;
+ return LDAP_OTHER;
case LDAP_USER_CANCELLED:
- return LDAP_OPERATIONS_ERROR;
+ return LDAP_OTHER;
case LDAP_PARAM_ERROR:
return LDAP_PROTOCOL_ERROR;
case LDAP_NO_MEMORY:
- return LDAP_OPERATIONS_ERROR;
+ return LDAP_OTHER;
case LDAP_CONNECT_ERROR:
return LDAP_UNAVAILABLE;
case LDAP_NOT_SUPPORTED:
return( -1 );
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "Operations error", NULL, NULL );
return( -1 );
}
return( -1 );
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "Operations error", NULL, NULL );
return( -1 );
}
return( -1 );
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "Operations error", NULL, NULL );
return( -1 );
}
return( -1 );
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "Operations error",
NULL, NULL );
return( -1 );
return( -1 );
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "Operations error", NULL, NULL );
return( -1 );
}
goto finish;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "Operations error", NULL, NULL );
rc = -1;
goto finish;
/* if (rc) something bad happened to ldbm cache */
ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
send_ldap_result( conn, op,
- rc ? LDAP_OPERATIONS_ERROR : LDAP_ALREADY_EXISTS,
+ rc ? LDAP_OTHER : LDAP_ALREADY_EXISTS,
NULL, NULL, NULL, NULL );
return( -1 );
}
--- /dev/null
+/* extended.c - ldbm backend extended routines */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-ldbm.h"
+#include "proto-back-ldbm.h"
+
+struct exop {
+ char *oid;
+ BI_op_extended *extended;
+} exop_table[] = {
+ { LDAP_EXOP_MODIFY_PASSWD, ldbm_back_exop_passwd },
+ { NULL, NULL }
+};
+
+int
+ldbm_back_extended(
+ Backend *be,
+ Connection *conn,
+ Operation *op,
+ const char *reqoid,
+ struct berval *reqdata,
+ char **rspoid,
+ struct berval **rspdata,
+ LDAPControl *** rspctrls,
+ const char** text,
+ BerVarray *refs
+)
+{
+ int i;
+
+ for( i=0; exop_table[i].oid != NULL; i++ ) {
+ if( strcmp( exop_table[i].oid, reqoid ) == 0 ) {
+ return (exop_table[i].extended)(
+ be, conn, op,
+ reqoid, reqdata,
+ rspoid, rspdata, rspctrls,
+ text, refs );
+ }
+ }
+
+ *text = "not supported within naming context";
+ return LDAP_UNWILLING_TO_PERFORM;
+}
+
np->e_dn, 0, 0 );
#endif
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "newSuperior is a referral", NULL, NULL );
goto return_results;
if ( ( rc_id = dn2id ( be, &new_ndn, &id ) ) || id != NOID ) {
/* if (rc_id) something bad happened to ldbm cache */
send_ldap_result( conn, op,
- rc_id ? LDAP_OPERATIONS_ERROR : LDAP_ALREADY_EXISTS,
+ rc_id ? LDAP_OTHER : LDAP_ALREADY_EXISTS,
NULL, NULL, NULL, NULL );
goto return_results;
}
0, 0, 0 );
#endif
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_INVALID_DN_SYNTAX,
NULL, "unable to parse type(s)/value(s) used in RDN", NULL, NULL );
goto return_results;
}
if( dn.bv_len == 0 ) {
*text = "No password is associated with the Root DSE";
- rc = LDAP_OPERATIONS_ERROR;
+ rc = LDAP_UNWILLING_TO_PERFORM;
goto done;
}
goto done;
}
- rc = LDAP_OPERATIONS_ERROR;
+ rc = LDAP_OTHER;
if( is_entry_referral( e ) ) {
/* entry is an referral, don't allow operation */
lc = meta_back_getconn( li, conn, op, META_OP_REQUIRE_SINGLE,
&e->e_nname, &candidate );
if ( !lc || !meta_back_dobind( lc, op ) || !meta_back_is_valid( lc, candidate ) ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
return -1;
}
return -1;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
return -1;
}
"meta_back_bind: no target for dn %s.\n%s%s",
dn->bv_val, "", "");
#endif /* !NEW_LOGGING */
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
return -1;
}
return LDAP_UNWILLING_TO_PERFORM;
case REWRITE_REGEXEC_ERR:
- return LDAP_OPERATIONS_ERROR;
+ return LDAP_OTHER;
}
rc = ldap_bind_s( lc->conns[ candidate ]->ld, mdn.bv_val, cred->bv_val, method );
return -1;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
- NULL, "Operations error",
+ send_ldap_result( conn, op, LDAP_OTHER,
+ NULL, "Rewrite error",
NULL, NULL );
return -1;
}
continue;
} else if ( lrc == LDAP_RES_COMPARE ) {
if ( count > 0 ) {
- rres = LDAP_OPERATIONS_ERROR;
+ rres = LDAP_OTHER;
rc = -1;
goto finish;
}
goto cleanup;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
- NULL, "Operations error",
+ send_ldap_result( conn, op, LDAP_OTHER,
+ NULL, "Rewrite error",
NULL, NULL );
rc = -1;
goto cleanup;
case REWRITE_REGEXEC_ERR:
send_ldap_result( conn, op,
- LDAP_OPERATIONS_ERROR,
- NULL, "Operations error",
+ LDAP_OTHER,
+ NULL, "Rewrite error",
NULL, NULL );
- return LDAP_OPERATIONS_ERROR;
+ return LDAP_OTHER;
}
assert( lsc->bound_dn.bv_val );
* Err could be -1 in case a duplicate metaconn is inserted
*/
if ( err != 0 ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, "Internal server error", NULL, NULL );
metaconn_free( lc );
return NULL;
lc = meta_back_getconn( li, conn, op, META_OP_REQUIRE_SINGLE,
ndn, &candidate );
if ( !lc || !meta_back_dobind( lc, op ) || !meta_back_is_valid( lc, candidate ) ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
return -1;
}
return -1;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
return -1;
}
lc = meta_back_getconn( li, conn, op, META_OP_REQUIRE_SINGLE,
ndn, &candidate );
if ( !lc || !meta_back_dobind( lc, op ) || !meta_back_is_valid( lc, candidate ) ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
return -1;
}
return -1;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
return -1;
}
lc = meta_back_getconn( li, conn, op, META_OP_REQUIRE_SINGLE,
ndn, &candidate );
if ( !lc || !meta_back_dobind( lc, op ) || !meta_back_is_valid( lc, candidate ) ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
return -1;
}
return -1;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
return -1;
}
return -1;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
return -1;
}
*/
msgid = ch_calloc( sizeof( int ), li->ntargets );
if ( msgid == NULL ) {
- send_search_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_search_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL, 0 );
return -1;
}
goto finish;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
- NULL, "Operations error",
+ send_ldap_result( conn, op, LDAP_OTHER,
+ NULL, "Rewrite error",
NULL, NULL );
rc = -1;
goto finish;
goto finish;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
rc = -1;
goto finish;
( void )meta_clear_unused_candidates( li,
lc, -1, 0 );
send_search_result( conn, op,
- LDAP_OPERATIONS_ERROR,
+ LDAP_OTHER,
"", "", NULL, NULL, count );
/* anything else needs be done? */
goto finish;
case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
rc = -1;
goto finish;
break;
default:
- rc = LDAP_OPERATIONS_ERROR;
+ rc = LDAP_OTHER;
break;
}
}
if ( !(e = pw2entry( be, pw, &text )) ) {
- err = LDAP_OPERATIONS_ERROR;
+ err = LDAP_OTHER;
endpwent();
ldap_pvt_thread_mutex_unlock( &passwd_mutex );
goto done;
if ( ldap_bv2rdn( base, &rdn, (char **)&text,
LDAP_DN_FORMAT_LDAP ))
{
- err = LDAP_OPERATIONS_ERROR;
+ err = LDAP_OTHER;
goto done;
}
e = pw2entry( be, pw, &text );
ldap_pvt_thread_mutex_unlock( &passwd_mutex );
if ( !e ) {
- err = LDAP_OPERATIONS_ERROR;
+ err = LDAP_OTHER;
goto done;
}
}
if ( (op->o_private = (void *) forkandexec( si->si_add, &rfp, &wfp )) == (void *) -1 ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
+ send_ldap_result( conn, op, LDAP_OTHER, NULL,
"could not fork/exec", NULL, NULL );
return( -1 );
}
if ( (op->o_private = (void *) forkandexec( si->si_bind, &rfp, &wfp ))
== (void *) -1 ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
+ send_ldap_result( conn, op, LDAP_OTHER, NULL,
"could not fork/exec", NULL, NULL );
return( -1 );
}
if ( (op->o_private = (void *) forkandexec( si->si_compare, &rfp, &wfp ))
== (void *) -1 ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
+ send_ldap_result( conn, op, LDAP_OTHER, NULL,
"could not fork/exec", NULL, NULL );
return( -1 );
}
if ( (op->o_private = (void *) forkandexec( si->si_delete, &rfp, &wfp ))
== (void *) -1 ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
+ send_ldap_result( conn, op, LDAP_OTHER, NULL,
"could not fork/exec", NULL, NULL );
return( -1 );
}
if ( (op->o_private = (void *) forkandexec( si->si_modify, &rfp, &wfp ))
== (void *) -1 ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
+ send_ldap_result( conn, op, LDAP_OTHER, NULL,
"could not fork/exec", NULL, NULL );
return( -1 );
}
if ( (op->o_private = (void *) forkandexec( si->si_modrdn, &rfp, &wfp ))
== (void *) -1 ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
+ send_ldap_result( conn, op, LDAP_OTHER, NULL,
"could not fork/exec", NULL, NULL );
return( -1 );
}
if ( (op->o_private = (void *) forkandexec( si->si_search, &rfp, &wfp ))
== (void *) -1 ) {
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
+ send_ldap_result( conn, op, LDAP_OTHER, NULL,
"could not fork/exec", NULL, NULL );
return( -1 );
}
+/* $OpenLDAP$ */
/*
shellutil.c - common routines useful when building shell-based backends
for the standalone ldap server
*/
-#include <sys/types.h>
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
+
+#include <ac/stdlib.h>
+#include <ac/stdarg.h>
+
#include <pwd.h>
-#include <varargs.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+
#include <lber.h>
#include <ldap.h>
#include "shellutil.h"
int
test_filter( struct ldop *op, struct ldentry *entry )
{
- return (( random() & 0x07 ) == 0x07 ); /* XXX random for now */
+ return ((random() & 0x07 ) == 0x07) /* XXX random for now */
+ ? LDAP_COMPARE_TRUE : LDAP_COMPARE_FALSE;
}
struct inputparams *ip;
if ( fgets( line, MAXLINELEN, ifp ) == NULL ) {
- write_result( ofp, LDAP_OPERATIONS_ERROR, NULL, "Empty Input" );
+ write_result( ofp, LDAP_OTHER, NULL, "Empty Input" );
}
line[ strlen( line ) - 1 ] = '\0';
if ( strncasecmp( line, STR_OP_SEARCH, sizeof( STR_OP_SEARCH ) - 1 )
if (( op->ldop_srch.ldsp_scope = atoi( args )) != LDAP_SCOPE_BASE &&
op->ldop_srch.ldsp_scope != LDAP_SCOPE_ONELEVEL &&
op->ldop_srch.ldsp_scope != LDAP_SCOPE_SUBTREE ) {
- write_result( ofp, LDAP_OPERATIONS_ERROR, NULL, "Bad scope" );
+ write_result( ofp, LDAP_OTHER, NULL, "Bad scope" );
return( -1 );
}
break;
while ( args != NULL ) {
if (( p = strchr( args, ' ' )) != NULL ) {
*p++ = '\0';
- while ( isspace( *p )) {
+ while ( isspace( (unsigned char) *p )) {
++p;
}
}
if ( op->ldop_suffixes == NULL || op->ldop_dn == NULL ||
op->ldop_srch.ldsp_filter == NULL ) {
- write_result( ofp, LDAP_OPERATIONS_ERROR, NULL,
+ write_result( ofp, LDAP_OTHER, NULL,
"Required suffix:, base:, or filter: missing" );
return( -1 );
}
for ( i = 0; ips[ i ].ip_type != 0; ++i ) {
if ( strncasecmp( *linep, ips[ i ].ip_tag, p - *linep ) == 0 ) {
- while ( isspace( *(++p) )) {
+ while ( isspace( (unsigned char) *(++p) )) {
;
}
*linep = p;
if (( p = strdup( s )) == NULL ) {
debug_printf( "strdup failed\n" );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
return( p );
if ( p == NULL ) {
debug_printf( "realloc( p, %d ) failed\n", size );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
return( p );
if (( p = calloc( nelem, elsize )) == NULL ) {
debug_printf( "calloc( %d, %d ) failed\n", nelem, elsize );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
return( p );
/* VARARGS */
void
-debug_printf( va_alist /* char *fmt, args... */ )
- va_dcl
+debug_printf( const char *fmt, ... )
{
- char *fmt;
va_list ap;
- if ( debugflg ) {
- va_start( ap );
- fmt = va_arg( ap, char * );
- fprintf( stderr, "%s: ", progname );
- vfprintf( stderr, fmt, ap );
- va_end( ap );
- }
+ if ( debugflg ) {
+ va_start( ap, fmt );
+ fprintf( stderr, "%s: ", progname );
+ vfprintf( stderr, fmt, ap );
+ va_end( ap );
+ }
}