From 7e0079f95f9b7306b40f2300301af80d915e15e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 7 Dec 2020 08:45:15 +0100 Subject: [PATCH] Make support for nscd flushing optional Fedora will deprecate support for nscd in the upcoming release [1] and plans to drop it in the next one [2]. At that point we might as well build systemd without that support too, since there'll be nothing to talk too. [1] https://fedoraproject.org/wiki/Changes/DeprecateNSCD [2] https://fedoraproject.org/wiki/Changes/RemoveNSCD --- meson.build | 2 ++ meson_options.txt | 2 ++ src/machine/machined-core.c | 2 ++ src/machine/machined.c | 2 ++ src/machine/machined.h | 6 ++++++ src/shared/meson.build | 5 ++++- src/shared/nscd-flush.h | 4 ++++ src/test/meson.build | 25 ++++++++++++++----------- 8 files changed, 36 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 75eb6fc1dc..5d9413a5bb 100644 --- a/meson.build +++ b/meson.build @@ -1460,6 +1460,7 @@ foreach term : ['analyze', 'ima', 'initrd', 'compat-mutable-uid-boundaries', + 'nscd', 'ldconfig', 'localed', 'logind', @@ -3763,6 +3764,7 @@ foreach tuple : [ ['idn'], ['initrd'], ['compat-mutable-uid-boundaries'], + ['nscd'], ['libidn2'], ['libidn'], ['libiptc'], diff --git a/meson_options.txt b/meson_options.txt index b50b0e9224..cfe11c9ae9 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -44,6 +44,8 @@ option('initrd', type : 'boolean', description : 'install services for use when running systemd in initrd') option('compat-mutable-uid-boundaries', type : 'boolean', value : 'false', description : 'look at uid boundaries in /etc/login.defs for compatibility') +option('nscd', type : 'boolean', + description : 'build support for flushing of the nscd caches') option('quotaon-path', type : 'string', description : 'path to quotaon') option('quotacheck-path', type : 'string', description : 'path to quotacheck') diff --git a/src/machine/machined-core.c b/src/machine/machined-core.c index 1416fbf823..ffca209494 100644 --- a/src/machine/machined-core.c +++ b/src/machine/machined-core.c @@ -5,6 +5,7 @@ #include "strv.h" #include "user-util.h" +#if ENABLE_NSCD static int on_nscd_cache_flush_event(sd_event_source *s, void *userdata) { /* Let's ask glibc's nscd daemon to flush its caches. We request this for the three database machines may show * up in: the hosts database (for resolvable machine names) and the user and group databases (for the user ns @@ -35,6 +36,7 @@ int manager_enqueue_nscd_cache_flush(Manager *m) { return 0; } +#endif int manager_find_machine_for_uid(Manager *m, uid_t uid, Machine **ret_machine, uid_t *ret_internal_uid) { Machine *machine; diff --git a/src/machine/machined.c b/src/machine/machined.c index c3c08d181d..4d8891c4fc 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -83,7 +83,9 @@ static Manager* manager_unref(Manager *m) { hashmap_free(m->image_cache); sd_event_source_unref(m->image_cache_defer_event); +#if ENABLE_NSCD sd_event_source_unref(m->nscd_cache_flush_event); +#endif bus_verify_polkit_async_registry_free(m->polkit_registry); diff --git a/src/machine/machined.h b/src/machine/machined.h index 6e4182bbd6..280c32bab6 100644 --- a/src/machine/machined.h +++ b/src/machine/machined.h @@ -36,7 +36,9 @@ struct Manager { LIST_HEAD(Operation, operations); unsigned n_operations; +#if ENABLE_NSCD sd_event_source *nscd_cache_flush_event; +#endif VarlinkServer *varlink_server; }; @@ -57,7 +59,11 @@ int manager_unref_unit(Manager *m, const char *unit, sd_bus_error *error); int manager_unit_is_active(Manager *manager, const char *unit); int manager_job_is_active(Manager *manager, const char *path); +#if ENABLE_NSCD int manager_enqueue_nscd_cache_flush(Manager *m); +#else +static inline void manager_enqueue_nscd_cache_flush(Manager *m) {} +#endif int manager_find_machine_for_uid(Manager *m, uid_t host_uid, Machine **ret_machine, uid_t *ret_internal_uid); int manager_find_machine_for_gid(Manager *m, gid_t host_gid, Machine **ret_machine, gid_t *ret_internal_gid); diff --git a/src/shared/meson.build b/src/shared/meson.build index 53165541ac..cc9501f5b2 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -173,7 +173,6 @@ shared_sources = files(''' net-condition.h netif-naming-scheme.c netif-naming-scheme.h - nscd-flush.c nscd-flush.h nsflags.c nsflags.h @@ -308,6 +307,10 @@ if conf.get('HAVE_PAM') == 1 '''.split()) endif +if conf.get('ENABLE_NSCD') == 1 + shared_sources += files('nscd-flush.c') +endif + generate_ip_protocol_list = find_program('generate-ip-protocol-list.sh') ip_protocol_list_txt = custom_target( 'ip-protocol-list.txt', diff --git a/src/shared/nscd-flush.h b/src/shared/nscd-flush.h index 5aafa9a24e..dac223e658 100644 --- a/src/shared/nscd-flush.h +++ b/src/shared/nscd-flush.h @@ -1,4 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#if ENABLE_NSCD int nscd_flush_cache(char **databases); +#else +static inline void nscd_flush_cache(char **databases) {} +#endif diff --git a/src/test/meson.build b/src/test/meson.build index 12bcf35708..9e781f88dc 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -92,17 +92,6 @@ tests += [ libblkid], '', 'manual'], - [['src/test/test-nscd-flush.c'], - [libcore, - libshared], - [threads, - librt, - libseccomp, - libselinux, - libmount, - libblkid], - '', 'manual'], - [['src/test/test-loopback.c'], [libcore, libshared], @@ -827,6 +816,20 @@ tests += [ [libdl]], ] +if conf.get('ENABLE_NSCD') == 1 + tests += [ + [['src/test/test-nscd-flush.c'], + [libcore, + libshared], + [threads, + librt, + libseccomp, + libselinux, + libmount, + libblkid], + '', 'manual']] +endif + ############################################################ # define some tests here, because the link_with deps were not defined earlier