From: Kurt Zeilenga Date: Mon, 21 Dec 1998 00:21:58 +0000 (+0000) Subject: LDAP C-API changes X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~905 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2d15a94d16ee417f6165c39dc71bdcf30b331774;p=openldap LDAP C-API changes struct friendly (Friendly) changed to ldap_friendly (LDAPFriendly) ldap_friendly friend prefix changed to 'lf_' from 'f_' removed mod_next field from LDAPMod (struct ldapmod) modified slapd to use new LDAPModList (struct ldapmodlist) struct. Added LDAPv3 result codes to ldap.h --- diff --git a/clients/ud/util.c b/clients/ud/util.c index a0bd849790..b75b5ff6f8 100644 --- a/clients/ud/util.c +++ b/clients/ud/util.c @@ -477,7 +477,7 @@ code_to_str( int i ) char * friendly_name( char *s ) { - static FriendlyMap *map = NULL; + static LDAPFriendlyMap *map = NULL; static char *cp; cp = ldap_friendly_name(FRIENDLYFILE, s, &map); diff --git a/doc/man/man3/ldap_friendly.3 b/doc/man/man3/ldap_friendly.3 index ac3d8674f2..88a2b382ee 100644 --- a/doc/man/man3/ldap_friendly.3 +++ b/doc/man/man3/ldap_friendly.3 @@ -8,22 +8,22 @@ ldap_friendly_name, ldap_free_friendlymap \- LDAP unfriendly to friendly name ma #include .LP .ft B -typedef struct friendly { - char *f_unfriendly; - char *f_friendly; -} FriendlyMap; +typedef struct ldap_friendly { + char *lf_unfriendly; + char *lf_friendly; +} LDAPFriendlyMap; .LP .ft B char *ldap_friendly_name(filename, name, map) .ft char *filename; char *name; -FriendlyMap **map; +LDAPFriendlyMap **map; .LP .ft B void ldap_free_friendlymap(map) .ft -FriendlyMap **map; +LDAPFriendlyMap **map; .SH DESCRIPTION This routine is used to map one set of strings to another. Typically, this is done for country names, to map from the two-letter country @@ -40,7 +40,7 @@ For example: .LP .nf .ft tt - FriendlyMap *map = NULL; + LDAPFriendlyMap *map = NULL; printf( "unfriendly %s => friendly %s\\n", name, ldap_friendly_name( "DATADIR/ldapfriendly", name, &map ) ); diff --git a/include/ldap.h b/include/ldap.h index 5fb02d29d0..0996e98d8a 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -59,22 +59,27 @@ LDAP_BEGIN_DECL #define LDAP_COMPAT #endif +/* LDAP_OPTions defined by draft-ldapext-ldap-c-api-01 */ #define LDAP_OPT_API_INFO 0x0000 #define LDAP_OPT_DESC 0x0001 #define LDAP_OPT_DEREF 0x0002 #define LDAP_OPT_SIZELIMIT 0x0003 #define LDAP_OPT_TIMELIMIT 0x0004 +/* 0x05 - 0x07 not defined by current draft */ #define LDAP_OPT_REFERRALS 0x0008 #define LDAP_OPT_RESTART 0x0009 +/* 0x0a - 0x10 not defined by current draft */ #define LDAP_OPT_PROTOCOL_VERSION 0x0011 #define LDAP_OPT_SERVER_CONTROLS 0x0012 #define LDAP_OPT_CLIENT_CONTROLS 0x0013 +/* 0x14 - 0x2f not defined by current draft */ #define LDAP_OPT_HOST_NAME 0x0030 #define LDAP_OPT_ERROR_NUMBER 0x0031 #define LDAP_OPT_ERROR_STRING 0x0032 -/* for LDAPv2 compatibility */ -#define LDAP_OPT_DNS 0x0101 /* use DN & DNS */ +/* not defined by current draft */ +/* for LDAPv2 compatibility */ +#define LDAP_OPT_DNS 0x1001 /* use DN & DNS */ /* on/off values */ #define LDAP_OPT_ON ((void *) 1) @@ -147,12 +152,14 @@ typedef struct ldapcontrol { /* possible result types a server can return */ #define LDAP_RES_BIND 0x61L /* application + constructed */ #define LDAP_RES_SEARCH_ENTRY 0x64L /* application + constructed */ +#define LDAP_RES_SEARCH_REFERENCE 0x73L /* V3: application + constructed */ #define LDAP_RES_SEARCH_RESULT 0x65L /* application + constructed */ #define LDAP_RES_MODIFY 0x67L /* application + constructed */ #define LDAP_RES_ADD 0x69L /* application + constructed */ #define LDAP_RES_DELETE 0x6bL /* application + constructed */ #define LDAP_RES_MODRDN 0x6dL /* application + constructed */ #define LDAP_RES_COMPARE 0x6fL /* application + constructed */ +#define LDAP_RES_EXTENDED 0x78L /* V3: application + constructed */ #define LDAP_RES_ANY (-1L) /* old broken stuff for backwards compatibility */ @@ -241,7 +248,6 @@ typedef struct ldapmod { } mod_vals; #define mod_values mod_vals.modv_strvals #define mod_bvalues mod_vals.modv_bvals - struct ldapmod *mod_next; } LDAPMod; /* @@ -449,10 +455,10 @@ typedef struct ldap LDAP; * structure for ldap friendly mapping routines */ -typedef struct friendly { - char *f_unfriendly; - char *f_friendly; -} FriendlyMap; +typedef struct ldap_friendly { + char *lf_unfriendly; + char *lf_friendly; +} LDAPFriendlyMap; /* @@ -691,8 +697,8 @@ LDAP_F void ldap_mods_free LDAP_P(( LDAPMod **mods, int freemods )); * in friendly.c */ LDAP_F char *ldap_friendly_name LDAP_P(( char *filename, char *uname, - FriendlyMap **map )); -LDAP_F void ldap_free_friendlymap LDAP_P(( FriendlyMap **map )); + LDAPFriendlyMap **map )); +LDAP_F void ldap_free_friendlymap LDAP_P(( LDAPFriendlyMap **map )); /* diff --git a/libraries/libldap/friendly.c b/libraries/libldap/friendly.c index 278c729cee..c07db1bd12 100644 --- a/libraries/libldap/friendly.c +++ b/libraries/libldap/friendly.c @@ -23,7 +23,7 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of #include "ldap-int.h" char * -ldap_friendly_name( char *filename, char *uname, FriendlyMap **map ) +ldap_friendly_name( char *filename, char *uname, LDAPFriendlyMap **map ) { int i, entries; FILE *fp; @@ -46,8 +46,8 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map ) } rewind( fp ); - if ( (*map = (FriendlyMap *) malloc( (entries + 1) * - sizeof(FriendlyMap) )) == NULL ) { + if ( (*map = (LDAPFriendlyMap *) malloc( (entries + 1) * + sizeof(LDAPFriendlyMap) )) == NULL ) { fclose( fp ); return( uname ); } @@ -83,35 +83,35 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map ) } } - (*map)[i].f_unfriendly = ldap_strdup( buf ); - (*map)[i].f_friendly = ldap_strdup( s ); + (*map)[i].lf_unfriendly = ldap_strdup( buf ); + (*map)[i].lf_friendly = ldap_strdup( s ); i++; } fclose( fp ); - (*map)[i].f_unfriendly = NULL; + (*map)[i].lf_unfriendly = NULL; } - for ( i = 0; (*map)[i].f_unfriendly != NULL; i++ ) { - if ( strcasecmp( uname, (*map)[i].f_unfriendly ) == 0 ) - return( (*map)[i].f_friendly ); + for ( i = 0; (*map)[i].lf_unfriendly != NULL; i++ ) { + if ( strcasecmp( uname, (*map)[i].lf_unfriendly ) == 0 ) + return( (*map)[i].lf_friendly ); } return( uname ); } void -ldap_free_friendlymap( FriendlyMap **map ) +ldap_free_friendlymap( LDAPFriendlyMap **map ) { - struct friendly* pF = *map; + LDAPFriendlyMap* pF = *map; if ( pF == NULL ) return; - while ( pF->f_unfriendly ) + while ( pF->lf_unfriendly ) { - free( pF->f_unfriendly ); - free( pF->f_friendly ); + free( pF->lf_unfriendly ); + free( pF->lf_friendly ); pF++; } free( *map ); diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 6e630ab14e..3afcda9f02 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -380,7 +380,7 @@ acl_access_allowed( } /* - * acl_check_mods - check access control on the given entry to see if + * acl_check_modlist - check access control on the given entry to see if * it allows the given modifications by the user associated with op. * returns LDAP_SUCCESS mods allowed ok * anything else mods not allowed - return is an error @@ -388,12 +388,12 @@ acl_access_allowed( */ int -acl_check_mods( +acl_check_modlist( Backend *be, Connection *conn, Operation *op, Entry *e, - LDAPMod *mods + LDAPModList *mlist ) { int i; @@ -402,31 +402,31 @@ acl_check_mods( edn = dn_normalize_case( ch_strdup( e->e_dn ) ); - for ( ; mods != NULL; mods = mods->mod_next ) { + for ( ; mlist != NULL; mlist = mlist->ml_next ) { regmatch_t matches[MAXREMATCHES]; /* the lastmod attributes are ignored by ACL checking */ - if ( strcasecmp( mods->mod_type, "modifiersname" ) == 0 || - strcasecmp( mods->mod_type, "modifytimestamp" ) == 0 || - strcasecmp( mods->mod_type, "creatorsname" ) == 0 || - strcasecmp( mods->mod_type, "createtimestamp" ) == 0 ) + if ( strcasecmp( mlist->ml_type, "modifiersname" ) == 0 || + strcasecmp( mlist->ml_type, "modifytimestamp" ) == 0 || + strcasecmp( mlist->ml_type, "creatorsname" ) == 0 || + strcasecmp( mlist->ml_type, "createtimestamp" ) == 0 ) { Debug( LDAP_DEBUG_ACL, "LASTMOD attribute: %s access allowed\n", - mods->mod_type, 0, 0 ); + mlist->ml_type, 0, 0 ); continue; } - a = acl_get_applicable( be, op, e, mods->mod_type, edn, + a = acl_get_applicable( be, op, e, mlist->ml_type, edn, MAXREMATCHES, matches ); - switch ( mods->mod_op & ~LDAP_MOD_BVALUES ) { + switch ( mlist->ml_op & ~LDAP_MOD_BVALUES ) { case LDAP_MOD_REPLACE: case LDAP_MOD_ADD: - if ( mods->mod_bvalues == NULL ) { + if ( mlist->ml_bvalues == NULL ) { break; } - for ( i = 0; mods->mod_bvalues[i] != NULL; i++ ) { - if ( ! acl_access_allowed( a, be, conn, e, mods->mod_bvalues[i], + for ( i = 0; mlist->ml_bvalues[i] != NULL; i++ ) { + if ( ! acl_access_allowed( a, be, conn, e, mlist->ml_bvalues[i], op, ACL_WRITE, edn, matches) ) { free(edn); @@ -436,7 +436,7 @@ acl_check_mods( break; case LDAP_MOD_DELETE: - if ( mods->mod_bvalues == NULL ) { + if ( mlist->ml_bvalues == NULL ) { if ( ! acl_access_allowed( a, be, conn, e, NULL, op, ACL_WRITE, edn, matches) ) { @@ -445,8 +445,8 @@ acl_check_mods( } break; } - for ( i = 0; mods->mod_bvalues[i] != NULL; i++ ) { - if ( ! acl_access_allowed( a, be, conn, e, mods->mod_bvalues[i], + for ( i = 0; mlist->ml_bvalues[i] != NULL; i++ ) { + if ( ! acl_access_allowed( a, be, conn, e, mlist->ml_bvalues[i], op, ACL_WRITE, edn, matches) ) { free(edn); diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index acb7844e8e..4fe0f98871 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -56,18 +56,20 @@ index_add_entry( int index_add_mods( Backend *be, - LDAPMod *mods, + LDAPModList *ml, ID id ) { int rc; - for ( ; mods != NULL; mods = mods->mod_next ) { - switch ( mods->mod_op & ~LDAP_MOD_BVALUES ) { + for ( ; ml != NULL; ml = ml->ml_next ) { + LDAPMod *mod = &ml->ml_mod; + + switch ( mod->mod_op & ~LDAP_MOD_BVALUES ) { case LDAP_MOD_ADD: case LDAP_MOD_REPLACE: - rc = index_add_values( be, mods->mod_type, - mods->mod_bvalues, id ); + rc = index_add_values( be, mod->mod_type, + mod->mod_bvalues, id ); break; case LDAP_MOD_DELETE: diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 2f74c108f1..16aeee9d4c 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -21,14 +21,14 @@ ldbm_back_modify( Connection *conn, Operation *op, char *dn, - LDAPMod *mods + LDAPModList *modlist ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; char *matched; + LDAPModList *ml; Entry *e; int i, err; - LDAPMod *mod; Debug(LDAP_DEBUG_ARGS, "ldbm_back_modify:\n", 0, 0, 0); @@ -45,12 +45,14 @@ ldbm_back_modify( /* lock entry */ - if ( (err = acl_check_mods( be, conn, op, e, mods )) != LDAP_SUCCESS ) { + if ( (err = acl_check_modlist( be, conn, op, e, modlist )) != LDAP_SUCCESS ) { send_ldap_result( conn, op, err, NULL, NULL ); goto error_return; } - for ( mod = mods; mod != NULL; mod = mod->mod_next ) { + for ( ml = modlist; ml != NULL; ml = ml->ml_next ) { + LDAPMod *mod = &ml->ml_mod; + switch ( mod->mod_op & ~LDAP_MOD_BVALUES ) { case LDAP_MOD_ADD: err = add_values( e, mod, op->o_dn ); @@ -88,7 +90,7 @@ ldbm_back_modify( pthread_mutex_unlock( &op->o_abandonmutex ); /* modify indexes */ - if ( index_add_mods( be, mods, e->e_id ) != 0 ) { + if ( index_add_mods( be, modlist, e->e_id ) != 0 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL ); goto error_return; } diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index b51691eb4c..c5d8ce936a 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -109,7 +109,7 @@ ID idl_nextid LDAP_P(( IDList *idl, ID id )); */ int index_add_entry LDAP_P(( Backend *be, Entry *e )); -int index_add_mods LDAP_P(( Backend *be, LDAPMod *mods, ID id )); +int index_add_mods LDAP_P(( Backend *be, LDAPModList *ml, ID id )); IDList * index_read LDAP_P(( Backend *be, char *type, int indextype, char *val )); int index_add_values LDAP_P(( Backend *be, char *type, struct berval **vals, ID id )); diff --git a/servers/slapd/back-shell/modify.c b/servers/slapd/back-shell/modify.c index 034830b649..3fee57bff8 100644 --- a/servers/slapd/back-shell/modify.c +++ b/servers/slapd/back-shell/modify.c @@ -16,7 +16,7 @@ shell_back_modify( Connection *conn, Operation *op, char *dn, - LDAPMod *mods + LDAPModList *ml ) { struct shellinfo *si = (struct shellinfo *) be->be_private; @@ -41,25 +41,25 @@ shell_back_modify( fprintf( wfp, "msgid: %ld\n", op->o_msgid ); print_suffixes( wfp, be ); fprintf( wfp, "dn: %s\n", dn ); - for ( ; mods != NULL; mods = mods->mod_next ) { - switch ( mods->mod_op & ~LDAP_MOD_BVALUES ) { + for ( ; ml != NULL; ml = ml->ml_next ) { + switch ( ml->ml_op & ~LDAP_MOD_BVALUES ) { case LDAP_MOD_ADD: - fprintf( wfp, "add: %s\n", mods->mod_type ); + fprintf( wfp, "add: %s\n", ml->ml_type ); break; case LDAP_MOD_DELETE: - fprintf( wfp, "delete: %s\n", mods->mod_type ); + fprintf( wfp, "delete: %s\n", ml->ml_type ); break; case LDAP_MOD_REPLACE: - fprintf( wfp, "replace: %s\n", mods->mod_type ); + fprintf( wfp, "replace: %s\n", ml->ml_type ); break; } - for ( i = 0; mods->mod_bvalues != NULL && mods->mod_bvalues[i] + for ( i = 0; ml->ml_bvalues != NULL && ml->ml_bvalues[i] != NULL; i++ ) { - fprintf( wfp, "%s: %s\n", mods->mod_type, - mods->mod_bvalues[i]->bv_val ); + fprintf( wfp, "%s: %s\n", ml->ml_type, + ml->ml_bvalues[i]->bv_val ); } } fclose( wfp ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 142fa8da99..7c18f43c4a 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -20,8 +20,8 @@ #include "slap.h" -static void modlist_free(LDAPMod *mods); -static void add_lastmods(Operation *op, LDAPMod **mods); +static void modlist_free(LDAPModList *ml); +static void add_lastmods(Operation *op, LDAPModList **ml); void @@ -33,8 +33,8 @@ do_modify( char *dn, *odn; char *last; unsigned long tag, len; - LDAPMod *mods, *tmp; - LDAPMod **modtail; + LDAPModList *modlist, *tmp; + LDAPModList **modtail; Backend *be; Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 ); @@ -58,7 +58,7 @@ do_modify( * } */ - if ( ber_scanf( op->o_ber, "{a", &dn ) == LBER_ERROR ) { + if ( ber_scanf( op->o_ber, "{a" /*}*/, &dn ) == LBER_ERROR ) { Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 ); send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" ); return; @@ -69,16 +69,17 @@ do_modify( Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn, 0, 0 ); /* collect modifications & save for later */ - mods = NULL; - modtail = &mods; + modlist = NULL; + modtail = &modlist; + for ( tag = ber_first_element( op->o_ber, &len, &last ); tag != LBER_DEFAULT; tag = ber_next_element( op->o_ber, &len, last ) ) { - (*modtail) = (LDAPMod *) ch_calloc( 1, sizeof(LDAPMod) ); + (*modtail) = (LDAPModList *) ch_calloc( 1, sizeof(LDAPModList) ); - if ( ber_scanf( op->o_ber, "{i{a[V]}}", &(*modtail)->mod_op, - &(*modtail)->mod_type, &(*modtail)->mod_bvalues ) + if ( ber_scanf( op->o_ber, "{i{a[V]}}", &(*modtail)->ml_op, + &(*modtail)->ml_type, &(*modtail)->ml_bvalues ) == LBER_ERROR ) { send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, @@ -86,43 +87,45 @@ do_modify( free( dn ); free( odn ); free( *modtail ); - modlist_free( mods ); + modlist_free( modlist ); return; } - if ( (*modtail)->mod_op != LDAP_MOD_ADD && - (*modtail)->mod_op != LDAP_MOD_DELETE && - (*modtail)->mod_op != LDAP_MOD_REPLACE ) + if ( (*modtail)->ml_op != LDAP_MOD_ADD && + (*modtail)->ml_op != LDAP_MOD_DELETE && + (*modtail)->ml_op != LDAP_MOD_REPLACE ) { send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "unrecognized modify operation" ); free( dn ); free( odn ); - modlist_free( mods ); + modlist_free( modlist ); return; } - if ( (*modtail)->mod_bvalues == NULL && (*modtail)->mod_op - != LDAP_MOD_DELETE ) { + if ( (*modtail)->ml_bvalues == NULL + && (*modtail)->ml_op != LDAP_MOD_DELETE ) + { send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "no values given" ); free( dn ); free( odn ); - modlist_free( mods ); + modlist_free( modlist ); return; } - attr_normalize( (*modtail)->mod_type ); + attr_normalize( (*modtail)->ml_type ); - modtail = &(*modtail)->mod_next; + modtail = &(*modtail)->ml_next; } *modtail = NULL; #ifdef LDAP_DEBUG Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 ); - for ( tmp = mods; tmp != NULL; tmp = tmp->mod_next ) { - Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n", tmp->mod_op - == LDAP_MOD_ADD ? "add" : (tmp->mod_op == LDAP_MOD_DELETE ? - "delete" : "replace"), tmp->mod_type, 0 ); + for ( tmp = modlist; tmp != NULL; tmp = tmp->ml_next ) { + Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n", + tmp->ml_op == LDAP_MOD_ADD + ? "add" : (tmp->ml_op == LDAP_MOD_DELETE + ? "delete" : "replace"), tmp->ml_type, 0 ); } #endif @@ -137,7 +140,7 @@ do_modify( if ( (be = select_backend( dn )) == NULL ) { free( dn ); free( odn ); - modlist_free( mods ); + modlist_free( modlist ); send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL, default_referral ); return; @@ -159,10 +162,10 @@ do_modify( if ( (be->be_lastmod == ON || ( be->be_lastmod == UNDEFINED && global_lastmod == ON ) ) && be->be_updatedn == NULL ) { - add_lastmods( op, &mods ); + add_lastmods( op, &modlist ); } - if ( (*be->be_modify)( be, conn, op, odn, mods ) == 0 ) { - replog( be, LDAP_REQ_MODIFY, dn, mods, 0 ); + if ( (*be->be_modify)( be, conn, op, odn, modlist ) == 0 ) { + replog( be, LDAP_REQ_MODIFY, dn, modlist, 0 ); } /* send a referral */ @@ -177,33 +180,35 @@ do_modify( free( dn ); free( odn ); - modlist_free( mods ); + modlist_free( modlist ); } static void modlist_free( - LDAPMod *mods + LDAPModList *ml ) { - LDAPMod *next; - - for ( ; mods != NULL; mods = next ) { - next = mods->mod_next; - free( mods->mod_type ); - if ( mods->mod_bvalues != NULL ) - ber_bvecfree( mods->mod_bvalues ); - free( mods ); + LDAPModList *next; + + for ( ; ml != NULL; ml = next ) { + next = ml->ml_next; + + free( ml->ml_type ); + if ( ml->ml_bvalues != NULL ) + ber_bvecfree( ml->ml_bvalues ); + + free( ml ); } } static void -add_lastmods( Operation *op, LDAPMod **mods ) +add_lastmods( Operation *op, LDAPModList **modlist ) { char buf[22]; struct berval bv; struct berval *bvals[2]; - LDAPMod **m; - LDAPMod *tmp; + LDAPModList **m; + LDAPModList *tmp; struct tm *ltm; Debug( LDAP_DEBUG_TRACE, "add_lastmods\n", 0, 0, 0 ); @@ -212,20 +217,20 @@ add_lastmods( Operation *op, LDAPMod **mods ) bvals[1] = NULL; /* remove any attempts by the user to modify these attrs */ - for ( m = mods; *m != NULL; m = &(*m)->mod_next ) { - if ( strcasecmp( (*m)->mod_type, "modifytimestamp" ) == 0 || - strcasecmp( (*m)->mod_type, "modifiersname" ) == 0 || - strcasecmp( (*m)->mod_type, "createtimestamp" ) == 0 || - strcasecmp( (*m)->mod_type, "creatorsname" ) == 0 ) { + for ( m = modlist; *m != NULL; m = &(*m)->ml_next ) { + if ( strcasecmp( (*m)->ml_type, "modifytimestamp" ) == 0 || + strcasecmp( (*m)->ml_type, "modifiersname" ) == 0 || + strcasecmp( (*m)->ml_type, "createtimestamp" ) == 0 || + strcasecmp( (*m)->ml_type, "creatorsname" ) == 0 ) { Debug( LDAP_DEBUG_TRACE, "add_lastmods: found lastmod attr: %s\n", - (*m)->mod_type, 0, 0 ); + (*m)->ml_type, 0, 0 ); tmp = *m; - *m = (*m)->mod_next; - free( tmp->mod_type ); - if ( tmp->mod_bvalues != NULL ) { - ber_bvecfree( tmp->mod_bvalues ); + *m = (*m)->ml_next; + free( tmp->ml_type ); + if ( tmp->ml_bvalues != NULL ) { + ber_bvecfree( tmp->ml_bvalues ); } free( tmp ); if (!*m) @@ -240,14 +245,14 @@ add_lastmods( Operation *op, LDAPMod **mods ) bv.bv_val = op->o_dn; bv.bv_len = strlen( bv.bv_val ); } - tmp = (LDAPMod *) ch_calloc( 1, sizeof(LDAPMod) ); - tmp->mod_type = ch_strdup( "modifiersname" ); - tmp->mod_op = LDAP_MOD_REPLACE; - tmp->mod_bvalues = (struct berval **) ch_calloc( 1, + tmp = (LDAPModList *) ch_calloc( 1, sizeof(LDAPModList) ); + tmp->ml_type = ch_strdup( "modifiersname" ); + tmp->ml_op = LDAP_MOD_REPLACE; + tmp->ml_bvalues = (struct berval **) ch_calloc( 1, 2 * sizeof(struct berval *) ); - tmp->mod_bvalues[0] = ber_bvdup( &bv ); - tmp->mod_next = *mods; - *mods = tmp; + tmp->ml_bvalues[0] = ber_bvdup( &bv ); + tmp->ml_next = *modlist; + *modlist = tmp; pthread_mutex_lock( ¤ttime_mutex ); #ifndef LDAP_LOCALTIME @@ -260,11 +265,11 @@ add_lastmods( Operation *op, LDAPMod **mods ) pthread_mutex_unlock( ¤ttime_mutex ); bv.bv_val = buf; bv.bv_len = strlen( bv.bv_val ); - tmp = (LDAPMod *) ch_calloc( 1, sizeof(LDAPMod) ); - tmp->mod_type = ch_strdup( "modifytimestamp" ); - tmp->mod_op = LDAP_MOD_REPLACE; - tmp->mod_bvalues = (struct berval **) ch_calloc( 1, 2 * sizeof(struct berval *) ); - tmp->mod_bvalues[0] = ber_bvdup( &bv ); - tmp->mod_next = *mods; - *mods = tmp; + tmp = (LDAPModList *) ch_calloc( 1, sizeof(LDAPModList) ); + tmp->ml_type = ch_strdup( "modifytimestamp" ); + tmp->ml_op = LDAP_MOD_REPLACE; + tmp->ml_bvalues = (struct berval **) ch_calloc( 1, 2 * sizeof(struct berval *) ); + tmp->ml_bvalues[0] = ber_bvdup( &bv ); + tmp->ml_next = *modlist; + *modlist = tmp; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index cc9229e664..2d26a5cb4e 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -16,8 +16,11 @@ int acl_access_allowed LDAP_P(( struct acl *a, Backend *be, Connection *conn, En struct berval *val, Operation *op, int access, char *edn, regmatch_t *matches )); -int acl_check_mods LDAP_P(( Backend *be, Connection *conn, Operation *op, Entry *e, - LDAPMod *mods )); +int acl_check_modlist LDAP_P(( Backend *be, + Connection *conn, + Operation *op, + Entry *e, + LDAPModList *ml )); /* * aclparse.c @@ -281,7 +284,7 @@ extern int ldbm_back_bind LDAP_P((Backend *be, Connection *c, Operation *o, c extern void ldbm_back_unbind LDAP_P((Backend *be, Connection *c, Operation *o )); extern int ldbm_back_search LDAP_P((Backend *be, Connection *c, Operation *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly)); extern int ldbm_back_compare LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, Ava *ava)); -extern int ldbm_back_modify LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, LDAPMod *m)); +extern int ldbm_back_modify LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, LDAPModList *ml)); extern int ldbm_back_modrdn LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, char *newrdn, int deleteoldrdn )); extern int ldbm_back_add LDAP_P((Backend *be, Connection *c, Operation *o, Entry *e)); extern int ldbm_back_delete LDAP_P((Backend *be, Connection *c, Operation *o, char *dn)); @@ -302,7 +305,7 @@ extern int shell_back_bind LDAP_P((Backend *be, Connection *c, Operation *o, extern void shell_back_unbind LDAP_P((Backend *be, Connection *c, Operation *o )); extern int shell_back_search LDAP_P((Backend *be, Connection *c, Operation *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly)); extern int shell_back_compare LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, Ava *ava)); -extern int shell_back_modify LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, LDAPMod *m)); +extern int shell_back_modify LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, LDAPModList *m)); extern int shell_back_modrdn LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, char *newrdn, int deleteoldrdn )); extern int shell_back_add LDAP_P((Backend *be, Connection *c, Operation *o, Entry *e)); extern int shell_back_delete LDAP_P((Backend *be, Connection *c, Operation *o, char *dn)); diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index 0961e30f25..f0f8818a3c 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -22,7 +22,7 @@ replog( int flag ) { - LDAPMod *mods; + LDAPModList *ml; Entry *e; char *newrdn, *tmp; int deleteoldrdn; @@ -50,35 +50,35 @@ replog( switch ( optype ) { case LDAP_REQ_MODIFY: fprintf( fp, "changetype: modify\n" ); - mods = change; - for ( ; mods != NULL; mods = mods->mod_next ) { - switch ( mods->mod_op & ~LDAP_MOD_BVALUES ) { + ml = change; + for ( ; ml != NULL; ml = ml->ml_next ) { + switch ( ml->ml_op & ~LDAP_MOD_BVALUES ) { case LDAP_MOD_ADD: - fprintf( fp, "add: %s\n", mods->mod_type ); + fprintf( fp, "add: %s\n", ml->ml_type ); break; case LDAP_MOD_DELETE: - fprintf( fp, "delete: %s\n", mods->mod_type ); + fprintf( fp, "delete: %s\n", ml->ml_type ); break; case LDAP_MOD_REPLACE: - fprintf( fp, "replace: %s\n", mods->mod_type ); + fprintf( fp, "replace: %s\n", ml->ml_type ); break; } - for ( i = 0; mods->mod_bvalues != NULL && - mods->mod_bvalues[i] != NULL; i++ ) { + for ( i = 0; ml->ml_bvalues != NULL && + ml->ml_bvalues[i] != NULL; i++ ) { char *buf, *bufp; - len = strlen( mods->mod_type ); + len = strlen( ml->ml_type ); len = LDIF_SIZE_NEEDED( len, - mods->mod_bvalues[i]->bv_len ) + 1; + ml->ml_bvalues[i]->bv_len ) + 1; buf = (char *) ch_malloc( len ); bufp = buf; - ldif_put_type_and_value( &bufp, mods->mod_type, - mods->mod_bvalues[i]->bv_val, - mods->mod_bvalues[i]->bv_len ); + ldif_put_type_and_value( &bufp, ml->ml_type, + ml->ml_bvalues[i]->bv_val, + ml->ml_bvalues[i]->bv_len ); *bufp = '\0'; fputs( buf, fp ); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 929e400d6e..e7c2dd2ffd 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -178,6 +178,18 @@ struct acl { struct acl *acl_next; }; +/* + * A list of LDAPMods + */ +typedef struct ldapmodlist { + struct ldapmod ml_mod; + struct ldapmodlist *ml_next; +#define ml_op ml_mod.mod_op +#define ml_type ml_mod.mod_type +#define ml_values ml_mod.mod_values +#define ml_bvalues ml_mod.mod_bvalues +} LDAPModList; + /* * represents schema information for a database */ @@ -218,7 +230,7 @@ struct backend { void (*be_unbind) LDAP_P((Backend *be, struct conn *c, struct op *o )); int (*be_search) LDAP_P((Backend *be, struct conn *c, struct op *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly)); int (*be_compare)LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, Ava *ava)); - int (*be_modify) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, LDAPMod *m)); + int (*be_modify) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, LDAPModList *m)); int (*be_modrdn) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, char *newrdn, int deleteoldrdn )); int (*be_add) LDAP_P((Backend *be, struct conn *c, struct op *o, Entry *e)); int (*be_delete) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn));