Skip to content

fixed home dir resolution for $HOME less envs#671

Closed
zackbradys wants to merge 2 commits into
mainfrom
fix-fun-homedir-bug
Closed

fixed home dir resolution for $HOME less envs#671
zackbradys wants to merge 2 commits into
mainfrom
fix-fun-homedir-bug

Conversation

@zackbradys

@zackbradys zackbradys commented Jul 17, 2026

Copy link
Copy Markdown
Member

Please check below, if the PR fulfills these requirements:

  • Commit(s) and code follow the repositories guidelines.
  • Test(s) have been added or updated to support these change(s).
  • Doc(s) have been added or updated to support these change(s).

Associated Links:

Types of Changes:

  • Bugfix

Proposed Changes:

  • Normalize $HOME at the start of every command (PersistentPreRunE) instead of assuming it's there
  • Environments like cloud-init runcmd, systemd services, and cron invoke hauler without a login shell, which leaves $HOME empty, and silently breaks credential lookup in ~/.docker/config.json
  • Resolution tries user.Current() first, then falls back to os.UserHomeDir() if that fails, logging a WARN only if both come up empty... this restores and extends the fallback behavior that getCosignPath() used to have before it was replaced during the overhaul and rewrite for v2.0.1...
  • Stop collapsing every credential-resolution failure in the registry auth bridge (pkg/content/registry.go) to a silent "anonymous" fallback... now we have a real resolution error such as unreadable config, corrupt JSON, missing $HOME and it now propagates instead of being random indistinguishable error messages

Verification/Testing of Changes:

Before the fix... NO $HOME set...

kiternetes01:/home/rancher # env -i PATH="$PATH" /usr/local/bin/hauler store copy --store /var/lib/harvester/defaultdisk/hauler/store/ registry://registry.kiternetes.kit
2026-07-17 18:24:56 INF edge/3.6/mariadb@sha256:4657b14c43d3a720c50fc1c484a36865fa5acc53edf560a6d597c0b8bec42c9d
2026-07-17 18:24:56 ERR error (attempt 1/3)... failed to copy config: push access denied, repository does not exist or may require authorization: authorization failed: no basic auth credentials
2026-07-17 18:25:01 ERR error (attempt 2/3)... failed to copy config: push access denied, repository does not exist or may require authorization: authorization failed: no basic auth credentials

Before the fix... $HOME set...

kiternetes01:/home/rancher # env -i HOME=/root PATH="$PATH" /usr/local/bin/hauler store copy --store /var/lib/harvester/defaultdisk/hauler/store/ registry://registry.kiternetes.
kit
2026-07-17 18:25:22 INF ranchergovernment/harvester-appliance-xfce:v1.7.2
2026-07-17 18:25:25 INF registry.kiternetes.kit/ranchergovernment/harvester-appliance-xfce:v1.7.2: digest: sha256:716f2b1c6d56904e0eafb6640c8fd5e3389f554e9402316f004edee030b61fb1 size: 864
2026-07-17 18:25:25 INF containers/nginx@sha256:02b935594b7aea4a7ffd1b701d4dfa8fff13af13152b5864f23129dd2a227a18
2026-07-17 18:25:26 INF registry.kiternetes.kit/containers/nginx@sha256:02b935594b7aea4a7ffd1b701d4dfa8fff13af13152b5864f23129dd2a227a18: digest: sha256:02b935594b7aea4a7ffd1b701d4dfa8fff13af13152b5864f23129dd2a227a18 size: 1622
2026-07-17 18:25:26 INF containers/postgresql:sha256-1f182741c1fef987502c2a18346b4db24be74d32e449a9141fb448f3e95ba2c7.att

After the fix... NO $HOME set...

TBD

After the fix... $HOME set...

TBD

Additional Context:

A short story from our friend claude...

Start by giving hauler a $HOME-less environment and it doesn't error, it doesn't warn, it doesn't blink.

Hauler takes over the wheel and silently decides you're anonymous.

Hauler lets you find out via a "no basic auth credentials" error that reads exactly like a server side auth bug and issue.

For THREE whole days... a line by line reading of a 3000 line script, multiple failed automation workflows, a JWT autopsy, and a CVE deep-dive...

Just for you to find out there is a bug fixable with one line... "export HOME=/root"...

@github-project-automation github-project-automation Bot moved this to To Triage in Hauler Jul 17, 2026
@zackbradys zackbradys self-assigned this Jul 17, 2026
@zackbradys zackbradys added bug Something isn't working size/S Denotes an issue/PR requiring a relatively small amount of work go Pull requests that update go code labels Jul 17, 2026
@zackbradys zackbradys moved this from To Triage to Testing in Hauler Jul 17, 2026
@zackbradys zackbradys added this to the Hauler v2.0-next1 milestone Jul 17, 2026
@zackbradys

Copy link
Copy Markdown
Member Author

Closing in favor of #672...

@zackbradys zackbradys closed this Jul 21, 2026
@github-project-automation github-project-automation Bot moved this from Testing to Resolved in Hauler Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code size/S Denotes an issue/PR requiring a relatively small amount of work

Projects

Status: Resolved

Development

Successfully merging this pull request may close these issues.

1 participant