From 7f9f26112388c6915fafb1b60b41a2d3e1e4e51e Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 23 Sep 2009 09:52:29 -0600 Subject: Should not attempt to pop SASL IO layer if not using SASL IO https://bugzilla.redhat.com/show_bug.cgi?id=519455 Resolves: bug 519455 Bug Description: Should not attempt to pop SASL IO layer if not using SASL IO Reviewed by: nkinder (Thanks!) Fix Description: Before attempting to pop the SASL IO layer from the prfd, first make sure we are using sasl IO, the prfd is not NULL, and the prfd has a SASL IO layer on it. This also fixes a bug with setting nsslapd-localhost in the bootstrap code - if you are using a system that does not have DNS configured correctly, you may want to force the SASL code to use the nsslapd-localhost for the FQDN. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no --- ldap/servers/slapd/config.c | 1 + ldap/servers/slapd/sasl_io.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ldap/servers/slapd/config.c b/ldap/servers/slapd/config.c index da87a0a1..c25438d1 100644 --- a/ldap/servers/slapd/config.c +++ b/ldap/servers/slapd/config.c @@ -592,6 +592,7 @@ slapd_bootstrap_config(const char *configdir) CONFIG_REWRITE_RFC1274_ATTRIBUTE, errorbuf); } + val[0] = 0; } /* what is our localhost name */ diff --git a/ldap/servers/slapd/sasl_io.c b/ldap/servers/slapd/sasl_io.c index 4c695b1d..3280a98b 100644 --- a/ldap/servers/slapd/sasl_io.c +++ b/ldap/servers/slapd/sasl_io.c @@ -467,15 +467,25 @@ sasl_io_write(PRFileDesc *fd, const void *buf, PRInt32 amount) static PRStatus PR_CALLBACK sasl_pop_IO_layer(PRFileDesc* stack) { - PRFileDesc* layer = PR_PopIOLayer(stack, sasl_LayerID); + PRFileDesc* layer = NULL; sasl_io_private *sp = NULL; + /* see if stack has the sasl io layer */ + if (!sasl_LayerID || !stack || !PR_GetIdentitiesLayer(stack, sasl_LayerID)) { + LDAPDebug0Args( LDAP_DEBUG_CONNS, + "sasl_pop_IO_layer: no SASL IO layer\n" ); + return PR_SUCCESS; + } + + /* remove the layer from the stack */ + layer = PR_PopIOLayer(stack, sasl_LayerID); if (!layer) { LDAPDebug0Args( LDAP_DEBUG_CONNS, - "sasl_pop_IO_layer: error - no SASL IO layer\n" ); + "sasl_pop_IO_layer: error - could not pop SASL IO layer\n" ); return PR_FAILURE; } + /* get our private data and clean it up */ sp = sasl_get_io_private(layer); if (sp) { -- cgit