dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0027-winbind-idmap-plugin-update-struct-idmap_domain-to-l.patch

841ac7
From e6734785fd1970c4b63d0dd021074003e35d7137 Mon Sep 17 00:00:00 2001
841ac7
From: Sumit Bose <sbose@redhat.com>
841ac7
Date: Fri, 5 Apr 2019 18:05:08 +0200
841ac7
Subject: [PATCH] winbind idmap plugin: update struct idmap_domain to latest
841ac7
 version
841ac7
841ac7
While updating to interface version 6 we forgot to add the query_user
841ac7
member.
841ac7
841ac7
Recent version of Samba added a new member dom_sid. Unfortunately the
841ac7
interface version was not update for this change so we have to enable
841ac7
the member based on the Samba version.
841ac7
841ac7
Related to https://pagure.io/SSSD/sssd/issue/4005
841ac7
841ac7
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
841ac7
(cherry picked from commit 30734e5f213f4bd2984e632d497d7cbfc16495db)
841ac7
---
841ac7
 src/external/samba.m4                         | 13 +++++++++++++
841ac7
 src/lib/winbind_idmap_sss/winbind_idmap_sss.c |  4 ++++
841ac7
 src/lib/winbind_idmap_sss/winbind_idmap_sss.h | 15 +++++++++++++++
841ac7
 3 files changed, 32 insertions(+)
841ac7
841ac7
diff --git a/src/external/samba.m4 b/src/external/samba.m4
841ac7
index 7a8c1eb7b..e68f064b3 100644
841ac7
--- a/src/external/samba.m4
841ac7
+++ b/src/external/samba.m4
841ac7
@@ -121,6 +121,19 @@ int main(void)
841ac7
     AC_MSG_NOTICE([Samba's idmap interface version: $idmap_version])
841ac7
     AC_DEFINE_UNQUOTED(SMB_IDMAP_INTERFACE_VERSION, $idmap_version,
841ac7
                        [Detected version of Samba's idmap plugin interface])
841ac7
+
841ac7
+    samba_major_version=`echo -e '#include <samba/version.h>\nSAMBA_VERSION_MAJOR' | $CPP $SMBCLIENT_CFLAGS -P -`
841ac7
+    samba_minor_version=`echo -e '#include <samba/version.h>\nSAMBA_VERSION_MINOR' | $CPP $SMBCLIENT_CFLAGS -P -`
841ac7
+    samba_release_version=`echo -e '#include <samba/version.h>\nSAMBA_VERSION_RELEASE' | $CPP $SMBCLIENT_CFLAGS -P -`
841ac7
+    AC_MSG_NOTICE([Samba version: $samba_major_version $samba_minor_version $samba_release_version])
841ac7
+    if test $samba_major_version -ge 4 -a $samba_minor_version -ge 8 ; then
841ac7
+        AC_DEFINE_UNQUOTED(SMB_IDMAP_DOMAIN_HAS_DOM_SID, 1,
841ac7
+                           [Samba's struct idmap_domain has dom_sid member])
841ac7
+        AC_MSG_NOTICE([Samba's struct idmap_domain has dom_sid member])
841ac7
+    else
841ac7
+        AC_MSG_NOTICE([Samba's struct idmap_domain does not have dom_sid member])
841ac7
+    fi
841ac7
+
841ac7
 fi
841ac7
 
841ac7
 SAVE_CFLAGS=$CFLAGS
841ac7
diff --git a/src/lib/winbind_idmap_sss/winbind_idmap_sss.c b/src/lib/winbind_idmap_sss/winbind_idmap_sss.c
841ac7
index 0d9109455..58375322a 100644
841ac7
--- a/src/lib/winbind_idmap_sss/winbind_idmap_sss.c
841ac7
+++ b/src/lib/winbind_idmap_sss/winbind_idmap_sss.c
841ac7
@@ -55,6 +55,10 @@ static NTSTATUS idmap_sss_initialize(struct idmap_domain *dom)
841ac7
         return NT_STATUS_NO_MEMORY;
841ac7
     }
841ac7
 
841ac7
+#if SMB_IDMAP_INTERFACE_VERSION == 6
841ac7
+    dom->query_user = NULL;
841ac7
+#endif
841ac7
+
841ac7
     dom->private_data = ctx;
841ac7
 
841ac7
     return NT_STATUS_OK;
841ac7
diff --git a/src/lib/winbind_idmap_sss/winbind_idmap_sss.h b/src/lib/winbind_idmap_sss/winbind_idmap_sss.h
841ac7
index 868049fff..78800838e 100644
841ac7
--- a/src/lib/winbind_idmap_sss/winbind_idmap_sss.h
841ac7
+++ b/src/lib/winbind_idmap_sss/winbind_idmap_sss.h
841ac7
@@ -70,9 +70,24 @@ struct id_map {
841ac7
 #error Missing Samba idmap interface version
841ac7
 #endif
841ac7
 
841ac7
+#if SMB_IDMAP_INTERFACE_VERSION == 6
841ac7
+struct wbint_userinfo;
841ac7
+#endif
841ac7
+
841ac7
 struct idmap_domain {
841ac7
     const char *name;
841ac7
+#if SMB_IDMAP_INTERFACE_VERSION == 6 && defined(SMB_IDMAP_DOMAIN_HAS_DOM_SID)
841ac7
+    /*
841ac7
+     * dom_sid is currently only initialized in the unixids_to_sids request,
841ac7
+     * so don't rely on this being filled out everywhere!
841ac7
+     */
841ac7
+    struct dom_sid dom_sid;
841ac7
+#endif
841ac7
     struct idmap_methods *methods;
841ac7
+#if SMB_IDMAP_INTERFACE_VERSION == 6
841ac7
+    NTSTATUS (*query_user)(struct idmap_domain *domain,
841ac7
+                           struct wbint_userinfo *info);
841ac7
+#endif
841ac7
     uint32_t low_id;
841ac7
     uint32_t high_id;
841ac7
     bool read_only;
841ac7
-- 
841ac7
2.19.1
841ac7