Blame SOURCES/0012-ldap-add-new-option-ldap_sasl_maxssf.patch

0d441c
From 4c855d55944087cb2317c681f1dc78953ec95c4e Mon Sep 17 00:00:00 2001
0d441c
From: Sumit Bose <sbose@redhat.com>
0d441c
Date: Fri, 27 Sep 2019 11:49:59 +0200
0d441c
Subject: [PATCH 12/13] ldap: add new option ldap_sasl_maxssf
0d441c
MIME-Version: 1.0
0d441c
Content-Type: text/plain; charset=UTF-8
0d441c
Content-Transfer-Encoding: 8bit
0d441c
0d441c
There is already the ldap_sasl_minssf option. To be able to control the
0d441c
maximal security strength factor (ssf) e.g. when using SASL together
0d441c
with TLS the option ldap_sasl_maxssf is added as well.
0d441c
0d441c
Related to https://pagure.io/SSSD/sssd/issue/4131
0d441c
0d441c
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
0d441c
---
0d441c
 src/config/SSSDConfig/__init__.py.in       |  1 +
0d441c
 src/config/cfg_rules.ini                   |  1 +
0d441c
 src/config/etc/sssd.api.d/sssd-ad.conf     |  1 +
0d441c
 src/config/etc/sssd.api.d/sssd-ipa.conf    |  1 +
0d441c
 src/config/etc/sssd.api.d/sssd-ldap.conf   |  1 +
0d441c
 src/man/sssd-ldap.5.xml                    | 16 ++++++++++++++++
0d441c
 src/providers/ad/ad_opts.c                 |  1 +
0d441c
 src/providers/ipa/ipa_opts.c               |  1 +
0d441c
 src/providers/ldap/ldap_opts.c             |  1 +
0d441c
 src/providers/ldap/sdap.h                  |  1 +
0d441c
 src/providers/ldap/sdap_async_connection.c | 14 ++++++++++++++
0d441c
 11 files changed, 39 insertions(+)
