mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-21 15:19:34 -05:00
TXN protocol element parsers (without any backend support)
Misc cleanup
This commit is contained in:
parent
17c826f370
commit
8ac8d70a55
10 changed files with 157 additions and 10 deletions
|
|
@ -626,6 +626,8 @@ typedef struct ldapcontrol {
|
||||||
#define LDAP_X_INVALIDREFERENCE 0x4112
|
#define LDAP_X_INVALIDREFERENCE 0x4112
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define LDAP_X_TXN_ID_INVALID 0x4120
|
||||||
|
|
||||||
/* API Error Codes
|
/* API Error Codes
|
||||||
*
|
*
|
||||||
* Based on draft-ietf-ldap-c-api-xx
|
* Based on draft-ietf-ldap-c-api-xx
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ SRCS = main.c globals.c bconfig.c config.c daemon.c \
|
||||||
backglue.c backover.c ctxcsn.c ldapsync.c frontend.c \
|
backglue.c backover.c ctxcsn.c ldapsync.c frontend.c \
|
||||||
slapadd.c slapcat.c slapcommon.c slapdn.c slapindex.c \
|
slapadd.c slapcat.c slapcommon.c slapdn.c slapindex.c \
|
||||||
slappasswd.c slaptest.c slapauth.c slapacl.c component.c \
|
slappasswd.c slaptest.c slapauth.c slapacl.c component.c \
|
||||||
aci.c alock.c \
|
aci.c alock.c txn.c \
|
||||||
$(@PLAT@_SRCS)
|
$(@PLAT@_SRCS)
|
||||||
|
|
||||||
OBJS = main.o globals.o bconfig.o config.o daemon.o \
|
OBJS = main.o globals.o bconfig.o config.o daemon.o \
|
||||||
|
|
@ -56,7 +56,7 @@ OBJS = main.o globals.o bconfig.o config.o daemon.o \
|
||||||
backglue.o backover.o ctxcsn.o ldapsync.o frontend.o \
|
backglue.o backover.o ctxcsn.o ldapsync.o frontend.o \
|
||||||
slapadd.o slapcat.o slapcommon.o slapdn.o slapindex.o \
|
slapadd.o slapcat.o slapcommon.o slapdn.o slapindex.o \
|
||||||
slappasswd.o slaptest.o slapauth.o slapacl.o component.o \
|
slappasswd.o slaptest.o slapauth.o slapacl.o component.o \
|
||||||
aci.o alock.o \
|
aci.o alock.o txn.o \
|
||||||
$(@PLAT@_OBJS)
|
$(@PLAT@_OBJS)
|
||||||
|
|
||||||
LDAP_INCDIR= ../../include -I$(srcdir) -I$(srcdir)/slapi -I.
|
LDAP_INCDIR= ../../include -I$(srcdir) -I$(srcdir)/slapi -I.
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
#include <lber_pvt.h>
|
#include <lber_pvt.h>
|
||||||
#include <lutil.h>
|
#include <lutil.h>
|
||||||
|
|
||||||
|
const struct berval slap_EXOP_CANCEL = BER_BVC(LDAP_EXOP_CANCEL);
|
||||||
|
|
||||||
int cancel_extop( Operation *op, SlapReply *rs )
|
int cancel_extop( Operation *op, SlapReply *rs )
|
||||||
{
|
{
|
||||||
Operation *o;
|
Operation *o;
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,13 @@ static struct slap_control control_defs[] = {
|
||||||
SLAP_CTRL_GLOBAL|SLAP_CTRL_UPDATE|SLAP_CTRL_HIDE,
|
SLAP_CTRL_GLOBAL|SLAP_CTRL_UPDATE|SLAP_CTRL_HIDE,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
parseManageDIT, LDAP_SLIST_ENTRY_INITIALIZER(next) },
|
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
|
#endif
|
||||||
{ LDAP_CONTROL_MANAGEDSAIT,
|
{ LDAP_CONTROL_MANAGEDSAIT,
|
||||||
(int)offsetof(struct slap_control_ids, sc_manageDSAit),
|
(int)offsetof(struct slap_control_ids, sc_manageDSAit),
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@
|
||||||
|
|
||||||
#define UNSUPPORTED_EXOP "unsupported extended operation"
|
#define UNSUPPORTED_EXOP "unsupported extended operation"
|
||||||
|
|
||||||
|
|
||||||
static struct extop_list {
|
static struct extop_list {
|
||||||
struct extop_list *next;
|
struct extop_list *next;
|
||||||
struct berval oid;
|
struct berval oid;
|
||||||
|
|
@ -56,16 +55,15 @@ static SLAP_EXTOP_MAIN_FN whoami_extop;
|
||||||
* just a way to get built-in extops onto the extop list without
|
* just a way to get built-in extops onto the extop list without
|
||||||
* having a separate init routine for each built-in extop.
|
* 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 {
|
static struct {
|
||||||
const struct berval *oid;
|
const struct berval *oid;
|
||||||
slap_mask_t flags;
|
slap_mask_t flags;
|
||||||
SLAP_EXTOP_MAIN_FN *ext_main;
|
SLAP_EXTOP_MAIN_FN *ext_main;
|
||||||
} builtin_extops[] = {
|
} 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_CANCEL, 0, cancel_extop },
|
||||||
{ &slap_EXOP_WHOAMI, 0, whoami_extop },
|
{ &slap_EXOP_WHOAMI, 0, whoami_extop },
|
||||||
{ &slap_EXOP_MODIFY_PASSWD, SLAP_EXOP_WRITES, passwd_extop },
|
{ &slap_EXOP_MODIFY_PASSWD, SLAP_EXOP_WRITES, passwd_extop },
|
||||||
|
|
@ -349,6 +347,8 @@ find_extop( struct extop_list *list, struct berval *oid )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const struct berval slap_EXOP_WHOAMI = BER_BVC(LDAP_EXOP_WHO_AM_I);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
whoami_extop (
|
whoami_extop (
|
||||||
Operation *op,
|
Operation *op,
|
||||||
|
|
@ -367,7 +367,8 @@ whoami_extop (
|
||||||
|
|
||||||
op->o_bd = op->o_conn->c_authz_backend;
|
op->o_bd = op->o_conn->c_authz_backend;
|
||||||
if( backend_check_restrictions( op, rs,
|
if( backend_check_restrictions( op, rs,
|
||||||
(struct berval *)&slap_EXOP_WHOAMI ) != LDAP_SUCCESS ) {
|
(struct berval *)&slap_EXOP_WHOAMI ) != LDAP_SUCCESS )
|
||||||
|
{
|
||||||
return rs->sr_err;
|
return rs->sr_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@
|
||||||
#include <lutil.h>
|
#include <lutil.h>
|
||||||
#include <lutil_sha1.h>
|
#include <lutil_sha1.h>
|
||||||
|
|
||||||
|
const struct berval slap_EXOP_MODIFY_PASSWD = BER_BVC(LDAP_EXOP_MODIFY_PASSWD);
|
||||||
|
|
||||||
static const char *defhash[] = {
|
static const char *defhash[] = {
|
||||||
#ifdef LUTIL_SHA1_BYTES
|
#ifdef LUTIL_SHA1_BYTES
|
||||||
"{SSHA}",
|
"{SSHA}",
|
||||||
|
|
|
||||||
|
|
@ -860,6 +860,10 @@ LDAP_SLAPD_V( const struct berval ) slap_EXOP_CANCEL;
|
||||||
LDAP_SLAPD_V( const struct berval ) slap_EXOP_WHOAMI;
|
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_MODIFY_PASSWD;
|
||||||
LDAP_SLAPD_V( const struct berval ) slap_EXOP_START_TLS;
|
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 ));
|
typedef int (SLAP_EXTOP_MAIN_FN) LDAP_P(( Operation *op, SlapReply *rs ));
|
||||||
|
|
||||||
|
|
@ -880,6 +884,15 @@ LDAP_SLAPD_F (int) extops_kill LDAP_P(( void ));
|
||||||
|
|
||||||
LDAP_SLAPD_F (struct berval *) get_supported_extop LDAP_P((int index));
|
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
|
* cancel.c
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2303,6 +2303,9 @@ struct slap_control_ids {
|
||||||
#endif
|
#endif
|
||||||
int sc_subentries;
|
int sc_subentries;
|
||||||
int sc_treeDelete;
|
int sc_treeDelete;
|
||||||
|
#ifdef LDAP_X_TXN
|
||||||
|
int sc_txnSpec;
|
||||||
|
#endif
|
||||||
int sc_valuesReturnFilter;
|
int sc_valuesReturnFilter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -2502,6 +2505,10 @@ typedef struct slap_op {
|
||||||
#define o_sortedresults o_ctrlflag[slap_cids.sc_sortedResults]
|
#define o_sortedresults o_ctrlflag[slap_cids.sc_sortedResults]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LDAP_X_TXN
|
||||||
|
#define o_txnSpec o_ctrlflag[slap_cids.sc_txnSpec]
|
||||||
|
#endif
|
||||||
|
|
||||||
#define o_sync o_ctrlflag[slap_cids.sc_LDAPsync]
|
#define o_sync o_ctrlflag[slap_cids.sc_LDAPsync]
|
||||||
|
|
||||||
AuthorizationInformation o_authz;
|
AuthorizationInformation o_authz;
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,14 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ac/socket.h>
|
#include <ac/socket.h>
|
||||||
|
#include <ac/string.h>
|
||||||
|
|
||||||
#include "slap.h"
|
#include "slap.h"
|
||||||
|
#include "lber_pvt.h"
|
||||||
|
|
||||||
|
const struct berval slap_EXOP_START_TLS = BER_BVC(LDAP_EXOP_START_TLS);
|
||||||
|
|
||||||
#ifdef HAVE_TLS
|
#ifdef HAVE_TLS
|
||||||
|
|
||||||
int
|
int
|
||||||
starttls_extop ( Operation *op, SlapReply *rs )
|
starttls_extop ( Operation *op, SlapReply *rs )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
110
servers/slapd/txn.c
Normal file
110
servers/slapd/txn.c
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
/* 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 */
|
||||||
Loading…
Reference in a new issue