dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

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

8d3578
From 07d19249a88d90135dce21e3d112caf70629ef02 Mon Sep 17 00:00:00 2001
8d3578
From: Sumit Bose <sbose@redhat.com>
8d3578
Date: Fri, 27 Sep 2019 11:49:59 +0200
8d3578
Subject: [PATCH 108/109] ldap: add new option ldap_sasl_maxssf
8d3578
MIME-Version: 1.0
8d3578
Content-Type: text/plain; charset=UTF-8
8d3578
Content-Transfer-Encoding: 8bit
8d3578
8d3578
There is already the ldap_sasl_minssf option. To be able to control the
8d3578
maximal security strength factor (ssf) e.g. when using SASL together
8d3578
with TLS the option ldap_sasl_maxssf is added as well.
8d3578
8d3578
Related to https://pagure.io/SSSD/sssd/issue/4131
8d3578
8d3578
(cherry picked from commit 3b95c39819591428b1e535e5dc874268cf5630c5)
8d3578
8d3578
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
8d3578
---
8d3578
 src/config/SSSDConfig/__init__.py.in       |  1 +
8d3578
 src/config/cfg_rules.ini                   |  1 +
8d3578
 src/config/etc/sssd.api.d/sssd-ad.conf     |  1 +
8d3578
 src/config/etc/sssd.api.d/sssd-ipa.conf    |  1 +
8d3578
 src/config/etc/sssd.api.d/sssd-ldap.conf   |  1 +
8d3578
 src/man/sssd-ldap.5.xml                    | 16 ++++++++++++++++
8d3578
 src/providers/ad/ad_opts.c                 |  1 +
8d3578
 src/providers/ipa/ipa_opts.c               |  1 +
8d3578
 src/providers/ldap/ldap_opts.c             |  1 +
8d3578
 src/providers/ldap/sdap.h                  |  1 +
8d3578
 src/providers/ldap/sdap_async_connection.c | 14 ++++++++++++++
8d3578
 11 files changed, 39 insertions(+)
