|
|
086f82 |
From 9ae62c07c579fa9b3f0804c12cc0715f5f2524d4 Mon Sep 17 00:00:00 2001
|
|
|
086f82 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
086f82 |
Date: Tue, 15 May 2018 11:55:35 +0200
|
|
|
086f82 |
Subject: [PATCH] winbind idmap plugin: support inferface version 6
|
|
|
086f82 |
MIME-Version: 1.0
|
|
|
086f82 |
Content-Type: text/plain; charset=UTF-8
|
|
|
086f82 |
Content-Transfer-Encoding: 8bit
|
|
|
086f82 |
|
|
|
086f82 |
With Samba 4.7 the interface version of the idmap plugin was updated to
|
|
|
086f82 |
6. The patch adds support for this new version but can be complied with
|
|
|
086f82 |
the older version as well.
|
|
|
086f82 |
|
|
|
086f82 |
A configure option is added to select the version, if no version is
|
|
|
086f82 |
given configure tries to detect the version with the help of an internal
|
|
|
086f82 |
Samba library libidmap-samba4.so.
|
|
|
086f82 |
|
|
|
086f82 |
To make sure that always the right version is used configure will fail
|
|
|
086f82 |
if Samba is used (--with-samba, default) and no version can be
|
|
|
086f82 |
determined.
|
|
|
086f82 |
|
|
|
086f82 |
Resolves https://pagure.io/SSSD/sssd/issue/3741
|
|
|
086f82 |
|
|
|
086f82 |
Reviewed-by: Alexander Bokovoy <abokovoy@redhat.com>
|
|
|
086f82 |
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
|
|
|
086f82 |
(cherry picked from commit c6b99b070268c3807833e9f894d9a36304014417)
|
|
|
086f82 |
|
|
|
086f82 |
DOWNSTREAM:
|
|
|
086f82 |
Resolves: rhbz#1580281 - Samba can not register sss idmap module because it's using an outdated SMB_IDMAP_INTERFACE_VERSION [rhel-7.5.z]
|
|
|
086f82 |
---
|
|
|
086f82 |
contrib/ci/configure.sh | 9 ++
|
|
|
086f82 |
contrib/sssd.spec.in | 12 +++
|
|
|
086f82 |
src/external/samba.m4 | 82 +++++++++++++++++++
|
|
|
086f82 |
src/lib/winbind_idmap_sss/winbind_idmap_sss.c | 6 ++
|
|
|
086f82 |
src/lib/winbind_idmap_sss/winbind_idmap_sss.h | 6 +-
|
|
|
086f82 |
5 files changed, 114 insertions(+), 1 deletion(-)
|
|
|
086f82 |
|
|
|
086f82 |
diff --git a/contrib/ci/configure.sh b/contrib/ci/configure.sh
|
|
|
086f82 |
index 9d18d0c187561a2dc3bc47d3e8913626e7ff3046..09da5b4e7b0b4a7859bcf81db987394ac91f4fa2 100644
|
|
|
086f82 |
--- a/contrib/ci/configure.sh
|
|
|
086f82 |
+++ b/contrib/ci/configure.sh
|
|
|
086f82 |
@@ -35,6 +35,7 @@ declare -a CONFIGURE_ARG_LIST=(
|
|
|
086f82 |
if [[ "$DISTRO_BRANCH" == -redhat-redhatenterprise*-6.*- ||
|
|
|
086f82 |
"$DISTRO_BRANCH" == -redhat-centos-6.*- ]]; then
|
|
|
086f82 |
CONFIGURE_ARG_LIST+=(
|
|
|
086f82 |
+ "--with-smb-idmap-interface-version=5"
|
|
|
086f82 |
"--disable-cifs-idmap-plugin"
|
|
|
086f82 |
"--with-syslog=syslog"
|
|
|
086f82 |
"--without-python3-bindings"
|
|
|
086f82 |
@@ -56,6 +57,14 @@ if [[ "$DISTRO_BRANCH" == -redhat-redhatenterprise*-7.*- ||
|
|
|
086f82 |
)
|
|
|
086f82 |
fi
|
|
|
086f82 |
|
|
|
086f82 |
+# Different versions of Debian might need different versions here but this is
|
|
|
086f82 |
+# sufficient to make the CI work
|
|
|
086f82 |
+if [[ "$DISTRO_BRANCH" == -debian-* ]]; then
|
|
|
086f82 |
+ CONFIGURE_ARG_LIST+=(
|
|
|
086f82 |
+ "--with-smb-idmap-interface-version=5"
|
|
|
086f82 |
+ )
|
|
|
086f82 |
+fi
|
|
|
086f82 |
+
|
|
|
086f82 |
declare -r -a CONFIGURE_ARG_LIST
|
|
|
086f82 |
|
|
|
086f82 |
fi # _CONFIGURE_SH
|
|
|
086f82 |
diff --git a/contrib/sssd.spec.in b/contrib/sssd.spec.in
|
|
|
086f82 |
index d9323bf1a2d84f4219f8ab11886e5ce87b401c15..3ddd054dea8a4b5dd46457acf9aaabed29ab754e 100644
|
|
|
086f82 |
--- a/contrib/sssd.spec.in
|
|
|
086f82 |
+++ b/contrib/sssd.spec.in
|
|
|
086f82 |
@@ -127,6 +127,14 @@
|
|
|
086f82 |
%global with_gdm_pam_extensions 0
|
|
|
086f82 |
%endif
|
|
|
086f82 |
|
|
|
086f82 |
+# Do not try to detect the idmap version on RHEL6 to avoid conflicts between
|
|
|
086f82 |
+# samba and samba4 package
|
|
|
086f82 |
+%if (0%{?fedora} || 0%{?rhel} >= 7)
|
|
|
086f82 |
+ %global detect_idmap_version 1
|
|
|
086f82 |
+%else
|
|
|
086f82 |
+ %global with_idmap_version --with-smb-idmap-interface-version=5
|
|
|
086f82 |
+%endif
|
|
|
086f82 |
+
|
|
|
086f82 |
Name: @PACKAGE_NAME@
|
|
|
086f82 |
Version: @PACKAGE_VERSION@
|
|
|
086f82 |
Release: 0@PRERELEASE_VERSION@%{?dist}
|
|
|
086f82 |
@@ -225,6 +233,9 @@ BuildRequires: nfs-utils-lib-devel
|
|
|
086f82 |
|
|
|
086f82 |
BuildRequires: samba4-devel
|
|
|
086f82 |
BuildRequires: libsmbclient-devel
|
|
|
086f82 |
+%if (0%{?detect_idmap_version} == 1)
|
|
|
086f82 |
+BuildRequires: samba-winbind
|
|
|
086f82 |
+%endif
|
|
|
086f82 |
|
|
|
086f82 |
%if (0%{?enable_systemtap} == 1)
|
|
|
086f82 |
BuildRequires: systemtap-sdt-devel
|
|
|
086f82 |
@@ -747,6 +758,7 @@ autoreconf -ivf
|
|
|
086f82 |
%{?enable_systemtap_opt} \
|
|
|
086f82 |
%{?with_secret_responder} \
|
|
|
086f82 |
%{?with_kcm_option} \
|
|
|
086f82 |
+ %{?with_idmap_version} \
|
|
|
086f82 |
%{?experimental}
|
|
|
086f82 |
|
|
|
086f82 |
make %{?_smp_mflags} all
|
|
|
086f82 |
diff --git a/src/external/samba.m4 b/src/external/samba.m4
|
|
|
086f82 |
index 91a583a0d0f514dab40d4f65cc32b17d0368f540..610831bf054e3687eb13025e954acf345fca1a00 100644
|
|
|
086f82 |
--- a/src/external/samba.m4
|
|
|
086f82 |
+++ b/src/external/samba.m4
|
|
|
086f82 |
@@ -39,4 +39,86 @@ them. In this case, you will need to execute configure script with argument
|
|
|
086f82 |
--without-samba
|
|
|
086f82 |
]])
|
|
|
086f82 |
fi
|
|
|
086f82 |
+
|
|
|
086f82 |
+ AC_ARG_WITH([smb-idmap-interface-version],
|
|
|
086f82 |
+ [AC_HELP_STRING([--with-smb-idmap-interface-version=[5|6]],
|
|
|
086f82 |
+ [Idmap interface version of installed Samba]
|
|
|
086f82 |
+ )
|
|
|
086f82 |
+ ]
|
|
|
086f82 |
+ )
|
|
|
086f82 |
+
|
|
|
086f82 |
+ if test x"$with_smb_idmap_interface_version" != x; then
|
|
|
086f82 |
+ if test x"$with_smb_idmap_interface_version" = x5 -o x"$with_smb_idmap_interface_version" = x6; then
|
|
|
086f82 |
+ idmap_test_result=$with_smb_idmap_interface_version
|
|
|
086f82 |
+ else
|
|
|
086f82 |
+ AC_MSG_ERROR([Illegal value -$with_smb_idmap_interface_version- for option --with-smb-idmap-interface-version])
|
|
|
086f82 |
+ fi
|
|
|
086f82 |
+ else
|
|
|
086f82 |
+
|
|
|
086f82 |
+ AC_MSG_CHECKING([Samba's idmap plugin interface version])
|
|
|
086f82 |
+ sambalibdir="`$PKG_CONFIG --variable=libdir smbclient`"/samba
|
|
|
086f82 |
+ SAVE_CFLAGS=$CFLAGS
|
|
|
086f82 |
+ SAVE_LIBS=$LIBS
|
|
|
086f82 |
+ CFLAGS="$CFLAGS $SMBCLIENT_CFLAGS -I/usr/include/samba-4.0"
|
|
|
086f82 |
+ LIBS="$LIBS -L${sambalibdir} -lidmap-samba4 -Wl,-rpath ${sambalibdir}"
|
|
|
086f82 |
+ AC_RUN_IFELSE(
|
|
|
086f82 |
+ [AC_LANG_SOURCE([
|
|
|
086f82 |
+#include <stdlib.h>
|
|
|
086f82 |
+#include <stdint.h>
|
|
|
086f82 |
+#include <stdbool.h>
|
|
|
086f82 |
+#include <tevent.h>
|
|
|
086f82 |
+#include <core/ntstatus.h>
|
|
|
086f82 |
+
|
|
|
086f82 |
+struct winbindd_domain;
|
|
|
086f82 |
+
|
|
|
086f82 |
+/* overwrite some winbind internal functions */
|
|
|
086f82 |
+struct winbindd_domain *find_domain_from_name(const char *domain_name)
|
|
|
086f82 |
+{
|
|
|
086f82 |
+ return NULL;
|
|
|
086f82 |
+}
|
|
|
086f82 |
+
|
|
|
086f82 |
+bool get_global_winbindd_state_offline(void) {
|
|
|
086f82 |
+ return false;
|
|
|
086f82 |
+}
|
|
|
086f82 |
+
|
|
|
086f82 |
+struct tevent_context *winbind_event_context(void)
|
|
|
086f82 |
+{
|
|
|
086f82 |
+ return NULL;
|
|
|
086f82 |
+}
|
|
|
086f82 |
+
|
|
|
086f82 |
+struct idmap_methods;
|
|
|
086f82 |
+
|
|
|
086f82 |
+NTSTATUS smb_register_idmap(int version, const char *name, struct idmap_methods *methods);
|
|
|
086f82 |
+
|
|
|
086f82 |
+int main(void)
|
|
|
086f82 |
+{
|
|
|
086f82 |
+ int v;
|
|
|
086f82 |
+ NTSTATUS ret;
|
|
|
086f82 |
+
|
|
|
086f82 |
+ /* Check the versions we know about */
|
|
|
086f82 |
+ for (v = 5; v <= 6; v++) {
|
|
|
086f82 |
+ ret = smb_register_idmap(v, NULL, NULL);
|
|
|
086f82 |
+ if (ret != NT_STATUS_OBJECT_TYPE_MISMATCH) {
|
|
|
086f82 |
+ return v;
|
|
|
086f82 |
+ }
|
|
|
086f82 |
+ }
|
|
|
086f82 |
+
|
|
|
086f82 |
+ return -1;
|
|
|
086f82 |
+}])],
|
|
|
086f82 |
+ [AC_MSG_ERROR([idmap version test program is not expected to return 0])],
|
|
|
086f82 |
+ [idmap_test_result=$?; AC_MSG_RESULT([idmap test result is: $idmap_test_result])]
|
|
|
086f82 |
+ )
|
|
|
086f82 |
+ fi
|
|
|
086f82 |
+
|
|
|
086f82 |
+ CFLAGS=$SAVE_CFLAGS
|
|
|
086f82 |
+ LIBS=$SAVE_LIBS
|
|
|
086f82 |
+
|
|
|
086f82 |
+ if test $idmap_test_result -eq 5 -o $idmap_test_result -eq 6 ; then
|
|
|
086f82 |
+ idmap_version=$idmap_test_result
|
|
|
086f82 |
+ else
|
|
|
086f82 |
+ AC_MSG_ERROR([Cannot determine Samba's idmap interface version, please use --with-smb-idmap-interface-version])
|
|
|
086f82 |
+ fi
|
|
|
086f82 |
+ AC_MSG_NOTICE([Samba's idmap interface version: $idmap_version])
|
|
|
086f82 |
+ AC_DEFINE_UNQUOTED(SMB_IDMAP_INTERFACE_VERSION, $idmap_version,
|
|
|
086f82 |
+ [Detected version of Samba's idmap plugin interface])
|
|
|
086f82 |
fi
|
|
|
086f82 |
diff --git a/src/lib/winbind_idmap_sss/winbind_idmap_sss.c b/src/lib/winbind_idmap_sss/winbind_idmap_sss.c
|
|
|
086f82 |
index 26f753708303f513e265de465e4d888f84e22b6a..ea5e727c3461524c3af84ea35c6ee032a5948ddf 100644
|
|
|
086f82 |
--- a/src/lib/winbind_idmap_sss/winbind_idmap_sss.c
|
|
|
086f82 |
+++ b/src/lib/winbind_idmap_sss/winbind_idmap_sss.c
|
|
|
086f82 |
@@ -190,7 +190,13 @@ static struct idmap_methods sss_methods = {
|
|
|
086f82 |
.sids_to_unixids = idmap_sss_sids_to_unixids,
|
|
|
086f82 |
};
|
|
|
086f82 |
|
|
|
086f82 |
+#if SMB_IDMAP_INTERFACE_VERSION == 5
|
|
|
086f82 |
NTSTATUS idmap_sss_init(void)
|
|
|
086f82 |
+#elif SMB_IDMAP_INTERFACE_VERSION == 6
|
|
|
086f82 |
+NTSTATUS idmap_sss_init(TALLOC_CTX *ctx)
|
|
|
086f82 |
+#else
|
|
|
086f82 |
+#error Unexpected Samba idmpa inferface version
|
|
|
086f82 |
+#endif
|
|
|
086f82 |
{
|
|
|
086f82 |
return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, "sss", &sss_methods);
|
|
|
086f82 |
}
|
|
|
086f82 |
diff --git a/src/lib/winbind_idmap_sss/winbind_idmap_sss.h b/src/lib/winbind_idmap_sss/winbind_idmap_sss.h
|
|
|
086f82 |
index 0f27c8561a540b63fb365edb79867eb4eb8d6e21..868049ffff7bd788507bf02d61245ff254aca465 100644
|
|
|
086f82 |
--- a/src/lib/winbind_idmap_sss/winbind_idmap_sss.h
|
|
|
086f82 |
+++ b/src/lib/winbind_idmap_sss/winbind_idmap_sss.h
|
|
|
086f82 |
@@ -32,6 +32,8 @@
|
|
|
086f82 |
#include <ndr.h>
|
|
|
086f82 |
#include <gen_ndr/security.h>
|
|
|
086f82 |
|
|
|
086f82 |
+#include "config.h"
|
|
|
086f82 |
+
|
|
|
086f82 |
/* The following definitions are taken from the Samba header files
|
|
|
086f82 |
* - winbindd/idmap_proto.h
|
|
|
086f82 |
* - idmap.d
|
|
|
086f82 |
@@ -64,7 +66,9 @@ struct id_map {
|
|
|
086f82 |
enum id_mapping status;
|
|
|
086f82 |
};
|
|
|
086f82 |
|
|
|
086f82 |
-#define SMB_IDMAP_INTERFACE_VERSION 5
|
|
|
086f82 |
+#ifndef SMB_IDMAP_INTERFACE_VERSION
|
|
|
086f82 |
+#error Missing Samba idmap interface version
|
|
|
086f82 |
+#endif
|
|
|
086f82 |
|
|
|
086f82 |
struct idmap_domain {
|
|
|
086f82 |
const char *name;
|
|
|
086f82 |
--
|
|
|
086f82 |
2.17.0
|
|
|
086f82 |
|