From 48d47954a611a8658b88c9b1a802ffe247f1c7a5 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 8 Feb 2003 21:53:05 +0000 Subject: [PATCH] Rework #ifdef'ing of expermental controls to ease release engineering using LDAP_DEVEL (to indicate experimental) to enable experimental features (true for HEAD unless LDAP_REL_ENG is defined) --- acconfig.h | 5 ++ clients/tools/ldapsearch.c | 41 ++++++++--- include/ldap.h | 124 +++++++++++++++----------------- include/portable.h.in | 5 ++ libraries/libldap/cancel.c | 4 ++ libraries/libldap/error.c | 24 ++++--- libraries/libldap/extended.c | 2 + libraries/libldap/result.c | 7 +- servers/slapd/back-bdb/init.c | 2 + servers/slapd/back-bdb/modify.c | 12 ++-- servers/slapd/back-bdb/search.c | 19 +++-- servers/slapd/backend.c | 2 + servers/slapd/cancel.c | 3 + servers/slapd/connection.c | 14 +++- servers/slapd/controls.c | 62 ++++++++++++---- servers/slapd/extended.c | 24 ++++--- servers/slapd/init.c | 50 ------------- servers/slapd/result.c | 6 ++ servers/slapd/root_dse.c | 6 +- servers/slapd/slap.h | 35 ++++++--- 20 files changed, 263 insertions(+), 184 deletions(-) diff --git a/acconfig.h b/acconfig.h index 42ae54b229..a076b059c7 100644 --- a/acconfig.h +++ b/acconfig.h @@ -88,12 +88,17 @@ # include #endif +#ifndef LDAP_REL_ENG +#if (LDAP_VENDOR_VERSION == 000000) && !defined(LDAP_DEVEL) +#define LDAP_DEVEL +#endif #if defined(LDAP_DEVEL) && !defined(LDAP_TEST) #define LDAP_TEST #endif #if defined(LDAP_TEST) && !defined(LDAP_DEBUG) #define LDAP_DEBUG #endif +#endif #ifdef HAVE_EBCDIC /* ASCII/EBCDIC converting replacements for stdio funcs diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index b191671787..e65ca0ca36 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -65,7 +65,9 @@ usage( void ) " -b basedn base dn for search\n" " -E [!][=] search controls (! indicates criticality)\n" " [!]mv= (matched values filter)\n" +#ifdef LDAP_CONTROL_PAGEDRESULTS " [!]pr= (paged results)\n" +#endif #ifdef LDAP_CONTROL_SUBENTRIES " [!]subentries[=true|false] (subentries)\n" #endif @@ -167,6 +169,7 @@ static struct berval sync_cookie = { 0, NULL }; static int sync_slimit = -1; #endif +#ifdef LDAP_CONTROL_PAGEDRESULTS static int pagedResults = 0; static ber_int_t pageSize = 0; static ber_int_t entriesLeft = 0; @@ -182,6 +185,7 @@ static int parse_page_control( LDAP *ld, LDAPMessage *result, struct berval *cookie ); +#endif static void urlize(char *url) @@ -266,6 +270,7 @@ handle_private_option( int i ) vrFilter = cvalue; protocol = LDAP_VERSION3; +#ifdef LDAP_CONTROL_PAGEDRESULTS } else if ( strcasecmp( control, "pr" ) == 0 ) { int num, tmp; /* PagedResults control */ @@ -283,6 +288,7 @@ handle_private_option( int i ) pageSize = (ber_int_t) tmp; pagedResults = 1 + crit; +#endif #ifdef LDAP_CONTROL_SUBENTRIES } else if ( strcasecmp( control, "subentries" ) == 0 ) { if( subentries ) { @@ -508,8 +514,10 @@ main( int argc, char **argv ) struct berval *syncbvalp = NULL; #endif +#ifdef LDAP_CONTROL_PAGEDRESULTS npagedresponses = npagedentries = npagedreferences = npagedextended = npagedpartial = 0; +#endif prog = lutil_progname( "ldapsearch", argc, argv ); @@ -600,8 +608,10 @@ main( int argc, char **argv ) tool_bind( ld ); getNextPage: - if ( manageDSAit || noop || subentries - || valuesReturnFilter || pageSize + if ( manageDSAit || noop || subentries || valuesReturnFilter +#ifdef LDAP_CONTROL_PAGEDRESULTS + || pageSize +#endif #ifdef LDAP_CLIENT_UPDATE || lcup #endif @@ -716,6 +726,7 @@ getNextPage: i++; } +#ifdef LDAP_CONTROL_PAGEDRESULTS if ( pagedResults ) { if (( prber = ber_alloc_t(LBER_USE_DER)) == NULL ) { return EXIT_FAILURE; @@ -730,6 +741,7 @@ getNextPage: c[i].ldctl_iscritical = pagedResults > 1; i++; } +#endif tool_server_controls( ld, c, i ); @@ -796,11 +808,13 @@ getNextPage: printf("\n# with valuesReturnFilter %scontrol: %s", valuesReturnFilter > 1 ? "critical " : "", vrFilter ); } +#ifdef LDAP_CONTROL_PAGEDRESULTS if ( pageSize ) { printf("\n# with pagedResults %scontrol: size=%d", (pagedResults > 1) ? "critical " : "", pageSize ); } +#endif printf( "\n#\n\n" ); } @@ -827,7 +841,8 @@ getNextPage: } } - if ( ( pageSize != 0 ) && ( morePagedResults != 0 ) ) { +#ifdef LDAP_CONTROL_PAGEDRESULTS + if ( ( pageSize != 0 ) && ( morePagedResults != 0 ) ) { char buf[6]; int i, moreEntries, tmpSize; @@ -862,6 +877,7 @@ getNextPage: goto getNextPage; } +#endif ldap_unbind( ld ); return( rc ); @@ -996,9 +1012,11 @@ static int dosearch( case LDAP_RES_SEARCH_RESULT: rc = print_result( ld, msg, 1 ); +#ifdef LDAP_CONTROL_PAGEDRESULTS if ( pageSize != 0 ) { rc = parse_page_control( ld, msg, &cookie ); } +#endif #ifdef LDAP_CLIENT_UPDATE if ( lcup == LDAP_CUP_PERSIST_ONLY || @@ -1067,6 +1085,7 @@ static int dosearch( } done: +#ifdef LDAP_CONTROL_PAGEDRESULTS if ( pageSize != 0 ) { npagedresponses = npagedresponses + nresponses; npagedentries = npagedentries + nentries; @@ -1080,7 +1099,9 @@ done: if( npartial ) printf( "# numPartial: %d\n", npagedpartial ); if( nreferences ) printf( "# numReferences: %d\n", npagedreferences ); } - } else if ( ldif < 2 ) { + } else +#endif + if ( ldif < 2 ) { printf( "\n# numResponses: %d\n", nresponses ); if( nentries ) printf( "# numEntries: %d\n", nentries ); if( nextended ) printf( "# numExtended: %d\n", nextended ); @@ -1583,6 +1604,7 @@ write_ldif( int type, char *name, char *value, ber_len_t vallen ) } +#ifdef LDAP_CONTROL_PAGEDRESULTS static int parse_page_control( LDAP *ld, @@ -1597,7 +1619,6 @@ parse_page_control( ber_tag_t tag; struct berval servercookie = { 0, NULL }; - rc = ldap_parse_result( ld, result, &err, NULL, NULL, NULL, &ctrl, 0 ); @@ -1616,6 +1637,7 @@ parse_page_control( * size INTEGER (0..maxInt), * -- result set size estimate from server - unused * cookie OCTET STRING + * } */ ctrlp = *ctrl; ber = ber_init( &ctrlp->ldctl_value ); @@ -1629,20 +1651,23 @@ parse_page_control( (void) ber_free( ber, 1 ); if( tag == LBER_ERROR ) { - fprintf( stderr, "Paged results response control could not be decoded.\n" ); + fprintf( stderr, + "Paged results response control could not be decoded.\n" ); return EXIT_FAILURE; } if( entriesLeft < 0 ) { - fprintf( stderr, "Invalid entries estimate in paged results response.\n" ); + fprintf( stderr, + "Invalid entries estimate in paged results response.\n" ); return EXIT_FAILURE; } - ldap_controls_free( ctrl ); + } else { morePagedResults = 0; } return err; } +#endif diff --git a/include/ldap.h b/include/ldap.h index 827e6c749f..f30a60ee1a 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -143,7 +143,6 @@ LDAP_BEGIN_DECL #define LDAP_OPT_X_SASL_SSF_MAX 0x6108 #define LDAP_OPT_X_SASL_MAXBUFSIZE 0x6109 - /* on/off values */ #define LDAP_OPT_ON ((void *) 1) #define LDAP_OPT_OFF ((void *) 0) @@ -181,18 +180,11 @@ typedef struct ldapcontrol { } LDAPControl; /* LDAP Controls */ - -#if 0 - /* chase referrals client control (not yet implemented) */ -#define LDAP_CONTROL_REFERRALS "1.2.840.113666.1.4.616" -#define LDAP_CHASE_SUBORDINATE_REFERRALS 0x0020U -#define LDAP_CHASE_EXTERNAL_REFERRALS 0x0040U -#endif - -#define LDAP_CONTROL_PROXY_AUTHZ "2.16.840.1.113730.3.4.18" -#define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" +#define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.334810.2.3" #define LDAP_CONTROL_SUBENTRIES "1.3.6.1.4.1.4203.1.10.1" #define LDAP_CONTROL_NOOP "1.3.6.1.4.1.4203.1.10.2" +#define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" +#define LDAP_CONTROL_PROXY_AUTHZ "2.16.840.1.113730.3.4.18" #if 0 #define LDAP_CONTROL_DUPENT_REQUEST "2.16.840.1.113719.1.27.101.1" @@ -201,12 +193,14 @@ typedef struct ldapcontrol { #define LDAP_CONTROL_DUPENT LDAP_CONTROL_DUPENT_REQUEST #endif +#ifdef LDAP_DEVEL #define LDAP_CONTROL_PAGEDRESULTS "1.2.840.113556.1.4.319" +#endif -/* +#ifdef LDAP_DEVEL #define LDAP_CLIENT_UPDATE 1 #define LDAP_SYNC 2 -*/ +#endif #ifdef LDAP_CLIENT_UPDATE #define LDAP_CONTROL_CLIENT_UPDATE "1.3.6.1.4.1.4203.666.5.3" @@ -235,10 +229,10 @@ typedef struct ldapcontrol { #define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9" #define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10" -#define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.334810.2.3" - +#ifdef LDAP_DEVEL #define LDAP_CONTROL_PERMITMODIFY "1.2.840.113556.1.4.1413" #define LDAP_CONTROL_NOREFERRALS "1.2.840.113556.1.4.1339" +#endif /* LDAP Unsolicited Notifications */ #define LDAP_NOTICE_OF_DISCONNECTION "1.3.6.1.4.1.1466.20036" @@ -253,7 +247,9 @@ typedef struct ldapcontrol { #define LDAP_TAG_EXOP_MODIFY_PASSWD_NEW ((ber_tag_t) 0x82U) #define LDAP_TAG_EXOP_MODIFY_PASSWD_GEN ((ber_tag_t) 0x80U) +#ifdef LDAP_DEVEL #define LDAP_EXOP_X_CANCEL "1.3.6.1.4.1.4203.666.6.3" +#endif #define LDAP_EXOP_X_WHO_AM_I "1.3.6.1.4.1.4203.1.11.3" /* LDAP Features */ @@ -288,21 +284,9 @@ typedef struct ldapcontrol { #define LDAP_TAG_MESSAGE ((ber_tag_t) 0x30U) /* constructed + 16 */ #define LDAP_TAG_MSGID ((ber_tag_t) 0x02U) /* integer */ -#ifdef LDAP_CLIENT_UPDATE -#define LDAP_TAG_INTERVAL ((ber_tag_t) 0x02U) /* integer */ -#endif /* LDAP_CLIENT_UPDATE */ - #define LDAP_TAG_LDAPDN ((ber_tag_t) 0x04U) /* octet string */ #define LDAP_TAG_LDAPCRED ((ber_tag_t) 0x04U) /* octet string */ -#ifdef LDAP_CLIENT_UPDATE -#define LDAP_LCUP_TAG_COOKIE ((ber_tag_t) 0x30U) /* sequence */ -#endif - -#ifdef LDAP_SYNC -#define LDAP_SYNC_TAG_COOKIE ((ber_tag_t) 0x04U) /* octet string */ -#endif - #define LDAP_TAG_CONTROLS ((ber_tag_t) 0xa0U) /* context specific + constructed + 0 */ #define LDAP_TAG_REFERRAL ((ber_tag_t) 0xa3U) /* context specific + constructed + 3 */ @@ -315,6 +299,15 @@ typedef struct ldapcontrol { #define LDAP_TAG_SASL_RES_CREDS ((ber_tag_t) 0x87U) /* context specific + primitive */ +#ifdef LDAP_CLIENT_UPDATE +#define LDAP_TAG_INTERVAL ((ber_tag_t) 0x02U) /* integer */ +#define LDAP_LCUP_TAG_COOKIE ((ber_tag_t) 0x30U) /* sequence */ +#endif + +#ifdef LDAP_SYNC +#define LDAP_SYNC_TAG_COOKIE ((ber_tag_t) 0x04U) /* octet string */ +#endif + /* possible operations a client can invoke */ #define LDAP_REQ_BIND ((ber_tag_t) 0x60U) /* application + constructed */ @@ -344,7 +337,9 @@ typedef struct ldapcontrol { #define LDAP_RES_COMPARE ((ber_tag_t) 0x6fU) /* application + constructed */ #define LDAP_RES_EXTENDED ((ber_tag_t) 0x78U) /* V3: application + constructed */ #define LDAP_RES_EXTENDED_PARTIAL ((ber_tag_t) 0x79U) /* V3+: application + constructed */ +#ifdef LDAP_DEVEL #define LDAP_RES_INTERMEDIATE_RESP ((ber_tag_t) 0x7aU) +#endif #define LDAP_RES_ANY (-1) #define LDAP_RES_UNSOLICITED (0) @@ -493,31 +488,33 @@ typedef struct ldapcontrol { #ifdef LDAP_CLIENT_UPDATE /* resultCode for LCUP */ -#define LDAP_CUP_RESOURCES_EXHAUSTED 0x62 -#define LDAP_CUP_SECURITY_VIOLATION 0x63 -#define LDAP_CUP_INVALID_COOKIE 0x64 -#define LDAP_CUP_UNSUPPORTED_SCHEME 0x65 -#define LDAP_CUP_CLIENT_DISCONNECT 0x66 -#define LDAP_CUP_RELOAD_REQUIRED 0x67 +#define LDAP_CUP_RESOURCES_EXHAUSTED 0x100 +#define LDAP_CUP_SECURITY_VIOLATION 0x101 +#define LDAP_CUP_INVALID_COOKIE 0x102 +#define LDAP_CUP_UNSUPPORTED_SCHEME 0x103 +#define LDAP_CUP_CLIENT_DISCONNECT 0x104 +#define LDAP_CUP_RELOAD_REQUIRED 0x105 #endif +#ifdef LDAP_EXOP_X_CANCEL /* resultCode for Cancel Response */ -#define LDAP_CANCELLED 0x68 -#define LDAP_NO_SUCH_OPERATION 0x69 -#define LDAP_TOO_LATE 0x6a -#define LDAP_CANNOT_CANCEL 0x6b - -#define LDAP_CANCEL_NONE 0x00 -#define LDAP_CANCEL_REQ 0x01 -#define LDAP_CANCEL_ACK 0x02 -#define LDAP_CANCEL_DONE 0x03 +#define LDAP_CANCELLED 0x110 +#define LDAP_NO_SUCH_OPERATION 0x111 +#define LDAP_TOO_LATE 0x112 +#define LDAP_CANNOT_CANCEL 0x113 + +#define LDAP_CANCEL_NONE 0x00 +#define LDAP_CANCEL_REQ 0x01 +#define LDAP_CANCEL_ACK 0x02 +#define LDAP_CANCEL_DONE 0x03 +#endif #ifdef LDAP_CLIENT_UPDATE /* LCUP update type */ -#define LDAP_CUP_NONE 0x00 -#define LDAP_CUP_SYNC_ONLY 0x01 -#define LDAP_CUP_PERSIST_ONLY 0x02 -#define LDAP_CUP_SYNC_AND_PERSIST 0x03 +#define LDAP_CUP_NONE 0x00 +#define LDAP_CUP_SYNC_ONLY 0x01 +#define LDAP_CUP_PERSIST_ONLY 0x02 +#define LDAP_CUP_SYNC_AND_PERSIST 0x03 /* LCUP default cookie interval */ #define LDAP_CUP_DEFAULT_SEND_COOKIE_INTERVAL 0x01 @@ -525,8 +522,8 @@ typedef struct ldapcontrol { /* LDAP SYNC request type */ #ifdef LDAP_SYNC -#define LDAP_SYNC_NONE 0x00 -#define LDAP_SYNC_REFRESH_ONLY 0x01 +#define LDAP_SYNC_NONE 0x00 +#define LDAP_SYNC_REFRESH_ONLY 0x01 #define LDAP_SYNC_REFRESH_AND_PERSIST 0x03 #endif @@ -1261,9 +1258,9 @@ typedef struct ldap_ava { struct berval la_attr; struct berval la_value; unsigned la_flags; -#define LDAP_AVA_STRING 0x0000U -#define LDAP_AVA_BINARY 0x0001U -#define LDAP_AVA_NONPRINTABLE 0x0002U +#define LDAP_AVA_STRING 0x0000U +#define LDAP_AVA_BINARY 0x0001U +#define LDAP_AVA_NONPRINTABLE 0x0002U void *la_private; } LDAPAVA; @@ -1272,28 +1269,25 @@ typedef LDAPAVA** LDAPRDN; typedef LDAPRDN** LDAPDN; /* DN formats */ -#define LDAP_DN_FORMAT_LDAP 0x0000U +#define LDAP_DN_FORMAT_LDAP 0x0000U #define LDAP_DN_FORMAT_LDAPV3 0x0010U #define LDAP_DN_FORMAT_LDAPV2 0x0020U -#define LDAP_DN_FORMAT_DCE 0x0030U -#define LDAP_DN_FORMAT_UFN 0x0040U /* dn2str only */ +#define LDAP_DN_FORMAT_DCE 0x0030U +#define LDAP_DN_FORMAT_UFN 0x0040U /* dn2str only */ #define LDAP_DN_FORMAT_AD_CANONICAL 0x0050U /* dn2str only */ -#define LDAP_DN_FORMAT_LBER 0x00F0U /* for testing only */ -#define LDAP_DN_FORMAT_MASK 0x00F0U +#define LDAP_DN_FORMAT_LBER 0x00F0U /* for testing only */ +#define LDAP_DN_FORMAT_MASK 0x00F0U /* DN flags */ -#define LDAP_DN_PRETTY 0x0100U -#define LDAP_DN_SKIP 0x0200U +#define LDAP_DN_PRETTY 0x0100U +#define LDAP_DN_SKIP 0x0200U #define LDAP_DN_P_NOLEADTRAILSPACES 0x1000U #define LDAP_DN_P_NOSPACEAFTERRDN 0x2000U -#define LDAP_DN_PEDANTIC 0xF000U +#define LDAP_DN_PEDANTIC 0xF000U -LDAP_F( void ) -ldap_avafree LDAP_P(( LDAPAVA *ava )); -LDAP_F( void ) -ldap_rdnfree LDAP_P(( LDAPRDN *rdn )); -LDAP_F( void ) -ldap_dnfree LDAP_P(( LDAPDN *dn )); +LDAP_F( void ) ldap_avafree LDAP_P(( LDAPAVA *ava )); +LDAP_F( void ) ldap_rdnfree LDAP_P(( LDAPRDN *rdn )); +LDAP_F( void ) ldap_dnfree LDAP_P(( LDAPDN *dn )); LDAP_F( int ) ldap_bv2dn LDAP_P(( diff --git a/include/portable.h.in b/include/portable.h.in index e1f688f8f8..e80c1b6e42 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -1039,12 +1039,17 @@ # include #endif +#ifndef LDAP_REL_ENG +#if (LDAP_VENDOR_VERSION == 000000) && !defined(LDAP_DEVEL) +#define LDAP_DEVEL +#endif #if defined(LDAP_DEVEL) && !defined(LDAP_TEST) #define LDAP_TEST #endif #if defined(LDAP_TEST) && !defined(LDAP_DEBUG) #define LDAP_DEBUG #endif +#endif #ifdef HAVE_EBCDIC /* ASCII/EBCDIC converting replacements for stdio funcs diff --git a/libraries/libldap/cancel.c b/libraries/libldap/cancel.c index e42a37afd9..ffc026be75 100644 --- a/libraries/libldap/cancel.c +++ b/libraries/libldap/cancel.c @@ -20,6 +20,8 @@ #include "ldap-int.h" #include "ldap_log.h" +#ifdef LDAP_EXOP_X_CANCEL + int ldap_cancel( LDAP *ld, @@ -60,3 +62,5 @@ ldap_cancel_s( ber_free( cancelidber, 1 ); return rc; } + +#endif /* LDAP_EXOP_X_CANCEL */ diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index 7b6dfb68b9..01c6b96a3a 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -92,18 +92,22 @@ static struct ldaperror ldap_builtin_errlist[] = { {LDAP_MORE_RESULTS_TO_RETURN, "More results to return" }, {LDAP_CLIENT_LOOP, "Client Loop" }, {LDAP_REFERRAL_LIMIT_EXCEEDED, "Referral Limit Exceeded" }, + #ifdef LDAP_CLIENT_UPDATE - {LDAP_CUP_RESOURCES_EXHAUSTED, "LDAP Client Update Resource Exhausted" }, - {LDAP_CUP_SECURITY_VIOLATION, "LDAP Client Update Security Violation" }, - {LDAP_CUP_INVALID_COOKIE, "LDAP Client Update Invalid Cookie" }, - {LDAP_CUP_UNSUPPORTED_SCHEME, "LDAP Client Update Unsupported Scheme" }, - {LDAP_CUP_CLIENT_DISCONNECT, "LDAP Client Update Client Disconnect" }, - {LDAP_CUP_RELOAD_REQUIRED, "LDAP Client Update Reload Required" }, + {LDAP_CUP_RESOURCES_EXHAUSTED, "Client Update Resource Exhausted" }, + {LDAP_CUP_SECURITY_VIOLATION, "Client Update Security Violation" }, + {LDAP_CUP_INVALID_COOKIE, "Client Update Invalid Cookie" }, + {LDAP_CUP_UNSUPPORTED_SCHEME, "Client Update Unsupported Scheme" }, + {LDAP_CUP_CLIENT_DISCONNECT, "Client Update Client Disconnect" }, + {LDAP_CUP_RELOAD_REQUIRED, "Client Update Reload Required" }, +#endif + +#ifdef LDAP_EXOP_X_CANCEL + {LDAP_CANCELLED, "Cancelled" }, + {LDAP_NO_SUCH_OPERATION, "No Operation to Cancel" }, + {LDAP_TOO_LATE, "Too Late to Cancel" }, + {LDAP_CANNOT_CANCEL, "Cannot Cancel" }, #endif - {LDAP_CANCELLED, "LDAP Cancelled" }, - {LDAP_NO_SUCH_OPERATION, "LDAP No Operation to Cancel" }, - {LDAP_TOO_LATE, "LDAP Too Late to Cancel" }, - {LDAP_CANNOT_CANCEL, "LDAP Cannot Cancel" }, {-1, NULL} }; diff --git a/libraries/libldap/extended.c b/libraries/libldap/extended.c index 5a6508f9b8..c9c27be37d 100644 --- a/libraries/libldap/extended.c +++ b/libraries/libldap/extended.c @@ -394,6 +394,7 @@ free_and_return: return LDAP_SUCCESS; } +#ifdef LDAP_RES_INTERMEDIATE_RESP /* Parse an intermediate response result */ int ldap_parse_intermediate_resp_result ( @@ -508,3 +509,4 @@ ldap_parse_intermediate_resp_result ( return LDAP_SUCCESS; } +#endif diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index f6d62b64ef..8b12ae3975 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -645,8 +645,11 @@ retry_ber: * go through the following code. This code also chases V2 referrals * and checks if all referrals have been chased. */ - if ( (tag != LDAP_RES_SEARCH_ENTRY) && (v3ref > -1) && - (tag != LDAP_RES_INTERMEDIATE_RESP ) ) { + if ( (tag != LDAP_RES_SEARCH_ENTRY) && (v3ref > -1) +#ifdef LDAP_RES_INTERMEDIATE_RESP + && (tag != LDAP_RES_INTERMEDIATE_RESP ) +#endif + ) { /* For a v3 search referral/reference, only come here if already chased it */ if ( ld->ld_version >= LDAP_VERSION2 && ( lr->lr_parent != NULL || diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 2f2bb16acc..91d81b7a2a 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -535,7 +535,9 @@ bdb_initialize( static char *controls[] = { LDAP_CONTROL_MANAGEDSAIT, LDAP_CONTROL_NOOP, +#ifdef LDAP_CONTROL_PAGEDRESULTS LDAP_CONTROL_PAGEDRESULTS, +#endif LDAP_CONTROL_VALUESRETURNFILTER, #ifdef LDAP_CONTROL_SUBENTRIES LDAP_CONTROL_SUBENTRIES, diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 8df7b7b5cc..3d9e86dceb 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -56,7 +56,8 @@ int bdb_modify_internal( #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: add\n", 0, 0, 0); #endif - err = modify_add_values( e, mod, op->o_permitmodify, text, textbuf, textlen ); + err = modify_add_values( e, mod, get_permitmodify(op), + text, textbuf, textlen ); if( err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ERR, @@ -75,7 +76,8 @@ int bdb_modify_internal( #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: delete\n", 0, 0, 0); #endif - err = modify_delete_values( e, mod, op->o_permitmodify, text, textbuf, textlen ); + err = modify_delete_values( e, mod, get_permitmodify(op), + text, textbuf, textlen ); assert( err != LDAP_TYPE_OR_VALUE_EXISTS ); if( err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -95,7 +97,8 @@ int bdb_modify_internal( #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: replace\n", 0, 0, 0); #endif - err = modify_replace_values( e, mod, op->o_permitmodify, text, textbuf, textlen ); + err = modify_replace_values( e, mod, get_permitmodify(op), + text, textbuf, textlen ); if( err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ERR, @@ -119,7 +122,8 @@ int bdb_modify_internal( */ mod->sm_op = LDAP_MOD_ADD; - err = modify_add_values( e, mod, op->o_permitmodify, text, textbuf, textlen ); + err = modify_add_values( e, mod, get_permitmodify(op), + text, textbuf, textlen ); if ( err == LDAP_TYPE_OR_VALUE_EXISTS ) { err = LDAP_SUCCESS; } diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index a0d3046878..7f83a341fe 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -61,7 +61,6 @@ bdb_search( struct berval realbase = { 0, NULL }; int nentries = 0; int manageDSAit; - int pagedresults; int tentries = 0; ID lastid = NOID; @@ -125,7 +124,6 @@ bdb_search( manageDSAit = get_manageDSAit( op ); - pagedresults = get_pagedresults( op ); rc = LOCK_ID (bdb->bi_dbenv, &locker ); @@ -312,7 +310,7 @@ dn2entry_retry: /* if no limit is required, use soft limit */ if ( slimit <= 0 ) { - if ( pagedresults && limit->lms_s_pr != 0 ) { + if ( get_pagedresults(op) && limit->lms_s_pr != 0 ) { slimit = limit->lms_s_pr; } else { slimit = limit->lms_s_soft; @@ -396,7 +394,8 @@ dn2entry_retry: tentries = BDB_IDL_N(candidates); } - if ( pagedresults ) { +#ifdef LDAP_CONTROL_PAGEDRESULTS + if ( get_pagedresults(op) ) { if ( op->o_pagedresults_state.ps_cookie == 0 ) { id = 0; } else { @@ -427,6 +426,7 @@ dn2entry_retry: } goto loop_begin; } +#endif #ifdef LDAP_CLIENT_UPDATE if ( op->o_clientupdate_type & SLAP_LCUP_SYNC ) { @@ -498,6 +498,7 @@ loop_begin: goto done; } +#ifdef LDAP_EXOP_X_CANCEL if ( op->o_cancel ) { assert( op->o_cancel == LDAP_CANCEL_REQ ); rc = 0; @@ -506,6 +507,7 @@ loop_begin: op->o_cancel = LDAP_CANCEL_ACK; goto done; } +#endif /* check time limit */ if ( tlimit != -1 && slap_get_time() > stoptime ) { @@ -717,13 +719,16 @@ id2entry_retry: goto done; } - if ( pagedresults ) { +#ifdef LDAP_CONTROL_PAGEDRESULTS + if ( get_pagedresults(op) ) { if ( nentries >= op->o_pagedresults_size ) { - send_pagerequest_response( conn, op, lastid, nentries, tentries ); + send_pagerequest_response( conn, op, + lastid, nentries, tentries ); goto done; } lastid = id; } +#endif if (e) { int result; @@ -1133,6 +1138,7 @@ static int search_candidates( return rc; } +#ifdef LDAP_CONTROL_PAGEDRESULTS static void send_pagerequest_response( Connection *conn, @@ -1188,6 +1194,7 @@ send_pagerequest_response( done: (void) ber_free_buf( ber ); } +#endif #ifdef LDAP_CLIENT_UPDATE int diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 4ebc6839eb..679fceba7e 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -868,12 +868,14 @@ backend_check_restrictions( } } +#ifdef LDAP_EXOP_X_CANCEL { struct berval bv = BER_BVC( LDAP_EXOP_X_CANCEL ); if ( bvmatch( opdata, &bv ) ) { break; } } +#endif /* treat everything else as a modify */ opflag = SLAP_RESTRICT_OP_MODIFY; diff --git a/servers/slapd/cancel.c b/servers/slapd/cancel.c index 34c071d3c8..fc2832bfab 100644 --- a/servers/slapd/cancel.c +++ b/servers/slapd/cancel.c @@ -16,6 +16,8 @@ #include "slap.h" +#ifdef LDAP_EXOP_X_CANCEL + #include #include @@ -129,3 +131,4 @@ int cancel_extop( return rc; } +#endif /* LDAP_EXOP_X_CANCEL */ diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index c94ceb3d53..f5fe518b77 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -416,7 +416,9 @@ long connection_init( c->c_send_search_result = slap_send_search_result; c->c_send_search_reference = slap_send_search_reference; c->c_send_ldap_extended = slap_send_ldap_extended; +#ifdef LDAP_RES_INTERMEDIATE_RESP c->c_send_ldap_intermediate_resp = slap_send_ldap_intermediate_resp; +#endif c->c_authmech.bv_val = NULL; c->c_authmech.bv_len = 0; @@ -1025,13 +1027,17 @@ operations_error: #endif /* SLAPD_MONITOR */ ldap_pvt_thread_mutex_unlock( &num_ops_mutex ); - if ( arg->co_op->o_cancel == LDAP_CANCEL_REQ ) +#ifdef LDAP_EXOP_X_CANCEL + if ( arg->co_op->o_cancel == LDAP_CANCEL_REQ ) { arg->co_op->o_cancel = LDAP_TOO_LATE; + } while ( arg->co_op->o_cancel != LDAP_CANCEL_NONE && - arg->co_op->o_cancel != LDAP_CANCEL_DONE ) { - ldap_pvt_thread_yield(); + arg->co_op->o_cancel != LDAP_CANCEL_DONE ) + { + ldap_pvt_thread_yield(); } +#endif ldap_pvt_thread_mutex_lock( &conn->c_mutex ); @@ -1429,7 +1435,9 @@ connection_input( op->o_conn = conn; op->vrFilter = NULL; +#ifdef LDAP_CONTROL_PAGEDRESULTS op->o_pagedresults_state = conn->c_pagedresults_state; +#endif #ifdef LDAP_CONNECTIONLESS op->o_peeraddr = peeraddr; if (cdn ) { diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index 82d5673eb4..56187c587a 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -70,6 +70,39 @@ static char *proxy_authz_extops[] = { NULL }; +/* + * all known request control OIDs should be added to this list + */ +char *slap_known_controls[] = { + LDAP_CONTROL_MANAGEDSAIT, + LDAP_CONTROL_PROXY_AUTHZ, + +#ifdef LDAP_CONTROL_SUBENTRIES + LDAP_CONTROL_SUBENTRIES, +#endif /* LDAP_CONTROL_SUBENTRIES */ + + LDAP_CONTROL_NOOP, + +#ifdef LDAP_CONTROL_DUPENT_REQUEST + LDAP_CONTROL_DUPENT_REQUEST, +#endif /* LDAP_CONTROL_DUPENT_REQUEST */ + +#ifdef LDAP_CONTROL_PAGEDRESULTS + LDAP_CONTROL_PAGEDRESULTS, +#endif + +#ifdef LDAP_CONTROL_SORTREQUEST + LDAP_CONTROL_SORTREQUEST, +#endif /* LDAP_CONTROL_SORTREQUEST */ + +#ifdef LDAP_CONTROL_VLVREQUEST + LDAP_CONTROL_VLVREQUEST, +#endif /* LDAP_CONTROL_VLVREQUEST */ + + LDAP_CONTROL_VALUESRETURNFILTER, + NULL +}; + static struct slap_control { char *sc_oid; slap_mask_t sc_mask; @@ -77,18 +110,6 @@ static struct slap_control { SLAP_CTRL_PARSE_FN *sc_parse; } supportedControls[] = { - { LDAP_CONTROL_PROXY_AUTHZ, - SLAP_CTRL_FRONTEND|SLAP_CTRL_ACCESS, proxy_authz_extops, - parseProxyAuthz }, - { LDAP_CONTROL_MANAGEDSAIT, - SLAP_CTRL_ACCESS, NULL, - parseManageDSAit }, - { LDAP_CONTROL_NOOP, - SLAP_CTRL_ACCESS, NULL, - parseNoOp }, - { LDAP_CONTROL_PAGEDRESULTS, - SLAP_CTRL_SEARCH, NULL, - parsePagedResults }, { LDAP_CONTROL_VALUESRETURNFILTER, SLAP_CTRL_SEARCH, NULL, parseValuesReturnFilter }, @@ -97,6 +118,20 @@ static struct slap_control { SLAP_CTRL_SEARCH, NULL, parseSubentries }, #endif + { LDAP_CONTROL_NOOP, + SLAP_CTRL_ACCESS, NULL, + parseNoOp }, +#ifdef LDAP_CONTROL_PAGEDRESULTS + { LDAP_CONTROL_PAGEDRESULTS, + SLAP_CTRL_SEARCH, NULL, + parsePagedResults }, +#endif + { LDAP_CONTROL_MANAGEDSAIT, + SLAP_CTRL_ACCESS, NULL, + parseManageDSAit }, + { LDAP_CONTROL_PROXY_AUTHZ, + SLAP_CTRL_FRONTEND|SLAP_CTRL_ACCESS, proxy_authz_extops, + parseProxyAuthz }, #ifdef LDAP_CONTROL_PERMITMODIFY { LDAP_CONTROL_PERMITMODIFY, SLAP_CTRL_UPDATE, NULL, @@ -602,6 +637,7 @@ static int parseNoOp ( return LDAP_SUCCESS; } +#ifdef LDAP_CONTROL_PAGEDRESULTS static int parsePagedResults ( Connection *conn, Operation *op, @@ -629,6 +665,7 @@ static int parsePagedResults ( * -- requested page size from client * -- result set size estimate from server * cookie OCTET STRING + * } */ ber = ber_init( &ctrl->ldctl_value ); if( ber == NULL ) { @@ -682,6 +719,7 @@ static int parsePagedResults ( return LDAP_SUCCESS; } +#endif int parseValuesReturnFilter ( Connection *conn, diff --git a/servers/slapd/extended.c b/servers/slapd/extended.c index 878ba0b0e1..41eb8e32e8 100644 --- a/servers/slapd/extended.c +++ b/servers/slapd/extended.c @@ -59,12 +59,14 @@ static struct { struct berval oid; SLAP_EXTOP_MAIN_FN *ext_main; } builtin_extops[] = { + { BVC(LDAP_EXOP_X_WHO_AM_I), whoami_extop }, + { BVC(LDAP_EXOP_MODIFY_PASSWD), passwd_extop }, +#ifdef LDAP_EXOP_X_CANCEL + { BVC(LDAP_EXOP_X_CANCEL), cancel_extop }, +#endif #ifdef HAVE_TLS { BVC(LDAP_EXOP_START_TLS), starttls_extop }, #endif - { BVC(LDAP_EXOP_MODIFY_PASSWD), passwd_extop }, - { BVC(LDAP_EXOP_X_WHO_AM_I), whoami_extop }, - { BVC(LDAP_EXOP_X_CANCEL), cancel_extop }, { {0,NULL}, NULL } }; @@ -149,14 +151,16 @@ do_extended( goto done; } -#if !defined(LDAP_SLAPI) - if( !(ext = find_extop(supp_ext_list, &reqoid)) ) { -#else /* defined(LDAP_SLAPI) */ - /* Netscape extended operation */ - getPluginFunc( &reqoid, &funcAddr ); + if( !(ext = find_extop(supp_ext_list, &reqoid)) +#ifdef LDAP_SLAPI + && !(funcAddr) +#endif + ) { +#ifdef LDAP_SLAPI + /* Netscape extended operation */ + getPluginFunc( &reqoid, &funcAddr ); +#endif - if( !(ext = find_extop(supp_ext_list, &reqoid)) && !(funcAddr) ) { -#endif /* defined(LDAP_SLAPI) */ #ifdef NEW_LOGGING LDAP_LOG( OPERATION, ERR, "do_extended: conn %d unsupported operation \"%s\"\n", diff --git a/servers/slapd/init.c b/servers/slapd/init.c index 46e5501126..a9031b6f6b 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -71,56 +71,6 @@ ldap_pvt_thread_mutex_t replog_mutex; static const char* slap_name = NULL; int slapMode = SLAP_UNDEFINED_MODE; -/* - * all known control OIDs should be added to this list - */ -char *slap_known_controls[] = { -#ifdef LDAP_CONTROL_REFERRALS - LDAP_CONTROL_REFERRALS, -#endif /* LDAP_CONTROL_REFERRALS */ - - LDAP_CONTROL_MANAGEDSAIT, - -#ifdef LDAP_CONTROL_SUBENTRIES - LDAP_CONTROL_SUBENTRIES, -#endif /* LDAP_CONTROL_SUBENTRIES */ - - LDAP_CONTROL_NOOP, - -#ifdef LDAP_CONTROL_DUPENT_REQUEST - LDAP_CONTROL_DUPENT_REQUEST, -#endif /* LDAP_CONTROL_DUPENT_REQUEST */ - -#ifdef LDAP_CONTROL_DUPENT_RESPONSE - LDAP_CONTROL_DUPENT_RESPONSE, -#endif /* LDAP_CONTROL_DUPENT_RESPONSE */ - -#ifdef LDAP_CONTROL_DUPENT_ENTRY - LDAP_CONTROL_DUPENT_ENTRY, -#endif /* LDAP_CONTROL_DUPENT_ENTRY */ - - LDAP_CONTROL_PAGEDRESULTS, - -#ifdef LDAP_CONTROL_SORTREQUEST - LDAP_CONTROL_SORTREQUEST, -#endif /* LDAP_CONTROL_SORTREQUEST */ - -#ifdef LDAP_CONTROL_SORTRESPONSE - LDAP_CONTROL_SORTRESPONSE, -#endif /* LDAP_CONTROL_SORTRESPONSE */ - -#ifdef LDAP_CONTROL_VLVREQUEST - LDAP_CONTROL_VLVREQUEST, -#endif /* LDAP_CONTROL_VLVREQUEST */ - -#ifdef LDAP_CONTROL_VLVRESPONSE - LDAP_CONTROL_VLVRESPONSE, -#endif /* LDAP_CONTROL_VLVRESPONSE */ - - LDAP_CONTROL_VALUESRETURNFILTER, - NULL -}; - int slap_init( int mode, const char *name ) { diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 23c4099df7..749407f5ca 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -480,9 +480,11 @@ slap_send_ldap_result( assert( err != LDAP_PARTIAL_RESULTS ); if ( err == LDAP_REFERRAL ) { +#ifdef LDAP_CONTROL_NOREFERRALS if( op->o_noreferrals ) { ref = NULL; } +#endif if( ref == NULL ) { err = LDAP_NO_SUCH_OBJECT; } else if ( op->o_protocol < LDAP_VERSION3 ) { @@ -582,6 +584,7 @@ slap_send_ldap_extended( rspoid, rspdata, NULL, ctrls ); } +#ifdef LDAP_RES_INTERMEDIATE_RESP void slap_send_ldap_intermediate_resp( Connection *conn, @@ -614,6 +617,7 @@ slap_send_ldap_intermediate_resp( err, matched, text, refs, rspoid, rspdata, NULL, ctrls ); } +#endif void slap_send_search_result( @@ -1379,6 +1383,7 @@ slap_send_search_reference( return( 1 ); } +#ifdef LDAP_CONTROL_NOREFERRALS if( op->o_noreferrals ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, ERR, @@ -1392,6 +1397,7 @@ slap_send_search_reference( return( 0 ); } +#endif if( refs == NULL ) { #ifdef NEW_LOGGING diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index 5c0ca35866..b9c7f35e80 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -21,8 +21,6 @@ #include #include "lber_pvt.h" -struct berval *ns_get_supported_extop (int); - static struct berval supportedFeatures[] = { BER_BVC(LDAP_FEATURE_ALL_OPERATIONAL_ATTRS), /* all Operational Attributes ("+") */ BER_BVC(LDAP_FEATURE_OBJECTCLASS_ATTRS), /* OCs in Attributes List */ @@ -138,13 +136,13 @@ root_dse_info( return LDAP_OTHER; } -#if defined( LDAP_SLAPI ) +#ifdef LDAP_SLAPI /* netscape supportedExtension */ for ( i = 0; (bv = ns_get_supported_extop(i)) != NULL; i++ ) { vals[0] = *bv; attr_merge( e, ad_supportedExtension, vals ); } -#endif /* defined( LDAP_SLAPI ) */ +#endif /* LDAP_SLAPI */ /* supportedFeatures */ if( attr_merge( e, ad_supportedFeatures, supportedFeatures ) ) diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index c09d1bf0cf..b0801608cc 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -165,7 +165,6 @@ typedef struct slap_ssf_set { slap_ssf_t sss_simple_bind; } slap_ssf_set_t; - /* Flags for telling slap_sasl_getdn() what type of identity is being passed */ #define SLAP_GETDN_AUTHCID 2 #define SLAP_GETDN_AUTHZID 4 @@ -1672,17 +1671,37 @@ typedef struct slap_op { #define SLAP_NONCRITICAL_CONTROL 1 #define SLAP_CRITICAL_CONTROL 2 char o_managedsait; +#define get_manageDSAit(op) ((int)(op)->o_managedsait) + char o_noop; char o_proxy_authz; + char o_subentries; +#define get_subentries(op) ((int)(op)->o_subentries) char o_subentries_visibility; +#define get_subentries_visibility(op) ((int)(op)->o_subentries_visibility) + char o_valuesreturnfilter; +#ifdef LDAP_CONTROL_PERMITMODIFY char o_permitmodify; +#define get_permitmodify(op) ((int)(op)->o_permitmodify) +#else +#define get_permitmodify(op) (0) +#endif + +#ifdef LDAP_CONTROL_NOREFERRALS char o_noreferrals; +#endif + +#ifdef LDAP_CONTROL_PAGEDRESULTS char o_pagedresults; +#define get_pagedresults(op) ((int)(op)->o_pagedresults) ber_int_t o_pagedresults_size; PagedResultsState o_pagedresults_state; +#else +#define get_pagedresults(op) (0) +#endif #ifdef LDAP_CLIENT_UPDATE char o_clientupdate; @@ -1729,17 +1748,11 @@ typedef struct slap_op { LDAP_STAILQ_ENTRY(slap_op) o_next; /* next operation in list */ ValuesReturnFilter *vrFilter; /* Structure represents ValuesReturnFilter */ - void *o_pb; /* Netscape plugin */ - +#ifdef LDAP_SLAPI + void *o_pb; /* NS-SLAPI plugin */ +#endif } Operation; -#define get_manageDSAit(op) ((int)(op)->o_managedsait) -#define get_subentries(op) ((int)(op)->o_subentries) -#define get_subentries_visibility(op) ((int)(op)->o_subentries_visibility) -#define get_pagedresults(op) ((int)(op)->o_pagedresults) - - - typedef void (*SEND_LDAP_RESULT)( struct slap_conn *conn, struct slap_op *op, @@ -1922,7 +1935,9 @@ typedef struct slap_conn { SEND_SEARCH_RESULT c_send_search_result; SEND_SEARCH_REFERENCE c_send_search_reference; SEND_LDAP_EXTENDED c_send_ldap_extended; +#ifdef LDAP_RES_INTERMEDIATE_RESP SEND_LDAP_INTERMEDIATE_RESP c_send_ldap_intermediate_resp; +#endif } Connection; -- 2.39.5