Skip to content

Support dynamic guest identity (UID/GID) configuration via environment variables #103

Description

@doanbaotrung

Problem Description

Currently, elfuse hardcodes the guest environment's simulated user identity (UID and GID) to a static non-root user (e.g., 1000 / 1000).

This hardcoded configuration prevents running package managers (like pacman, apt, apk, or dnf) or other system administration utilities inside the simulated guest. When executed, these applications perform internal root checks (expecting UID 0) and immediately abort with errors such as:

error: you cannot perform this operation unless you are root.

To run these tools successfully, the guest environment needs to simulate a root user identity (UID 0, GID 0) dynamically.


Proposed Solution

Allow users to dynamically configure the simulated guest UID and GID at runtime via environment variables, for example: ELFUSE_GUEST_UID and ELFUSE_GUEST_GID.

If these variables are present in the host process environment, elfuse should parse them and override the default guest UID/GID.

Override parsed UID/GID at startup (src/syscall/proc-identity.c)
In proc_identity_init(), check the host environment for ELFUSE_GUEST_UID and ELFUSE_GUEST_GID. If defined, parse them (using strtoul) and override the default values of emu_uid and emu_gid instead of falling back to the hardcoded constants.

Propagate dynamic identity to the guest process stack (src/core/stack.c)
In build_linux_stack(), the auxiliary vectors (AT_UID, AT_EUID, AT_GID, AT_EGID) are currently populated with hardcoded macros (e.g., GUEST_UID and GUEST_GID).
These should be replaced with calls to dynamic lookup helpers (such as proc_get_uid(), proc_get_euid(), etc.) so that the guest dynamic linker and standard library (glibc/musl) correctly read the dynamically configured simulated identity.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions