Skip to content

Conversation

@aanderse
Copy link
Contributor

When a service is configured to run as a non-root user (@user), finit correctly drops privileges via setuid() and sets HOME and PATH, but does not set the USER and LOGNAME environment variables. They remain set to "root" from boot time.

This causes problems for software that determines its identity from the environment rather than getuid(). For example, rootless Podman checks os.Getenv("USER") first when looking up subordinate UID/GID ranges in /etc/subuid and /etc/subgid.

With USER=root but UID=1000, Podman looks up root's subuid entry instead of the actual user's, causing applications like newuidmap to fail. Setting USER and LOGNAME to match the actual user identity follows POSIX conventions and matches the behavior of su, sudo, and login.


https://github.com/containers/podman/blob/fd90d334a3a7a66fd4e07b3fe98a18378bbc55ed/pkg/rootless/rootless_linux.go#L168

When a service is configured to run as a non-root user (@user), finit
correctly drops privileges via setuid() and sets HOME and PATH, but
does not set the USER and LOGNAME environment variables. They remain
set to "root" from boot time.

This causes problems for software that determines its identity from
the environment rather than getuid(). For example, rootless Podman
checks os.Getenv("USER") first when looking up subordinate UID/GID
ranges in /etc/subuid and /etc/subgid.

With USER=root but UID=1000, Podman looks up root's subuid entry
instead of the actual user's, causing applications like newuidmap
to fail. Setting USER and LOGNAME to match the actual user identity
follows POSIX conventions and matches the behavior of su, sudo, and
login.
Copy link
Collaborator

@troglobit troglobit left a comment

Choose a reason for hiding this comment

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

Nice catch!

@troglobit troglobit merged commit bb111f9 into finit-project:master Jan 11, 2026
2 checks passed
@troglobit troglobit added this to the 4.16 milestone Jan 12, 2026
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.

2 participants