host ensure fails with EACCES for a second OS user: senpi-rpc-host-locks is shared across users

Open Beginner friendly
#6,738 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript
Domain
backend, cli

Research direction

Start in the modes/rpc host lifecycle code where the lock path is built with join(tmpdir(), "senpi-rpc-host-locks", createSocketLockName(socket)); that is the only place the path is derived. Decide the per-user root first: $XDG_RUNTIME_DIR when set, otherwise <tmpdir>/senpi-rpc-host-locks-<uid>, created 0700 with an ownership/stat check before reuse. Find the existing tests around the host-ensure path and add a case with two distinct lock roots, or one root plus a foreign-owner check. Done means a second OS user's host ensure succeeds while the first user's directory exists, and no foreign-owned directory is written to.

Written by the indexing model from the issue text.

Description

Summary

senpi host ensure puts its socket lock at join(os.tmpdir(), "senpi-rpc-host-locks", <socket lock name>). The directory is shared by every OS user on the machine. The first user creates it with mode 0700, so every other user's host ensure (and omo daemon run on top of it) fails with EACCES and no host starts.

Reproduction

  1. On one Linux machine, user A runs omo daemon run (any build that ensures a host). /tmp/senpi-rpc-host-locks is created, owned by A, mode drwx------.
  2. User B, with its own HOME and agent dir and TMPDIR unset, runs omo daemon run --json.

Expected

Each OS user gets its own lock directory, so B's host starts. For example, put it under $XDG_RUNTIME_DIR when that is set, else a per-uid directory such as <tmpdir>/senpi-rpc-host-locks-<uid>, created 0700 and checked for ownership before use.

Actual

{"action":"error","reason":"host_error","detail":"EACCES: permission denied, open '/tmp/senpi-rpc-host-locks/<hash>'"}

ls -ld /tmp/senpi-rpc-host-locks → drwx------ <user A> <user A>.

It shows up wherever a second account runs omo on the same machine: a service account, a test user, or a second person on a shared box. A systemd --user unit for user B fails on every start and restarts forever.

Workaround

Give user B its own TMPDIR; for a systemd user unit, systemctl --user set-environment TMPDIR=<dir> before the unit starts. With that, B's host starts normally.

Root cause

The lock path is built from tmpdir() only (modes/rpc host lifecycle: join(tmpdir(), "senpi-rpc-host-locks", createSocketLockName(socket))), with no per-user part.

Acceptance

  • The lock directory is per OS user, and a second user's host ensure succeeds while another user's lock directory exists.
  • An existing directory owned by another user is never written to or trusted.
  • A test with two lock roots, or one root plus an ownership check.

Related

  • #2754 (lock files in the same directory are never removed): the same directory, a different defect.
Dominant language
TypeScript
Stars
517
Forks
163
Avg merge
23h 31m
Merged PRs (30d)
700

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from code-yeongyu/senpi

All issues in code-yeongyu/senpi

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.