|
|
b69e47 |
From d2648bbddbf087c4e3803a89cb67541a50682eae Mon Sep 17 00:00:00 2001
|
|
|
b69e47 |
From: William Brown <firstyear@redhat.com>
|
|
|
b69e47 |
Date: Mon, 15 May 2017 09:04:45 +1000
|
|
|
b69e47 |
Subject: [PATCH] Ticket 49231 - force EXTERNAL always
|
|
|
b69e47 |
|
|
|
b69e47 |
Bug Description: Because of how our sasl code works, EXTERNAL bypasses
|
|
|
b69e47 |
a number of checks so is always available.
|
|
|
b69e47 |
|
|
|
b69e47 |
Fix Description: Force EXTERNAL to the present mech list, regardless
|
|
|
b69e47 |
of the whitelist.
|
|
|
b69e47 |
|
|
|
b69e47 |
https://pagure.io/389-ds-base/issue/49231
|
|
|
b69e47 |
|
|
|
b69e47 |
Author: wibrown
|
|
|
b69e47 |
|
|
|
b69e47 |
Review by: mreynosd (Thanks!)
|
|
|
b69e47 |
|
|
|
b69e47 |
(cherry picked from commit e6e0db35842fc6612134cff5a08c4968230d1b2f)
|
|
|
b69e47 |
---
|
|
|
b69e47 |
dirsrvtests/tests/suites/sasl/allowed_mechs.py | 13 +++++++++++--
|
|
|
b69e47 |
ldap/servers/slapd/charray.c | 14 ++++++++++++++
|
|
|
b69e47 |
ldap/servers/slapd/saslbind.c | 9 +++++++++
|
|
|
b69e47 |
ldap/servers/slapd/slapi-private.h | 2 ++
|
|
|
b69e47 |
4 files changed, 36 insertions(+), 2 deletions(-)
|
|
|
b69e47 |
|
|
|
b69e47 |
diff --git a/dirsrvtests/tests/suites/sasl/allowed_mechs.py b/dirsrvtests/tests/suites/sasl/allowed_mechs.py
|
|
|
b69e47 |
index a3e385e..7958db4 100644
|
|
|
b69e47 |
--- a/dirsrvtests/tests/suites/sasl/allowed_mechs.py
|
|
|
b69e47 |
+++ b/dirsrvtests/tests/suites/sasl/allowed_mechs.py
|
|
|
b69e47 |
@@ -25,12 +25,21 @@ def test_sasl_allowed_mechs(topology_st):
|
|
|
b69e47 |
assert('EXTERNAL' in orig_mechs)
|
|
|
b69e47 |
|
|
|
b69e47 |
# Now edit the supported mechs. CHeck them again.
|
|
|
b69e47 |
- standalone.config.set('nsslapd-allowed-sasl-mechanisms', 'EXTERNAL, PLAIN')
|
|
|
b69e47 |
+ standalone.config.set('nsslapd-allowed-sasl-mechanisms', 'PLAIN')
|
|
|
b69e47 |
|
|
|
b69e47 |
limit_mechs = standalone.rootdse.supported_sasl()
|
|
|
b69e47 |
- print(limit_mechs)
|
|
|
b69e47 |
assert('PLAIN' in limit_mechs)
|
|
|
b69e47 |
+ # Should always be in the allowed list, even if not set.
|
|
|
b69e47 |
assert('EXTERNAL' in limit_mechs)
|
|
|
b69e47 |
+ # Should not be there!
|
|
|
b69e47 |
+ assert('GSSAPI' not in limit_mechs)
|
|
|
b69e47 |
+
|
|
|
b69e47 |
+ standalone.config.set('nsslapd-allowed-sasl-mechanisms', 'PLAIN, EXTERNAL')
|
|
|
b69e47 |
+
|
|
|
b69e47 |
+ limit_mechs = standalone.rootdse.supported_sasl()
|
|
|
b69e47 |
+ assert('PLAIN' in limit_mechs)
|
|
|
b69e47 |
+ assert('EXTERNAL' in limit_mechs)
|
|
|
b69e47 |
+ # Should not be there!
|
|
|
b69e47 |
assert('GSSAPI' not in limit_mechs)
|
|
|
b69e47 |
|
|
|
b69e47 |
# Do a config reset
|
|
|
b69e47 |
diff --git a/ldap/servers/slapd/charray.c b/ldap/servers/slapd/charray.c
|
|
|
b69e47 |
index 6b89714..9056f16 100644
|
|
|
b69e47 |
--- a/ldap/servers/slapd/charray.c
|
|
|
b69e47 |
+++ b/ldap/servers/slapd/charray.c
|
|
|
b69e47 |
@@ -272,6 +272,20 @@ charray_utf8_inlist(
|
|
|
b69e47 |
return( 0 );
|
|
|
b69e47 |
}
|
|
|
b69e47 |
|
|
|
b69e47 |
+/*
|
|
|
b69e47 |
+ * Assert that some str s is in the charray, or add it.
|
|
|
b69e47 |
+ */
|
|
|
b69e47 |
+void
|
|
|
b69e47 |
+charray_assert_present(char ***a, char *s)
|
|
|
b69e47 |
+{
|
|
|
b69e47 |
+ int result = charray_utf8_inlist(*a, s);
|
|
|
b69e47 |
+ /* Not in the list */
|
|
|
b69e47 |
+ if (result == 0) {
|
|
|
b69e47 |
+ char *sdup = slapi_ch_strdup(s);
|
|
|
b69e47 |
+ slapi_ch_array_add_ext(a, sdup);
|
|
|
b69e47 |
+ }
|
|
|
b69e47 |
+}
|
|
|
b69e47 |
+
|
|
|
b69e47 |
int slapi_ch_array_utf8_inlist(char **a, char *s)
|
|
|
b69e47 |
{
|
|
|
b69e47 |
return charray_utf8_inlist(a,s);
|
|
|
b69e47 |
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
|
|
|
b69e47 |
index 75b83fe..dd0c4fb 100644
|
|
|
b69e47 |
--- a/ldap/servers/slapd/saslbind.c
|
|
|
b69e47 |
+++ b/ldap/servers/slapd/saslbind.c
|
|
|
b69e47 |
@@ -794,6 +794,15 @@ char **ids_sasl_listmech(Slapi_PBlock *pb)
|
|
|
b69e47 |
ret = sup_ret;
|
|
|
b69e47 |
}
|
|
|
b69e47 |
|
|
|
b69e47 |
+ /*
|
|
|
b69e47 |
+ * https://pagure.io/389-ds-base/issue/49231
|
|
|
b69e47 |
+ * Because of the way that SASL mechs are managed in bind.c and saslbind.c
|
|
|
b69e47 |
+ * even if EXTERNAL was *not* in the list of allowed mechs, it was allowed
|
|
|
b69e47 |
+ * in the bind process because it bypasses lots of our checking. As a result
|
|
|
b69e47 |
+ * we have to always present it.
|
|
|
b69e47 |
+ */
|
|
|
b69e47 |
+ charray_assert_present(&ret, "EXTERNAL");
|
|
|
b69e47 |
+
|
|
|
b69e47 |
slapi_log_err(SLAPI_LOG_TRACE, "ids_sasl_listmech", "<=\n");
|
|
|
b69e47 |
|
|
|
b69e47 |
return ret;
|
|
|
b69e47 |
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
|
|
|
b69e47 |
index 3f732e8..0836d66 100644
|
|
|
b69e47 |
--- a/ldap/servers/slapd/slapi-private.h
|
|
|
b69e47 |
+++ b/ldap/servers/slapd/slapi-private.h
|
|
|
b69e47 |
@@ -834,6 +834,8 @@ void charray_subtract( char **a, char **b, char ***c );
|
|
|
b69e47 |
char **charray_intersection(char **a, char **b);
|
|
|
b69e47 |
int charray_get_index(char **array, char *s);
|
|
|
b69e47 |
int charray_normdn_add(char ***chararray, char *dn, char *errstr);
|
|
|
b69e47 |
+void charray_assert_present(char ***a, char *s);
|
|
|
b69e47 |
+
|
|
|
b69e47 |
|
|
|
b69e47 |
/******************************************************************************
|
|
|
b69e47 |
* value array routines.
|
|
|
b69e47 |
--
|
|
|
b69e47 |
2.9.4
|
|
|
b69e47 |
|