]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machined: call unlockpt() in container, not host
authorLennart Poettering <lennart@poettering.net>
Tue, 1 Sep 2015 17:39:14 +0000 (19:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 1 Sep 2015 18:40:24 +0000 (20:40 +0200)
It makes assumptions about the pty path, hence better call it in the
container namespace rather than the host.

src/basic/util.c
src/machine/machine-dbus.c
src/run/run.c

index 737f2a221c614b714211e398cd42fd5dd6509861..f01f5f237b5c53fe79e2b2b1b228711f29568108 100644 (file)
@@ -6095,6 +6095,9 @@ int openpt_in_namespace(pid_t pid, int flags) {
                 if (master < 0)
                         _exit(EXIT_FAILURE);
 
+                if (unlockpt(master) < 0)
+                        _exit(EXIT_FAILURE);
+
                 cmsg = CMSG_FIRSTHDR(&mh);
                 cmsg->cmsg_level = SOL_SOCKET;
                 cmsg->cmsg_type = SCM_RIGHTS;
index af2b8eff063b79b04190c8a19d3be7121963304c..f27b58b89361e77a26b17d76437b43be189e7015 100644 (file)
@@ -597,9 +597,6 @@ int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bu
         if (!p)
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "PTS name %s is invalid", pty_name);
 
-        if (unlockpt(master) < 0)
-                return -errno;
-
         r = container_bus_new(m, &allocated_bus);
         if (r < 0)
                 return r;
@@ -701,9 +698,6 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
         utmp_id = path_startswith(pty_name, "/dev/");
         assert(utmp_id);
 
-        if (unlockpt(master) < 0)
-                return -errno;
-
         r = container_bus_new(m, &allocated_bus);
         if (r < 0)
                 return r;
index a69560208c7090539a92f1a1bd4c5d5e13b556bc..657c6fcaf10a88d0c7acf0a5ff0bbf095d6750c6 100644 (file)
@@ -702,6 +702,9 @@ static int start_transient_service(
                         if (r < 0)
                                 return log_error_errno(r, "Failed to determine tty name: %m");
 
+                        if (unlockpt(master) < 0)
+                                return log_error_errno(errno, "Failed to unlock tty: %m");
+
                 } else if (arg_transport == BUS_TRANSPORT_MACHINE) {
                         _cleanup_bus_unref_ sd_bus *system_bus = NULL;
                         const char *s;
@@ -738,9 +741,6 @@ static int start_transient_service(
                                 return log_oom();
                 } else
                         assert_not_reached("Can't allocate tty via ssh");
-
-                if (unlockpt(master) < 0)
-                        return log_error_errno(errno, "Failed to unlock tty: %m");
         }
 
         if (!arg_no_block) {