Skip to content

fix(obs-util): preserve configs when opening fails - #1944

Merged
zackees merged 2 commits into
obs-rust:masterfrom
ProtonDev-sys:fix/1942-config-open-read-failure
Oct 23, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
ProtonDev-sys:fix/1942-config-open-read-failure

Conversation

@ProtonDev-sys

@ProtonDev-sys ProtonDev-sys commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Opening an unreadable config with CONFIG_OPEN_ALWAYS preserves its contents and returns CONFIG_FILENOTFOUND, matching C. The Rust port previously retried a failed read using a write-only truncating create, so an unprivileged user opening a mode-0200 config lost all its bytes.

The fix opens first, retries only failed opens with C's read/write/create/truncate access, and reads that same handle. A read error after a successful open keeps C's empty successful parse, including config_open_defaults. BOM handling is preserved without an extra copy. Production diff: 19 added / 22 removed lines, net -3, in one Rust file. The feature ledger is updated.

Fixes #1942.

Validation on DESKTOP-3FLAOFG Ubuntu/WSL as dev, uid 1000, with PATH=/home/dev/.local/bin:/home/dev/.soldr/bin/llvm-21.1.5-r2/bin:$PATH, SOLDR_RUSTC_WRAPPER=none, and CARGO_BUILD_JOBS=3:

  • RED 8d4118d: soldr cargo test -p obs-util --lib tests::config::config_file -- --nocapture — 68 passed, 4 failed. Separate known-byte mode-0200 files: C returned -1 and retained all 18 bytes; Rust returned 0 and retained zero bytes. Successful directory opens followed by read failure also exposed Rust -1 versus C 0.
  • GREEN f46617c: soldr cargo test -p obs-util --locked — 832 passed, 0 failed; 2 doctests passed. Includes safe-core and C-ABI/oracle regressions for byte preservation, both open modes, null output handles on failure, and defaults after read failure.
  • soldr cargo clippy -p obs-util --all-targets --locked -- -D warnings — passed.
  • soldr cargo fmt --all --check and git diff --check — passed.
  • uv run ci/test_binary_cap.py --report — eight category binaries, no new executable.

Tier 1 and Tier 3 ran locally. Existing C tests and public headers are unchanged; Tier 2 runs in PR CI (Docker/bosn are not installed on this Linux host). Tier 4 does not apply to the local config-file API. No intentional difference from C is introduced. Permission assertions report a skip only when run by a privileged user who can read mode-0200 files; they executed as unprivileged dev in the recorded runs.

The other PC became read-only after validation, so the tested GREEN changes were committed and pushed from the isolated Windows checkout using its existing Git credentials. The parent remote checkout was not changed.

Ready for review; PR CI/review results remain pending. This worker will not merge or monitor the PR.

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Coordinator review: matches C config_open with CONFIG_OPEN_ALWAYS. A failed open retries with w+ semantics (read+write+create+truncate), so a write-only (0200) file fails the retry and keeps its bytes, returning CONFIG_FILENOTFOUND. A read error after a successful open gives an empty successful parse, as in C. Tier 1 and parity tests and the ledger line are included. LGTM.

@zackees
zackees added this pull request to the merge queue Oct 23, 2026
Merged via the queue into obs-rust:master with commit 0905cee Oct 23, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: obs-util: CONFIG_OPEN_ALWAYS truncates unreadable configs

2 participants