diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/missing.h | 8 | ||||
-rw-r--r-- | src/util.c | 19 | ||||
-rw-r--r-- | src/util.h | 2 |
4 files changed, 22 insertions, 13 deletions
diff --git a/src/main.c b/src/main.c index 72015bc544..2e17f9b6fa 100644 --- a/src/main.c +++ b/src/main.c @@ -994,11 +994,7 @@ int main(int argc, char *argv[]) { /* Disable nscd, to avoid deadlocks when systemd uses * NSS and the nscd socket is maintained by us. */ - /* if (nss_disable_nscd) { */ - /* log_debug("Disabling nscd"); */ - /* nss_disable_nscd(); */ - /* } else */ - /* log_debug("Hmm, can't disable nscd."); */ + nss_disable_nscd(); if (!serialization) { if (arg_show_status) diff --git a/src/missing.h b/src/missing.h index d6114cc2b2..f40d36ebc4 100644 --- a/src/missing.h +++ b/src/missing.h @@ -55,14 +55,6 @@ static inline int pivot_root(const char *new_root, const char *put_old) { return syscall(SYS_pivot_root, new_root, put_old); } -/* This is an internal glibc function call. We are not supposed to - * call this, because we are not nscd. However sometimes we feel - * really dangerous and do it nonetheless. Muahahah! But at least we - * protect this with a weak ref just in case glibc takes this away - * from us. */ - -/* static void nss_disable_nscd(void) _weakref_(__nss_disable_nscd); */ - #ifndef AUDIT_SERVICE_START #define AUDIT_SERVICE_START 1130 /* Service (daemon) start */ #endif diff --git a/src/util.c b/src/util.c index c4ff5aa575..c2ef34dd43 100644 --- a/src/util.c +++ b/src/util.c @@ -48,6 +48,7 @@ #include <pwd.h> #include <netinet/ip.h> #include <linux/kd.h> +#include <dlfcn.h> #include "macro.h" #include "util.h" @@ -2979,6 +2980,24 @@ char *ellipsize(const char *s, unsigned length, unsigned percent) { return r; } +void nss_disable_nscd(void) { + + void (*func)(void); + + /* This is an internal glibc function call. We are not + * supposed to call this, because we are not nscd. However + * sometimes we feel really dangerous and do it + * nonetheless. Muahahah! But at least we protect this with a + * dlsym() just in case glibc takes this away from us. */ + + if ((func = dlsym(RTLD_DEFAULT, "__nss_disable_nscd"))) { + log_debug("Disabling nscd."); + func(); + } else + log_debug("Cannot disable nscd."); +} + + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime", diff --git a/src/util.h b/src/util.h index 21f47dc169..66ebb46dbf 100644 --- a/src/util.h +++ b/src/util.h @@ -336,6 +336,8 @@ int running_in_chroot(void); char *ellipsize(const char *s, unsigned length, unsigned percent); +void nss_disable_nscd(void); + const char *ioprio_class_to_string(int i); int ioprio_class_from_string(const char *s); |