chiark / gitweb /
nspawn: Include netlink headers rather than using #ifdef
[elogind.git] / src / nspawn / nspawn.c
index 09153c87ce2694de46835467aa19f99838ae75b8..95d76eb3c3f51bed2a9f6d472e62ce8d8a3f1d13 100644 (file)
@@ -39,6 +39,7 @@
 #include <sys/signalfd.h>
 #include <grp.h>
 #include <linux/fs.h>
+#include <linux/netlink.h>
 #include <sys/un.h>
 #include <sys/socket.h>
 
@@ -1219,6 +1220,17 @@ finish:
         return r;
 }
 
+static bool audit_enabled(void) {
+        int fd;
+
+        fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
+        if (fd >= 0) {
+                close_nointr_nofail(fd);
+                return true;
+        }
+        return false;
+}
+
 int main(int argc, char *argv[]) {
         pid_t pid = 0;
         int r = EXIT_FAILURE, k;
@@ -1284,6 +1296,13 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
+        if (audit_enabled()) {
+                log_warning("The kernel auditing subsystem is known to be incompatible with containers.\n"
+                            "Please make sure to turn off auditing with 'audit=0' on the kernel command\n"
+                            "line before using systemd-nspawn. Sleeping for 5s...\n");
+                sleep(5);
+        }
+
         if (path_equal(arg_directory, "/")) {
                 log_error("Spawning container on root directory not supported.");
                 goto finish;