#define LDAP_X_INVALIDREFERENCE 0x4112
#endif
+#define LDAP_X_TXN_ID_INVALID 0x4120
+
/* API Error Codes
*
* Based on draft-ietf-ldap-c-api-xx
backglue.c backover.c ctxcsn.c ldapsync.c frontend.c \
slapadd.c slapcat.c slapcommon.c slapdn.c slapindex.c \
slappasswd.c slaptest.c slapauth.c slapacl.c component.c \
- aci.c alock.c \
+ aci.c alock.c txn.c \
$(@PLAT@_SRCS)
OBJS = main.o globals.o bconfig.o config.o daemon.o \
backglue.o backover.o ctxcsn.o ldapsync.o frontend.o \
slapadd.o slapcat.o slapcommon.o slapdn.o slapindex.o \
slappasswd.o slaptest.o slapauth.o slapacl.o component.o \
- aci.o alock.o \
+ aci.o alock.o txn.o \
$(@PLAT@_OBJS)
LDAP_INCDIR= ../../include -I$(srcdir) -I$(srcdir)/slapi -I.
#include <lber_pvt.h>
#include <lutil.h>
+const struct berval slap_EXOP_CANCEL = BER_BVC(LDAP_EXOP_CANCEL);
+
int cancel_extop( Operation *op, SlapReply *rs )
{
Operation *o;
SLAP_CTRL_GLOBAL|SLAP_CTRL_UPDATE|SLAP_CTRL_HIDE,
NULL, NULL,
parseManageDIT, LDAP_SLIST_ENTRY_INITIALIZER(next) },
+#endif
+#ifdef LDAP_X_TXN
+ { LDAP_CONTROL_X_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),
#define UNSUPPORTED_EXOP "unsupported extended operation"
-
static struct extop_list {
struct extop_list *next;
struct berval oid;
* just a way to get built-in extops onto the extop list without
* having a separate init routine for each built-in extop.
*/
-const struct berval slap_EXOP_CANCEL = BER_BVC(LDAP_EXOP_CANCEL);
-const struct berval slap_EXOP_WHOAMI = BER_BVC(LDAP_EXOP_WHO_AM_I);
-const struct berval slap_EXOP_MODIFY_PASSWD = BER_BVC(LDAP_EXOP_MODIFY_PASSWD);
-const struct berval slap_EXOP_START_TLS = BER_BVC(LDAP_EXOP_START_TLS);
-
static struct {
const struct berval *oid;
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 },
}
+const struct berval slap_EXOP_WHOAMI = BER_BVC(LDAP_EXOP_WHO_AM_I);
+
static int
whoami_extop (
Operation *op,
op->o_bd = op->o_conn->c_authz_backend;
if( backend_check_restrictions( op, rs,
- (struct berval *)&slap_EXOP_WHOAMI ) != LDAP_SUCCESS ) {
+ (struct berval *)&slap_EXOP_WHOAMI ) != LDAP_SUCCESS )
+ {
return rs->sr_err;
}
#include <lutil.h>
#include <lutil_sha1.h>
+const struct berval slap_EXOP_MODIFY_PASSWD = BER_BVC(LDAP_EXOP_MODIFY_PASSWD);
+
static const char *defhash[] = {
#ifdef LUTIL_SHA1_BYTES
"{SSHA}",
LDAP_SLAPD_V( const struct berval ) slap_EXOP_WHOAMI;
LDAP_SLAPD_V( const struct berval ) slap_EXOP_MODIFY_PASSWD;
LDAP_SLAPD_V( const struct berval ) slap_EXOP_START_TLS;
+#ifdef LDAP_X_TXN
+LDAP_SLAPD_V( const struct berval ) slap_EXOP_TXN_START;
+LDAP_SLAPD_V( const struct berval ) slap_EXOP_TXN_END;
+#endif
typedef int (SLAP_EXTOP_MAIN_FN) LDAP_P(( Operation *op, SlapReply *rs ));
LDAP_SLAPD_F (struct berval *) get_supported_extop LDAP_P((int index));
+/*
+ * txn.c
+ */
+#ifdef LDAP_X_TXN
+LDAP_SLAPD_F ( SLAP_CTRL_PARSE_FN ) txn_spec_ctrl;
+LDAP_SLAPD_F ( SLAP_EXTOP_MAIN_FN ) txn_start_extop;
+LDAP_SLAPD_F ( SLAP_EXTOP_MAIN_FN ) txn_end_extop;
+#endif
+
/*
* cancel.c
*/
#endif
int sc_subentries;
int sc_treeDelete;
+#ifdef LDAP_X_TXN
+ int sc_txnSpec;
+#endif
int sc_valuesReturnFilter;
};
#define o_sortedresults o_ctrlflag[slap_cids.sc_sortedResults]
#endif
+#ifdef LDAP_X_TXN
+#define o_txnSpec o_ctrlflag[slap_cids.sc_txnSpec]
+#endif
+
#define o_sync o_ctrlflag[slap_cids.sc_LDAPsync]
AuthorizationInformation o_authz;
#include <stdio.h>
#include <ac/socket.h>
+#include <ac/string.h>
#include "slap.h"
+#include "lber_pvt.h"
-#ifdef HAVE_TLS
+const struct berval slap_EXOP_START_TLS = BER_BVC(LDAP_EXOP_START_TLS);
+#ifdef HAVE_TLS
int
starttls_extop ( Operation *op, SlapReply *rs )
{
--- /dev/null
+/* txn.c - LDAP Transactions */
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2006 The OpenLDAP Foundation.
+ * 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 the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/krb.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#include "slap.h"
+
+#include <lber_pvt.h>
+#include <lutil.h>
+
+#ifdef LDAP_X_TXN
+const struct berval slap_EXOP_TXN_START = BER_BVC(LDAP_EXOP_X_TXN_START);
+const struct berval slap_EXOP_TXN_END = BER_BVC(LDAP_EXOP_X_TXN_END);
+
+int txn_start_extop(
+ Operation *op, SlapReply *rs )
+{
+ struct berval *bv;
+
+ if( op->ore_reqdata != NULL ) {
+ rs->sr_text = "no request data expected";
+ return LDAP_PROTOCOL_ERROR;
+ }
+
+ Statslog( LDAP_DEBUG_STATS, "%s TXN START\n",
+ op->o_log_prefix, 0, 0, 0, 0 );
+
+ op->o_bd = op->o_conn->c_authz_backend;
+ if( backend_check_restrictions( op, rs,
+ (struct berval *)&slap_EXOP_TXN_START ) != LDAP_SUCCESS )
+ {
+ return rs->sr_err;
+ }
+
+ bv = (struct berval *) ch_malloc( sizeof (struct berval) );
+ bv->bv_len = 0;
+ bv->bv_val = NULL;
+
+ rs->sr_rspdata = bv;
+ return LDAP_SUCCESS;
+}
+
+int txn_spec_ctrl(
+ Operation *op, SlapReply *rs, LDAPControl *ctrl )
+{
+ if ( !ctrl->ldctl_iscritical ) {
+ rs->sr_text = "txnSpec control must be marked critical";
+ return LDAP_PROTOCOL_ERROR;
+ }
+ if( op->o_txnSpec ) {
+ rs->sr_text = "txnSpec control provided multiple times";
+ return LDAP_PROTOCOL_ERROR;
+ }
+
+ if ( ctrl->ldctl_value.bv_val == NULL ) {
+ rs->sr_text = "no transaction identifier provided";
+ return LDAP_PROTOCOL_ERROR;
+ }
+ if ( ctrl->ldctl_value.bv_len != 0 ) {
+ rs->sr_text = "invalid transaction identifier";
+ return LDAP_X_TXN_ID_INVALID;
+ }
+
+ op->o_txnSpec = SLAP_CONTROL_CRITICAL;
+ return LDAP_SUCCESS;
+}
+
+int txn_end_extop(
+ Operation *op, SlapReply *rs )
+{
+ if( op->ore_reqdata == NULL ) {
+ rs->sr_text = "request data expected";
+ return LDAP_PROTOCOL_ERROR;
+ }
+
+ Statslog( LDAP_DEBUG_STATS, "%s TXN END\n",
+ op->o_log_prefix, 0, 0, 0, 0 );
+
+ op->o_bd = op->o_conn->c_authz_backend;
+ if( backend_check_restrictions( op, rs,
+ (struct berval *)&slap_EXOP_TXN_END ) != LDAP_SUCCESS )
+ {
+ return rs->sr_err;
+ }
+
+ rs->sr_text = "not yet implemented";
+ return LDAP_UNWILLING_TO_PERFORM;
+}
+
+#endif /* LDAP_X_TXN */