chiark / gitweb /
kmod-setup: improve for "kdbus" word on the kernel cmdline
[elogind.git] / src / core / kmod-setup.c
index 8136d3c0f809b681808451e6d92cc5263dc9dead..fd0a0e06adcdff080d7af7512a216ebb25e4bca8 100644 (file)
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
+
+#ifdef HAVE_KMOD
 #include <libkmod.h>
+#endif
 
 #include "macro.h"
 #include "execute.h"
 #include "capability.h"
 #include "kmod-setup.h"
 
+#ifdef HAVE_KMOD
 static void systemd_kmod_log(
                 void *data,
                 int priority,
@@ -46,14 +50,29 @@ static void systemd_kmod_log(
 
 static bool cmdline_check_kdbus(void) {
         _cleanup_free_ char *line = NULL;
+        const char *p;
+        int r;
 
-        if (proc_cmdline(&line) < 0)
+        r = proc_cmdline(&line);
+        if (r < 0)
                 return false;
 
-        return strstr(line, "kdbus") != NULL;
+        p = line;
+        for (;;) {
+                _cleanup_free_ char *word = NULL;
+
+                r = unquote_first_word(&p, &word, true);
+                if (r <= 0)
+                        return false;
+
+                if (streq(word, "kdbus"))
+                        return true;
+        }
 }
+#endif
 
 int kmod_setup(void) {
+#ifdef HAVE_KMOD
 
         static const struct {
                 const char *module;
@@ -123,5 +142,6 @@ int kmod_setup(void) {
         if (ctx)
                 kmod_unref(ctx);
 
+#endif
         return 0;
 }