Skip to content

fix: HOME fallback for custom container user#88

Merged
anisaoshafi merged 2 commits intolocalstackfrom
drg-715
Mar 31, 2026
Merged

fix: HOME fallback for custom container user#88
anisaoshafi merged 2 commits intolocalstackfrom
drg-715

Conversation

@anisaoshafi
Copy link
Copy Markdown

@anisaoshafi anisaoshafi commented Mar 30, 2026

Context

When a container starts with --user=1000:1000, AddUser is never called so there is no /etc/passwd entry. Combined with UnsetLsEnvs stripping HOME, Node's os.homedir() and AWS SDK config loading throw ENOENT.

Changes

EnsureHome() runs once at startup after UnsetLsEnvs. If user.Current() fails (no passwd entry), it sets HOME=/tmp. The normal root-start flow is unaffected.

Testing

See test-homedir.md (will be removed) for a manual end-to-end test using a Node.js 22 function that calls os.homedir() with --user=1000:1000.

Towards DRG-715

@anisaoshafi anisaoshafi marked this pull request as ready for review March 31, 2026 14:03
Copy link
Copy Markdown
Member

@dfangl dfangl left a comment

Choose a reason for hiding this comment

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

I think this is a sensible workaround! Where possible, we should try to actually set the right user id and home directory (sbx_user1051), however in cases where we cannot influence the user, it makes sense to have this fallback.

@anisaoshafi anisaoshafi merged commit 3335deb into localstack Mar 31, 2026
3 of 4 checks passed
@anisaoshafi anisaoshafi deleted the drg-715 branch March 31, 2026 14:32
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