Skip to content

Support one-shot guest exec through the Manager API - #543

Closed
horner wants to merge 5 commits into
mainfrom
feat/manager-guest-exec
Closed

horner wants to merge 5 commits into
mainfrom
feat/manager-guest-exec

Conversation

@horner

@horner horner commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Part of #541.

A container owner or Manager administrator can run a one-shot command in an already-running unprivileged Proxmox LXC guest with their existing Manager login. The guest needs no SSH server or published port.

  • Add POST /api/v1/sites/{siteId}/containers/{id}/exec and the OS provider implementation. Preserve literal argv, both output streams and the guest exit status. An interrupted request reports an unknown outcome and is never replayed.
  • Resolve the guest from Manager's owner/admin authorization check. On the node, a restricted OpenSSH key invokes a fixed runner which checks the configured site domain, guest identity, Linux ID mappings and running state before attaching. The default UID and GID are 1000. An administrator can grant guest root for a specific guest and owner.
  • Enforce a 30-second execution limit and cap each stream at 64 KiB. Audit who ran a command, where, when, and its outcome without recording arguments or output. The change includes node setup and fixture instructions.

Verification

  • All 12 Manager route tests and 126 provider tests passed. The provider typecheck and build passed. The complete Manager suite had one unrelated MCP proxy failure which also reproduces on the unchanged base.

  • A real CLI and provider exercised the HTTP API, Manager credentials, a restricted SSH connection, and an unprivileged Linux LXC guest with SSH unpublished. It preserved a literal argument, returned separate stdout/stderr with exit status 23, and denied a different owner's guest before dispatch.

  • A dropped HTTP reply after a completed state-changing command produced CLI status 125 and an unknown-outcome diagnostic. An independent guest read confirmed exactly one execution.

  • The standalone nested-LXC suite covers UID/GID, grants, binary output, truncation, timeout and cleanup of detached descendants. The fixture substitutes Proxmox configuration lookup. Process execution, user namespaces and cgroups are real. Run it with bash images/proxmox-ve/guest-exec/tests/lxc.sh.

  • On a disposable Proxmox VE 9.3.1 VM, the installed runner passed all six acceptance tests against an unprivileged guest. Holding the actual Proxmox guest configuration lock prevented dispatch, and the command succeeded after unlock. SIGHUP and SIGTERM each removed the job cgroup and reaped the command and its detached child. Proxmox validation details

Deploy Manager, configure the node and release the OS provider before releasing the CLI companion.

CLI companion: mieweb/cloud#30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unhandled SIGHUP or SIGTERM can terminate the runner without cleanup, allowing detached guest descendants to run indefinitely and leaving the job cgroup behind.

1 open issue
What changed in this PR

Adds one-shot execution in running Proxmox guests through Manager authentication, supporting #541 without requiring guest SSH access.

Changes:

  • Adds an owner/admin-authorized API and OS provider capability preserving arguments, output streams, and exit status.
  • Introduces a restricted node runner with identity checks, privilege grants, and execution limits.
  • Adds tests, CI coverage, and deployment instructions.
File Description
packages/​os-cloud-provider/​test/​provider.test.ts Tests provider execution and error handling.
packages/​os-cloud-provider/​test/​exec-guest.e2e.mjs Checks CLI execution and authorization end to end.
packages/​os-cloud-provider/​src/​index.ts Exposes the exec capability.
packages/​os-cloud-provider/​src/​exec.ts Implements requests and validates results.
packages/​os-cloud-provider/​src/​deploy.ts Exports the shared authenticated client factory.
packages/​os-cloud-provider/​src/​client.ts Supports preserving permission-denial errors.
packages/​os-cloud-provider/​README.md Documents CLI usage and retry precautions.
mie-opensource-landing/​zensical.toml Adds administrator documentation navigation.
mie-opensource-landing/​docs/​admins/​guest-exec.md Documents setup, privileges, and limits.
images/​proxmox-ve/​guest-exec/​tests/​verify.py Checks runner behavior in an LXC guest.
images/​proxmox-ve/​guest-exec/​tests/​lxc.sh Creates the disposable LXC fixture.
images/​proxmox-ve/​guest-exec/​mieweb-guest-exec Implements restricted guest execution and cleanup.
images/​proxmox-ve/​guest-exec/​install-node.sh Installs the runner and Python bindings.
create-a-container/​utils/​guest-exec.js Dispatches over restricted SSH and validates replies.
create-a-container/​routers/​api/​v1/​containers.js Adds authorization, validation, and auditing.
create-a-container/​routers/​api/​v1/​__tests__/​containers.exec.test.js Tests API permissions, validation, and outcomes.
create-a-container/​openapi.v1.yaml Defines the execution API contract.
.github/​workflows/​os-cloud-provider.yml Includes execution route tests and triggers.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings December 4, 2026 09:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The root-run SSH runner crosses host–guest security boundaries, requiring human security review and real Proxmox node validation of liblxc attachment, lifecycle locking, and cgroup cleanup beyond the substituted-configuration fixture.

