From cf47e7bcbc363fc555820dc44da37827714bfe16 Mon Sep 17 00:00:00 2001
From: Simo Sorce <ssorce@redhat.com>
Date: Thu, 16 Sep 2010 14:04:14 -0400
Subject: [PATCH 1/6] Add option to limit nested groups

---
 src/config/etc/sssd.api.d/sssd-ipa.conf  |    1 +
 src/config/etc/sssd.api.d/sssd-ldap.conf |    1 +
 src/man/sssd-ldap.5.xml                  |   16 ++++++++++++++++
 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 +
 7 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/config/etc/sssd.api.d/sssd-ipa.conf b/src/config/etc/sssd.api.d/sssd-ipa.conf
index 88ff0f058251d7fe20ae9d904523732669f6891d..b559b78dc1fbdcb40952a1ccf75d99094c8e1ba1 100644
--- a/src/config/etc/sssd.api.d/sssd-ipa.conf
+++ b/src/config/etc/sssd.api.d/sssd-ipa.conf
@@ -70,6 +70,7 @@ ldap_group_member = str, None, false
 ldap_group_uuid = str, None, false
 ldap_group_modify_timestamp = str, None, false
 ldap_force_upper_case_realm = bool, None, false
+ldap_group_nesting_level = int, None, false
 ldap_netgroup_search_base = str, None, false
 ldap_netgroup_object_class = str, None, false
 ldap_netgroup_name = str, None, false
diff --git a/src/config/etc/sssd.api.d/sssd-ldap.conf b/src/config/etc/sssd.api.d/sssd-ldap.conf
index 38c75b2eb8824a7c6bfb85d922bc2395797be5c2..75eba586611f7110642f438f017a715b53f95195 100644
--- a/src/config/etc/sssd.api.d/sssd-ldap.conf
+++ b/src/config/etc/sssd.api.d/sssd-ldap.conf
@@ -62,6 +62,7 @@ ldap_group_gid_number = str, None, false
 ldap_group_member = str, None, false
 ldap_group_uuid = str, None, false
 ldap_group_modify_timestamp = str, None, false
+ldap_group_nesting_level = int, None, false
 ldap_force_upper_case_realm = bool, None, false
 ldap_netgroup_search_base = str, None, false
 ldap_netgroup_object_class = str, None, false
diff --git a/src/man/sssd-ldap.5.xml b/src/man/sssd-ldap.5.xml
index 646ef4cff4beb3fdf0897f148f88a1ee403d9eee..54b8e0c7cdbe06b1994b3d75201ea88594ca5994 100644
--- a/src/man/sssd-ldap.5.xml
+++ b/src/man/sssd-ldap.5.xml
@@ -578,6 +578,22 @@
                 </varlistentry>
 
                 <varlistentry>
+                    <term>ldap_group_nesting_level (string)</term>
+                    <listitem>
+                        <para>
+                            If ldap_schema is set to a schema format that
+                            supports nested groups (e.g. RFC2307bis), then
+                            this option controls how many levels of nesting
+                            SSSD will follow. This option has no effect on the
+                            RFC2307 schema.
+                        </para>
+                        <para>
+                            Default: 2
+                        </para>
+                    </listitem>
+                </varlistentry>
+
+                <varlistentry>
                     <term>ldap_netgroup_search_base (string)</term>
                     <listitem>
                         <para>
diff --git a/src/providers/ipa/ipa_common.c b/src/providers/ipa/ipa_common.c
index 2acd72a6062827c79532b726529803254c2f2cab..95d99de84ab8f64327078a6561978a99e555ca33 100644
--- a/src/providers/ipa/ipa_common.c
+++ b/src/providers/ipa/ipa_common.c
@@ -74,7 +74,8 @@ struct dp_option ipa_def_ldap_opts[] = {
     { "ldap_dns_service_name", DP_OPT_STRING, { SSS_LDAP_SRV_NAME }, NULL_STRING },
     { "ldap_krb5_ticket_lifetime", DP_OPT_NUMBER, { .number = (24 * 60 * 60) }, NULL_NUMBER },
     { "ldap_access_filter", DP_OPT_STRING, NULL_STRING, NULL_STRING },
-    { "ldap_netgroup_search_base", DP_OPT_STRING, NULL_STRING, NULL_STRING }
+    { "ldap_netgroup_search_base", DP_OPT_STRING, NULL_STRING, NULL_STRING },
+    { "ldap_group_nesting_level", DP_OPT_NUMBER, { .number = 2 }, NULL_NUMBER }
 };
 
 struct sdap_attr_map ipa_attr_map[] = {
diff --git a/src/providers/ipa/ipa_common.h b/src/providers/ipa/ipa_common.h
index 144ebf0c644ab6fac4282b68bd40a91fedae794f..8cbcaebb6368efb5801f2d94be9322d036d8dbad 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 37
+#define IPA_OPTS_BASIC_TEST 38
 
 /* 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 6925e694e59a3e2dedc036f495b8b915956d4954..ea5f957076675b4b8210917a928761e68088d485 100644
--- a/src/providers/ldap/ldap_common.c
+++ b/src/providers/ldap/ldap_common.c
@@ -64,13 +64,14 @@ struct dp_option default_basic_opts[] = {
     /* use the same parm name as the krb5 module so we set it only once */
     { "krb5_kdcip", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "krb5_realm", DP_OPT_STRING, NULL_STRING, NULL_STRING },
-    { "ldap_pwd_policy", DP_OPT_STRING, { "none" } , NULL_STRING },
+    { "ldap_pwd_policy", DP_OPT_STRING, { "none" }, NULL_STRING },
     { "ldap_referrals", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
     { "account_cache_expiration", DP_OPT_NUMBER, { .number = 0 }, NULL_NUMBER },
     { "ldap_dns_service_name", DP_OPT_STRING, { SSS_LDAP_SRV_NAME }, NULL_STRING },
     { "ldap_krb5_ticket_lifetime", DP_OPT_NUMBER, { .number = (24 * 60 * 60) }, NULL_NUMBER },
     { "ldap_access_filter", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "ldap_netgroup_search_base", DP_OPT_STRING, NULL_STRING, NULL_STRING },
+    { "ldap_group_nesting_level", DP_OPT_NUMBER, { .number = 2 }, NULL_NUMBER }
 };
 
 struct sdap_attr_map generic_attr_map[] = {
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
index bb50db8e57b4dd109f47ece219778d082d89311f..4506085f1ac03bf117ed7a050bdc56c6e94d2675 100644
--- a/src/providers/ldap/sdap.h
+++ b/src/providers/ldap/sdap.h
@@ -177,6 +177,7 @@ enum sdap_basic_opt {
     SDAP_KRB5_TICKET_LIFETIME,
     SDAP_ACCESS_FILTER,
     SDAP_NETGROUP_SEARCH_BASE,
+    SDAP_NESTING_LEVEL,
 
     SDAP_OPTS_BASIC /* opts counter */
 };
-- 
1.7.2.3

