From 719f80c649b64b746c83439836d7d39c704fc8e7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 23 Oct 2023 12:14:15 +0200 Subject: [PATCH] spawn/IProtocol: add EXEC_PATH The `exec_path` field never worked because it was never copied to the server. --- src/spawn/Client.cxx | 2 ++ src/spawn/IProtocol.hxx | 1 + src/spawn/Server.cxx | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/src/spawn/Client.cxx b/src/spawn/Client.cxx index a4ecbcb6c..636147cb9 100644 --- a/src/spawn/Client.cxx +++ b/src/spawn/Client.cxx @@ -277,6 +277,8 @@ Serialize(SpawnSerializer &s, const PreparedChildProcess &p) s.WriteOptionalString(SpawnExecCommand::HOOK_INFO, p.hook_info); + s.WriteOptionalString(SpawnExecCommand::EXEC_PATH, p.exec_path); + for (const char *i : p.args) s.WriteString(SpawnExecCommand::ARG, i); diff --git a/src/spawn/IProtocol.hxx b/src/spawn/IProtocol.hxx index 358a53dc0..f1b6ddacc 100644 --- a/src/spawn/IProtocol.hxx +++ b/src/spawn/IProtocol.hxx @@ -21,6 +21,7 @@ enum class SpawnRequestCommand : uint8_t { }; enum class SpawnExecCommand : uint8_t { + EXEC_PATH, ARG, SETENV, UMASK, diff --git a/src/spawn/Server.cxx b/src/spawn/Server.cxx index 577c06222..54a03c8b7 100644 --- a/src/spawn/Server.cxx +++ b/src/spawn/Server.cxx @@ -511,6 +511,10 @@ SpawnServerConnection::HandleExecMessage(SpawnPayload payload, while (!payload.empty()) { const SpawnExecCommand cmd = (SpawnExecCommand)payload.ReadByte(); switch (cmd) { + case SpawnExecCommand::EXEC_PATH: + p.exec_path = payload.ReadString(); + break; + case SpawnExecCommand::ARG: if (p.args.size() >= 16384) throw MalformedSpawnPayloadError();