andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 59b853372d3e06636620a192e1fdad6d89e8cc0e Mon Sep 17 00:00:00 2001
dc8c34
From: Mark Reynolds <mreynolds@redhat.com>
dc8c34
Date: Fri, 22 Mar 2013 13:18:28 -0400
dc8c34
Subject: [PATCH 53/99] Ticket 632 - 389-ds-base cannot handle Kerberos tickets
dc8c34
 with PAC
dc8c34
dc8c34
        Bug Description:  When FreeIPA is configured with AD trust support, Kerberos
dc8c34
                          tickets may also contain PAC which makes them bigger than
dc8c34
                          usually expected (bigger than 2048 B)
dc8c34
dc8c34
        Fix Description:  Make the default 64k(65536), and allow it to be configurable
dc8c34
                          using: nsslapd-sasl-max-buffer-size
dc8c34
dc8c34
        https://fedorahosted.org/389/ticket/632
dc8c34
dc8c34
        Reviewed by: nkinder(Thanks!)
dc8c34
(cherry picked from commit 6a2b0b1741ce6cdcceea06e630141673d47c6012)
dc8c34
---
dc8c34
 ldap/schema/01core389.ldif      | 13 +++++++++++++
dc8c34
 ldap/servers/slapd/libglobs.c   | 43 +++++++++++++++++++++++++++++++++++++++++
dc8c34
 ldap/servers/slapd/proto-slap.h |  2 ++
dc8c34
 ldap/servers/slapd/saslbind.c   |  2 +-
dc8c34
 ldap/servers/slapd/slap.h       |  2 ++
dc8c34
 5 files changed, 61 insertions(+), 1 deletion(-)
dc8c34
dc8c34
diff --git a/ldap/schema/01core389.ldif b/ldap/schema/01core389.ldif
dc8c34
index d9d1c33..c99c34c 100644
dc8c34
--- a/ldap/schema/01core389.ldif
dc8c34
+++ b/ldap/schema/01core389.ldif
dc8c34
@@ -139,6 +139,19 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2136 NAME 'nsds5ReplicaCleanRUVNotified'
dc8c34
 attributeTypes: ( 2.16.840.1.113730.3.1.2137 NAME 'nsds5ReplicaAbortCleanRUV' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
dc8c34
 attributeTypes: ( 2.16.840.1.113730.3.1.2111 NAME 'tombstoneNumSubordinates' DESC 'count of immediate subordinates for tombstone entries' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation X-ORIGIN '389 directory server' )
dc8c34
 attributeTypes: ( 2.16.840.1.113730.3.1.2138 NAME 'nsslapd-readonly' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2143 NAME 'nsslapd-sasl-mapping-fallback' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2144 NAME 'rootdn-open-time' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2145 NAME 'rootdn-close-time' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2146 NAME 'rootdn-days-allowed' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2147 NAME 'rootdn-allow-host' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2148 NAME 'rootdn-deny-host' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2149 NAME 'rootdn-allow-ip' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2150 NAME 'rootdn-deny-ip' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2151 NAME 'nsslapd-plugin-depends-on-type' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2152 NAME 'nsds5ReplicaProtocolTimeout' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2154 NAME 'nsds5ReplicaBackoffMin' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2155 NAME 'nsds5ReplicaBackoffMax' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
dc8c34
+attributeTypes: ( 2.16.840.1.113730.3.1.2156 NAME 'nsslapd-sasl-max-buffer-size' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
dc8c34
 #
dc8c34
 # objectclasses
dc8c34
 #
dc8c34
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
dc8c34
index 413351d..5bfd665 100644
dc8c34
--- a/ldap/servers/slapd/libglobs.c
dc8c34
+++ b/ldap/servers/slapd/libglobs.c
dc8c34
@@ -83,6 +83,8 @@
dc8c34
 #include "plhash.h"
dc8c34
 
dc8c34
 #define REMOVE_CHANGELOG_CMD "remove"
dc8c34
+#define DEFAULT_SASL_MAXBUFSIZE "65536"
dc8c34
+#define SLAPD_DEFAULT_SASL_MAXBUFSIZE 65536
dc8c34
 
dc8c34
 /* On UNIX, there's only one copy of slapd_ldap_debug */
dc8c34
 /* On NT, each module keeps its own module_ldap_debug, which */
dc8c34
@@ -687,6 +689,10 @@ static struct config_get_and_set {
dc8c34
 		NULL, 0,
dc8c34
 		(void**)&global_slapdFrontendConfig.disk_logging_critical,
dc8c34
 		CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_logging_critical},
dc8c34
+	{CONFIG_SASL_MAXBUFSIZE, config_set_sasl_maxbufsize,
dc8c34
+		NULL, 0,
dc8c34
+		(void**)&global_slapdFrontendConfig.sasl_max_bufsize,
dc8c34
+		CONFIG_INT, (ConfigGetFunc)config_get_sasl_maxbufsize},
dc8c34
 #ifdef MEMPOOL_EXPERIMENTAL
dc8c34
 	,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
dc8c34
 		NULL, 0,
dc8c34
@@ -1087,6 +1093,7 @@ FrontendConfig_init () {
dc8c34
   cfg->disk_threshold = 2097152;  /* 2 mb */
dc8c34
   cfg->disk_grace_period = 60; /* 1 hour */
dc8c34
   cfg->disk_logging_critical = LDAP_OFF;
dc8c34
+  cfg->sasl_max_bufsize = SLAPD_DEFAULT_SASL_MAXBUFSIZE;
dc8c34
 
dc8c34
 #ifdef MEMPOOL_EXPERIMENTAL
dc8c34
   cfg->mempool_switch = LDAP_ON;
dc8c34
@@ -1295,6 +1302,29 @@ config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf,
dc8c34
     return retVal;
dc8c34
 }
dc8c34
 
dc8c34
+int
dc8c34
+config_set_sasl_maxbufsize(const char *attrname, char *value, char *errorbuf, int apply )
dc8c34
+{
dc8c34
+    slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
dc8c34
+    int retVal = LDAP_SUCCESS;
dc8c34
+    int default_size = atoi(DEFAULT_SASL_MAXBUFSIZE);
dc8c34
+    int size;
dc8c34
+
dc8c34
+    size = atoi(value);
dc8c34
+    if(size < default_size){
dc8c34
+        PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "nsslapd-sasl-max-buffer-size is too low (%d), "
dc8c34
+            "setting to default value (%d).\n",size, default_size);
dc8c34
+        size = default_size;
dc8c34
+    }
dc8c34
+    if(apply){
dc8c34
+        CFG_LOCK_WRITE(slapdFrontendConfig);
dc8c34
+        slapdFrontendConfig->sasl_max_bufsize = size;
dc8c34
+        CFG_UNLOCK_WRITE(slapdFrontendConfig);
dc8c34
+    }
dc8c34
+
dc8c34
+    return retVal;
dc8c34
+}
dc8c34
+
dc8c34
 int 
dc8c34
 config_set_port( const char *attrname, char *port, char *errorbuf, int apply ) {
dc8c34
   long nPort;
dc8c34
@@ -3715,6 +3745,19 @@ config_get_port(){
dc8c34
 }
dc8c34
 
dc8c34
 int
dc8c34
+config_get_sasl_maxbufsize()
dc8c34
+{
dc8c34
+    slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
dc8c34
+    int retVal;
dc8c34
+
dc8c34
+    CFG_LOCK_READ(slapdFrontendConfig);
dc8c34
+    retVal = slapdFrontendConfig->sasl_max_bufsize;
dc8c34
+    CFG_UNLOCK_READ(slapdFrontendConfig);
dc8c34
+
dc8c34
+    return retVal;
dc8c34
+}
dc8c34
+
dc8c34
+int
dc8c34
 config_get_disk_monitoring(){
dc8c34
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
dc8c34
     int retVal;
dc8c34
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
dc8c34
index 9d3a16d..a68c2d9 100644
dc8c34
--- a/ldap/servers/slapd/proto-slap.h
dc8c34
+++ b/ldap/servers/slapd/proto-slap.h
dc8c34
@@ -390,6 +390,7 @@ int config_set_disk_threshold( const char *attrname, char *value, char *errorbuf
dc8c34
 int config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, int apply );
dc8c34
 int config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply );
dc8c34
 int config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply);
dc8c34
+int config_set_sasl_maxbufsize(const char *attrname, char *value, char *errorbuf, int apply );
dc8c34
 
dc8c34
 #if !defined(_WIN32) && !defined(AIX)
dc8c34
 int config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply );
dc8c34
@@ -544,6 +545,7 @@ int config_get_disk_monitoring();
dc8c34
 PRUint64 config_get_disk_threshold();
dc8c34
 int config_get_disk_grace_period();
dc8c34
 int config_get_disk_logging_critical();
dc8c34
+int config_get_sasl_maxbufsize();
dc8c34
 
dc8c34
 int is_abspath(const char *);
dc8c34
 char* rel2abspath( char * );
dc8c34
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
dc8c34
index f75e977..2d6ec0a 100644
dc8c34
--- a/ldap/servers/slapd/saslbind.c
dc8c34
+++ b/ldap/servers/slapd/saslbind.c
dc8c34
@@ -659,7 +659,7 @@ void ids_sasl_server_new(Connection *conn)
dc8c34
     }
