Blame SOURCES/0054-ad-add-ad_allow_remote_domain_local_groups.patch

32a074
From 6f31f43ee15bcb0933ddca8726b166a93f9371a9 Mon Sep 17 00:00:00 2001
32a074
From: Sumit Bose <sbose@redhat.com>
32a074
Date: Tue, 1 Oct 2019 20:24:09 +0200
32a074
Subject: [PATCH] ad: add ad_allow_remote_domain_local_groups
32a074
MIME-Version: 1.0
32a074
Content-Type: text/plain; charset=UTF-8
32a074
Content-Transfer-Encoding: 8bit
32a074
32a074
As the option name says if set to true Domain Local groups from remote
32a074
domains won't be filtered out. This option is added to facilitate the
32a074
migration from other solution and should only be used for this purpose.
32a074
32a074
Resolves: https://github.com/SSSD/sssd/issues/5346
32a074
32a074
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
32a074
(cherry picked with changes from commit 4f65a8d15b8e5f3dd613e789d68f38e60e0addc5)
32a074
32a074
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
32a074
---
32a074
 src/config/SSSDConfig/__init__.py.in   |  1 +
32a074
 src/config/cfg_rules.ini               |  1 +
32a074
 src/config/etc/sssd.api.d/sssd-ad.conf |  1 +
32a074
 src/man/sssd-ad.5.xml                  | 49 ++++++++++++++++++++++++++
32a074
 src/providers/ad/ad_common.c           |  3 ++
32a074
 src/providers/ad/ad_common.h           |  1 +
32a074
 src/providers/ad/ad_opts.c             |  1 +
32a074
 src/providers/ldap/sdap.h              |  1 +
32a074
 src/providers/ldap/sdap_ad_groups.c    |  3 +-
32a074
 9 files changed, 60 insertions(+), 1 deletion(-)
