mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 16:10:02 -06:00
78ad1cfe4f
Refactor nsswitch operations in ipa-extdom-extop plugin to allow use of timeout-enabled nsswitch calls provided by libsss_nss_idmap. Standard POSIX nsswitch API has no way to cancel requests which may cause ipa-extdom-extop requests to hang far too long and potentially exhaust LDAP server workers. In addition, glibc nsswitch API iterates through all nsswitch modules one by one and with multiple parallel requests a lock up may happen in an unrelated nsswitch module like nss_files.so.2. A solution to the latter issue is to directly load nss_sss.so.2 plugin and utilize it. This, however, does not solve a problem with lack of cancellable API. With SSSD 1.16.1, libsss_nss_idmap provides a timeout-enabled variant of nsswitch API that is directly integrated with SSSD client side machinery used by nss_sss.so.2. As result, this API can be used instead of loading nss_sss.so.2 directly. To support older SSSD version, both direct loading of nss_sss.so.2 and new timeout-enabled API are supported by this changeset. An API to abstract both is designed to be a mix between internal glibc nsswitch API and external nsswitch API that libsss_nss_idmap mimics. API does not expose per-call timeout. Instead, it allows to set a timeout per nsswitch operation context to reduce requirements on information a caller has to maintain. A choice which API to use is made at configure time. In order to test the API, a cmocka test is updated to explicitly load nss_files.so.2 as a backend. Since use of nss_sss.so.2 would always depend on availablility of SSSD, predictable testing would not be possible without it otherwise. Also, cmocka test does not use nss_wrapper anymore because nss_wrapper overrides higher level glibc nsswitch API while we are loading an individual nsswitch module directly. As result, cmocka test overrides fopen() call used by nss_files.so.2 to load /etc/passwd and /etc/group. An overridden version changes paths to /etc/passwd and /etc/group to a local test_data/passwd and test_data/group. This way we can continue testing a backend API for ipa-extdom-extop with the same data as with nss_wrapper. Fixes https://pagure.io/freeipa/issue/5464 Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Simo Sorce <ssorce@redhat.com> Reviewed-By: Robbie Harwood <rharwood@redhat.com>
85 lines
1.7 KiB
Makefile
85 lines
1.7 KiB
Makefile
NULL =
|
|
|
|
PLUGIN_COMMON_DIR = $(srcdir)/../common
|
|
|
|
AM_CPPFLAGS = \
|
|
-I$(srcdir) \
|
|
-I$(PLUGIN_COMMON_DIR) \
|
|
-DPREFIX=\""$(prefix)"\" \
|
|
-DBINDIR=\""$(bindir)"\" \
|
|
-DLIBDIR=\""$(libdir)"\" \
|
|
-DLIBEXECDIR=\""$(libexecdir)"\" \
|
|
-DDATADIR=\""$(datadir)"\" \
|
|
$(DIRSRV_CFLAGS) \
|
|
$(LDAP_CFLAGS) \
|
|
$(WARN_CFLAGS) \
|
|
$(SSSNSSIDMAP_CFLAGS) \
|
|
$(NULL)
|
|
|
|
plugindir = $(libdir)/dirsrv/plugins
|
|
plugin_LTLIBRARIES = \
|
|
libipa_extdom_extop.la \
|
|
$(NULL)
|
|
|
|
libipa_extdom_extop_la_SOURCES = \
|
|
ipa_extdom.h \
|
|
ipa_extdom_extop.c \
|
|
ipa_extdom_common.c \
|
|
back_extdom.h \
|
|
$(NULL)
|
|
|
|
libipa_extdom_extop_la_LDFLAGS = -avoid-version
|
|
|
|
libipa_extdom_extop_la_LIBADD = \
|
|
$(LDAP_LIBS) \
|
|
$(SSSNSSIDMAP_LIBS) \
|
|
$(NULL)
|
|
|
|
# We have two backends for nss operations:
|
|
# (1) directly loading nss_sss.so.2
|
|
# (2) using timeout-enabled API from libsss_nss_idmap
|
|
# We prefer (2) if available
|
|
if USE_SSS_NSS_TIMEOUT
|
|
libipa_extdom_extop_la_SOURCES += back_extdom_sss_idmap.c
|
|
else
|
|
libipa_extdom_extop_la_SOURCES += back_extdom_nss_sss.c
|
|
endif
|
|
|
|
|
|
TESTS =
|
|
check_PROGRAMS =
|
|
|
|
if HAVE_CMOCKA
|
|
TESTS += extdom_cmocka_tests
|
|
check_PROGRAMS += extdom_cmocka_tests
|
|
endif
|
|
|
|
extdom_cmocka_tests_SOURCES = \
|
|
ipa_extdom_cmocka_tests.c \
|
|
ipa_extdom_common.c \
|
|
back_extdom_nss_sss.c \
|
|
$(NULL)
|
|
extdom_cmocka_tests_CFLAGS = $(CMOCKA_CFLAGS)
|
|
extdom_cmocka_tests_LDFLAGS = \
|
|
-rpath $(shell pkg-config --libs-only-L dirsrv | sed -e 's/-L//') \
|
|
$(NULL)
|
|
extdom_cmocka_tests_LDADD = \
|
|
$(CMOCKA_LIBS) \
|
|
$(LDAP_LIBS) \
|
|
$(DIRSRV_LIBS) \
|
|
$(SSSNSSIDMAP_LIBS) \
|
|
-ldl \
|
|
$(NULL)
|
|
|
|
|
|
appdir = $(IPA_DATA_DIR)
|
|
app_DATA = \
|
|
ipa-extdom-extop-conf.ldif \
|
|
$(NULL)
|
|
|
|
EXTRA_DIST = \
|
|
README \
|
|
test_data \
|
|
$(app_DATA) \
|
|
$(NULL)
|