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
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-12-07 08:45:15 +01:00
parent e0f90ad988
commit 7e0079f95f
8 changed files with 36 additions and 12 deletions

View File

@ -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'],

View File

@ -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')

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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',

View File

@ -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

View File

@ -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