fix: use podman unshare to clean up rootless home directories#107
Conversation
In podman rootless mode, files created as root inside the container are owned by a mapped subuid on the host. When an agent is deleted, RemoveAllSafe() fails silently because the host user can't remove these files, leaving stale directories in ~/.scion/grove-configs/*/home/. Fall back to `podman unshare rm -rf` when standard removal fails. This enters the user namespace where the mapped UIDs are accessible, allowing cleanup without requiring sudo.
PR #107 Review: fix: use podman unshare to clean up rootless home directoriesExecutive SummaryThis PR makes two changes: (1) adds a Critical Issues1. Command Injection Risk via
|
|
@meatballs I'm happy to patch up minor found issues like this, or let you fix - your choice, just let me know |
Addresses review feedback on GoogleCloudPlatform#107: exec.Command(...).Run() blocks indefinitely if podman unshare hangs (e.g. waiting on a user namespace lock). Use exec.CommandContext with a 30s timeout so DeleteAgentFiles always returns.
|
Thanks for the review @ptone — pushed Re issues #2 and #3 (worktree prune in |
Addresses review feedback on GoogleCloudPlatform#107: exec.Command(...).Run() blocks indefinitely if podman unshare hangs (e.g. waiting on a user namespace lock). Use exec.CommandContext with a 30s timeout so DeleteAgentFiles always returns.
Summary
Fixes #105 — Agent deletion fails to clean up home directory in podman rootless mode.
In podman rootless mode, files created as root inside the container are owned by a mapped subuid on the host.
DeleteAgentFiles()callsRemoveAllSafe()on the external home directory, but this fails silently because the host user can't remove mapped-UID files.Fix: When
RemoveAllSafe()fails, fall back topodman unshare rm -rf <path>. This enters the user namespace where the mapped UIDs are accessible, allowing cleanup without sudo.This is the Podman equivalent of the
chown -Rpattern already used in the K8s runtime (pkg/runtime/k8s_runtime.go:302-308).Test plan
go build/go vetcleanpodman unsharefailure is non-fatal (graceful degradation if podman not available)