chiark / gitweb /
nspawn: use automatic cleanup
[elogind.git] / src / nspawn / nspawn.c
index 7f084ef2d01274a4ddefca9fa6351a9fc957e95a..c46f63ba29a4d7ab89bf9dec972e010db18e60e2 100644 (file)
@@ -46,6 +46,7 @@
 #include "log.h"
 #include "util.h"
 #include "mkdir.h"
+#include "macro.h"
 #include "audit.h"
 #include "missing.h"
 #include "cgroup-util.h"
@@ -273,6 +274,7 @@ static int mount_all(const char *dest) {
                 { "sysfs",     "/sys",      "sysfs", NULL,       MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV, true  },
                 { "tmpfs",     "/dev",      "tmpfs", "mode=755", MS_NOSUID|MS_STRICTATIME,     true  },
                 { "/dev/pts",  "/dev/pts",  NULL,    NULL,       MS_BIND,                      true  },
+                { "tmpfs",     "/dev/shm",  "tmpfs", "mode=1777", MS_NOSUID|MS_NODEV|MS_STRICTATIME, true  },
                 { "tmpfs",     "/run",      "tmpfs", "mode=755", MS_NOSUID|MS_NODEV|MS_STRICTATIME, true  },
 #ifdef HAVE_SELINUX
                 { "/sys/fs/selinux", "/sys/fs/selinux", NULL, NULL, MS_BIND,                      false },  /* Bind mount first */
@@ -282,7 +284,7 @@ static int mount_all(const char *dest) {
 
         unsigned k;
         int r = 0;
-        char *where;
+        char _cleanup_free_ *where = NULL;
 
         for (k = 0; k < ELEMENTSOF(mount_table); k++) {
                 int t;
@@ -299,7 +301,6 @@ static int mount_all(const char *dest) {
                 t = path_is_mount_point(where, true);
                 if (t < 0) {
                         log_error("Failed to detect whether %s is a mount point: %s", where, strerror(-t));
-                        free(where);
 
                         if (r == 0)
                                 r = t;
@@ -325,8 +326,6 @@ static int mount_all(const char *dest) {
                         if (r == 0)
                                 r = -errno;
                 }
-
-                free(where);
         }
 
         return r;