Skip to content

sysroot bypass hardcoded /etc/passwd and /etc/group intercepts#215

Merged
jserv merged 1 commit into
sysprog21:mainfrom
open-sources-port:etc-passwd
Jul 18, 2026
Merged

sysroot bypass hardcoded /etc/passwd and /etc/group intercepts#215
jserv merged 1 commit into
sysprog21:mainfrom
open-sources-port:etc-passwd

Conversation

@doanbaotrung

@doanbaotrung doanbaotrung commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

When a custom guest sysroot is configured, hardcoded intercepts on /etc/passwd and /etc/group shadow the actual files in the guest rootfs. This prevents guest processes from resolving users and groups that were added during package provisioning.

We now check if a sysroot is active in path_might_use_open_intercept() and bypass the synthetic intercepts in that case, allowing the guest to read the actual user/group database from its rootfs.

Fix #188


Summary by cubic

Prefer the guest sysroot’s /etc/passwd and /etc/group over synthetic intercepts when those files exist; otherwise fall back to intercepts. Fixes #188.

  • Bug Fixes
    • Updated path_might_use_open_intercept to check the active sysroot via proc_sysroot_snapshot and stat the target; bypass intercept only if the sysroot file exists.
    • Extended tests to assert /etc/passwd in the sysroot wins and /etc/group falls back when absent; test setup now creates sysroot/etc/passwd.

Written for commit f1fd55d. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

@jserv
jserv requested a review from Max042004 July 17, 2026 05:34
Comment thread src/syscall/path.c
!strcmp(path, "/etc/group"))
if (!strcmp(path, "/etc/mtab"))
return true;
if (!strcmp(path, "/etc/passwd") || !strcmp(path, "/etc/group")) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path_might_use_open_intercept() only checks that a sysroot is configured
(proc_sysroot_snapshot()), not that the sysroot actually contains
/etc/passwd / /etc/group. When it doesn't, the request falls through to
proc_resolve_sysroot_path_flags()'s host-literal fallback, which resolves
the literal host path — on macOS that's the real /etc/passwd /
/etc/group on the machine running elfuse.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix Details

  1. Added Existence Checks: Updated path_might_use_open_intercept in path.c to perform a stat existence check on the guest sysroot-resolved files (${sysroot}/etc/passwd / ${sysroot}/etc/group). The synthetic intercept is bypassed only when the file is present in the sysroot.
  2. Updated Test Harness: Modified tests.mk to only stage passwd in the fallback test's guest sysroot, leaving group absent.
  3. Added Assertions: Updated test-sysroot-host-fallback.c to verify that the absent guest group file falls back to the synthetic group intercept instead of resolving to the host machine's /etc/group.

When a custom guest sysroot is configured, hardcoded intercepts on
/etc/passwd and /etc/group shadow the actual files in the guest rootfs.
This prevents guest processes from resolving users and groups that
were added during package provisioning.

We now check if a sysroot is active in path_might_use_open_intercept()
and bypass the synthetic intercepts in that case, allowing the guest
to read the actual user/group database from its rootfs.

Fix sysprog21#188
@jserv
jserv merged commit f9e601b into sysprog21:main Jul 18, 2026
10 checks passed
@doanbaotrung
doanbaotrung deleted the etc-passwd branch July 18, 2026 17:14
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.

Hardcoded /etc/passwd and /etc/group intercepts break guest name resolution

3 participants