1 open issue

Review effort: Balanced

@horner
horner enabled auto-merge December 4, 2026 09:49
Copilot AI balanced review requested due to automatic review settings December 4, 2026 09:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The root-run SSH runner crosses namespace and cgroup security boundaries, requiring human security review and native Proxmox validation because the fixture does not exercise lifecycle locking.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings December 4, 2026 09:58
@horner

horner commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

I validated commit 6810166 on a disposable x86-64 VM running Proxmox VE 9.3.1, kernel 7.0.14-32-pve, and a live unprivileged LXC guest. This run used the installed node runner and real pmxcfs, pct config, liblxc and cgroup v2.

  • All six acceptance tests passed. For each of SIGHUP and SIGTERM, the test waited for the main process and detached child to start, signalled the runner, then checked both pidfds and verified the job cgroup had been removed within five seconds. No job cgroups remained after the suite.
  • Holding Proxmox’s exclusive guest configuration lock through PVE::LXC::Config->lock_config caused exec to return exec_unavailable without applying the guest side effect. The same command succeeded once the lock was released.
  • The guest ran as UID/GID 1000 by default. The matching guest-root grant and mismatched-grant denial, literal arguments, binary streams, exit status, truncation and execution timeout all passed.

A cold pct config took 5.16 seconds under CPU emulation. That exposed a false rejection at the old five-second configuration-read timeout. The eight-second configuration-read budget passed the same test; the guest runtime budget is still 30 seconds and the Manager transport budget is 45 seconds.

The VM and its disks have been removed. The host/guest privilege boundary is ready for independent human security review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The root-run SSH/liblxc security boundary requires maintainer review and real Proxmox validation of lifecycle locking, ABI compatibility, and cgroup handling, since the fixture substitutes Proxmox configuration lookup.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings December 4, 2026 10:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The root-run SSH/liblxc bridge crosses host–guest privilege boundaries, requiring independent security review of credentials, capabilities, containment, and guest-root grants beyond the reported acceptance tests.

No open issues 🎉

Review effort: Balanced

@runleveldev runleveldev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes

Thanks for this. The work is careful, and much of the Manager side is well thought out: owner/admin authorization, argument and output limits, unknown-outcome handling that never retries, and auditing that omits arguments and output. I can't accept the node-side design, though. It breaks something that has been a goal of this project, even if we never wrote it down: this software does not touch the underlying Proxmox hosts. The only exceptions are the local compose stack, which is dev only, and small changes an admin can easily understand, such as creating the volumes directory or the NVIDIA snippets. I should have documented that more clearly, and I'll make sure it gets written down.

