Skip to content

Fix config guards for unset secure_dir and shell_bin - #25

Merged
jackboberg merged 2 commits into
latestfrom
fix/hosts-setup-empty-secure-dir
Sep 15, 2026
Merged

jackboberg merged 2 commits into
latestfrom
fix/hosts-setup-empty-secure-dir

Conversation

@jackboberg

Copy link
Copy Markdown
Owner

Problem

Two functions in script/setup did not guard against empty config values before using them, leading to unexpected behavior when those values were unset:

  1. setup_hosts (line 141): When secure_dir was unset, config_get secure_dir "" returned empty string, making hosts_file resolve to /hosts. If that file existed on the system, sudo hostile load would load an unrelated system-level file.

  2. setup_shell (line 73): When shell_bin was unset, the empty value would fail the file existence check with a confusing error message ( does not exist!) before exiting.

Solution

Added early-return guards in both functions to check for empty config values before constructing paths or performing operations:

  • setup_hosts: Return with warning if secure_dir is empty
  • setup_shell: Return with warning if shell_bin is empty

This matches the pattern already used in setup_secure_files (line 44), which correctly guards with [ -n "$secure_dir" ] before use.

Changes

  • script/setup: Added empty-value guards to setup_hosts and setup_shell

Fixes #24

Guard against empty secure_dir before constructing hosts_file path.
Prevents loading /hosts if it exists on the system when secure_dir
is not configured.
Guard against empty shell_bin before checking if file exists.
Prevents confusing 'does not exist!' error message when shell_bin
is not configured.

Copilot AI 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.

🟢 Approval recommended

The reviewed changes address the identified unset-configuration cases with no unresolved blocking issues.

Pull request overview

Adds guards for unset shell_bin and secure_dir values in script/setup.

Changes:

  • Skip shell setup when shell_bin is empty.
  • Skip hosts setup when secure_dir is empty.
  • Validate secure_dir before constructing the hosts path.
File summaries
File Description
script/setup Adds configuration guards before shell and hosts setup operations.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jackboberg
jackboberg merged commit 3b880a6 into latest Sep 15, 2026
1 check passed
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.

setup_hosts loads /hosts when secure_dir is unset

2 participants