Commit 76c43165 authored by Ondřej Kuzník's avatar Ondřej Kuzník
Browse files

Remove LDAP_X_TXN and rename accordingly

parent 0cf2b121
......@@ -94,11 +94,9 @@ static int process_response(
int res,
const struct berval *dn );
#ifdef LDAP_X_TXN
static int txn = 0;
static int txnabort = 0;
struct berval *txn_id = NULL;
#endif
void
usage( void )
......@@ -117,10 +115,8 @@ usage( void )
fprintf( stderr, _(" -f file read operations from `file'\n"));
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
#ifdef LDAP_X_TXN
fprintf( stderr,
_(" [!]txn=<commit|abort> (transaction)\n"));
#endif
fprintf( stderr, _(" -S file write skipped modifications to `file'\n"));
tool_common_usage();
......@@ -161,7 +157,6 @@ handle_private_option( int i )
*cvalue++ = '\0';
}
#ifdef LDAP_X_TXN
if( strcasecmp( control, "txn" ) == 0 ) {
/* Transaction */
if( txn ) {
......@@ -181,7 +176,6 @@ handle_private_option( int i )
txn = 1 + crit;
} else
#endif
{
fprintf( stderr, _("Invalid modify extension name: %s\n"),
control );
......@@ -265,7 +259,6 @@ main( int argc, char **argv )
tool_bind( ld );
}
#ifdef LDAP_X_TXN
if( txn ) {
/* start transaction */
rc = ldap_txn_start_s( ld, NULL, NULL, &txn_id );
......@@ -278,22 +271,12 @@ main( int argc, char **argv )
txn = 0;
}
}
#endif
if ( 0
#ifdef LDAP_X_TXN
|| txn
#endif
)
{
#ifdef LDAP_X_TXN
if( txn ) {
c[i].ldctl_oid = LDAP_CONTROL_X_TXN_SPEC;
c[i].ldctl_value = *txn_id;
c[i].ldctl_iscritical = 1;
i++;
}
#endif
if( txn ) {
c[i].ldctl_oid = LDAP_CONTROL_TXN_SPEC;
c[i].ldctl_value = *txn_id;
c[i].ldctl_iscritical = 1;
i++;
}
tool_server_controls( ld, c, i );
......@@ -348,7 +331,6 @@ main( int argc, char **argv )
if ( ldifrc < 0 )
retval = LDAP_OTHER;
#ifdef LDAP_X_TXN
if( retval == 0 && txn ) {
rc = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, NULL );
if ( rc != LDAP_OPT_SUCCESS ) {
......@@ -362,7 +344,6 @@ main( int argc, char **argv )
retval = rc;
}
}
#endif
fail:;
if ( rejfp != NULL ) {
......@@ -694,12 +675,9 @@ static int process_response(
rc = ldap_parse_result( ld, res, &err, &matched, &text, &refs, &ctrls, 1 );
if ( rc == LDAP_SUCCESS ) rc = err;
#ifdef LDAP_X_TXN
if ( rc == LDAP_X_TXN_SPECIFY_OKAY ) {
if ( rc == LDAP_TXN_SPECIFY_OKAY ) {
rc = LDAP_SUCCESS;
} else
#endif
if ( rc != LDAP_SUCCESS ) {
} else if ( rc != LDAP_SUCCESS ) {
tool_perror( res2str( op ), rc, NULL, matched, text, refs );
} else if ( msgtype != op ) {
fprintf( stderr, "%s: msgtype: expected %d got %d\n",
......
......@@ -438,16 +438,10 @@ typedef struct ldapcontrol {
#define LDAP_URLEXT_X_FAILEDNAME "x-failedName"
#define LDAP_TXN "1.3.6.1.1.21" /* RFC 5805 */
#define LDAP_EXOP_TXN_START LDAP_X_TXN ".1"
#define LDAP_CONTROL_TXN_SPEC LDAP_X_TXN ".2"
#define LDAP_EXOP_TXN_END LDAP_X_TXN ".3"
#define LDAP_EXOP_TXN_ABORTED_NOTICE LDAP_X_TXN ".4"
#define LDAP_X_TXN LDAP_TXN
#define LDAP_EXOP_X_TXN_START LDAP_EXOP_TXN_START
#define LDAP_CONTROL_X_TXN_SPEC LDAP_CONTROL_TXN_SPEC
#define LDAP_EXOP_X_TXN_END LDAP_EXOP_TXN_END
#define LDAP_EXOP_X_TXN_ABORTED_NOTICE LDAP_EXOP_TXN_ABORTED_NOTICE
#define LDAP_EXOP_TXN_START LDAP_TXN ".1"
#define LDAP_CONTROL_TXN_SPEC LDAP_TXN ".2"
#define LDAP_EXOP_TXN_END LDAP_TXN ".3"
#define LDAP_EXOP_TXN_ABORTED_NOTICE LDAP_TXN ".4"
/* LDAP Features */
#define LDAP_FEATURE_ALL_OP_ATTRS "1.3.6.1.4.1.4203.1.5.1" /* RFC 3673 */
......@@ -712,10 +706,8 @@ typedef struct ldapcontrol {
#define LDAP_X_INVALIDREFERENCE 0x4112
#endif
#ifdef LDAP_X_TXN
#define LDAP_X_TXN_SPECIFY_OKAY 0x4120
#define LDAP_X_TXN_ID_INVALID 0x4121
#endif
#define LDAP_TXN_SPECIFY_OKAY 0x4120
#define LDAP_TXN_ID_INVALID 0x4121
/* API Error Codes
*
......@@ -2452,7 +2444,6 @@ ldap_refresh_s LDAP_P((
/*
* LDAP Transactions
*/
#ifdef LDAP_X_TXN
LDAP_F( int )
ldap_txn_start LDAP_P(( LDAP *ld,
LDAPControl **sctrls,
......@@ -2480,7 +2471,6 @@ ldap_txn_end_s LDAP_P(( LDAP *ld,
LDAPControl **sctrl,
LDAPControl **cctrl,
int *retidp ));
#endif
/*
* in ldap_sync.c
......
......@@ -126,11 +126,8 @@ ldap_err2string( int err )
C(LDAP_CUP_UNSUPPORTED_SCHEME, N_("LCUP Unsupported Scheme"));
C(LDAP_CUP_RELOAD_REQUIRED, N_("LCUP Reload Required"));
#ifdef LDAP_X_TXN
/* Codes related to LDAP Transactions (draft-zeilenga-ldap-txn) */
C(LDAP_X_TXN_SPECIFY_OKAY, N_("TXN specify okay"));
C(LDAP_X_TXN_ID_INVALID, N_("TXN ID is invalid"));
#endif
C(LDAP_TXN_SPECIFY_OKAY, N_("TXN specify okay"));
C(LDAP_TXN_ID_INVALID, N_("TXN ID is invalid"));
/* API codes - renumbered since draft-ietf-ldapext-ldap-c-api */
C(LDAP_SERVER_DOWN, N_("Can't contact LDAP server"));
......
......@@ -33,7 +33,6 @@
#include "ldap-int.h"
#include "ldap_log.h"
#ifdef LDAP_X_TXN
int
ldap_txn_start(
LDAP *ld,
......@@ -41,7 +40,7 @@ ldap_txn_start(
LDAPControl **cctrls,
int *msgidp )
{
return ldap_extended_operation( ld, LDAP_EXOP_X_TXN_START,
return ldap_extended_operation( ld, LDAP_EXOP_TXN_START,
NULL, sctrls, cctrls, msgidp );
}
......@@ -54,7 +53,7 @@ ldap_txn_start_s(
{
assert( txnid != NULL );
return ldap_extended_operation_s( ld, LDAP_EXOP_X_TXN_START,
return ldap_extended_operation_s( ld, LDAP_EXOP_TXN_START,
NULL, sctrls, cctrls, NULL, txnid );
}
......@@ -83,7 +82,7 @@ ldap_txn_end(
ber_flatten( txnber, &txnval );
rc = ldap_extended_operation( ld, LDAP_EXOP_X_TXN_END,
rc = ldap_extended_operation( ld, LDAP_EXOP_TXN_END,
txnval, sctrls, cctrls, msgidp );
ber_free( txnber, 1 );
......@@ -116,7 +115,7 @@ ldap_txn_end_s(
ber_flatten( txnber, &txnval );
rc = ldap_extended_operation_s( ld, LDAP_EXOP_X_TXN_END,
rc = ldap_extended_operation_s( ld, LDAP_EXOP_TXN_END,
txnval, sctrls, cctrls, NULL, &retdata );
ber_free( txnber, 1 );
......@@ -152,4 +151,3 @@ done:
return rc;
}
#endif
......@@ -199,13 +199,10 @@ do_add( Operation *op, SlapReply *rs )
}
LDAP_SLIST_REMOVE(&op->o_extra, &oex->oe, OpExtra, oe_next);
#ifdef LDAP_X_TXN
if ( rc == LDAP_X_TXN_SPECIFY_OKAY ) {
if ( rc == LDAP_TXN_SPECIFY_OKAY ) {
/* skip cleanup */
return rc;
} else
#endif
if ( rc == 0 ) {
} else if ( rc == 0 ) {
if ( op->ora_e != NULL && oex->oe_db != NULL ) {
BackendDB *bd = op->o_bd;
......
......@@ -48,10 +48,8 @@ mdb_add(Operation *op, SlapReply *rs )
Debug(LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(mdb_add) ": %s\n",
op->ora_e->e_name.bv_val );
#ifdef LDAP_X_TXN
if( op->o_txnSpec && txn_preop( op, rs ))
return rs->sr_err;
#endif
ctrls[num_ctrls] = 0;
......
......@@ -46,10 +46,8 @@ mdb_delete( Operation *op, SlapReply *rs )
Debug( LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(mdb_delete) ": %s\n",
op->o_req_dn.bv_val );
#ifdef LDAP_X_TXN
if( op->o_txnSpec && txn_preop( op, rs ))
return rs->sr_err;
#endif
ctrls[num_ctrls] = 0;
......
......@@ -809,7 +809,6 @@ ok:
return 0;
}
#ifdef LDAP_X_TXN
int mdb_txn( Operation *op, int txnop, OpExtra **ptr )
{
struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
......@@ -838,7 +837,6 @@ int mdb_txn( Operation *op, int txnop, OpExtra **ptr )
}
return LDAP_OTHER;
}
#endif
/* Count up the sizes of the components of an entry */
static int mdb_entry_partsize(struct mdb_info *mdb, MDB_txn *txn, Entry *e,
......
......@@ -394,9 +394,7 @@ mdb_back_initialize(
LDAP_CONTROL_POST_READ,
LDAP_CONTROL_SUBENTRIES,
LDAP_CONTROL_X_PERMISSIVE_MODIFY,
#ifdef LDAP_X_TXN
LDAP_CONTROL_X_TXN_SPEC,
#endif
LDAP_CONTROL_TXN_SPEC,
NULL
};
......
......@@ -573,10 +573,8 @@ mdb_modify( Operation *op, SlapReply *rs )
Debug( LDAP_DEBUG_ARGS, LDAP_XSTRING(mdb_modify) ": %s\n",
op->o_req_dn.bv_val );
#ifdef LDAP_X_TXN
if( op->o_txnSpec && txn_preop( op, rs ))
return rs->sr_err;
#endif
ctrls[num_ctrls] = NULL;
......
......@@ -59,10 +59,8 @@ mdb_modrdn( Operation *op, SlapReply *rs )
op->o_req_dn.bv_val,op->oq_modrdn.rs_newrdn.bv_val,
op->oq_modrdn.rs_newSup ? op->oq_modrdn.rs_newSup->bv_val : "NULL" );
#ifdef LDAP_X_TXN
if( op->o_txnSpec && txn_preop( op, rs ))
return rs->sr_err;
#endif
ctrls[num_ctrls] = NULL;
......
......@@ -359,9 +359,7 @@ ndb_back_initialize(
LDAP_CONTROL_POST_READ,
LDAP_CONTROL_SUBENTRIES,
LDAP_CONTROL_X_PERMISSIVE_MODIFY,
#ifdef LDAP_X_TXN
LDAP_CONTROL_X_TXN_SPEC,
#endif
LDAP_CONTROL_TXN_SPEC,
NULL
};
......
......@@ -52,10 +52,8 @@ wt_delete( Operation *op, SlapReply *rs )
Debug( LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(wt_delete) ": %s\n",
op->o_req_dn.bv_val );
#ifdef LDAP_X_TXN
if( op->o_txnSpec && txn_preop( op, rs ))
return rs->sr_err;
#endif
ctrls[num_ctrls] = 0;
rs->sr_text = NULL;
......
......@@ -463,10 +463,8 @@ wt_modify( Operation *op, SlapReply *rs )
Debug( LDAP_DEBUG_ARGS, LDAP_XSTRING(wt_modify) ": %s\n",
op->o_req_dn.bv_val );
#ifdef LDAP_X_TXN
if( op->o_txnSpec && txn_preop( op, rs ))
return rs->sr_err;
#endif
ctrls[num_ctrls] = NULL;
......
......@@ -382,11 +382,9 @@ Connection * connection_init(
LDAP_STAILQ_INIT(&c->c_ops);
LDAP_STAILQ_INIT(&c->c_pending_ops);
#ifdef LDAP_X_TXN
c->c_txn = CONN_TXN_INACTIVE;
c->c_txn_backend = NULL;
LDAP_STAILQ_INIT(&c->c_txn_ops);
#endif
BER_BVZERO( &c->c_sasl_bind_mech );
c->c_sasl_done = 0;
......@@ -420,11 +418,9 @@ Connection * connection_init(
assert( BER_BVISNULL( &c->c_peer_name ) );
assert( LDAP_STAILQ_EMPTY(&c->c_ops) );
assert( LDAP_STAILQ_EMPTY(&c->c_pending_ops) );
#ifdef LDAP_X_TXN
assert( c->c_txn == CONN_TXN_INACTIVE );
assert( c->c_txn_backend == NULL );
assert( LDAP_STAILQ_EMPTY(&c->c_txn_ops) );
#endif
assert( BER_BVISNULL( &c->c_sasl_bind_mech ) );
assert( c->c_sasl_done == 0 );
assert( c->c_sasl_authctx == NULL );
......@@ -627,11 +623,9 @@ connection_destroy( Connection *c )
assert( c->c_conn_state != SLAP_C_INVALID );
assert( LDAP_STAILQ_EMPTY(&c->c_ops) );
assert( LDAP_STAILQ_EMPTY(&c->c_pending_ops) );
#ifdef LDAP_X_TXN
assert( c->c_txn == CONN_TXN_INACTIVE );
assert( c->c_txn_backend == NULL );
assert( LDAP_STAILQ_EMPTY(&c->c_txn_ops) );
#endif
assert( c->c_writewaiter == 0);
assert( c->c_writers == 0);
......@@ -748,7 +742,6 @@ static void connection_abandon( Connection *c )
frontendDB->be_abandon( &op, &rs );
}
#ifdef LDAP_X_TXN
/* remove operations in pending transaction */
while ( (o = LDAP_STAILQ_FIRST( &c->c_txn_ops )) != NULL) {
LDAP_STAILQ_REMOVE_HEAD( &c->c_txn_ops, o_next );
......@@ -759,7 +752,6 @@ static void connection_abandon( Connection *c )
/* clear transaction */
c->c_txn_backend = NULL;
c->c_txn = CONN_TXN_INACTIVE;
#endif
/* remove pending operations */
while ( (o = LDAP_STAILQ_FIRST( &c->c_pending_ops )) != NULL) {
......@@ -1144,7 +1136,6 @@ connection_operation( void *ctx, void *arg_v )
goto operations_error;
}
#ifdef LDAP_X_TXN
if (( conn->c_txn == CONN_TXN_SPECIFY ) && (
( tag == LDAP_REQ_ADD ) ||
( tag == LDAP_REQ_DELETE ) ||
......@@ -1155,9 +1146,7 @@ connection_operation( void *ctx, void *arg_v )
issued inside of a transaction */
op->o_tmpmemctx = NULL;
op->o_tmpmfuncs = &ch_mfuncs;
} else
#endif
{
} else {
/* We can use Thread-Local storage for most mallocs. We can
* also use TL for ber parsing, but not on Add or Modify.
*/
......@@ -1234,10 +1223,7 @@ operations_error:
ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, &memctx_null );
#ifdef LDAP_X_TXN
if ( rc != LDAP_X_TXN_SPECIFY_OKAY )
#endif
{
if ( rc != LDAP_TXN_SPECIFY_OKAY ) {
LDAP_STAILQ_REMOVE( &conn->c_ops, op, Operation, o_next);
LDAP_STAILQ_NEXT(op, o_next) = NULL;
}
......@@ -1255,10 +1241,7 @@ operations_error:
connection_resched( conn );
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
#ifdef LDAP_X_TXN
if ( rc != LDAP_X_TXN_SPECIFY_OKAY )
#endif
{
if ( rc != LDAP_TXN_SPECIFY_OKAY ) {
slap_op_free( op, ctx );
}
return NULL;
......
......@@ -198,13 +198,11 @@ static struct slap_control control_defs[] = {
SLAP_CTRL_GLOBAL|SLAP_CTRL_UPDATE|SLAP_CTRL_HIDE,
NULL, NULL,
parseRelax, LDAP_SLIST_ENTRY_INITIALIZER(next) },
#ifdef LDAP_X_TXN
{ LDAP_CONTROL_X_TXN_SPEC,
{ LDAP_CONTROL_TXN_SPEC,
(int)offsetof(struct slap_control_ids, sc_txnSpec),
SLAP_CTRL_UPDATE|SLAP_CTRL_HIDE,
NULL, NULL,
txn_spec_ctrl, LDAP_SLIST_ENTRY_INITIALIZER(next) },
#endif
{ LDAP_CONTROL_MANAGEDSAIT,
(int)offsetof(struct slap_control_ids, sc_manageDSAit),
SLAP_CTRL_ACCESS,
......@@ -1498,12 +1496,10 @@ parseReadAttrs(
return LDAP_PROTOCOL_ERROR;
}
#ifdef LDAP_X_TXN
if ( op->o_txnSpec ) { /* temporary limitation */
rs->sr_text = READMSG( post, "cannot perform in transaction" );
return LDAP_UNWILLING_TO_PERFORM;
}
#endif
ber = ber_init( &ctrl->ldctl_value );
if ( ber == NULL ) {
......
......@@ -98,12 +98,10 @@ do_delete(
return rs->sr_err;
}
#ifdef LDAP_X_TXN
if( rs->sr_err == LDAP_X_TXN_SPECIFY_OKAY ) {
if( rs->sr_err == LDAP_TXN_SPECIFY_OKAY ) {
/* skip cleanup */
return rs->sr_err;
}
#endif
cleanup:;
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
......
......@@ -58,10 +58,8 @@ static struct {
slap_mask_t flags;
SLAP_EXTOP_MAIN_FN *ext_main;
} builtin_extops[] = {
#ifdef LDAP_X_TXN
{ &slap_EXOP_TXN_START, 0, txn_start_extop },
{ &slap_EXOP_TXN_END, 0, txn_end_extop },
#endif
{ &slap_EXOP_CANCEL, 0, cancel_extop },
{ &slap_EXOP_WHOAMI, 0, whoami_extop },
{ &slap_EXOP_MODIFY_PASSWD, SLAP_EXOP_WRITES, passwd_extop },
......
......@@ -177,12 +177,10 @@ do_modify(
return rs->sr_err;
}
#ifdef LDAP_X_TXN
if( rs->sr_err == LDAP_X_TXN_SPECIFY_OKAY ) {
if( rs->sr_err == LDAP_TXN_SPECIFY_OKAY ) {
/* skip cleanup */
return rs->sr_err;
}
#endif
cleanup:
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
......
......@@ -189,12 +189,10 @@ do_modrdn(
/* skip cleanup */
return rs->sr_err;
}
#ifdef LDAP_X_TXN
if( rs->sr_err == LDAP_X_TXN_SPECIFY_OKAY ) {
if( rs->sr_err == LDAP_TXN_SPECIFY_OKAY ) {
/* skip cleanup */
return rs->sr_err;
}
#endif
cleanup:
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment