Skip to content

Commit

Permalink
Make support for nscd flushing optional
Browse files Browse the repository at this point in the history
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
  • Loading branch information
keszybz committed Dec 7, 2020
1 parent e0f90ad commit 7e0079f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 12 deletions.
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,7 @@ foreach term : ['analyze',
'ima',
'initrd',
'compat-mutable-uid-boundaries',
'nscd',
'ldconfig',
'localed',
'logind',
Expand Down Expand Up @@ -3763,6 +3764,7 @@ foreach tuple : [
['idn'],
['initrd'],
['compat-mutable-uid-boundaries'],
['nscd'],
['libidn2'],
['libidn'],
['libiptc'],
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions src/machine/machined-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/machine/machined.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions src/machine/machined.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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);
5 changes: 4 additions & 1 deletion src/shared/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions src/shared/nscd-flush.h
Original file line number Diff line number Diff line change
@@ -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
25 changes: 14 additions & 11 deletions src/test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7e0079f

Please sign in to comment.