Why the node-side runner doesn't fit

  1. Installation. Setup is currently a single container: the Manager image. This PR adds manual steps on every Proxmox node (run install-node.sh, edit root's authorized_keys) and on Manager for every site and node pair (generate a key, write ssh_config, add the node's host key to known_hosts under /etc/mieweb/guest-exec/<site>/<node>/). None of this can be done through the UI or API, and the work grows with every node added.

  2. Maintenance and fragility. We currently support any Proxmox version with a compatible API. The runner relies on Proxmox internals that aren't public interfaces:

    • the lock file path /run/lock/lxc/pve-config-<vmid>.lock
    • the output format of pct config --current
    • the owner tag being the first tag
    • the cgroup v2 layout and cgroup.kill
    • liblxc's attach behavior

    install-node.sh also downloads Debian's python3-lxc and copies its bindings into /usr/local, where they load against the liblxc.so.1 that ships with lxc-pve. Nothing guarantees those two are compatible. The docs already say to re-run the installer after upgrading the node's distribution or Python. Any of these can break on a routine Proxmox update.

  3. Administration. Today admins can change their Proxmox hosts to meet their own organizational requirements, and this software keeps working. This PR adds state that each node has to preserve: /usr/local/lib/mieweb-guest-exec, entries in authorized_keys, and the root-grant files in /etc/mieweb/guest-exec-root/. Ordinary hardening, such as disabling root SSH or managing authorized_keys centrally, breaks exec. Root grants also live on node filesystems instead of in Manager's database, so authorization is split between Manager and files on each hypervisor that the UI and API can't see.

  4. Access and security. It isn't a listening daemon, but it gives every hypervisor a root entry point that Manager can reach with a key. The forced command and the restrict/from= options narrow it. Still, if Manager or that key is compromised, the attacker can run root code that attaches to guests on every enabled node. Also, on a clustered PVE install /root/.ssh/authorized_keys is normally a symlink to /etc/pve/priv/authorized_keys, which is shared across the cluster. If so, the "dedicated key per node" setup actually applies to every node in the cluster. Either way, this is the kind of interaction with the host we should avoid.

  5. Updates. The runner has no update path. Every release that changes the runner or its protocol needs an admin to redeploy it to every node, in the right order relative to Manager. The PR already needs a strict rollout order: Manager, then the nodes, then the OS provider, then the CLI.

  6. Operations. We don't currently require SSH access from Manager to the Proxmox nodes, only API access. This adds a new network path (Manager to each node's management IP on port 22), an SSH client in the Manager image, and per-node key and host-key management.

  7. Test coverage. CI uses a fixture that replaces Proxmox's configuration lookup with a stand-in. The real Proxmox behavior (the lock, pct config, the liblxc ABI) was checked by hand on one disposable PVE 9.3.1 VM. So the parts most likely to break on upgrades are the parts CI doesn't cover.

Other concerns

Running as UID/GID 1000 by default. Unless a root-grant file on the node matches the request, the runner runs commands as UID and GID 1000 (mieweb-guest-exec:68-70, docs/admins/guest-exec.md:48). Nothing else in this project gives UID 1000 a special meaning, and the assumption doesn't hold up:

  • There may be no such user in the guest. Guests come from arbitrary Docker/OCI images, and many have no account with UID 1000. The command then runs as an unnamed UID with no home directory, no shell entry and none of the permissions the image expects.
  • It isn't the caller's identity. Manager users have their own LDAP uidNumber, so UID 1000 doesn't correspond to the person running the command. It's an arbitrary unprivileged ID, and its security benefit is unclear.
  • It doesn't match how ownership works today. The container owner already has full control of the guest: they choose the image and entrypoint, and they can SSH in. Running their commands as non-root protects nothing meaningful. It mainly breaks routine work like installing packages.
  • It forces the root-grant mechanism. The non-root default is the reason per-node grant files exist. That puts authorization state on hypervisor filesystems, which makes the problem in point 3 worse.

Unless there's a specific threat model behind it, commands should run as guest root for owners and admins. If a different user is ever needed, it should be an optional per-request user name that the guest resolves, not a fixed numeric ID.

Exec cleanup kills daemons the user deliberately started. The runner puts each command in its own cgroup and writes to cgroup.kill when the command finishes or times out. As documented, this includes detached children and descendants that call setsid() (mieweb-guest-exec:225-226, docs/admins/guest-exec.md:62). So mieweb exec -- systemctl start foo keeps working, because systemd starts the service outside the exec's cgroup. But mieweb exec -- ./start-server.sh or nohup myapp & is killed the moment the exec returns. That breaks the behavior people expect from SSH: closing the session hangs up plain background jobs, but processes that detached on purpose keep running. The docs suggest using the guest's service manager, which assumes every guest image has one, and many Docker-derived guests don't. Cleanup should kill the command only when it times out. It shouldn't kill processes the command deliberately detached.

Preferred approach: termproxy with cmode: shell and a POSIX wrapper

This uses only the existing Proxmox API and the token Manager already stores for each node. Nothing is installed on the hosts or in the guests, and no new ports or SSH access are needed.

