mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-30 16:39:33 +01:00
fix(launch): a server running as root starts Claude without the bypass flag
Installed and started as root (a VPS, an LXC container), every local Claude
session died at once: the default permission mode launches Claude Code with
--dangerously-skip-permissions, and Claude Code refuses that flag under uid 0
("cannot be used with root/sudo privileges for security reasons", pane dead
with status 1). Shell sessions were fine. Measured 2026-11-27 with the public
installer in a fresh ubuntu:24.04 container.
Docker cases already answer the same refusal for a root container with
overlays.docker.rootCommand. This is the host-level form, as registry data:
- An enum launch param may declare rootValue, a map from a value to the value
it takes when the server process runs as uid 0 and the launch is local.
Claude declares claudeMode: dangerously-skip-permissions -> normal. The
schema holds keys and replacements to the param's values.
- applyRootValues() (config/cli-registry/root-launch.ts, pure) rewrites the
param values before the argv engine sees them and hands back the object it
was given when nothing changes, so a launch that is not root is
byte-identical (the spawn goldens are untouched).
- serverRunsAsRoot() (utils/server-uid.ts) reads the uid at call time. Under
vitest it answers false unless a test stubs it.
- The uid is asked in two places only. serverRootSpawnOptions() feeds the two
tmux launches (createSession, respawnPane), which every local tmux launch
goes through: new session, resume, dead-pane respawn, restartCli(), cron,
quick-start, reboot restore. buildPermissionArgs() covers the two launches
with no tmux, the direct-PTY fallback and the one-shot run.
- Remote and Docker pane commands never read it, and auto, allowedTools and
normal are passed through unchanged. IS_SANDBOX is not set.
- Each swap is logged once per launch, naming the cause and the way out.
Checked end to end in a throwaway ubuntu:24.04 container running this tree's
server as root with Claude Code 2.1.332: the pane command carries no bypass
flag, the pane stays alive on Claude's first-run screen, and the log line is
there. The same run as an ordinary user keeps the flag.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
6db166f3f8
commit
d9fce03444
15 files changed
+785
-10
No files matched your search
@@ -298,6 +298,12 @@ The allowlist is not a formality. If a branch is about what a CLI can DO it belo
|
||||
|
||||
This matters because it is invisible when it is wrong. `capabilities.privilegedParams[].param` is the multi-user bypass clamp's only handle on a CLI's privilege switch, and a name from the wrong namespace clamps **nothing**: no load error, no failing test, the clamp simply stops running. Codex is the entry where the two names differ (`bypassApprovals` as the param, `dangerouslyBypassApprovals` on the wire), so it is the one that catches a regression. `schema.ts` rejects any entry naming a param it never declared, on both `configSetenv.fromParam` and `privilegedParams.param`.
|
||||
|
||||
## A server that runs as root (`rootValue`)
|
||||
|
||||
An `enum` launch param may declare `rootValue`: a map from a value to the value it takes instead when the Codeman **server process** runs as uid 0 and the launch is **local**, where the CLI is the server's child and so runs as root too. Claude declares the one entry there is, `claudeMode: { 'dangerously-skip-permissions': 'normal' }`, because Claude Code exits on `--dangerously-skip-permissions` under root and that mode is the default: on a server installed as root (a VPS, an LXC container) every local Claude session was a dead pane. It is the host-level form of `overlays.docker.rootCommand`, which answers the same refusal by the container's uid.
|
||||
|
||||
`applyRootValues()` (`root-launch.ts`, pure) rewrites the param values before the argv engine sees them and hands back the object it was given when nothing changes, so a launch that is not root is byte-identical. The uid is asked at call time through `serverRunsAsRoot()` (`utils/server-uid.ts`; under vitest it answers `false` unless a test stubs it), and only by the local launch sites: `serverRootSpawnOptions()` for the two tmux launches (`createSession`, `respawnPane`) and `buildPermissionArgs()` for the direct-PTY fallback and the one-shot run. Remote and Docker pane commands never read it. Each swap is logged once per launch. The schema requires every key and every replacement to be one of the param's `values`, and refuses a replacement that is itself replaced. Tests: `test/root-launch.test.ts`.
|
||||
|
||||
## Fields declared for later
|
||||
|
||||
`accent`, `capabilities.echo`, `capabilities.keyboardAccessory` and `capabilities.maxFrameBytes` are **declared but not yet read**. (`shortBadge` was on this list until the CLI management list in Settings started showing it, and `capabilities.wheelForward` until the browser's wheel gate started reading it, see below.) They all describe frontend behaviour, and the frontend is deliberately untouched here: `app.js`, `terminal-ui.js` and `styles.css` keep their own hand-authored per-CLI rules, and moving them is its own piece of work verified by a browser/mobile suite the CI gate cannot see.
|
||||
|
||||
Reference in new issue
Block a user