Skip to content

Containers: exec straight after start finds the image's users (#311) - #343

Merged
libracoder merged 1 commit into
libracoder:mainfrom
Dazzanova:fix/311-exec-after-start-user
Nov 16, 2026
Merged

libracoder merged 1 commit into
libracoder:mainfrom
Dazzanova:fix/311-exec-after-start-user

Conversation

@Dazzanova

@Dazzanova Dazzanova commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • A container start now waits until the child has finished its mounts and run pivot_root before reporting success.
  • This stops an immediate docker exec from joining the container's mount namespace while its root is still the agent's, where users from the image do not exist.

Root cause

container::spawn returned as soon as the child was cloned. Filling a fresh named volume from the image (copy-up) delayed pivot_root, widening the window where an exec read the host's /etc/passwd instead of the image's. Retrying a second later worked because the root was then in place.

Changes

  • Added a one-byte readiness pipe from the container child to the agent. The child writes after mounts, pivot_root and namespace setup; spawn waits for it before reporting Started.
  • If the child exits before signalling readiness, the existing failure path reports the child's own error.
  • Added regression coverage to tests/e2e.sh, tests/linux-host.sh and tests/wsl.sh: start containers with fresh named volumes and immediately exec as the image's non-root user.

Testing

  • cargo check -p kiri-init
  • cargo test -p kiri-init --bin kiri-init container::tests — 11 passed
  • bash -n tests/e2e.sh tests/linux-host.sh tests/wsl.sh

Fixes #311

@libracoder

Copy link
Copy Markdown
Owner

@Dazzanova thanks for this PR. Before it can be reviewed and merged, every commit needs to be signed. GitHub shows these as unsigned: 82a0a76. Please sign them (GPG or SSH, with the key added to your GitHub account as a signing key), then force-push. GitHub's guide: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

…oder#311)

A start now waits for the container child to make its mounts and run pivot_root before reporting success. An immediate exec could previously join the mount namespace while its root was still the agent's, so an image user was unknown, especially while a fresh volume was being copied up.

Fixes libracoder#311.
@Dazzanova
Dazzanova force-pushed the fix/311-exec-after-start-user branch from 82a0a76 to b91ff4b Compare November 16, 2026 17:18
@Dazzanova

Dazzanova commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Noted! I have signed with an SSH signing key, so please have a look at the PR and let me know if any change is required.

@libracoder
libracoder merged commit 3c3c321 into libracoder:main Nov 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux: immediate docker exec fails with unknown user after starting a container with a fresh named volume

2 participants