[Bug] run_as_user: agent can't connect to 0600 root-owned API socket (EACCES) — send/timer/cron fail
cc-connect Version
1.4.1 (also present on main / v1.5.0-beta.1)
Operating System
Linux (Docker container)
Agent Type
Claude Code (claudecode)
Platform
Any (platform-independent — affects the agent→daemon control CLI, not any specific platform)
Bug Description
With run_as_user set, the agent cannot use the daemon control CLI (cc-connect send, cc-connect timer …, cc-connect cron …). Commands fail with connect: permission denied on the API socket — e.g. when the agent tries to send back a generated image or create a timer.
cc-connect runs as root and spawns the agent as the configured run_as_user (a different, unprivileged user). The daemon's API control socket is created and locked down in NewAPIServer (core/api.go:76-83):
listener, err := net.Listen("unix", sockPath) // <data_dir>/run/api.sock
...
os.Chmod(sockPath, 0o600) // owner-only, owned by the daemon user (root)The send, timer/*, and cron/* endpoints are all served on this socket (core/api.go:92-104). Every one of those subcommands the agent is instructed to run (core/interfaces.go) dials this socket. Because the socket is 0600 owned by root and the agent runs as a different user, the agent gets EACCES on connect().
This is the same class as #1429 (a 0600 root-owned file unreadable by the run_as_user agent), which was fixed for the per-spawn system-prompt file but not for the API socket. It is also the permission-side counterpart to #966: even after the socket path resolves correctly (agent's home == daemon data_dir, or CC_DATA_DIR/--data-dir supplied), the 0600 ownership still blocks the connection.
Note CC_DATA_DIR, CC_PROJECT, CC_SESSION_KEY are also dropped crossing the sudo -i boundary (not in DefaultEnvAllowlist, core/runas.go), so on a default data_dir the agent additionally resolves the wrong socket path via the home-dir fallback (cmd/cc-connect/send.go resolveSocketPath) — related to #966.
Steps to Reproduce
- Configure a claudecode project with
run_as_user = "someuser", cc-connect itself running as root. - Put
data_diron a path the target user can traverse (so path resolution is not the blocker — isolates the permission issue). - In an active agent session, have the agent run
cc-connect send --image /path/to/img.png(orcc-connect timer add …). - Observe the command fail to reach the socket:
Error: dial unix /home/<daemon-user>/.cc-connect/run/api.sock: connect: permission deniedExpected Behavior
When run_as_user is set, the agent (running as that user) should be able to connect to the daemon's API control socket, so the documented send / timer / cron back-channel commands work.
Related
- #1429 — sibling
run_as_userEACCES on the0600root-owned per-spawn system-prompt file (fixed for that file, not the socket). - #966 —
cc-connect sendsocket-path resolution under a customdata_dir(the path-side counterpart to this permission-side bug).
90% Claude
Source: chenhg5/cc-connect