chiark / gitweb /
main: disable nscd properly, if possible
authorLennart Poettering <lennart@poettering.net>
Wed, 11 Aug 2010 21:31:07 +0000 (23:31 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 11 Aug 2010 21:31:07 +0000 (23:31 +0200)
configure.ac
fixme
src/main.c
src/missing.h
src/util.c
src/util.h

index 72218e4df4211f3acb74734612164da0246e80f6..f8a4247e666fe759d02f80780d8f4d7a428e7ea7 100644 (file)
@@ -91,6 +91,7 @@ LT_PREREQ(2.2)
 LT_INIT
 
 AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])])
+AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])])
 AC_SEARCH_LIBS([cap_init], [cap], [], [AC_MSG_ERROR([*** POSIX caps library not found])])
 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
 
diff --git a/fixme b/fixme
index 32bd40fa40f3d9560d3957f6f5f2301ad4392512..6d0f5b2edb50a7c760f5ba0908b22afa3dc93846 100644 (file)
--- a/fixme
+++ b/fixme
@@ -79,8 +79,6 @@
 
 * plymouth different shut down msgs
 
-* fix nscd disable
-
 External:
 
 * sysv functions should color when stdout is tty, not stdin
index 72015bc544f3766519a8b041ff7112d58e62a317..2e17f9b6fa95519981ed9524b4e037140e764129 100644 (file)
@@ -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)
index d6114cc2b2c4090bd33e6fb694f5528fe8b4da13..f40d36ebc4f5a8643b6be2270b3800673eb364be 100644 (file)
@@ -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
index c4ff5aa575d4ea45d6b69cb42c1560354fef7acc..c2ef34dd4378af94500e6cfe3a830186a920c013 100644 (file)
@@ -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",
index 21f47dc1694fd2b277af1dbdf1eb16af8a0ece88..66ebb46dbf6741f9fd579e4a9414a8d20ebd7561 100644 (file)
@@ -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);