dc8c34
 
dc8c34
     /* Enable security for this connection */
dc8c34
-    secprops.maxbufsize = 2048; /* DBDB: hack */
dc8c34
+    secprops.maxbufsize = config_get_sasl_maxbufsize();
dc8c34
     secprops.max_ssf = 0xffffffff;
dc8c34
     secprops.min_ssf = config_get_minssf();
dc8c34
     /* If anonymous access is disabled, set the appropriate flag */
dc8c34
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
dc8c34
index 403ea8a..d290c92 100644
dc8c34
--- a/ldap/servers/slapd/slap.h
dc8c34
+++ b/ldap/servers/slapd/slap.h
dc8c34
@@ -2002,6 +2002,7 @@ typedef struct _slapdEntryPoints {
dc8c34
 #define CONFIG_DISK_THRESHOLD "nsslapd-disk-monitoring-threshold"
dc8c34
 #define CONFIG_DISK_GRACE_PERIOD "nsslapd-disk-monitoring-grace-period"
dc8c34
 #define CONFIG_DISK_LOGGING_CRITICAL "nsslapd-disk-monitoring-logging-critical"
dc8c34
+#define CONFIG_SASL_MAXBUFSIZE "nsslapd-sasl-max-buffer-size"
dc8c34
 
dc8c34
 #ifdef MEMPOOL_EXPERIMENTAL
dc8c34
 #define CONFIG_MEMPOOL_SWITCH_ATTRIBUTE "nsslapd-mempool"
dc8c34
@@ -2230,6 +2231,7 @@ typedef struct _slapdFrontendConfig {
dc8c34
   char *entryusn_import_init;   /* Entry USN: determine the initital value of import */
dc8c34
   int pagedsizelimit;
dc8c34
   char *default_naming_context; /* Default naming context (normalized) */
dc8c34
+  int sasl_max_bufsize;         /* The max receive buffer size for SASL */
dc8c34
 
dc8c34
   /* disk monitoring */
dc8c34
   int disk_monitoring;
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34