From 3a2fdf234fa485807a21b59c67132ce8771a2e56 Mon Sep 17 00:00:00 2001 From: Ludwig Krispenz Date: Wed, 16 Apr 2014 14:35:36 +0200 Subject: [PATCH] Ticket 47761 - Return all attributes in rootdse without explicit request Bug Description: a search for the rootdse: -s base -b "" only returns the user attributes not the operational attributes like "supportedControl" This is correct inLDAPv3, and behaviour was introduced with fix for #47634, but for backward compatibility the old behaviour should be configurable Fix Description: Introduce a multivalued attribute to specify the attribites which should be returned without specific request https://fedorahosted.org/389/ticket/47634 Reviewed by: ? --- ldap/schema/01core389.ldif | 1 + ldap/servers/slapd/result.c | 17 +++++++++++++++++ ldap/servers/slapd/slap.h | 1 + 3 files changed, 19 insertions(+) diff --git a/ldap/schema/01core389.ldif b/ldap/schema/01core389.ldif index c5e4877..6a2d28c 100644 --- a/ldap/schema/01core389.ldif +++ b/ldap/schema/01core389.ldif @@ -297,6 +297,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2302 NAME 'nsslapd-listen-backlog-size' attributeTypes: ( 2.16.840.1.113730.3.1.2303 NAME 'nsslapd-ignore-time-skew' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.2304 NAME 'nsslapd-dynamic-plugins' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.2305 NAME 'nsslapd-moddn-aci' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) +attributeTypes: ( 2.16.840.1.113730.3.1.2306 NAME 'nsslapd-return-default-opattr' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE directoryOperation X-ORIGIN 'Netscape Directory Server' ) # # objectclasses # diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c index a10dfae..7b45e75 100644 --- a/ldap/servers/slapd/result.c +++ b/ldap/servers/slapd/result.c @@ -1157,6 +1157,8 @@ static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_ char *current_type_name = NULL; int rewrite_rfc1274 = 0; int vattr_flags = 0; + char *dn = NULL; + char **default_attrs = NULL; if(real_attrs_only == SLAPI_SEND_VATTR_FLAG_REALONLY) vattr_flags = SLAPI_REALATTRS_ONLY; @@ -1193,6 +1195,10 @@ static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_ rewrite_rfc1274 = config_get_rewrite_rfc1274(); + dn = slapi_entry_get_dn_const(e); + if (dn == NULL || *dn == '\0' ) { + default_attrs = slapi_entry_attr_get_charray(e, CONFIG_RETURN_DEFAULT_OPATTR); + } /* Send the attrs back to the client */ for (current_type = vattr_typethang_first(typelist); current_type; current_type = vattr_typethang_next(current_type) ) { @@ -1224,6 +1230,14 @@ static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_ break; } } + if (!sendit && default_attrs) { + for ( i = 0; default_attrs != NULL && default_attrs[i] != NULL; i++ ) { + if ( slapi_attr_type_cmp( default_attrs[i], current_type_name, SLAPI_TYPE_CMP_SUBTYPE ) == 0 ) { + sendit = 1; + break; + } + } + } } /* * it's a user attribute. send it. @@ -1324,6 +1338,9 @@ exit: if (NULL != typelist) { slapi_vattr_attrs_free(&typelist,typelist_flags); } + if (NULL != default_attrs) { + slapi_ch_free((void**)&default_attrs); + } return rc; } diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index f807d8d..642f3b2 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -2150,6 +2150,7 @@ typedef struct _slapdEntryPoints { #define CONFIG_PLUGIN_LOGGING "nsslapd-plugin-logging" #define CONFIG_LISTEN_BACKLOG_SIZE "nsslapd-listen-backlog-size" #define CONFIG_DYNAMIC_PLUGINS "nsslapd-dynamic-plugins" +#define CONFIG_RETURN_DEFAULT_OPATTR "nsslapd-return-default-opattr" /* getenv alternative */ #define CONFIG_MALLOC_MXFAST "nsslapd-malloc-mxfast" -- 1.7.11.7