diff --git a/app/Services/Proxmox/HttpProxmoxClient.php b/app/Services/Proxmox/HttpProxmoxClient.php index c93d749..ceefe33 100644 --- a/app/Services/Proxmox/HttpProxmoxClient.php +++ b/app/Services/Proxmox/HttpProxmoxClient.php @@ -95,8 +95,11 @@ class HttpProxmoxClient implements ProxmoxClient public function guestExec(string $node, int $vmid, string $command): array { - $pid = $this->http()->asForm() - ->post("/nodes/{$node}/qemu/{$vmid}/agent/exec", ['command' => $command]) + // The guest agent runs a program directly, not a shell — wrap compound + // commands (cd/&&/pipes/redirects/env) in an explicit shell. command is a + // JSON array so each argument is passed safely without re-quoting. + $pid = $this->http() + ->post("/nodes/{$node}/qemu/{$vmid}/agent/exec", ['command' => ['/bin/sh', '-c', $command]]) ->throw()->json('data.pid'); // Poll exec-status until the command has exited.