## top-level directory of the distribution or, alternatively, at
## <http://www.OpenLDAP.org/license.html>.
-SLAPTOOLS=slapadd slapcat slapdn slapindex slappasswd slaptest slapsaslauth
+SLAPTOOLS=slapadd slapcat slapdn slapindex slappasswd slaptest slapauth
PROGRAMS=slapd $(SLAPTOOLS)
XPROGRAMS=sslapd libbackends.a .backend liboverlays.a
XSRCS=version.c
backglue.c operational.c matchedValues.c cancel.c syncrepl.c \
backover.c ctxcsn.c ldapsync.c sessionlog.c \
slapadd.c slapcat.c slapcommon.c slapdn.c slapindex.c \
- slappasswd.c slaptest.c slapsaslauth.c \
+ slappasswd.c slaptest.c slapauth.c \
$(@PLAT@_SRCS)
OBJS = main.o globals.o config.o daemon.o \
backglue.o operational.o matchedValues.o cancel.o syncrepl.o \
backover.o ctxcsn.o ldapsync.o sessionlog.o \
slapadd.o slapcat.o slapcommon.o slapdn.o slapindex.o \
- slappasswd.o slaptest.o slapsaslauth.o \
+ slappasswd.o slaptest.o slapauth.o \
$(@PLAT@_OBJS)
LDAP_INCDIR= ../../include -I$(srcdir)/slapi
lutil_salt_format( cargv[1] );
- /* SASL config options */
- } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
- if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
- return 1;
#ifdef SLAP_SASL_REWRITE
/* use authid rewrite instead of sasl regexp */
- } else if ( strncasecmp( cargv[0], "authid-rewrite", sizeof("authid-rewrite") - 1 ) == 0 ) {
+ } else if ( strncasecmp( cargv[0], "auth-rewrite",
+ sizeof("auth-rewrite") - 1 ) == 0 )
+ {
int rc = slap_sasl_rewrite_config( fname, lineno,
cargc, cargv );
if ( rc ) {
}
#endif /* SLAP_SASL_REWRITE */
+ /* Auth + SASL config options */
+ } else if ( !strncasecmp( cargv[0], "auth", sizeof("auth")-1 ) ||
+ !strncasecmp( cargv[0], "sasl", sizeof("sasl")-1 ))
+ {
+ if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
+ return 1;
+
+
} else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
struct berval dn;
if ( cargc < 2 ) {
#endif
typedef int (MainFunc) LDAP_P(( int argc, char *argv[] ));
-extern MainFunc slapadd, slapcat, slapdn, slapindex, slappasswd, slaptest, slapsaslauth;
+extern MainFunc slapadd, slapcat, slapdn, slapindex, slappasswd,
+ slaptest, slapauth;
static struct {
char *name;
{"slapindex", slapindex},
{"slappasswd", slappasswd},
{"slaptest", slaptest},
- {"slapsaslauth", slapsaslauth},
+ {"slapauth", slapauth},
{NULL, NULL}
};
const char *fname, int lineno )
{
/* set SASL proxy authorization policy */
- if ( strcasecmp( cargv[0], "sasl-authz-policy" ) == 0 ) {
+ if ( !strcasecmp( cargv[0], "authz-policy" ) ||
+ !strcasecmp( cargv[0], "sasl-authz-policy" ))
+ {
if ( cargc != 2 ) {
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, CRIT,
"%s: line %d: missing policy in"
- " \"sasl-authz-policy <policy>\" line\n",
- fname, lineno, 0 );
+ " \"%s <policy>\" line\n",
+ cargv[0], fname, lineno );
#else
Debug( LDAP_DEBUG_ANY,
"%s: line %d: missing policy in"
- " \"sasl-authz-policy <policy>\" line\n",
- fname, lineno, 0 );
+ " \"%s <policy>\" line\n",
+ cargv[0], fname, lineno );
#endif
return( 1 );
}
if ( slap_sasl_setpolicy( cargv[1] ) ) {
#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: unable "
- "to parse value \"%s\" "
- "in \"sasl-authz-policy "
- "<policy>\" line.\n",
- fname, lineno, cargv[1] );
+ LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
+ "unable to parse value \"%s\" in \"authz-policy "
+ "<policy>\" line.\n",
+ fname, lineno, cargv[1] );
#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: unable "
- "to parse value \"%s\" "
- "in \"sasl-authz-policy "
- "<policy>\" line\n",
- fname, lineno, cargv[1] );
+ Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+ "unable to parse value \"%s\" in \"authz-policy "
+ "<policy>\" line.\n",
+ fname, lineno, cargv[1] );
#endif
return( 1 );
}
- } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
- || !strcasecmp( cargv[0], "saslregexp" ) )
+ } else if ( !strcasecmp( cargv[0], "authz-regexp" ) ||
+ !strcasecmp( cargv[0], "sasl-regexp" ) ||
+ !strcasecmp( cargv[0], "saslregexp" ) )
{
int rc;
if ( cargc != 3 ) {
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, CRIT,
"%s: line %d: need 2 args in "
- "\"saslregexp <match> <replace>\"\n",
+ "\"authz-regexp <match> <replace>\"\n",
fname, lineno, 0 );
#else
Debug( LDAP_DEBUG_ANY,
"%s: line %d: need 2 args in "
- "\"saslregexp <match> <replace>\"\n",
+ "\"authz-regexp <match> <replace>\"\n",
fname, lineno, 0 );
#endif
* dn.exact: the value must pass normalization and is used
* in exact DN match.
* dn.regex: the value is treated as a regular expression
- * in matching DN values in saslAuthz{To|From}
+ * in matching DN values in authz{To|From}
* attributes.
* dn: for backwards compatibility reasons, the value
* is treated as a regular expression, and thus
NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_children) },
- { "saslAuthzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
- "NAME 'saslAuthzTo' "
- "DESC 'SASL proxy authorization targets' "
+ { "authzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
+ "NAME ( 'authzTo' 'saslAuthzTo' ) "
+ "DESC 'proxy authorization targets' "
"EQUALITY caseExactMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
"USAGE distributedOperation )",
NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_saslAuthzTo) },
- { "saslAuthzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
- "NAME 'saslAuthzFrom' "
- "DESC 'SASL proxy authorization sources' "
+ { "authzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
+ "NAME ( 'authzFrom' 'saslAuthzFrom' ) "
+ "DESC 'proxy authorization sources' "
"EQUALITY caseExactMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
"USAGE distributedOperation )",
--- /dev/null
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2004 The OpenLDAP Foundation.
+ * Portions Copyright 2004 Pierangelo Masarati.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by Pierangelo Masarati for inclusion
+ * in OpenLDAP Software.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
+#include <lber.h>
+#include <ldif.h>
+#include <lutil.h>
+
+#include "slapcommon.h"
+
+static int
+do_check( Connection *c, Operation *op, struct berval *id )
+{
+ struct berval authcDN;
+ int rc;
+
+ rc = slap_sasl_getdn( c, op, id, NULL, &authcDN, SLAP_GETDN_AUTHCID );
+ if ( rc != LDAP_SUCCESS ) {
+ fprintf( stderr, "ID: <%s> check failed %d (%s)\n",
+ id->bv_val, rc,
+ ldap_err2string( rc ) );
+ rc = 1;
+
+ } else {
+ if ( !BER_BVISNULL( &authzID ) ) {
+ rc = slap_sasl_authorized( op, &authcDN, &authzID );
+
+ fprintf( stderr,
+ "ID: <%s>\n"
+ "authcDN: <%s>\n"
+ "authzDN: <%s>\n"
+ "authorization %s\n",
+ id->bv_val,
+ authcDN.bv_val,
+ authzID.bv_val,
+ rc == LDAP_SUCCESS ? "OK" : "failed" );
+
+ } else {
+ fprintf( stderr, "ID: <%s> check succeeded\n"
+ "authcID: <%s>\n",
+ id->bv_val,
+ authcDN.bv_val );
+ op->o_tmpfree( authcDN.bv_val, op->o_tmpmemctx );
+ }
+ rc = 0;
+ }
+
+ return rc;
+}
+
+int
+slapauth( int argc, char **argv )
+{
+ int rc = EXIT_SUCCESS;
+ const char *progname = "slapauth";
+ Connection conn;
+ Operation op;
+
+#ifdef NEW_LOGGING
+ lutil_log_initialize( argc, argv );
+#endif
+ slap_tool_init( progname, SLAPAUTH, argc, argv );
+
+ argv = &argv[ optind ];
+ argc -= optind;
+
+ memset( &conn, 0, sizeof( Connection ) );
+ memset( &op, 0, sizeof( Operation ) );
+
+ connection_fake_init( &conn, &op, &conn );
+
+ if ( !BER_BVISNULL( &authzID ) ) {
+ struct berval authzDN;
+
+ rc = slap_sasl_getdn( &conn, &op, &authzID, NULL, &authzDN,
+ SLAP_GETDN_AUTHZID );
+ if ( rc != LDAP_SUCCESS ) {
+ fprintf( stderr, "authzID: <%s> check failed %d (%s)\n",
+ authzID.bv_val, rc,
+ ldap_err2string( rc ) );
+ rc = 1;
+ BER_BVZERO( &authzID );
+ goto destroy;
+ }
+
+ authzID = authzDN;
+ }
+
+
+ if ( !BER_BVISNULL( &authcID ) ) {
+ if ( !BER_BVISNULL( &authzID ) || argc == 0 ) {
+ rc = do_check( &conn, &op, &authcID );
+ goto destroy;
+ }
+
+ for ( ; argc--; argv++ ) {
+ struct berval authzDN;
+
+ ber_str2bv( argv[ 0 ], 0, 0, &authzID );
+
+ rc = slap_sasl_getdn( &conn, &op, &authzID, NULL, &authzDN,
+ SLAP_GETDN_AUTHZID );
+ if ( rc != LDAP_SUCCESS ) {
+ fprintf( stderr, "authzID: <%s> check failed %d (%s)\n",
+ authzID.bv_val, rc,
+ ldap_err2string( rc ) );
+ rc = 1;
+ BER_BVZERO( &authzID );
+ goto destroy;
+ }
+
+ authzID = authzDN;
+
+ rc = do_check( &conn, &op, &authcID );
+
+ op.o_tmpfree( authzID.bv_val, op.o_tmpmemctx );
+ BER_BVZERO( &authzID );
+
+ if ( rc ) {
+ goto destroy;
+ }
+ }
+
+ goto destroy;
+ }
+
+ for ( ; argc--; argv++ ) {
+ struct berval id;
+
+ ber_str2bv( argv[ 0 ], 0, 0, &id );
+
+ rc = do_check( &conn, &op, &id );
+
+ if ( rc ) {
+ goto destroy;
+ }
+ }
+
+destroy:;
+ if ( !BER_BVISNULL( &authzID ) ) {
+ op.o_tmpfree( authzID.bv_val, op.o_tmpmemctx );
+ }
+ slap_tool_destroy();
+
+ return rc;
+}
+
options = "\t[-n databasenumber | -b suffix]\n";
break;
- case SLAPSASLAUTH:
+ case SLAPAUTH:
options = "\t[-U authcID] [-X authzID] ID [...]\n";
break;
}
options = "d:f:v";
break;
- case SLAPSASLAUTH:
+ case SLAPAUTH:
options = "d:f:U:vX:";
break;
}
break;
- case SLAPSASLAUTH:
+ case SLAPAUTH:
if ( argc == optind && BER_BVISNULL( &authcID ) ) {
usage( tool, progname );
}
case SLAPTEST:
return;
- case SLAPSASLAUTH:
+ case SLAPAUTH:
be = NULL;
goto startup;
SLAPINDEX, /* database index tool */
SLAPPASSWD, /* password generation tool */
SLAPTEST, /* slapd.conf test tool */
- SLAPSASLAUTH, /* test sasl-regexp and authc/authz stuff */
+ SLAPAUTH, /* test authz-regexp and authc/authz stuff */
SLAPLAST
};
+++ /dev/null
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 2004 The OpenLDAP Foundation.
- * Portions Copyright 2004 Pierangelo Masarati.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by Pierangelo Masarati for inclusion
- * in OpenLDAP Software.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-
-#include <ac/ctype.h>
-#include <ac/string.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-
-#include <lber.h>
-#include <ldif.h>
-#include <lutil.h>
-
-#include "slapcommon.h"
-
-static int
-do_check( Connection *c, Operation *op, struct berval *id )
-{
- struct berval authcDN;
- int rc;
-
- rc = slap_sasl_getdn( c, op, id, NULL, &authcDN, SLAP_GETDN_AUTHCID );
- if ( rc != LDAP_SUCCESS ) {
- fprintf( stderr, "ID: <%s> check failed %d (%s)\n",
- id->bv_val, rc,
- ldap_err2string( rc ) );
- rc = 1;
-
- } else {
- if ( !BER_BVISNULL( &authzID ) ) {
- rc = slap_sasl_authorized( op, &authcDN, &authzID );
-
- fprintf( stderr,
- "ID: <%s>\n"
- "authcDN: <%s>\n"
- "authzDN: <%s>\n"
- "authorization %s\n",
- id->bv_val,
- authcDN.bv_val,
- authzID.bv_val,
- rc == LDAP_SUCCESS ? "OK" : "failed" );
-
- } else {
- fprintf( stderr, "ID: <%s> check succeeded\n"
- "authcID: <%s>\n",
- id->bv_val,
- authcDN.bv_val );
- op->o_tmpfree( authcDN.bv_val, op->o_tmpmemctx );
- }
- rc = 0;
- }
-
- return rc;
-}
-
-int
-slapsaslauth( int argc, char **argv )
-{
- int rc = EXIT_SUCCESS;
- const char *progname = "slapsaslauth";
- Connection conn;
- Operation op;
-
-#ifdef NEW_LOGGING
- lutil_log_initialize( argc, argv );
-#endif
- slap_tool_init( progname, SLAPSASLAUTH, argc, argv );
-
- argv = &argv[ optind ];
- argc -= optind;
-
- memset( &conn, 0, sizeof( Connection ) );
- memset( &op, 0, sizeof( Operation ) );
-
- connection_fake_init( &conn, &op, &conn );
-
- if ( !BER_BVISNULL( &authzID ) ) {
- struct berval authzDN;
-
- rc = slap_sasl_getdn( &conn, &op, &authzID, NULL, &authzDN,
- SLAP_GETDN_AUTHZID );
- if ( rc != LDAP_SUCCESS ) {
- fprintf( stderr, "authzID: <%s> check failed %d (%s)\n",
- authzID.bv_val, rc,
- ldap_err2string( rc ) );
- rc = 1;
- BER_BVZERO( &authzID );
- goto destroy;
- }
-
- authzID = authzDN;
- }
-
-
- if ( !BER_BVISNULL( &authcID ) ) {
- if ( !BER_BVISNULL( &authzID ) || argc == 0 ) {
- rc = do_check( &conn, &op, &authcID );
- goto destroy;
- }
-
- for ( ; argc--; argv++ ) {
- struct berval authzDN;
-
- ber_str2bv( argv[ 0 ], 0, 0, &authzID );
-
- rc = slap_sasl_getdn( &conn, &op, &authzID, NULL, &authzDN,
- SLAP_GETDN_AUTHZID );
- if ( rc != LDAP_SUCCESS ) {
- fprintf( stderr, "authzID: <%s> check failed %d (%s)\n",
- authzID.bv_val, rc,
- ldap_err2string( rc ) );
- rc = 1;
- BER_BVZERO( &authzID );
- goto destroy;
- }
-
- authzID = authzDN;
-
- rc = do_check( &conn, &op, &authcID );
-
- op.o_tmpfree( authzID.bv_val, op.o_tmpmemctx );
- BER_BVZERO( &authzID );
-
- if ( rc ) {
- goto destroy;
- }
- }
-
- goto destroy;
- }
-
- for ( ; argc--; argv++ ) {
- struct berval id;
-
- ber_str2bv( argv[ 0 ], 0, 0, &id );
-
- rc = do_check( &conn, &op, &id );
-
- if ( rc ) {
- goto destroy;
- }
- }
-
-destroy:;
- if ( !BER_BVISNULL( &authzID ) ) {
- op.o_tmpfree( authzID.bv_val, op.o_tmpmemctx );
- }
- slap_tool_destroy();
-
- return rc;
-}
-
Debug( LDAP_DEBUG_ANY, "out of memory\n", 0,0,0 );
#endif
}
+
} else {
tmp = ( char ** ) ch_realloc( si->si_attrs, 5 * sizeof( char * ));
if ( tmp == NULL ) {
si->si_attrs = tmp;
/* Add Attributes */
-
for ( i = 0; sync_descs[ i ] != NULL; i++ ) {
si->si_attrs[ n++ ] = ch_strdup ( sync_descs[i]->ad_cname.bv_val );
si->si_attrs[ n ] = NULL;
static int
ldap_sync_search(
syncinfo_t *si,
- void *ctx
-)
+ void *ctx )
{
BerElementBuffer berbuf;
BerElement *ber = (BerElement *)&berbuf;
ber_set_option( ber, LBER_OPT_BER_MEMCTX, &ctx );
if ( si->si_syncCookie.octet_str &&
- si->si_syncCookie.octet_str[0].bv_val ) {
- ber_printf( ber, "{eO}", abs(si->si_type),
- &si->si_syncCookie.octet_str[0] );
+ si->si_syncCookie.octet_str[0].bv_val )
+ {
+ ber_printf( ber, "{eO}",
+ abs(si->si_type),
+ &si->si_syncCookie.octet_str[0] );
} else {
- ber_printf( ber, "{e}", abs(si->si_type) );
+ ber_printf( ber, "{e}",
+ abs(si->si_type) );
}
if ( (rc = ber_flatten2( ber, &c[0].ldctl_value, 0 )) == LBER_ERROR ) {
ctrls, NULL, si->si_tlimit < 0 ? NULL : &timeout,
si->si_slimit, &msgid );
ber_free_buf( ber );
-
return rc;
}
psub = &si->si_be->be_nsuffix[0];
/* Init connection to master */
-
rc = ldap_initialize( &si->si_ld, si->si_provideruri );
if ( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
}
}
- defaults = lutil_sasl_defaults( si->si_ld,
- si->si_saslmech, si->si_realm,
- si->si_authcId, si->si_passwd, si->si_authzId );
+ defaults = lutil_sasl_defaults( si->si_ld, si->si_saslmech,
+ si->si_realm, si->si_authcId, si->si_passwd, si->si_authzId );
rc = ldap_sasl_interactive_bind_s( si->si_ld,
si->si_binddn,
}
#else /* HAVE_CYRUS_SASL */
/* Should never get here, we trapped this at config time */
+ assert(0);
fprintf( stderr, "not compiled with SASL support\n" );
rc = LDAP_OTHER;
goto done;
#endif
+
} else {
rc = ldap_bind_s( si->si_ld,
si->si_binddn, si->si_passwd, si->si_bindmethod );
}
/* get syncrepl cookie of shadow replica from subentry */
-
assert( si->si_rid < 1000 );
syncrepl_cn_bv.bv_val = syncrepl_cbuf;
syncrepl_cn_bv.bv_len = snprintf(syncrepl_cbuf, sizeof(syncrepl_cbuf),
slap_dup_sync_cookie( &si->si_syncCookie, sc );
slap_sync_cookie_free( sc, 1 );
sc = NULL;
+
} else {
/* stored cookie */
struct berval newcookie = BER_BVNULL;
si->si_syncCookie.sid, si->si_syncCookie.rid );
ber_bvarray_add( &si->si_syncCookie.octet_str, &newcookie );
}
+
} else {
/* no command line cookie is specified */
if ( si->si_syncCookie.octet_str == NULL ) {
slap_dup_sync_cookie( &syncCookie_req, &si->si_syncCookie );
- if ( abs(si->si_type) == LDAP_SYNC_REFRESH_AND_PERSIST ){
+ if ( abs(si->si_type) == LDAP_SYNC_REFRESH_AND_PERSIST ) {
tout_p = &tout;
} else {
tout_p = NULL;
}
- while (( rc = ldap_result( si->si_ld, LDAP_RES_ANY, LDAP_MSG_ONE, tout_p, &res ))
- > 0 )
+ while (( rc = ldap_result( si->si_ld, LDAP_RES_ANY, LDAP_MSG_ONE,
+ tout_p, &res )) > 0 )
{
if ( slapd_shutdown ) {
rc = -2;
goto done;
}
for( msg = ldap_first_message( si->si_ld, res );
- msg != NULL;
- msg = ldap_next_message( si->si_ld, msg ) )
+ msg != NULL;
+ msg = ldap_next_message( si->si_ld, msg ) )
{
switch( ldap_msgtype( msg ) ) {
case LDAP_RES_SEARCH_ENTRY:
}
rctrlp = *rctrls;
ber_init2( ber, &rctrlp->ldctl_value, LBER_USE_DER );
- ber_scanf( ber, "{em", &syncstate, &syncUUID );
+ ber_scanf( ber, "{em" /*"}"*/, &syncstate, &syncUUID );
if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SYNC_COOKIE ) {
- ber_scanf( ber, "m}", &cookie );
+ ber_scanf( ber, /*"{"*/ "m}", &cookie );
if ( cookie.bv_val ) {
struct berval tmp_bv;
ber_dupbv( &tmp_bv, &cookie );
if ( syncrepl_message_to_entry( si, op, msg,
&modlist, &entry, syncstate ) == LDAP_SUCCESS ) {
rc_efree = syncrepl_entry( si, op, entry, modlist,
- syncstate, &syncUUID, &syncCookie_req );
+ syncstate, &syncUUID, &syncCookie_req );
if ( syncCookie.octet_str &&
- syncCookie.octet_str[0].bv_val ) {
+ syncCookie.octet_str[0].bv_val )
+ {
syncrepl_updateCookie( si, op, psub, &syncCookie );
}
}
ber_init2( ber, &rctrlp->ldctl_value, LBER_USE_DER );
ber_scanf( ber, "{" /*"}"*/);
- if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SYNC_COOKIE )
- {
+ if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SYNC_COOKIE ) {
ber_scanf( ber, "m", &cookie );
if ( cookie.bv_val ) {
struct berval tmp_bv;
ber_bvarray_add( &syncCookie.octet_str, &tmp_bv);
}
if ( syncCookie.octet_str &&
- syncCookie.octet_str[0].bv_val )
+ syncCookie.octet_str[0].bv_val )
+ {
slap_parse_sync_cookie( &syncCookie );
+ }
}
if ( ber_peek_tag( ber, &len ) == LDAP_TAG_REFRESHDELETES )
{
ber_scanf( ber, "b", &refreshDeletes );
}
- ber_scanf( ber, "}" );
+ ber_scanf( ber, /*"{"*/ "}" );
}
if ( syncCookie_req.ctxcsn == NULL ) {
match = -1;
value_match( &match, slap_schema.si_ad_entryCSN,
slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
- &syncCookie_req.ctxcsn[0], &syncCookie.ctxcsn[0], &text );
+ &syncCookie_req.ctxcsn[0], &syncCookie.ctxcsn[0],
+ &text );
}
- if ( syncCookie.octet_str && syncCookie.octet_str->bv_val
- && match < 0 && err == LDAP_SUCCESS ) {
+ if ( syncCookie.octet_str && syncCookie.octet_str->bv_val &&
+ match < 0 && err == LDAP_SUCCESS )
+ {
syncrepl_updateCookie( si, op, psub, &syncCookie );
}
if ( rctrls ) {
* 2) on err policy : stop service, stop sync, retry
*/
if ( refreshDeletes == 0 && match < 0 &&
- err == LDAP_SUCCESS ) {
+ err == LDAP_SUCCESS )
+ {
syncrepl_del_nonpresent( op, si );
} else {
avl_free( si->si_presentlist, avl_ber_bvfree );
si_refreshDelete = 1;
case LDAP_TAG_SYNC_REFRESH_PRESENT:
si_refreshPresent = 1;
- ber_scanf( ber, "t{", &tag );
+ ber_scanf( ber, "t{" /*"}"*/, &tag );
if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SYNC_COOKIE )
{
ber_scanf( ber, "m", &cookie );
if ( cookie.bv_val ) {
struct berval tmp_bv;
ber_dupbv( &tmp_bv, &cookie );
- ber_bvarray_add( &syncCookie.octet_str, &tmp_bv);
+ ber_bvarray_add( &syncCookie.octet_str,
+ &tmp_bv);
}
if ( syncCookie.octet_str &&
- syncCookie.octet_str[0].bv_val )
+ syncCookie.octet_str[0].bv_val )
+ {
slap_parse_sync_cookie( &syncCookie );
+ }
}
if ( ber_peek_tag( ber, &len ) ==
- LDAP_TAG_REFRESHDONE )
+ LDAP_TAG_REFRESHDONE )
{
ber_scanf( ber, "b", &refreshDone );
}
- ber_scanf( ber, "}" );
+ ber_scanf( ber, /*"{"*/ "}" );
break;
case LDAP_TAG_SYNC_ID_SET:
- ber_scanf( ber, "t{", &tag );
+ ber_scanf( ber, "t{" /*"}"*/, &tag );
if ( ber_peek_tag( ber, &len ) ==
- LDAP_TAG_SYNC_COOKIE ) {
+ LDAP_TAG_SYNC_COOKIE )
+ {
ber_scanf( ber, "m", &cookie );
if ( cookie.bv_val ) {
struct berval tmp_bv;
ber_dupbv( &tmp_bv, &cookie );
ber_bvarray_add( &syncCookie.octet_str,
- &tmp_bv );
+ &tmp_bv );
}
if ( syncCookie.octet_str &&
- syncCookie.octet_str[0].bv_val )
+ syncCookie.octet_str[0].bv_val )
+ {
slap_parse_sync_cookie( &syncCookie );
+ }
}
if ( ber_peek_tag( ber, &len ) ==
- LDAP_TAG_REFRESHDELETES )
+ LDAP_TAG_REFRESHDELETES )
{
ber_scanf( ber, "b", &refreshDeletes );
}
ber_scanf( ber, "[W]", &syncUUIDs );
- ber_scanf( ber, "}" );
+ ber_scanf( ber, /*"{"*/ "}" );
for ( i = 0; syncUUIDs[i].bv_val; i++ ) {
struct berval *syncuuid_bv;
syncuuid_bv = ber_dupbv( NULL, &syncUUIDs[i] );
avl_insert( &si->si_presentlist,
- (caddr_t) syncuuid_bv,
- syncuuid_cmp, avl_dup_error );
+ (caddr_t) syncuuid_bv,
+ syncuuid_cmp, avl_dup_error );
}
ber_memfree_x( syncUUIDs, op->o_tmpmemctx );
break;
&syncCookie.ctxcsn[0], &text );
}
- if ( syncCookie.ctxcsn && syncCookie.ctxcsn[0].bv_val
- && match < 0 ) {
+ if ( syncCookie.ctxcsn && syncCookie.ctxcsn[0].bv_val &&
+ match < 0 )
+ {
syncrepl_updateCookie( si, op, psub, &syncCookie);
}
ldap_memfree( retoid );
ber_bvfree( retdata );
break;
+
} else {
#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ERR,"do_syncrep2 :"
+ LDAP_LOG( OPERATION, ERR, "do_syncrep2 :"
" unknown intermediate "
"response\n", 0, 0, 0 );
#else
break;
}
break;
+
default:
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR, "do_syncrep2 : "
sl_free( ndn.bv_val, op->o_tmpmemctx );
sl_free( dn.bv_val, op->o_tmpmemctx );
- if ( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_DELETE )
- {
+ if ( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_DELETE ) {
return LDAP_SUCCESS;
}
if ( *modlist == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
- "syncrepl_message_to_entry: no attributes\n", 0, 0, 0 );
+ "syncrepl_message_to_entry: no attributes\n", 0, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: no attributes\n",
- 0, 0, 0 );
+ 0, 0, 0 );
#endif
}
if ( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
- "syncrepl_message_to_entry: mods check (%s)\n", text, 0, 0 );
+ "syncrepl_message_to_entry: mods check (%s)\n", text, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: mods check (%s)\n",
- text, 0, 0 );
+ text, 0, 0 );
#endif
goto done;
}
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
- "syncrepl_message_to_entry: mods2entry (%s)\n", text, 0, 0 );
+ "syncrepl_message_to_entry: mods2entry (%s)\n", text, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: mods2entry (%s)\n",
- text, 0, 0 );
+ text, 0, 0 );
#endif
}
Modifications* modlist,
int syncstate,
struct berval* syncUUID,
- struct sync_cookie* syncCookie_req
-)
+ struct sync_cookie* syncCookie_req )
{
Backend *be = op->o_bd;
slap_callback cb = { NULL };
struct berval org_ndn = BER_BVNULL;
int org_managedsait;
- if (( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_ADD ))
- {
+ if (( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_ADD )) {
syncuuid_bv = ber_dupbv( NULL, syncUUID );
avl_insert( &si->si_presentlist, (caddr_t) syncuuid_bv,
syncuuid_cmp, avl_dup_error );
cb.sc_response = null_callback;
cb.sc_private = si;
- if ( rc == LDAP_SUCCESS && si->si_syncUUID_ndn.bv_val )
- {
+ if ( rc == LDAP_SUCCESS && si->si_syncUUID_ndn.bv_val ) {
char *subseq_ptr;
if ( syncstate != LDAP_SYNC_DELETE ) {
op->o_ndn = op->o_bd->be_rootndn;
op->o_managedsait = 1;
- while ( rs.sr_err == LDAP_SUCCESS &&
- op->o_delete_glue_parent ) {
+ while ( rs.sr_err == LDAP_SUCCESS && op->o_delete_glue_parent ) {
op->o_delete_glue_parent = 0;
if ( !be_issuffix( op->o_bd, &op->o_req_ndn )) {
slap_callback cb = { NULL };
static void
syncrepl_del_nonpresent(
Operation *op,
- syncinfo_t *si
-)
+ syncinfo_t *si )
{
Backend* be = op->o_bd;
slap_callback cb = { NULL };
return;
}
-
void
syncrepl_add_glue(
Operation* op,
- Entry *e
-)
+ Entry *e )
{
Backend *be = op->o_bd;
slap_callback cb = { NULL };
syncinfo_t *si,
Operation *op,
struct berval *pdn,
- struct sync_cookie *syncCookie
-)
+ struct sync_cookie *syncCookie )
{
Backend *be = op->o_bd;
Modifications *ml;
op->o_tag = LDAP_REQ_ADD;
rc = slap_mods_opattrs( op, modlist, modtail,
- &text,txtbuf, textlen );
+ &text, txtbuf, textlen );
for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
ml->sml_op = LDAP_MOD_REPLACE;
int
syncrepl_isupdate_dn(
Backend* be,
- struct berval* ndn
-)
+ struct berval* ndn )
{
syncinfo_t* si;
int ret = 0;
static int
dn_callback(
Operation* op,
- SlapReply* rs
-)
+ SlapReply* rs )
{
syncinfo_t *si = op->o_callback->sc_private;
static int
nonpresent_callback(
Operation* op,
- SlapReply* rs
-)
+ SlapReply* rs )
{
syncinfo_t *si = op->o_callback->sc_private;
Attribute *a;
unsigned char nibble;
int i, d = 0;
- if ( normalized == NULL )
- return NULL;
-
- if ( normalized->bv_len != 16 ) {
- return NULL;
- }
+ if ( normalized == NULL ) return NULL;
+ if ( normalized->bv_len != 16 ) return NULL;
if ( uuidstr ) {
new = uuidstr;
new->bv_len = 36;
if (( new->bv_val = sl_malloc( new->bv_len + 1, ctx )) == NULL) {
- if ( !uuidstr )
- sl_free( new, ctx );
+ if ( !uuidstr ) sl_free( new, ctx );
return NULL;
}
}
new->bv_val[new->bv_len] = '\0';
-
return new;
}
static void
avl_ber_bvfree( void *bv )
{
- if( bv == NULL ) {
- return;
- }
+ if( bv == NULL ) return;
if ( ((struct berval *)bv)->bv_val != NULL ) {
- ch_free ( ((struct berval *)bv)->bv_val );
+ ch_free( ((struct berval *)bv)->bv_val );
}
- ch_free ( (char *) bv );
+ ch_free( (char *) bv );
}