summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2025-01-15 17:27:25 +0100
committerMike Yuan <me@yhndnzj.com>2025-01-15 17:46:10 +0100
commit9843ad6dc394beed767e48c41f36f524a6476aa0 (patch)
tree7376873800e62762070df2689d59062316f42f39
parentrun: correct log level for pty_open_peer() error (diff)
downloadsystemd-9843ad6dc394beed767e48c41f36f524a6476aa0.tar.xz
systemd-9843ad6dc394beed767e48c41f36f524a6476aa0.zip
run: with TIOCGPTPEER there's no longer need to acquire pty peer through IPC
-rw-r--r--src/run/run.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/run/run.c b/src/run/run.c
index f1564b522e..0de5e4e491 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -1153,7 +1153,7 @@ static int transient_service_set_properties(sd_bus_message *m, const char *pty_p
bool use_ex_prop = !arg_expand_environment;
assert(m);
- assert(pty_path || pty_fd < 0);
+ assert((!!pty_path) == (pty_fd >= 0));
r = transient_unit_set_properties(m, UNIT_SERVICE, arg_property);
if (r < 0)
@@ -1204,22 +1204,11 @@ static int transient_service_set_properties(sd_bus_message *m, const char *pty_p
}
if (pty_path) {
- r = sd_bus_message_append(m, "(sv)", "TTYPath", "s", pty_path);
- if (r < 0)
- return bus_log_create_error(r);
-
- if (pty_fd >= 0)
- r = sd_bus_message_append(m,
- "(sv)(sv)(sv)",
- "StandardInputFileDescriptor", "h", pty_fd,
- "StandardOutputFileDescriptor", "h", pty_fd,
- "StandardErrorFileDescriptor", "h", pty_fd);
- else
- r = sd_bus_message_append(m,
- "(sv)(sv)(sv)",
- "StandardInput", "s", "tty",
- "StandardOutput", "s", "tty",
- "StandardError", "s", "tty");
+ r = sd_bus_message_append(m, "(sv)(sv)(sv)(sv)",
+ "TTYPath", "s", pty_path,
+ "StandardInputFileDescriptor", "h", pty_fd,
+ "StandardOutputFileDescriptor", "h", pty_fd,
+ "StandardErrorFileDescriptor", "h", pty_fd);
if (r < 0)
return bus_log_create_error(r);
@@ -1967,9 +1956,6 @@ static int start_transient_service(sd_bus *bus) {
peer_fd = pty_open_peer(pty_fd, O_RDWR|O_NOCTTY|O_CLOEXEC);
if (peer_fd < 0)
return log_error_errno(peer_fd, "Failed to open PTY peer: %m");
-
- // FIXME: Introduce OpenMachinePTYEx() that accepts ownership/permission as param
- // and additionally returns the pty fd, for #33216 and #32999
} else
assert_not_reached();
}