32a074
32a074
diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
32a074
index 1aa93f8cf..15ab632aa 100644
32a074
--- a/src/config/SSSDConfig/__init__.py.in
32a074
+++ b/src/config/SSSDConfig/__init__.py.in
32a074
@@ -250,6 +250,7 @@ option_strings = {
32a074
     'ad_maximum_machine_account_password_age' : _('Maximum age in days before the machine account password should be renewed'),
32a074
     'ad_machine_account_password_renewal_opts' : _('Option for tuning the machine account renewal task'),
32a074
     'ad_use_ldaps' : _('Use LDAPS port for LDAP and Global Catalog requests'),
32a074
+    'ad_allow_remote_domain_local_groups' : _('Do not filter domain local groups from other domains'),
32a074
 
32a074
     # [provider/krb5]
32a074
     'krb5_kdcip' : _('Kerberos server address'),
32a074
diff --git a/src/config/cfg_rules.ini b/src/config/cfg_rules.ini
32a074
index e8ea13081..8f8ef30c3 100644
32a074
--- a/src/config/cfg_rules.ini
32a074
+++ b/src/config/cfg_rules.ini
32a074
@@ -459,6 +459,7 @@ option = ad_maximum_machine_account_password_age
32a074
 option = ad_server
32a074
 option = ad_site
32a074
 option = ad_use_ldaps
32a074
+option = ad_allow_remote_domain_local_groups
32a074
 
32a074
 # IPA provider specific options
32a074
 option = ipa_anchor_uuid
32a074
diff --git a/src/config/etc/sssd.api.d/sssd-ad.conf b/src/config/etc/sssd.api.d/sssd-ad.conf
32a074
index c53c08f37..74599a56d 100644
32a074
--- a/src/config/etc/sssd.api.d/sssd-ad.conf
32a074
+++ b/src/config/etc/sssd.api.d/sssd-ad.conf
32a074
@@ -21,6 +21,7 @@ ad_site = str, None, false
32a074
 ad_maximum_machine_account_password_age = int, None, false
32a074
 ad_machine_account_password_renewal_opts = str, None, false
32a074
 ad_use_ldaps = bool, None, false
32a074
+ad_allow_remote_domain_local_groups = bool, None, false
32a074
 ldap_uri = str, None, false
32a074
 ldap_backup_uri = str, None, false
32a074
 ldap_search_base = str, None, false
32a074
diff --git a/src/man/sssd-ad.5.xml b/src/man/sssd-ad.5.xml
32a074
index 6fc57ca21..839279bad 100644
32a074
--- a/src/man/sssd-ad.5.xml
32a074
+++ b/src/man/sssd-ad.5.xml
32a074
@@ -923,6 +923,55 @@ ad_gpo_map_deny = +my_pam_service
32a074
                     </listitem>
32a074
                 </varlistentry>
32a074
 
32a074
+                <varlistentry>
32a074
+                    <term>ad_allow_remote_domain_local_groups (boolean)</term>
32a074
+                    <listitem>
32a074
+                        <para>
32a074
+                            If this option is set to <quote>true</quote> SSSD
32a074
+                            will not filter out Domain Local groups from remote
32a074
+                            domains in the AD forest. By default they are
32a074
+                            filtered out e.g. when following a nested group
32a074
+                            hierarchy in remote domains because they are not
32a074
+                            valid in the local domain. To be compatible with
32a074
+                            other solutions which make AD users and groups
32a074
+                            available on Linux client this option was added.
32a074
+                        </para>
32a074
+                        <para>
32a074
+                            Please note that setting this option to
32a074
+                            <quote>true</quote> will be against the intention of
32a074
+                            Domain Local group in Active Directory and
32a074
+                            <emphasis>SHOULD ONLY BE USED TO FACILITATE
32a074
+                            MIGRATION FROM OTHER SOLUTIONS</emphasis>. Although
32a074
+                            the group exists and user can be member of the group
32a074
+                            the intention is that the group should be only used
32a074
+                            in the domain it is defined and in no others. Since
32a074
+                            there is only one type of POSIX groups the only way
32a074
+                            to achieve this on the Linux side is to ignore those
32a074
+                            groups. This is also done by Active Directory as can
32a074
+                            be seen in the PAC of the Kerberos ticket for a
32a074
+                            local service or in tokenGroups requests where
32a074
+                            remote Domain Local groups are missing as well.
32a074
+                        </para>
32a074
+                        <para>
32a074
+                            Given the comments above, if this option is set to
32a074
+                            <quote>true</quote> the tokenGroups request must be
32a074
+                            disabled by setting
32a074
+                            <quote>ldap_use_tokengroups</quote> to
32a074
+                            <quote>false</quote> to get consistent
32a074
+                            group-memberships of a users. Additionally the
32a074
+                            Global Catalog lookup should be skipped as well by
32a074
+                            setting <quote>ad_enable_gc</quote> to
32a074
+                            <quote>false</quote>. Finally it might be necessary
32a074
+                            to modify <quote>ldap_group_nesting_level</quote> if
32a074
+                            the remote Domain Local groups can only be found
32a074
+                            with a deeper nesting level.
32a074
+                        </para>
32a074
+                        <para>
32a074
+                            Default: False
32a074
+                        </para>
32a074
+                    </listitem>
32a074
+                </varlistentry>
32a074
+
32a074
                 <varlistentry>
32a074
                     <term>dyndns_update (boolean)</term>
32a074
                     <listitem>
32a074
diff --git a/src/providers/ad/ad_common.c b/src/providers/ad/ad_common.c
32a074
index 4e46da7f2..4e51d08e6 100644
32a074
--- a/src/providers/ad/ad_common.c
32a074
+++ b/src/providers/ad/ad_common.c
32a074
@@ -1072,6 +1072,9 @@ ad_set_sdap_options(struct ad_options *ad_opts,
32a074
                keytab_path);
32a074
     }
