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

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