0d441c
0d441c
diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
0d441c
index 84631862a..a1b088bc4 100644
0d441c
--- a/src/config/SSSDConfig/__init__.py.in
0d441c
+++ b/src/config/SSSDConfig/__init__.py.in
0d441c
@@ -305,6 +305,7 @@ option_strings = {
0d441c
     'ldap_sasl_authid' : _('Specify the sasl authorization id to use'),
0d441c
     'ldap_sasl_realm' : _('Specify the sasl authorization realm to use'),
0d441c
     'ldap_sasl_minssf' : _('Specify the minimal SSF for LDAP sasl authorization'),
0d441c
+    'ldap_sasl_maxssf' : _('Specify the maximal SSF for LDAP sasl authorization'),
0d441c
     'ldap_krb5_keytab' : _('Kerberos service keytab'),
0d441c
     'ldap_krb5_init_creds' : _('Use Kerberos auth for LDAP connection'),
0d441c
     'ldap_referrals' : _('Follow LDAP referrals'),
0d441c
diff --git a/src/config/cfg_rules.ini b/src/config/cfg_rules.ini
0d441c
index 1034a1fd6..fd5336db7 100644
0d441c
--- a/src/config/cfg_rules.ini
0d441c
+++ b/src/config/cfg_rules.ini
0d441c
@@ -664,6 +664,7 @@ option = ldap_sasl_authid
0d441c
 option = ldap_sasl_canonicalize
0d441c
 option = ldap_sasl_mech
0d441c
 option = ldap_sasl_minssf
0d441c
+option = ldap_sasl_maxssf
0d441c
 option = ldap_schema
0d441c
 option = ldap_pwmodify_mode
0d441c
 option = ldap_search_base
0d441c
diff --git a/src/config/etc/sssd.api.d/sssd-ad.conf b/src/config/etc/sssd.api.d/sssd-ad.conf
0d441c
index a2af72603..d6443e200 100644
0d441c
--- a/src/config/etc/sssd.api.d/sssd-ad.conf
0d441c
+++ b/src/config/etc/sssd.api.d/sssd-ad.conf
0d441c
@@ -41,6 +41,7 @@ ldap_tls_reqcert = str, None, false
0d441c
 ldap_sasl_mech = str, None, false
0d441c
 ldap_sasl_authid = str, None, false
0d441c
 ldap_sasl_minssf = int, None, false
0d441c
+ldap_sasl_maxssf = int, None, false
0d441c
 krb5_kdcip = str, None, false
0d441c
 krb5_server = str, None, false
0d441c
 krb5_backup_server = str, None, false
0d441c
diff --git a/src/config/etc/sssd.api.d/sssd-ipa.conf b/src/config/etc/sssd.api.d/sssd-ipa.conf
0d441c
index 7ed153d36..839f9f471 100644
0d441c
--- a/src/config/etc/sssd.api.d/sssd-ipa.conf
0d441c
+++ b/src/config/etc/sssd.api.d/sssd-ipa.conf
0d441c
@@ -32,6 +32,7 @@ ldap_tls_reqcert = str, None, false
0d441c
 ldap_sasl_mech = str, None, false
0d441c
 ldap_sasl_authid = str, None, false
0d441c
 ldap_sasl_minssf = int, None, false
0d441c
+ldap_sasl_maxssf = int, None, false
0d441c
 krb5_kdcip = str, None, false
0d441c
 krb5_server = str, None, false
0d441c
 krb5_backup_server = str, None, false
0d441c
diff --git a/src/config/etc/sssd.api.d/sssd-ldap.conf b/src/config/etc/sssd.api.d/sssd-ldap.conf
0d441c
index 4f73e901e..6db9828b9 100644
0d441c
--- a/src/config/etc/sssd.api.d/sssd-ldap.conf
0d441c
+++ b/src/config/etc/sssd.api.d/sssd-ldap.conf
0d441c
@@ -35,6 +35,7 @@ ldap_page_size = int, None, false
0d441c
 ldap_deref_threshold = int, None, false
0d441c
 ldap_sasl_canonicalize = bool, None, false
0d441c
 ldap_sasl_minssf = int, None, false
0d441c
+ldap_sasl_maxssf = int, None, false
0d441c
 ldap_connection_expire_timeout = int, None, false
0d441c
 ldap_connection_expire_offset = int, None, false
0d441c
 ldap_disable_paging = bool, None, false
0d441c
diff --git a/src/man/sssd-ldap.5.xml b/src/man/sssd-ldap.5.xml
0d441c
index f8bb973c7..0dc675410 100644
0d441c
--- a/src/man/sssd-ldap.5.xml
0d441c
+++ b/src/man/sssd-ldap.5.xml
0d441c
@@ -612,6 +612,22 @@
0d441c
                     </listitem>
0d441c
                 </varlistentry>
0d441c
 
0d441c
+                <varlistentry>
0d441c
+                    <term>ldap_sasl_maxssf (integer)</term>
0d441c
+                    <listitem>
0d441c
+                        <para>
0d441c
+                            When communicating with an LDAP server using SASL,
0d441c
+                            specify the maximal security level necessary to
0d441c
+                            establish the connection. The values of this
0d441c
+                            option are defined by OpenLDAP.
0d441c
+                        </para>
0d441c
+                        <para>
0d441c
+                            Default: Use the system default (usually specified
0d441c
+                            by ldap.conf)
0d441c
+                        </para>
0d441c
+                    </listitem>
0d441c
+                </varlistentry>
0d441c
+
0d441c
                 <varlistentry>
0d441c
                     <term>ldap_deref_threshold (integer)</term>
0d441c
                     <listitem>
0d441c
diff --git a/src/providers/ad/ad_opts.c b/src/providers/ad/ad_opts.c
0d441c
index 30f9b62fd..905a15cd0 100644
0d441c
--- a/src/providers/ad/ad_opts.c
0d441c
+++ b/src/providers/ad/ad_opts.c
0d441c
@@ -105,6 +105,7 @@ struct dp_option ad_def_ldap_opts[] = {
0d441c
     { "ldap_sasl_authid", DP_OPT_STRING, NULL_STRING, NULL_STRING },
0d441c
     { "ldap_sasl_realm", DP_OPT_STRING, NULL_STRING, NULL_STRING },
0d441c
     { "ldap_sasl_minssf", DP_OPT_NUMBER, { .number = -1 }, NULL_NUMBER },
0d441c
+    { "ldap_sasl_maxssf", DP_OPT_NUMBER, { .number = -1 }, NULL_NUMBER },
0d441c
     { "ldap_krb5_keytab", DP_OPT_STRING, NULL_STRING, NULL_STRING },
0d441c
     { "ldap_krb5_init_creds", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
0d441c
     /* use the same parm name as the krb5 module so we set it only once */
0d441c
diff --git a/src/providers/ipa/ipa_opts.c b/src/providers/ipa/ipa_opts.c
0d441c
index 4fafa073d..55de6e600 100644
0d441c
--- a/src/providers/ipa/ipa_opts.c
0d441c
+++ b/src/providers/ipa/ipa_opts.c
0d441c
@@ -114,6 +114,7 @@ struct dp_option ipa_def_ldap_opts[] = {
0d441c
     { "ldap_sasl_authid", DP_OPT_STRING, NULL_STRING, NULL_STRING },
0d441c
     { "ldap_sasl_realm", DP_OPT_STRING, NULL_STRING, NULL_STRING },
0d441c
     { "ldap_sasl_minssf", DP_OPT_NUMBER, { .number = 56 }, NULL_NUMBER },
0d441c
+    { "ldap_sasl_maxssf", DP_OPT_NUMBER, { .number = -1 }, NULL_NUMBER },
0d441c
     { "ldap_krb5_keytab", DP_OPT_STRING, NULL_STRING, NULL_STRING },
0d441c
     { "ldap_krb5_init_creds", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
0d441c
     /* use the same parm name as the krb5 module so we set it only once */
0d441c
diff --git a/src/providers/ldap/ldap_opts.c b/src/providers/ldap/ldap_opts.c
0d441c
index ffd0c6baa..d1b4e98ad 100644
0d441c
--- a/src/providers/ldap/ldap_opts.c
0d441c
+++ b/src/providers/ldap/ldap_opts.c
0d441c
@@ -74,6 +74,7 @@ struct dp_option default_basic_opts[] = {
0d441c
     { "ldap_sasl_authid", DP_OPT_STRING, NULL_STRING, NULL_STRING },
0d441c
     { "ldap_sasl_realm", DP_OPT_STRING, NULL_STRING, NULL_STRING },
0d441c
     { "ldap_sasl_minssf", DP_OPT_NUMBER, { .number = -1 }, NULL_NUMBER },
0d441c
+    { "ldap_sasl_maxssf", DP_OPT_NUMBER, { .number = -1 }, NULL_NUMBER },
0d441c
     { "ldap_krb5_keytab", DP_OPT_STRING, NULL_STRING, NULL_STRING },
0d441c
     { "ldap_krb5_init_creds", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
0d441c
     /* use the same parm name as the krb5 module so we set it only once */
0d441c
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
0d441c
index f27b3c480..808a2c400 100644
0d441c
--- a/src/providers/ldap/sdap.h
0d441c
+++ b/src/providers/ldap/sdap.h
0d441c
@@ -192,6 +192,7 @@ enum sdap_basic_opt {
0d441c
     SDAP_SASL_AUTHID,
0d441c
     SDAP_SASL_REALM,
0d441c
     SDAP_SASL_MINSSF,
0d441c
+    SDAP_SASL_MAXSSF,
0d441c
     SDAP_KRB5_KEYTAB,
0d441c
     SDAP_KRB5_KINIT,
0d441c
     SDAP_KRB5_KDC,
0d441c
diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c
0d441c
index 7438d14a7..5f69cedcc 100644
0d441c
--- a/src/providers/ldap/sdap_async_connection.c
0d441c
+++ b/src/providers/ldap/sdap_async_connection.c
0d441c
@@ -148,6 +148,8 @@ static void sdap_sys_connect_done(struct tevent_req *subreq)
0d441c
     const char *sasl_mech;
0d441c
     int sasl_minssf;
0d441c
     ber_len_t ber_sasl_minssf;
0d441c
+    int sasl_maxssf;
0d441c
+    ber_len_t ber_sasl_maxssf;
0d441c
 
0d441c
     ret = sss_ldap_init_recv(subreq, &state->sh->ldap, &sd);
0d441c
     talloc_zfree(subreq);
0d441c
@@ -291,6 +293,18 @@ static void sdap_sys_connect_done(struct tevent_req *subreq)
0d441c
                 goto fail;
0d441c
             }
0d441c
         }
0d441c
+
0d441c
+        sasl_maxssf = dp_opt_get_int(state->opts->basic, SDAP_SASL_MAXSSF);
0d441c
+        if (sasl_maxssf >= 0) {
0d441c
+            ber_sasl_maxssf = (ber_len_t)sasl_maxssf;
0d441c
+            lret = ldap_set_option(state->sh->ldap, LDAP_OPT_X_SASL_SSF_MAX,
0d441c
+                                   &ber_sasl_maxssf);
0d441c
+            if (lret != LDAP_OPT_SUCCESS) {
0d441c
+                DEBUG(SSSDBG_CRIT_FAILURE, "Failed to set LDAP MAX SSF option "
0d441c
+                                            "to %d\n", sasl_maxssf);
0d441c
+                goto fail;
0d441c
+            }
0d441c
+        }
0d441c
     }
0d441c
 
0d441c
     /* if we do not use start_tls the connection is not really connected yet
0d441c
-- 
0d441c
2.20.1
0d441c