32a074
 
32a074
+    id_opts->allow_remote_domain_local_groups = dp_opt_get_bool(ad_opts->basic,
32a074
+                                                  AD_ALLOW_REMOTE_DOMAIN_LOCAL);
32a074
+
32a074
     ret = sdap_set_sasl_options(id_opts,
32a074
                                 dp_opt_get_string(ad_opts->basic,
32a074
                                                   AD_HOSTNAME),
32a074
diff --git a/src/providers/ad/ad_common.h b/src/providers/ad/ad_common.h
32a074
index 753394832..815b41419 100644
32a074
--- a/src/providers/ad/ad_common.h
32a074
+++ b/src/providers/ad/ad_common.h
32a074
@@ -69,6 +69,7 @@ enum ad_basic_opt {
32a074
     AD_MAXIMUM_MACHINE_ACCOUNT_PASSWORD_AGE,
32a074
     AD_MACHINE_ACCOUNT_PASSWORD_RENEWAL_OPTS,
32a074
     AD_USE_LDAPS,
32a074
+    AD_ALLOW_REMOTE_DOMAIN_LOCAL,
32a074
 
32a074
     AD_OPTS_BASIC /* opts counter */
32a074
 };
32a074
diff --git a/src/providers/ad/ad_opts.c b/src/providers/ad/ad_opts.c
32a074
index f2596a935..950ea51ff 100644
32a074
--- a/src/providers/ad/ad_opts.c
32a074
+++ b/src/providers/ad/ad_opts.c
32a074
@@ -55,6 +55,7 @@ struct dp_option ad_basic_opts[] = {
32a074
     { "ad_maximum_machine_account_password_age", DP_OPT_NUMBER, { .number = 30 }, NULL_NUMBER },
32a074
     { "ad_machine_account_password_renewal_opts", DP_OPT_STRING, { "86400:750" }, NULL_STRING },
32a074
     { "ad_use_ldaps", DP_OPT_BOOL, BOOL_FALSE, BOOL_FALSE },
32a074
+    { "ad_allow_remote_domain_local_groups", DP_OPT_BOOL, BOOL_FALSE, BOOL_FALSE },
32a074
     DP_OPTION_TERMINATOR
32a074
 };
32a074
 
32a074
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
32a074
index 0bf4fe12b..d9eff20ec 100644
32a074
--- a/src/providers/ldap/sdap.h
32a074
+++ b/src/providers/ldap/sdap.h
32a074
@@ -511,6 +511,7 @@ struct sdap_options {
32a074
     bool support_matching_rule;
32a074
     enum dc_functional_level dc_functional_level;
32a074
     const char *schema_basedn;
32a074
+    bool allow_remote_domain_local_groups;
32a074
 
32a074
     /* Certificate mapping support */
32a074
     struct sdap_certmap_ctx *sdap_certmap_ctx;
32a074
diff --git a/src/providers/ldap/sdap_ad_groups.c b/src/providers/ldap/sdap_ad_groups.c
32a074
index 0e36328b9..e8c6280d0 100644
32a074
--- a/src/providers/ldap/sdap_ad_groups.c
32a074
+++ b/src/providers/ldap/sdap_ad_groups.c
32a074
@@ -38,7 +38,8 @@ errno_t sdap_check_ad_group_type(struct sss_domain_info *dom,
32a074
     errno_t ret = EOK;
32a074
     *_need_filter = false;
32a074
 
32a074
-    if (opts->schema_type == SDAP_SCHEMA_AD) {
32a074
+    if (opts->schema_type == SDAP_SCHEMA_AD
32a074
+                && !opts->allow_remote_domain_local_groups) {
32a074
         ret = sysdb_attrs_get_int32_t(group_attrs, SYSDB_GROUP_TYPE,
32a074
                                       &ad_group_type);
32a074
         if (ret != EOK) {
32a074
-- 
32a074
2.21.3
32a074