Skip to content

fix: validate NANO_DRIVE after sourcing /etc/nanobsd.conf#59

Open
jailedengineer wants to merge 1 commit into
ocochard:masterfrom
jailedengineer:fix/upgrade-defensive-source
Open

fix: validate NANO_DRIVE after sourcing /etc/nanobsd.conf#59
jailedengineer wants to merge 1 commit into
ocochard:masterfrom
jailedengineer:fix/upgrade-defensive-source

Conversation

@jailedengineer
Copy link
Copy Markdown
Contributor

The upgrade script sources /etc/nanobsd.conf and immediately uses NANO_DRIVE without checking it was actually set. A corrupt, truncated or empty config file would leave NANO_DRIVE unset, tripping set -u later in the script with a less informative error.

Applies the same defensive pattern used in tenant's get_next_id() for sourcing legacy /etc/jail.lastid: use ${var:-} fallback when checking, fail early with a clear error message.

Low practical risk on a healthy system since /etc/nanobsd.conf is generated by the build process, but defensive enough to catch the case where the file was tampered with or partially written during recovery operations.

The upgrade script sources /etc/nanobsd.conf and immediately uses
NANO_DRIVE without checking it was actually set. A corrupt, truncated
or empty config file would leave NANO_DRIVE unset, tripping set -u
later in the script with a less informative error.

Applies the same defensive pattern used in tenant's get_next_id() for
sourcing legacy /etc/jail.lastid: use ${var:-} fallback when checking,
fail early with a clear error message.

Low practical risk on a healthy system since /etc/nanobsd.conf is
generated by the build process, but defensive enough to catch the
case where the file was tampered with or partially written during
recovery operations.
@ocochard
Copy link
Copy Markdown
Owner

But the "set -u" should catches those already:

  ./test_setu.sh: NANO_DRIVE: parameter not set

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