Background

  • The Proxmox API has no LXC equivalent of the QEMU guest agent's agent/exec, but POST /nodes/{node}/lxc/{vmid}/termproxy plus the vncwebsocket WebSocket gives a terminal session in the guest.
  • termproxy reads the container config on every call and builds the console command from cmode (pve-container src/PVE/LXC.pm get_console_command):
    • cmode: tty (the default) and cmode: console run lxc-console, which shows a getty login prompt.
    • cmode: shell runs lxc-attach --clear-env -n <vmid>, a root shell with no login.
  • Manager can set cmode: shell through the API. That's a guest config change, not a change to the host. On a running guest, though, the change doesn't take effect until the guest restarts (confirmed on a real Proxmox node). Manager should therefore set cmode: shell when it creates the container, before the first start, so new guests support exec with no extra steps. Existing guests need a one-time restart, which Manager can trigger or leave to the owner. Exec on a guest that is still in tty mode should fail with a clear "restart required" error instead of hanging at a login prompt. Manager can detect this with GET /nodes/{node}/lxc/{vmid}/pending, or by looking for a login prompt instead of the ready marker.
  • termproxy wraps the console in dtach -A /var/run/dtach/vzctlconsole<vmid> (src/PVE/API2/LXC.pm, termproxy). Every console connection to the same guest therefore joins one shared, persistent session. Two simultaneous connections share the same shell, and closing the WebSocket only disconnects from the session without ending it. The wrapper below is designed for this.

Protocol

Before each exec, Manager:

  1. Generates a random per-request value N (for example, 128 bits as hex).
  2. Quotes each argv element for the shell: wrap it in single quotes and replace every ' with '\''. NUL bytes are already rejected.
  3. Allows only one exec per guest at a time.

