Skip to content

fix: apply kukeon socket ownership in kuke daemon recreate - #1341

Merged
eminwux merged 1 commit into
mainfrom
fix/recreate-socket-ownership
Jun 17, 2026
Merged

fix: apply kukeon socket ownership in kuke daemon recreate#1341
eminwux merged 1 commit into
mainfrom
fix/recreate-socket-ownership

Conversation

@eminwux

@eminwux eminwux commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

kuke daemon recreate left /run/kukeon/kukeond.sock as 0600 root:root, so a non-root member of the kukeon group had to sudo to reach the daemon after a recreate β€” unlike kuke init, which leaves it 0660 root:kukeon. Reproduced on an upgrade-recreate (v0.7.1 daemon β†’ v0.9.0 binaries β†’ kuke daemon recreate).

Root cause β€” recreate skipped both things kuke init does to make the socket group-accessible:

  1. Provision with the wrong GID. resolveProvisionKukeondCell hardcoded KukeondSocketGID: 0 (recreate.go). With GID 0, bootstrap.go:472's if socketGID > 0 gate omits --socket-gid from the kukeond cell's persisted args, so kukeond serve defaults to socketModeRootOnly (0o600) and never chowns to the group. kuke init passes ensure.GID (init.go:562).
  2. No host-side re-assert. recreate never ran the post-ready sysuser.ChownAndChmod(socket, 0, gid, 0o660) that init.go:604 runs after the daemon binds the listener. This is the authoritative correction (the daemon resets ownership on every start).

Fix

  • recreate.go: resolve the kukeon GID (via new lifecycle.LookupKukeonGID) and pass it as KukeondSocketGID; add a post-ready resolveApplySocketOwnership step (test-seamed via MockApplySocketOwnershipKey) that re-asserts root:kukeon 0o660, mirroring init. Prints a kukeond socket …: chown root:kukeon mode 0660 notice.
  • consts.go: new KukeonSocketMode = 0o660 as the single source of truth; init.go's local kukeonSocketMode now references it so init and recreate can't drift again (this drift is the bug).
  • lifecycle/socketdir.go: extract the existing inline kukeon-GID lookup into an exported LookupKukeonGID reused by both the run-dir ownership step and recreate.

Scope note (verified)

kuke daemon start/restart are not affected: they re-launch the existing kukeond cell via StartCell, whose persisted container args already carry --socket-gid (baked in at bootstrap.go:472 during the original init), so the daemon re-binds 0660 and chowns to the group itself. Only recreate re-provisions the cell from scratch and was dropping the GID. No host-side re-chown was added to start/restart.

Test plan

  • make test (full CI suite, GOWORK=off) β€” exit 0
  • GOWORK=off go build ./... β€” exit 0 (note: a bare go build ./... fails on a pre-existing third-party containerd/cgroups/v2 break; go.work documents that builds/tests must run GOWORK=off, which make and CI do)
  • GOWORK=off go vet on touched packages β€” exit 0
  • New unit tests: TestDaemonRecreate_AppliesSocketOwnership (ownership step invoked + chown notice printed) and TestDaemonRecreate_SocketOwnershipFailureIsWrapped (error propagation)
  • End-to-end kuke daemon recreate on a real host verifying stat -c '%U:%G %a' /run/kukeon/kukeond.sock β†’ root:kukeon 660 β€” not run; the dev host has no initialized kukeon runtime to recreate. Recommend the reviewer confirm on a clean host.

@eminwux eminwux added ready-for-review PR is handed off to the reviewer agent in-review Reviewer agent is actively reading this PR and removed ready-for-review PR is handed off to the reviewer agent labels Jun 17, 2026
@eminwux

eminwux commented Jun 17, 2026

Copy link
Copy Markdown
Owner Author

PR #1341 Review β€” fix: apply kukeon socket ownership in kuke daemon recreate

LGTM β€” kuke daemon recreate now mirrors kuke init's socket-ownership path exactly: it resolves the kukeon GID and threads it into KukeondSocketGID (so bootstrap.go's if socketGID > 0 gate emits --socket-gid), then re-asserts root:kukeon 0o660 post-ready via resolveApplySocketOwnership β€” both halves the recreate path was previously dropping. The new consts.KukeonSocketMode collapses the init/recreate mode into one source of truth (the drift that caused the bug), and LookupKukeonGID is a clean extraction reused by both call sites with no duplicate inline lookups left behind. Errors wrapped with %w, no leaks, two new unit tests cover the ownership step + error propagation, CI all green.

Non-blocking, for you to run pre-merge: the one unchecked test-plan item is the documented host-gated e2e β€” kuke daemon recreate on a real initialized host, then stat -c '%U:%G %a' /run/kukeon/kukeond.sock β†’ root:kukeon 660. The author flagged the dev host can't run it; the unit tests prove the wiring but not the on-host chown.

@eminwux eminwux added ready-to-merge Reviewed and ready to merge and removed in-review Reviewer agent is actively reading this PR labels Jun 17, 2026
@eminwux
eminwux merged commit f3e56dc into main Jun 17, 2026
5 checks passed
@eminwux
eminwux deleted the fix/recreate-socket-ownership branch June 17, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Reviewed and ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant