Blame SOURCES/0061-CONFDB-Introduce-SSSD-domain-type-to-distinguish-POS.patch

ecf709
From 75a8d8e7996c35fd9bef504f2f4d3e308b7553c8 Mon Sep 17 00:00:00 2001
ecf709
From: Jakub Hrozek <jhrozek@redhat.com>
ecf709
Date: Wed, 22 Mar 2017 12:53:17 +0100
ecf709
Subject: [PATCH 61/72] CONFDB: Introduce SSSD domain type to distinguish POSIX
ecf709
 and application domains
ecf709
MIME-Version: 1.0
ecf709
Content-Type: text/plain; charset=UTF-8
ecf709
Content-Transfer-Encoding: 8bit
ecf709
ecf709
Related to:
ecf709
https://pagure.io/SSSD/sssd/issue/3310
ecf709
ecf709
Adds a new option that allows to distinguish domains that do contain
ecf709
POSIX users and groups and those that don't. The POSIX domains are the
ecf709
default. The non-POSIX domains are selected by selecting an
ecf709
"application" type domain.
ecf709
ecf709
Reviewed-by: Sumit Bose <sbose@redhat.com>
ecf709
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
ecf709
---
ecf709
 src/confdb/confdb.c                  | 18 +++++++++++++++++-
ecf709
 src/confdb/confdb.h                  | 15 +++++++++++++++
ecf709
 src/config/SSSDConfig/__init__.py.in |  1 +
ecf709
 src/config/SSSDConfigTest.py         |  2 ++
ecf709
 src/config/cfg_rules.ini             |  1 +
ecf709
 src/config/etc/sssd.api.conf         |  1 +
ecf709
 src/man/sssd.conf.5.xml              | 33 +++++++++++++++++++++++++++++++++
ecf709
 src/util/domain_info_utils.c         | 14 ++++++++++++++
ecf709
 src/util/util.h                      |  1 +
ecf709
 9 files changed, 85 insertions(+), 1 deletion(-)
ecf709
ecf709
diff --git a/src/confdb/confdb.c b/src/confdb/confdb.c
ecf709
index d82fd98ee02928b3c20df014528bd869ec946f92..70a1eb7b2c7e83dfa9d217a15c7d3d4c8580b891 100644
ecf709
--- a/src/confdb/confdb.c
ecf709
+++ b/src/confdb/confdb.c
ecf709
@@ -1367,6 +1367,22 @@ static int confdb_get_domain_internal(struct confdb_ctx *cdb,
ecf709
         }
ecf709
     }
ecf709
 
ecf709
+    domain->type = DOM_TYPE_POSIX;
ecf709
+    tmp = ldb_msg_find_attr_as_string(res->msgs[0],
ecf709
+                                      CONFDB_DOMAIN_TYPE,
ecf709
+                                      CONFDB_DOMAIN_TYPE_POSIX);
ecf709
+    if (tmp != NULL) {
ecf709
+        if (strcasecmp(tmp, CONFDB_DOMAIN_TYPE_POSIX) == 0) {
ecf709
+            domain->type = DOM_TYPE_POSIX;
ecf709
+        } else if (strcasecmp(tmp, CONFDB_DOMAIN_TYPE_APP) == 0) {
ecf709
+            domain->type = DOM_TYPE_APPLICATION;
ecf709
+        } else {
ecf709
+            DEBUG(SSSDBG_FATAL_FAILURE,
ecf709
+                  "Invalid value %s for [%s]\n", tmp, CONFDB_DOMAIN_TYPE);
ecf709
+            goto done;
ecf709
+        }
ecf709
+    }
ecf709
+
ecf709
     ret = get_entry_as_uint32(res->msgs[0], &domain->subdomain_refresh_interval,
ecf709
                               CONFDB_DOMAIN_SUBDOMAIN_REFRESH, 14400);
