chiark / gitweb /
getty-generator: fix stripping /dev/
[elogind.git] / src / libsystemd-bus / bus-container.c
index 31bb624b34cd4dca37cac8c063d8fa8b7c222e86..33478c02decdc925242eb8d476d7ae05b1d15d1e 100644 (file)
@@ -29,8 +29,9 @@
 #include "bus-container.h"
 
 int bus_container_connect(sd_bus *b) {
-        _cleanup_free_ char *p = NULL, *s = NULL, *ns = NULL, *root = NULL, *class = NULL;
+        _cleanup_free_ char *s = NULL, *ns = NULL, *root = NULL, *class = NULL;
         _cleanup_close_ int nsfd = -1, rootfd = -1;
+        char *p;
         siginfo_t si;
         pid_t leader, child;
         int r;
@@ -39,10 +40,7 @@ int bus_container_connect(sd_bus *b) {
         assert(b->input_fd < 0);
         assert(b->output_fd < 0);
 
-        p = strappend("/run/systemd/machines/", b->machine);
-        if (!p)
-                return -ENOMEM;
-
+        p = strappenda("/run/systemd/machines/", b->machine);
         r = parse_env_file(p, NEWLINE, "LEADER", &s, "CLASS", &class, NULL);
         if (r == -ENOENT)
                 return -EHOSTDOWN;
@@ -72,7 +70,7 @@ int bus_container_connect(sd_bus *b) {
         if (r < 0)
                 return -ENOMEM;
 
-        rootfd = open(root, O_RDONLY|O_NOCTTY|O_CLOEXEC);
+        rootfd = open(root, O_RDONLY|O_NOCTTY|O_CLOEXEC|O_DIRECTORY);
         if (rootfd < 0)
                 return -errno;
 
@@ -101,7 +99,6 @@ int bus_container_connect(sd_bus *b) {
                 if (chroot(".") < 0)
                         _exit(255);
 
-
                 r = connect(b->input_fd, &b->sockaddr.sa, b->sockaddr_size);
                 if (r < 0) {
                         if (errno == EINPROGRESS)