for the known exops.
#include "back-bdb.h"
#include "external.h"
+#include "lber_pvt.h"
static struct exop {
- char *oid;
+ struct berval *oid;
BI_op_extended *extended;
} exop_table[] = {
- { LDAP_EXOP_MODIFY_PASSWD, bdb_exop_passwd },
+ { (struct berval *)&slap_EXOP_MODIFY_PASSWD, bdb_exop_passwd },
{ NULL, NULL }
};
Backend *be,
Connection *conn,
Operation *op,
- const char *reqoid,
+ struct berval *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,
{
int i;
- for( i=0; exop_table[i].oid != NULL; i++ ) {
- if( strcmp( exop_table[i].oid, reqoid ) == 0 ) {
+ for( i=0; exop_table[i].extended != NULL; i++ ) {
+ if( ber_bvcmp( exop_table[i].oid, reqoid ) == 0 ) {
return (exop_table[i].extended)(
be, conn, op,
reqoid, reqdata,
#include "back-bdb.h"
#include "external.h"
+#include "lber_pvt.h"
int
bdb_exop_passwd(
Backend *be,
Connection *conn,
Operation *op,
- const char *reqoid,
+ struct berval *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,
DB_LOCK lock;
assert( reqoid != NULL );
- assert( strcmp( LDAP_EXOP_MODIFY_PASSWD, reqoid ) == 0 );
+ assert( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, reqoid ) == 0 );
rc = slap_passwd_parse( reqdata,
&id, NULL, &new, text );
#include "slap.h"
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
+#include "lber_pvt.h"
struct exop {
- char *oid;
+ struct berval *oid;
BI_op_extended *extended;
} exop_table[] = {
- { LDAP_EXOP_MODIFY_PASSWD, ldbm_back_exop_passwd },
+ { (struct berval *)&slap_EXOP_MODIFY_PASSWD, ldbm_back_exop_passwd },
{ NULL, NULL }
};
Backend *be,
Connection *conn,
Operation *op,
- const char *reqoid,
+ struct berval *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,
{
int i;
- for( i=0; exop_table[i].oid != NULL; i++ ) {
- if( strcmp( exop_table[i].oid, reqoid ) == 0 ) {
+ for( i=0; exop_table[i].extended != NULL; i++ ) {
+ if( ber_bvcmp( exop_table[i].oid, reqoid ) == 0 ) {
return (exop_table[i].extended)(
be, conn, op,
reqoid, reqdata,
#include "slap.h"
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
+#include "lber_pvt.h"
int
ldbm_back_exop_passwd(
Backend *be,
Connection *conn,
Operation *op,
- const char *reqoid,
+ struct berval *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,
struct berval ndn;
assert( reqoid != NULL );
- assert( strcmp( LDAP_EXOP_MODIFY_PASSWD, reqoid ) == 0 );
+ assert( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, reqoid ) == 0 );
rc = slap_passwd_parse( reqdata,
&id, NULL, &new, text );
}
{
- struct berval bv = BER_BVC( LDAP_EXOP_START_TLS );
- if( bvmatch( opdata, &bv ) ) {
+ if( bvmatch( opdata, &slap_EXOP_START_TLS ) ) {
session++;
starttls++;
break;
}
{
- struct berval bv = BER_BVC( LDAP_EXOP_X_WHO_AM_I );
- if( bvmatch( opdata, &bv ) ) {
+ if( bvmatch( opdata, &slap_EXOP_WHOAMI ) ) {
break;
}
}
#ifdef LDAP_EXOP_X_CANCEL
{
- struct berval bv = BER_BVC( LDAP_EXOP_X_CANCEL );
- if ( bvmatch( opdata, &bv ) ) {
+ if ( bvmatch( opdata, &slap_EXOP_CANCEL ) ) {
break;
}
}
int cancel_extop(
Connection *conn,
Operation *op,
- const char *reqoid,
+ struct berval *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,
int i;
assert( reqoid != NULL );
- assert( strcmp( LDAP_EXOP_X_CANCEL, reqoid ) == 0 );
+ assert( ber_bvcmp( &slap_EXOP_CANCEL, reqoid ) == 0 );
if ( reqdata == NULL ) {
*text = "no message ID supplied";
static SLAP_EXTOP_MAIN_FN whoami_extop;
-/* BerVal Constant initializer */
-
-#define BVC(x) {sizeof(x)-1, x}
-
/* this list of built-in extops is for extops that are not part
* of backends or in external modules. essentially, this is
* just a way to get built-in extops onto the extop list without
* having a separate init routine for each built-in extop.
*/
+#ifdef LDAP_EXOP_X_CANCEL
+const struct berval slap_EXOP_CANCEL = BER_BVC(LDAP_EXOP_X_CANCEL);
+#endif
+const struct berval slap_EXOP_WHOAMI = BER_BVC(LDAP_EXOP_X_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 {
- struct berval oid;
+ const struct berval *oid;
SLAP_EXTOP_MAIN_FN *ext_main;
} builtin_extops[] = {
#ifdef LDAP_EXOP_X_CANCEL
- { BVC(LDAP_EXOP_X_CANCEL), cancel_extop },
+ { &slap_EXOP_CANCEL, cancel_extop },
#endif
- { BVC(LDAP_EXOP_X_WHO_AM_I), whoami_extop },
- { BVC(LDAP_EXOP_MODIFY_PASSWD), passwd_extop },
+ { &slap_EXOP_WHOAMI, whoami_extop },
+ { &slap_EXOP_MODIFY_PASSWD, passwd_extop },
#ifdef HAVE_TLS
- { BVC(LDAP_EXOP_START_TLS), starttls_extop },
+ { &slap_EXOP_START_TLS, starttls_extop },
#endif
- { {0,NULL}, NULL }
+ { NULL, NULL }
};
#endif /* defined(LDAP_SLAPI) */
rc = (ext->ext_main)( conn, op,
- reqoid.bv_val, reqdata.bv_val ? &reqdata : NULL,
+ &reqoid, reqdata.bv_val ? &reqdata : NULL,
&rspoid, &rspdata, &rspctrls, &text, &refs );
if( rc != SLAPD_ABANDON ) {
int
load_extop(
- const char *ext_oid,
+ struct berval *ext_oid,
SLAP_EXTOP_MAIN_FN *ext_main )
{
struct extop_list *ext;
- if( ext_oid == NULL || *ext_oid == '\0' ) return -1;
+ if( ext_oid == NULL || ext_oid->bv_val == NULL ||
+ ext_oid->bv_val[0] == '\0' || ext_oid->bv_len == 0 ) return -1;
if(!ext_main) return -1;
- ext = ch_calloc(1, sizeof(struct extop_list));
+ ext = ch_calloc(1, sizeof(struct extop_list) + ext_oid->bv_len + 1);
if (ext == NULL)
return(-1);
- ber_str2bv( ext_oid, 0, 1, &ext->oid );
- if (ext->oid.bv_val == NULL) {
- free(ext);
- return(-1);
- }
+ ext->oid.bv_val = (char *)(ext + 1);
+ AC_MEMCPY( ext->oid.bv_val, ext_oid->bv_val, ext_oid->bv_len );
+ ext->oid.bv_len = ext_oid->bv_len;
+ ext->oid.bv_val[ext->oid.bv_len] = '\0';
ext->ext_main = ext_main;
ext->next = supp_ext_list;
{
int i;
- for (i = 0; builtin_extops[i].oid.bv_val != NULL; i++) {
- load_extop(builtin_extops[i].oid.bv_val, builtin_extops[i].ext_main);
+ for (i = 0; builtin_extops[i].oid != NULL; i++) {
+ load_extop((struct berval *)builtin_extops[i].oid, builtin_extops[i].ext_main);
}
return(0);
}
/* we allocated the memory, so we have to free it, too. */
while ((ext = supp_ext_list) != NULL) {
supp_ext_list = ext->next;
- if (ext->oid.bv_val != NULL)
- ch_free(ext->oid.bv_val);
ch_free(ext);
}
return(0);
whoami_extop (
Connection *conn,
Operation *op,
- const char * reqoid,
+ struct berval * reqoid,
struct berval * reqdata,
char ** rspoid,
struct berval ** rspdata,
}
{
- int rc;
- struct berval whoami = BER_BVC( LDAP_EXOP_X_WHO_AM_I );
-
- rc = backend_check_restrictions( conn->c_authz_backend,
- conn, op, &whoami, text );
+ int rc = backend_check_restrictions( conn->c_authz_backend,
+ conn, op, (struct berval *)&slap_EXOP_WHOAMI, text );
if( rc != LDAP_SUCCESS ) return rc;
}
)
{
SLAP_EXTOP_MAIN_FN *ext_main;
- int (*ext_getoid)(int index, char *oid, int blen);
- char *oid;
+ SLAP_EXTOP_GETOID_FN *ext_getoid;
+ struct berval oid;
int rc;
ext_main = (SLAP_EXTOP_MAIN_FN *)module_resolve(module, "ext_main");
return(-1);
}
- oid = ch_malloc(256);
- rc = (ext_getoid)(0, oid, 256);
+ rc = (ext_getoid)(0, &oid, 256);
if (rc != 0) {
- ch_free(oid);
return(rc);
}
- if (*oid == 0) {
- free(oid);
+ if (oid.bv_val == NULL || oid.bv_len == 0) {
return(-1);
}
- rc = load_extop( oid, ext_main );
- free(oid);
+ rc = load_extop( &oid, ext_main );
return rc;
}
#endif /* SLAPD_EXTERNAL_EXTENSIONS */
int passwd_extop(
Connection *conn, Operation *op,
- const char *reqoid,
+ struct berval *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,
int rc;
assert( reqoid != NULL );
- assert( strcmp( LDAP_EXOP_MODIFY_PASSWD, reqoid ) == 0 );
+ assert( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, reqoid ) == 0 );
if( op->o_dn.bv_len == 0 ) {
*text = "only authenticated users may change passwords";
}
{
- struct berval passwd = BER_BVC( LDAP_EXOP_MODIFY_PASSWD );
- rc = backend_check_restrictions( be, conn, op, &passwd, text );
+ rc = backend_check_restrictions( be, conn, op, &slap_EXOP_MODIFY_PASSWD, text );
}
if( rc != LDAP_SUCCESS ) {
/*
* extended.c
*/
+#ifdef LDAP_EXOP_X_CANCEL
+const struct berval slap_EXOP_CANCEL;
+#endif
+const struct berval slap_EXOP_WHOAMI;
+const struct berval slap_EXOP_MODIFY_PASSWD;
+const struct berval slap_EXOP_START_TLS;
+
typedef int (SLAP_EXTOP_MAIN_FN) LDAP_P((
Connection *conn, Operation *op,
- const char * reqoid,
+ struct berval * reqoid,
struct berval * reqdata,
char ** rspoid,
struct berval ** rspdata,
BerVarray *refs ));
typedef int (SLAP_EXTOP_GETOID_FN) LDAP_P((
- int index, char *oid, int blen ));
+ int index, struct berval *oid, int blen ));
LDAP_SLAPD_F (int) load_extop LDAP_P((
- const char *ext_oid,
+ struct berval *ext_oid,
SLAP_EXTOP_MAIN_FN *ext_main ));
LDAP_SLAPD_F (int) extops_init LDAP_P(( void ));
LDAP_SLAPD_F (int) slap_sasl_setpass(
Connection *conn,
Operation *op,
- const char *reqoid,
+ struct berval *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,
slap_sasl_setpass(
Connection *conn,
Operation *op,
- const char *reqoid,
+ struct berval *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,
struct berval old = { 0, NULL };
assert( reqoid != NULL );
- assert( strcmp( LDAP_EXOP_MODIFY_PASSWD, reqoid ) == 0 );
+ assert( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, reqoid ) == 0 );
rc = sasl_getprop( conn->c_sasl_context, SASL_USERNAME,
(SASL_CONST void **)&id.bv_val );
BackendDB *be,
struct slap_conn *conn,
struct slap_op *op,
- const char *reqoid,
+ struct berval *reqoid,
struct berval * reqdata,
char **rspoid,
struct berval ** rspdata,
starttls_extop (
Connection *conn,
Operation *op,
- const char * reqoid,
+ struct berval * reqoid,
struct berval * reqdata,
char ** rspoid,
struct berval ** rspdata,
int slap_sasl_setpass(
Connection *conn,
Operation *op,
- const char *reqoid,
+ struct berval *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,