ecf709
     if (ret != EOK || domain->subdomain_refresh_interval == 0) {
ecf709
@@ -1444,7 +1460,7 @@ int confdb_get_domains(struct confdb_ctx *cdb,
ecf709
         if (ret) {
ecf709
             DEBUG(SSSDBG_FATAL_FAILURE,
ecf709
                   "Error (%d [%s]) retrieving domain [%s], skipping!\n",
ecf709
-                      ret, sss_strerror(ret), domlist[i]);
ecf709
+                  ret, sss_strerror(ret), domlist[i]);
ecf709
             continue;
ecf709
         }
ecf709
 
ecf709
diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h
ecf709
index 56a603652d6c8256735e7f8b125300ff7b254645..a4046610f3cdbdb832de8924bf4397fb0018f2db 100644
ecf709
--- a/src/confdb/confdb.h
ecf709
+++ b/src/confdb/confdb.h
ecf709
@@ -209,6 +209,9 @@
ecf709
 #define CONFDB_DOMAIN_OFFLINE_TIMEOUT "offline_timeout"
ecf709
 #define CONFDB_DOMAIN_SUBDOMAIN_INHERIT "subdomain_inherit"
ecf709
 #define CONFDB_DOMAIN_CACHED_AUTH_TIMEOUT "cached_auth_timeout"
ecf709
+#define CONFDB_DOMAIN_TYPE "domain_type"
ecf709
+#define CONFDB_DOMAIN_TYPE_POSIX "posix"
ecf709
+#define CONFDB_DOMAIN_TYPE_APP "application"
ecf709
 
ecf709
 /* Local Provider */
ecf709
 #define CONFDB_LOCAL_DEFAULT_SHELL   "default_shell"
ecf709
@@ -261,11 +264,23 @@ enum sss_domain_state {
ecf709
     DOM_INCONSISTENT,
ecf709
 };
ecf709
 
ecf709
+/** Whether the domain only supports looking up POSIX entries */
ecf709
+enum sss_domain_type {
ecf709
+    /** This is the default domain type. It resolves only entries
ecf709
+     * with the full POSIX set of attributes
ecf709
+     */
ecf709
+    DOM_TYPE_POSIX,
ecf709
+    /** In this mode, entries are typically resolved only by name */
ecf709
+    DOM_TYPE_APPLICATION,
ecf709
+};
ecf709
+
ecf709
 /**
ecf709
  * Data structure storing all of the basic features
ecf709
  * of a domain.
ecf709
  */
ecf709
 struct sss_domain_info {
ecf709
+    enum sss_domain_type type;
ecf709
+
ecf709
     char *name;
ecf709
     char *conn_name;
ecf709
     char *provider;
ecf709
diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
ecf709
index e7fb7673d393d4f12910f355d3edf33f4390c1f1..806611b6076048c08ce08c772dbd3cea5fdd656c 100644
ecf709
--- a/src/config/SSSDConfig/__init__.py.in
ecf709
+++ b/src/config/SSSDConfig/__init__.py.in
ecf709
@@ -148,6 +148,7 @@ option_strings = {
ecf709
     'selinux_provider' : _('SELinux provider'),
ecf709
 
ecf709
     # [domain]
ecf709
+    'domain_type' : _('Whether the domain is usable by the OS or by applications'),
ecf709
     'min_id' : _('Minimum user ID'),
ecf709
     'max_id' : _('Maximum user ID'),
ecf709
     'enumerate' : _('Enable enumerating all users/groups'),
ecf709
diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py
ecf709
index 6899bf8ae04bf210546c8cbdba8235f094e23dc0..9b3175962c697e314b3d5d94c2bc5beda537b66e 100755
ecf709
--- a/src/config/SSSDConfigTest.py
ecf709
+++ b/src/config/SSSDConfigTest.py
ecf709
@@ -510,6 +510,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
ecf709
             'debug',
ecf709
             'debug_level',
ecf709
             'debug_timestamps',
ecf709
+            'domain_type',
ecf709
             'min_id',
ecf709
             'max_id',
ecf709
             'timeout',
ecf709
@@ -878,6 +879,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
ecf709
             'debug',
ecf709
             'debug_level',
ecf709
             'debug_timestamps',
ecf709
+            'domain_type',
ecf709
             'min_id',
ecf709
             'max_id',
ecf709
             'timeout',
ecf709
diff --git a/src/config/cfg_rules.ini b/src/config/cfg_rules.ini
ecf709
index 41efcea552a82c5492a0d21a8d0797ee42cdc8c7..3c857236eaa55b313d176bc4bb479918163b60d5 100644
ecf709
--- a/src/config/cfg_rules.ini
ecf709
+++ b/src/config/cfg_rules.ini
ecf709
@@ -311,6 +311,7 @@ option = subdomains_provider
ecf709
 option = selinux_provider
ecf709
 
ecf709
 # Options available to all domains
ecf709
+option = domain_type
ecf709
 option = min_id
ecf709
 option = max_id
ecf709
 option = timeout
ecf709
diff --git a/src/config/etc/sssd.api.conf b/src/config/etc/sssd.api.conf
ecf709
index 6965028e1ca748f8b6677d9fc1faa66d5c307a0c..a38b24208f89e4502e41625c540ea9958d5bbffe 100644
ecf709
--- a/src/config/etc/sssd.api.conf
ecf709
+++ b/src/config/etc/sssd.api.conf
ecf709
@@ -129,6 +129,7 @@ selinux_provider = str, None, false
ecf709
 [domain]
ecf709
 # Options available to all domains
ecf709
 description = str, None, false
ecf709
+domain_type = str, None, false
ecf709
 debug = int, None, false
ecf709
 debug_level = int, None, false
ecf709
 debug_timestamps = bool, None, false
ecf709
diff --git a/src/man/sssd.conf.5.xml b/src/man/sssd.conf.5.xml
ecf709
index 4fe13b85d511fb6a2ccc9b4de956710b05bc898c..9abcff84a95ea1b27e36845e830cc125fdc89f90 100644
ecf709
--- a/src/man/sssd.conf.5.xml
ecf709
+++ b/src/man/sssd.conf.5.xml
ecf709
@@ -1512,6 +1512,39 @@ pam_account_locked_message = Account locked, please contact help desk.
ecf709
             <quote>[domain/<replaceable>NAME</replaceable>]</quote>
ecf709
             <variablelist>
ecf709
                 <varlistentry>
ecf709
+                    <term>domain_type (string)</term>
ecf709
+                    <listitem>
ecf709
+                        <para>
ecf709
+                            Specifies whether the domain is meant to be used
ecf709
+                            by POSIX-aware clients such as the Name Service Switch
ecf709
+                            or by applications that do not need POSIX data to be
ecf709
+                            present or generated. Only objects from POSIX domains
ecf709
+                            are available to the operating system interfaces and
ecf709
+                            utilities.
ecf709
+                        </para>
ecf709
+                        <para>
ecf709
+                            Allowed values for this option are <quote>posix</quote>
ecf709
+                            and <quote>application</quote>.
ecf709
+                        </para>
ecf709
+                        <para>
ecf709
+                            POSIX domains are reachable by all services. Application
ecf709
+                            domains are only reachable from the InfoPipe responder (see
ecf709
+                            <citerefentry>
ecf709
+                                <refentrytitle>sssd-ifp</refentrytitle>
ecf709
+                                <manvolnum>5</manvolnum>
ecf709
+                            </citerefentry>) and the PAM responder.
ecf709
+                        </para>
ecf709
+                        <para>
ecf709
+                            NOTE: The application domains are currently well tested with
ecf709
+                            <quote>id_provider=ldap</quote> only.
ecf709
+                        </para>
ecf709
+                        <para>
ecf709
+                            Default: posix
ecf709
+                        </para>
ecf709
+                    </listitem>
ecf709
+                </varlistentry>
ecf709
+
ecf709
+                <varlistentry>
ecf709
                     <term>min_id,max_id (integer)</term>
ecf709
                     <listitem>
ecf709
                         <para>
ecf709
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
ecf709
index a7f118842aa8ba870143b2f2b425a3e3c0ea5a78..2af7852f03f89b61f5b9fd8a244e98fb27b7e6a2 100644
ecf709
--- a/src/util/domain_info_utils.c
ecf709
+++ b/src/util/domain_info_utils.c
ecf709
@@ -885,3 +885,17 @@ char *subdomain_create_conf_path(TALLOC_CTX *mem_ctx,
ecf709
                            subdomain->parent->name,
ecf709
                            subdomain->name);
ecf709
 }
ecf709
+
ecf709
+const char *sss_domain_type_str(struct sss_domain_info *dom)
ecf709
+{
ecf709
+    if (dom == NULL) {
ecf709
+        return "BUG: Invalid domain";
ecf709
+    }
ecf709
+    switch (dom->type) {
ecf709
+    case DOM_TYPE_POSIX:
ecf709
+        return "POSIX";
ecf709
+    case DOM_TYPE_APPLICATION:
ecf709
+        return "Application";
ecf709
+    }
ecf709
+    return "Unknown";
ecf709
+}
ecf709
diff --git a/src/util/util.h b/src/util/util.h
ecf709
index 2170c5fb7cffda3910d2b58e33ec7abe3ec4a7d4..436550f5078cc173b8ed8cb58836d366f813146b 100644
ecf709
--- a/src/util/util.h
ecf709
+++ b/src/util/util.h
ecf709
@@ -539,6 +539,7 @@ enum sss_domain_state sss_domain_get_state(struct sss_domain_info *dom);
ecf709
 void sss_domain_set_state(struct sss_domain_info *dom,
ecf709
                           enum sss_domain_state state);
ecf709
 bool is_email_from_domain(const char *email, struct sss_domain_info *dom);
ecf709
+const char *sss_domain_type_str(struct sss_domain_info *dom);
ecf709
 
ecf709
 struct sss_domain_info*
ecf709
 sss_get_domain_by_sid_ldap_fallback(struct sss_domain_info *domain,
ecf709
-- 
ecf709
2.9.3
ecf709