8d3578
8d3578
diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
8d3578
index 00e588f1c..703dee0a5 100644
8d3578
--- a/src/config/SSSDConfig/__init__.py.in
8d3578
+++ b/src/config/SSSDConfig/__init__.py.in
8d3578
@@ -300,6 +300,7 @@ option_strings = {
8d3578
     'ldap_sasl_authid' : _('Specify the sasl authorization id to use'),
8d3578
     'ldap_sasl_realm' : _('Specify the sasl authorization realm to use'),
8d3578
     'ldap_sasl_minssf' : _('Specify the minimal SSF for LDAP sasl authorization'),
8d3578
+    'ldap_sasl_maxssf' : _('Specify the maximal SSF for LDAP sasl authorization'),
8d3578
     'ldap_krb5_keytab' : _('Kerberos service keytab'),
8d3578
     'ldap_krb5_init_creds' : _('Use Kerberos auth for LDAP connection'),
8d3578
     'ldap_referrals' : _('Follow LDAP referrals'),
8d3578
diff --git a/src/config/cfg_rules.ini b/src/config/cfg_rules.ini
8d3578
index c3d8bd88f..bab9b4541 100644
8d3578
--- a/src/config/cfg_rules.ini
8d3578
+++ b/src/config/cfg_rules.ini
8d3578
@@ -655,6 +655,7 @@ option = ldap_sasl_authid
8d3578
 option = ldap_sasl_canonicalize
8d3578
 option = ldap_sasl_mech
8d3578
 option = ldap_sasl_minssf
8d3578
+option = ldap_sasl_maxssf
8d3578
 option = ldap_schema
8d3578
 option = ldap_pwmodify_mode
8d3578
 option = ldap_search_base
8d3578
diff --git a/src/config/etc/sssd.api.d/sssd-ad.conf b/src/config/etc/sssd.api.d/sssd-ad.conf
8d3578
index 48522437f..c53c08f37 100644
8d3578
--- a/src/config/etc/sssd.api.d/sssd-ad.conf
8d3578
+++ b/src/config/etc/sssd.api.d/sssd-ad.conf
8d3578
@@ -41,6 +41,7 @@ ldap_tls_reqcert = str, None, false
8d3578
 ldap_sasl_mech = str, None, false
8d3578
 ldap_sasl_authid = str, None, false
8d3578
 ldap_sasl_minssf = int, None, false
8d3578
+ldap_sasl_maxssf = int, None, false
8d3578
 krb5_kdcip = str, None, false
8d3578
 krb5_server = str, None, false
8d3578
 krb5_backup_server = str, None, false
8d3578
diff --git a/src/config/etc/sssd.api.d/sssd-ipa.conf b/src/config/etc/sssd.api.d/sssd-ipa.conf
8d3578
index 5b17de345..514e8b136 100644
8d3578
--- a/src/config/etc/sssd.api.d/sssd-ipa.conf
8d3578
+++ b/src/config/etc/sssd.api.d/sssd-ipa.conf
8d3578
@@ -32,6 +32,7 @@ ldap_tls_reqcert = str, None, false
8d3578
 ldap_sasl_mech = str, None, false
8d3578
 ldap_sasl_authid = str, None, false
8d3578
 ldap_sasl_minssf = int, None, false
8d3578
+ldap_sasl_maxssf = int, None, false
8d3578
 krb5_kdcip = str, None, false
8d3578
 krb5_server = str, None, false
8d3578
 krb5_backup_server = str, None, false
8d3578
diff --git a/src/config/etc/sssd.api.d/sssd-ldap.conf b/src/config/etc/sssd.api.d/sssd-ldap.conf
8d3578
index a911b1977..40746f8ff 100644
8d3578
--- a/src/config/etc/sssd.api.d/sssd-ldap.conf
8d3578
+++ b/src/config/etc/sssd.api.d/sssd-ldap.conf
8d3578
@@ -35,6 +35,7 @@ ldap_page_size = int, None, false
8d3578
 ldap_deref_threshold = int, None, false
8d3578
 ldap_sasl_canonicalize = bool, None, false
8d3578
 ldap_sasl_minssf = int, None, false
8d3578
+ldap_sasl_maxssf = int, None, false
8d3578
 ldap_connection_expire_timeout = int, None, false
8d3578
 ldap_disable_paging = bool, None, false
8d3578
 ldap_disable_range_retrieval = bool, None, false
8d3578
diff --git a/src/man/sssd-ldap.5.xml b/src/man/sssd-ldap.5.xml
8d3578
index 3e769038b..311203523 100644
8d3578
--- a/src/man/sssd-ldap.5.xml
8d3578
+++ b/src/man/sssd-ldap.5.xml
8d3578
@@ -1591,6 +1591,22 @@
8d3578
                     </listitem>
8d3578
                 </varlistentry>
8d3578
 
8d3578
+                <varlistentry>
8d3578
+                    <term>ldap_sasl_maxssf (integer)</term>
8d3578
+                    <listitem>
8d3578
+                        <para>
8d3578
+                            When communicating with an LDAP server using SASL,
8d3578
+                            specify the maximal security level necessary to
8d3578
+                            establish the connection. The values of this
8d3578
+                            option are defined by OpenLDAP.
8d3578
+                        </para>
8d3578
+                        <para>
8d3578
+                            Default: Use the system default (usually specified
8d3578
+                            by ldap.conf)
8d3578
+                        </para>
8d3578
+                    </listitem>
8d3578
+                </varlistentry>
8d3578
+
8d3578
                 <varlistentry>
8d3578
                     <term>ldap_deref_threshold (integer)</term>
8d3578
                     <listitem>
8d3578
diff --git a/src/providers/ad/ad_opts.c b/src/providers/ad/ad_opts.c
8d3578
index cd898cbd2..f181e5073 100644
8d3578
--- a/src/providers/ad/ad_opts.c
8d3578
+++ b/src/providers/ad/ad_opts.c
8d3578
@@ -105,6 +105,7 @@ struct dp_option ad_def_ldap_opts[] = {
8d3578
     { "ldap_sasl_authid", DP_OPT_STRING, NULL_STRING, NULL_STRING },
8d3578
     { "ldap_sasl_realm", DP_OPT_STRING, NULL_STRING, NULL_STRING },
8d3578
     { "ldap_sasl_minssf", DP_OPT_NUMBER, { .number = -1 }, NULL_NUMBER },
8d3578
+    { "ldap_sasl_maxssf", DP_OPT_NUMBER, { .number = -1 }, NULL_NUMBER },
8d3578
     { "ldap_krb5_keytab", DP_OPT_STRING, NULL_STRING, NULL_STRING },
8d3578
     { "ldap_krb5_init_creds", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
8d3578
     /* use the same parm name as the krb5 module so we set it only once */
8d3578
diff --git a/src/providers/ipa/ipa_opts.c b/src/providers/ipa/ipa_opts.c
8d3578
index 600b9ec4b..c43b21778 100644
8d3578
--- a/src/providers/ipa/ipa_opts.c
8d3578
+++ b/src/providers/ipa/ipa_opts.c
8d3578
@@ -113,6 +113,7 @@ struct dp_option ipa_def_ldap_opts[] = {
8d3578
     { "ldap_sasl_authid", DP_OPT_STRING, NULL_STRING, NULL_STRING },
8d3578
     { "ldap_sasl_realm", DP_OPT_STRING, NULL_STRING, NULL_STRING },
8d3578
     { "ldap_sasl_minssf", DP_OPT_NUMBER, { .number = 56 }, NULL_NUMBER },
8d3578
+    { "ldap_sasl_maxssf", DP_OPT_NUMBER, { .number = -1 }, NULL_NUMBER },
8d3578
     { "ldap_krb5_keytab", DP_OPT_STRING, NULL_STRING, NULL_STRING },
8d3578
     { "ldap_krb5_init_creds", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
8d3578
     /* use the same parm name as the krb5 module so we set it only once */
8d3578
diff --git a/src/providers/ldap/ldap_opts.c b/src/providers/ldap/ldap_opts.c
8d3578
index 9b4a277d0..b0e903f62 100644
8d3578
--- a/src/providers/ldap/ldap_opts.c
8d3578
+++ b/src/providers/ldap/ldap_opts.c
8d3578
@@ -74,6 +74,7 @@ struct dp_option default_basic_opts[] = {
8d3578
     { "ldap_sasl_authid", DP_OPT_STRING, NULL_STRING, NULL_STRING },
8d3578
     { "ldap_sasl_realm", DP_OPT_STRING, NULL_STRING, NULL_STRING },
8d3578
     { "ldap_sasl_minssf", DP_OPT_NUMBER, { .number = -1 }, NULL_NUMBER },
8d3578
+    { "ldap_sasl_maxssf", DP_OPT_NUMBER, { .number = -1 }, NULL_NUMBER },
8d3578
     { "ldap_krb5_keytab", DP_OPT_STRING, NULL_STRING, NULL_STRING },
8d3578
     { "ldap_krb5_init_creds", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
8d3578
     /* use the same parm name as the krb5 module so we set it only once */
8d3578
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
8d3578
index 126cb10d4..0bf4fe12b 100644
8d3578
--- a/src/providers/ldap/sdap.h
8d3578
+++ b/src/providers/ldap/sdap.h
8d3578
@@ -192,6 +192,7 @@ enum sdap_basic_opt {
8d3578
     SDAP_SASL_AUTHID,
8d3578
     SDAP_SASL_REALM,
8d3578
     SDAP_SASL_MINSSF,
8d3578
+    SDAP_SASL_MAXSSF,
8d3578
     SDAP_KRB5_KEYTAB,
8d3578
     SDAP_KRB5_KINIT,
8d3578
     SDAP_KRB5_KDC,
8d3578
diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c
8d3578
index 6bc271a91..afa31ea0f 100644
8d3578
--- a/src/providers/ldap/sdap_async_connection.c
8d3578
+++ b/src/providers/ldap/sdap_async_connection.c
8d3578
@@ -148,6 +148,8 @@ static void sdap_sys_connect_done(struct tevent_req *subreq)
8d3578
     const char *sasl_mech;
8d3578
     int sasl_minssf;
8d3578
     ber_len_t ber_sasl_minssf;
8d3578
+    int sasl_maxssf;
8d3578
+    ber_len_t ber_sasl_maxssf;
8d3578
 
8d3578
     ret = sss_ldap_init_recv(subreq, &state->sh->ldap, &sd);
8d3578
     talloc_zfree(subreq);
8d3578
@@ -291,6 +293,18 @@ static void sdap_sys_connect_done(struct tevent_req *subreq)
8d3578
                 goto fail;
8d3578
             }
8d3578
         }
8d3578
+
8d3578
+        sasl_maxssf = dp_opt_get_int(state->opts->basic, SDAP_SASL_MAXSSF);
8d3578
+        if (sasl_maxssf >= 0) {
8d3578
+            ber_sasl_maxssf = (ber_len_t)sasl_maxssf;
8d3578
+            lret = ldap_set_option(state->sh->ldap, LDAP_OPT_X_SASL_SSF_MAX,
8d3578
+                                   &ber_sasl_maxssf);
8d3578
+            if (lret != LDAP_OPT_SUCCESS) {
8d3578
+                DEBUG(SSSDBG_CRIT_FAILURE, "Failed to set LDAP MAX SSF option "
8d3578
+                                            "to %d\n", sasl_maxssf);
8d3578
+                goto fail;
8d3578
+            }
8d3578
+        }
8d3578
     }
8d3578
 
8d3578
     /* if we do not use start_tls the connection is not really connected yet
8d3578
-- 
8d3578
2.20.1
8d3578