Step 1: bootstrap. Manager sends this single line, followed by CR (\r), to whatever shell lxc-attach started (the guest root's login shell). It then discards all output until MIEWEB-READY-N appears:

stty -echo -icanon -iexten -isig -ixon -icrnl -inlcr -igncr -istrip -opost min 1 time 0; printf 'M\111EWEB-READY-%s\n' N; exec /bin/sh -s 2>/dev/null
  • stty puts the terminal into raw mode: no echo, no line buffering or line-length limit, no special handling of control characters (^C, ^D, ^V, ^S/^Q), and no CR/LF translation in either direction.
  • The \111 escape means the echoed copy of this line can't match the ready marker. Only the real printf output prints MIEWEB-READY-N.
  • exec /bin/sh -s 2>/dev/null replaces the login shell (which may be bash with line editing and tab completion) with a non-interactive POSIX sh that reads the rest of its script from the terminal. Redirecting stderr makes it non-interactive, so there are no prompts and no line editing.

Step 2: wrapper. After the ready marker appears, Manager sends the wrapper. Here N is the per-request value and the fifth line is the quoted argv, in this example ls -la /root:

d=/tmp/.mieweb-exec-N
umask 077
mkdir "$d" || { printf '\nMIEWEB-ERROR-N\n'; exit 1; }
cd / || exit 1
'ls' '-la' '/root' </dev/null >"$d/o" 2>"$d/e" &
p=$!
( sleep 30; : >"$d/t"; kill -s KILL "$p" ) </dev/null >/dev/null 2>&1 &
w=$!
wait "$p"; rc=$?
kill -s KILL "$w" 2>/dev/null
t=0; [ -e "$d/t" ] && t=1
printf '\nMIEWEB-BEGIN-N %s %s %s %s\n' "$rc" "$t" $(wc -c <"$d/o") $(wc -c <"$d/e")
dd if="$d/o" bs=65536 count=1 2>/dev/null | od -A n -t x1 -v
printf 'MIEWEB-SPLIT-N\n'
dd if="$d/e" bs=65536 count=1 2>/dev/null | od -A n -t x1 -v
printf 'MIEWEB-END-N\n'
rm -rf "$d"
exit "$rc"

What each part does:

  • Scratch directory. mkdir with umask 077 creates a private directory named with N. It fails if the path already exists, so concurrent runs can't collide and a pre-created symlink can't redirect the output.
  • </dev/null is required. The shell reads this script from the terminal. Without it, the command would consume the rest of the wrapper as its input.
  • Separate output streams. stdout and stderr go to separate files, so they never pass through the terminal raw.
  • Timeout without timeout. timeout isn't POSIX. A background sleep 30 records a timeout flag and kills only the command. wait returns the command's exit code, or 128 plus the signal number if it was killed, the same as the current PR.
  • Output encoding. POSIX has no base64 (uuencode -m is POSIX but rarely installed), so each stream is hex-encoded with od. dd caps each one at 64 KiB, and wc -c reports the full size so Manager can flag truncation. The command's output can never be mistaken for a marker, because it only reaches the terminal as hex.
  • Exiting. exit ends the shell, which ends the terminal session and the shared dtach session with it. The kernel then sends SIGHUP to the shell's process group. That stops the timeout watcher and any plain & background jobs, while processes that detached on purpose (setsid, a double fork, nohup) keep running. This is the same as closing an SSH session.

Step 3: parsing. Manager reads until MIEWEB-END-N, or treats a missing marker as an error (see the last bullet):

  • MIEWEB-BEGIN-N <exitCode> <timedOut> <stdoutBytes> <stderrBytes>: a stream was truncated if its byte count is over 65536.
  • The hex between BEGIN and SPLIT is stdout, and the hex between SPLIT and END is stderr. Strip the whitespace and decode it.
  • MIEWEB-ERROR-N means nothing was run.
  • If END doesn't arrive within an overall deadline (about 40 seconds), the outcome is unknown and must not be retried. That keeps the PR's current semantics.

What has been tested

  • Shells: the wrapper ran under bash, dash (debian:stable-slim) and BusyBox ash (alpine). It kept a literal argument containing ', returned stdout and stderr separately and kept exit code 23.
  • Timeout: scaled down to 2 seconds, it returned exit code 137 with the timed-out flag set.
  • Terminal bootstrap: the full bootstrap plus wrapper was run through a real terminal against both an interactive bash -i (with line editing) and sh -i. A 10,017-byte argument containing tab, ^C, ^D, ^V, ^Q, ^S, CR and ' arrived at the command with exactly its original length.
  • Process lifetime: run through a terminal, a command that started sleep &, setsid sleep & and nohup sleep & left the setsid and nohup processes running after the exec. The plain background job and the timeout watcher were hung up.
  • Not yet tested: the actual termproxy/vncwebsocket/dtach path on Proxmox. The only thing confirmed on a real node so far is that changing cmode on a running guest requires a restart.

Known limitations and open items

  • Shared dtach session. Manager's one-exec-per-guest rule prevents its own collisions. But if someone has the Proxmox web console open, or a previous session is stuck, the bootstrap line is typed into that shell. Manager can't detect a person who is attached. We should document this and maybe check for it.
  • API token permissions. Manager's API token needs VM.Console, plus permission to change cmode. Please confirm that vncwebsocket works with API token authentication and not only with ticket authentication.
  • Existing guests need a restart. Changing cmode only takes effect after a restart, so the rollout needs a plan for guests that were created before this change. For example: set cmode: shell on all of them, and have exec report "restart required" until each guest has restarted.
  • cmode: shell gives passwordless root to any Proxmox user with VM.Console on that guest. That's probably acceptable for our deployments, but it should be documented.
  • Tools required in the guest: sh, stty, mkdir, sleep, wc, dd and od. Nearly every image has them, but distroless images have no shell. For those, exec should return the existing "unavailable" error.
  • No disk cap while the command runs. Output is truncated only afterwards, so a very noisy command could fill /tmp within 30 seconds. ulimit -f would cap it, but it kills the command with SIGXFSZ. I think the risk is acceptable without it.
  • The command can fake the markers. It can write to /dev/tty and discover N through /proc/self/fd. That only lets it fake its own result to its own owner, so it isn't a security issue.

Also acceptable: an agent inside each guest

An agent in each guest that connects out to Manager, by long-polling or over a WebSocket, also needs no host changes, no new ports and no SSH. It would remove the terminal-related limitations above. The trade-offs are that every guest image needs the agent installed and it needs an update strategy. The authorization, limits and auditing in this PR would carry over almost unchanged.

If an agent on each node is truly necessary

I'd want to see why neither approach above can work. If a node agent is still needed, it must meet all of these:

  1. Packaged as a DEB, like the other components in this repo, with every non-system dependency bundled (PyPI packages, and the LXC Python bindings if they're still needed). No apt-get download and copying into /usr/local.
  2. Run as a sandboxed systemd service, preferably as a non-root user, with a bundled sudo and/or polkit policy for any privileges it needs. Use the usual systemd hardening options (ProtectSystem=, NoNewPrivileges=, a minimal CapabilityBoundingSet= and so on).
  3. No inbound connections to the node. We can't extend the Proxmox API, and I don't want to open a second port or require SSH. The agent should connect to Manager over HTTPS and either long-poll for jobs or hold a WebSocket open. Every configured site can already reach Manager's HTTP API, so this adds no new network requirement. The agent should register and authenticate through Manager, for example with an admin API key, not through keys placed on the node by hand.

Suggested path forward

The parts of this PR that don't depend on the execution method look reusable: the POST /sites/{siteId}/containers/{id}/exec contract in OpenAPI, the authorization checks, the argument and output limits, the unknown-outcome behavior, auditing, the OS provider and the CLI. Please keep those and replace the SSH runner with the termproxy approach above. Drop the UID 1000 default and the cleanup that kills detached processes. Happy to talk through any of it before you start.

@runleveldev

Copy link
Copy Markdown
Collaborator

We're taking this change over in #546. That PR keeps the parts of this one that don't depend on the execution method (the API contract, route, tests and OS provider), credited to @horner, and replaces the SSH node runner with a Proxmox termproxy backend, as described in the review. Closing this one in favor of #546. Thanks for the groundwork.

@runleveldev runleveldev closed this Dec 4, 2026
auto-merge was automatically disabled December 4, 2026 16:52

Pull request was closed

runleveldev added a commit that referenced this pull request Dec 4, 2026
Replace the SSH node runner from #543 with the Proxmox API alone.
Nothing is installed on the Proxmox hosts and Manager needs no SSH
access to them.

With cmode: shell, the console that termproxy opens for a container is
a root shell with no login. Manager connects to it with the existing
node credentials over vncwebsocket and types a bootstrap line that
puts the terminal into raw mode and switches to a non-interactive
sh -s. It then sends a POSIX wrapper that runs the quoted argv with
stdout and stderr redirected to files and a 30-second limit, and
prints the exit code and hex-encoded streams between markers that
contain a per-request nonce.

* Containers get cmode: shell at create and reconfigure. On a running
  container the change waits for a restart, so the first exec on an
  older container sets it and returns exec_restart_required.
* Commands run as guest root. The UID 1000 default and root grants are
  gone.
* When the command returns, the shell exits, so plain background jobs
  get SIGHUP. Processes started with setsid or nohup keep running.
* Only one exec runs per container at a time (exec_busy), because
  Proxmox shares a single dtach console session per container.
* The live hostname and running state are checked through the API
  before the console is opened.

Adds ws, because the WebSocket built into Node can't take the node's
TLS agent or auth headers.
runleveldev added a commit that referenced this pull request Dec 5, 2026
Carry over the parts of #543 that don't depend on how a command reaches
the guest. These are the exec_container OpenAPI contract, the
owner/admin route with its argument limits, error mapping and audit
logging, the route tests, the OS provider exec verb with its tests,
and the CI triggers.

The SSH node runner, its installer and fixtures, and the setup docs
are intentionally left behind (see the review on #543). The route
still imports utils/guest-exec. A Proxmox termproxy backend replaces
it in a follow-up commit.

Co-authored-by: Doug Horner <horner@mieweb.com>
runleveldev added a commit that referenced this pull request Dec 5, 2026
Replace the SSH node runner from #543 with the Proxmox API alone.
Nothing is installed on the Proxmox hosts and Manager needs no SSH
access to them.

With cmode: shell, the console that termproxy opens for a container is
a root shell with no login. Manager connects to it with the existing
node credentials over vncwebsocket and types a bootstrap line that
puts the terminal into raw mode and switches to a non-interactive
sh -s. It then sends a POSIX wrapper that runs the quoted argv with
stdout and stderr redirected to files and a 30-second limit, and
prints the exit code and hex-encoded streams between markers that
contain a per-request nonce.

* Containers get cmode: shell at create and reconfigure. On a running
  container the change waits for a restart, so the first exec on an
  older container sets it and returns exec_restart_required.
* Commands run as guest root. The UID 1000 default and root grants are
  gone.
* When the command returns, the shell exits, so plain background jobs
  get SIGHUP. Processes started with setsid or nohup keep running.
* Only one exec runs per container at a time (exec_busy), because
  Proxmox shares a single dtach console session per container.
* The live hostname and running state are checked through the API
  before the console is opened.

Adds ws, because the WebSocket built into Node can't take the node's
TLS agent or auth headers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants