[SSSD] Add LDAP provider option to set LDAP_OPT_X_SASL_NOCANON

Jakub Hrozek jhrozek at redhat.com
Fri Aug 26 17:56:06 UTC 2011


On Fri, Aug 26, 2011 at 12:15:13PM -0400, Stephen Gallagher wrote:
> On Fri, 2011-08-26 at 17:37 +0200, Jakub Hrozek wrote:
> > https://fedorahosted.org/sssd/ticket/978
> > 
> > This is currently not testable on Fedora 15 due to a number of bugs
> > (#733675, #733056). I used RHEL 6.2 to test the patch.
> > 
> > To test:
> >  * change the PTR record of the IPA server to point to something else
> >    than its hostname
> >  * on the client, run getent passwd admin
> > 
> > With the unpatched version, ldap_sasl_bind() would fail with a "Local
> > error". With the patch, which turns off canonicalization by default, the
> > user lookup should succeed.
> > 
> > The patch does not apply cleanly on 1.5. I'll send a 1.5 version once
> > this one is acked.
> 
> Ack, looks good (within the limitation of the third-party bugs)

Attached is a version that applies cleanly on the 1.5 branch.
-------------- next part --------------
>From b39d08201a9354469c0bf20586514eff5d820a9d Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Fri, 26 Aug 2011 10:54:09 +0200
Subject: [PATCH] Add LDAP provider option to set LDAP_OPT_X_SASL_NOCANON

https://fedorahosted.org/sssd/ticket/978
---
 src/config/SSSDConfig.py                   |    1 +
 src/config/etc/sssd.api.d/sssd-ldap.conf   |    1 +
 src/man/sssd-ldap.5.xml                    |   14 ++++++++++++++
 src/providers/ipa/ipa_common.c             |    3 ++-
 src/providers/ipa/ipa_common.h             |    2 +-
 src/providers/ldap/ldap_common.c           |    3 ++-
 src/providers/ldap/sdap.h                  |    1 +
 src/providers/ldap/sdap_async_connection.c |   11 +++++++++++
 8 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/src/config/SSSDConfig.py b/src/config/SSSDConfig.py
index 93a108e..3f98332 100644
--- a/src/config/SSSDConfig.py
+++ b/src/config/SSSDConfig.py
@@ -147,6 +147,7 @@ option_strings = {
     'ldap_deref' : _('How to dereference aliases'),
     'ldap_dns_service_name' : _('Service name for DNS service lookups'),
     'ldap_page_size' : _('The number of records to retrieve in a single LDAP query'),
+    'ldap_sasl_canonicalize' : _('Whether the LDAP library should perform a reverse lookup to canonicalize the host name during a SASL bind'),
 
     'ldap_entry_usn' : _('entryUSN attribute'),
     'ldap_rootdse_last_usn' : _('lastUSN attribute'),
diff --git a/src/config/etc/sssd.api.d/sssd-ldap.conf b/src/config/etc/sssd.api.d/sssd-ldap.conf
index d69b906..d84ceae 100644
--- a/src/config/etc/sssd.api.d/sssd-ldap.conf
+++ b/src/config/etc/sssd.api.d/sssd-ldap.conf
@@ -28,6 +28,7 @@ ldap_krb5_ticket_lifetime = int, None, false
 ldap_dns_service_name = str, None, false
 ldap_deref = str, None, false
 ldap_page_size = int, None, false
+ldap_sasl_canonicalize = bool, None, false
 
 [provider/ldap/id]
 ldap_search_timeout = int, None, false
diff --git a/src/man/sssd-ldap.5.xml b/src/man/sssd-ldap.5.xml
index b4a78a6..66fc3c4 100644
--- a/src/man/sssd-ldap.5.xml
+++ b/src/man/sssd-ldap.5.xml
@@ -1020,6 +1020,20 @@
                 </varlistentry>
 
                 <varlistentry>
+                    <term>ldap_sasl_canonicalize (boolean)</term>
+                    <listitem>
+                        <para>
+                            If set to true, the LDAP library would perform
+                            a reverse lookup to canonicalize the host name
+                            during a SASL bind.
+                        </para>
+                        <para>
+                            Default: false;
+                        </para>
+                    </listitem>
+                </varlistentry>
+
+                <varlistentry>
                     <term>ldap_krb5_keytab (string)</term>
                     <listitem>
                         <para>
diff --git a/src/providers/ipa/ipa_common.c b/src/providers/ipa/ipa_common.c
index a370a43..084400f 100644
--- a/src/providers/ipa/ipa_common.c
+++ b/src/providers/ipa/ipa_common.c
@@ -94,7 +94,8 @@ struct dp_option ipa_def_ldap_opts[] = {
      * manpages or SSSDConfig API
      */
     { "ldap_auth_disable_tls_never_use_in_production", DP_OPT_BOOL, BOOL_FALSE, BOOL_FALSE },
-    { "ldap_page_size", DP_OPT_NUMBER, { .number = 1000 }, NULL_NUMBER }
+    { "ldap_page_size", DP_OPT_NUMBER, { .number = 1000 }, NULL_NUMBER },
+    { "ldap_sasl_canonicalize", DP_OPT_BOOL, BOOL_FALSE, BOOL_FALSE }
 };
 
 struct sdap_attr_map ipa_attr_map[] = {
diff --git a/src/providers/ipa/ipa_common.h b/src/providers/ipa/ipa_common.h
index f6e1d4e..7a36a70 100644
--- a/src/providers/ipa/ipa_common.h
+++ b/src/providers/ipa/ipa_common.h
@@ -35,7 +35,7 @@ struct ipa_service {
 /* the following defines are used to keep track of the options in the ldap
  * module, so that if they change and ipa is not updated correspondingly
  * this will trigger a runtime abort error */
-#define IPA_OPTS_BASIC_TEST 49
+#define IPA_OPTS_BASIC_TEST 50
 
 /* the following define is used to keep track of the options in the krb5
  * module, so that if they change and ipa is not updated correspondingly
diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c
index 31b8139..b709dd1 100644
--- a/src/providers/ldap/ldap_common.c
+++ b/src/providers/ldap/ldap_common.c
@@ -86,7 +86,8 @@ struct dp_option default_basic_opts[] = {
      * manpages or SSSDConfig API
      */
     { "ldap_auth_disable_tls_never_use_in_production", DP_OPT_BOOL, BOOL_FALSE, BOOL_FALSE },
-    { "ldap_page_size", DP_OPT_NUMBER, { .number = 1000 }, NULL_NUMBER }
+    { "ldap_page_size", DP_OPT_NUMBER, { .number = 1000 }, NULL_NUMBER },
+    { "ldap_sasl_canonicalize", DP_OPT_BOOL, BOOL_FALSE, BOOL_FALSE }
 };
 
 struct sdap_attr_map generic_attr_map[] = {
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
index ccb079d..49ddbe9 100644
--- a/src/providers/ldap/sdap.h
+++ b/src/providers/ldap/sdap.h
@@ -194,6 +194,7 @@ enum sdap_basic_opt {
     SDAP_ENUM_SEARCH_TIMEOUT,
     SDAP_DISABLE_AUTH_TLS,
     SDAP_PAGE_SIZE,
+    SDAP_SASL_CANONICALIZE,
 
     SDAP_OPTS_BASIC /* opts counter */
 };
diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c
index 10f5ab4..345bd7c 100644
--- a/src/providers/ldap/sdap_async_connection.c
+++ b/src/providers/ldap/sdap_async_connection.c
@@ -151,6 +151,7 @@ static void sdap_sys_connect_done(struct tevent_req *subreq)
     int ldap_deref_val;
     struct sdap_rebind_proc_params *rebind_proc_params;
     int sd;
+    bool sasl_nocanon;
 
     ret = sss_ldap_init_recv(subreq, &state->sh->ldap, &sd);
     talloc_zfree(subreq);
@@ -260,6 +261,16 @@ static void sdap_sys_connect_done(struct tevent_req *subreq)
 
     }
 
+    /* Set host name canonicalization for LDAP SASL bind */
+    sasl_nocanon = !dp_opt_get_bool(state->opts->basic, SDAP_SASL_CANONICALIZE);
+    lret = ldap_set_option(state->sh->ldap, LDAP_OPT_X_SASL_NOCANON,
+                           sasl_nocanon ? LDAP_OPT_ON : LDAP_OPT_OFF);
+    if (lret != LDAP_OPT_SUCCESS) {
+        DEBUG(1, ("Failed to set LDAP SASL nocanon option to %s\n",
+                   sasl_nocanon ? "true" : "false"));
+        goto fail;
+    }
+
     /* if we do not use start_tls the connection is not really connected yet
      * just fake an async procedure and leave connection to the bind call */
     if (!state->use_start_tls) {
-- 
1.7.6



More information about the sssd-devel mailing list