Skip to content

platformtest: replace logmockzfs with safety interposer#920

Draft
problame wants to merge 3 commits intomasterfrom
platformtest-simplify
Draft

platformtest: replace logmockzfs with safety interposer#920
problame wants to merge 3 commits intomasterfrom
platformtest-simplify

Conversation

@problame
Copy link
Copy Markdown
Member

@problame problame commented Feb 10, 2026

Summary

  • Replace shell-script-based logmockzfs wrapper with a Go-native multi-personality binary (busybox-style) that acts as a safety interposer for zfs/zpool commands
  • Hardcode pool name, image path, and mountpoint as constants; remove CLI flags and ZpoolCreateArgs/Zpool structs
  • Add -no-interposer flag for direct execution as root (symlinks to real binaries, no sudo)

How it works

SetupInterposerPath creates a temp directory with symlinks and replaces PATH:

  • zfs/zpool → the platformtest binary itself (interposer mode)
  • zfs.real/zpool.real → actual binaries (for delegation via sudo)
  • sudo/bash → real binaries (so they remain accessible)

When invoked as zfs or zpool (via argv[0]), the binary validates that all commands reference the test pool zreplplatformtest before delegating through sudo. Safety checks include:

  • Pool name validation on all non-flag arguments
  • Blocking -a (all) flag without explicit pool reference
  • Command-aware flag parsing (-t is arg-taking for zfs, boolean for zpool)
  • Mountpoint path traversal protection on post-create chmod

Test plan

  • 49/54 platform tests pass (same as before)
  • 4 failures are pre-existing ZFS error message format incompatibilities, not interposer bugs
  • 1 test skipped (encryption-related, expected)
  • Verify -no-interposer flag works when running as root

🤖 Generated with Claude Code

problame and others added 3 commits February 10, 2026 19:56
…oser

Replace the shell-script-based logmockzfs wrapper with a Go-native
multi-personality binary (busybox-style). The platformtest binary now
acts as a safety interposer for zfs/zpool when invoked via symlinks,
validating that all commands reference the hardcoded test pool before
delegating through sudo.

Key changes:
- New interposer.go: SetupInterposerPath creates a tmpdir with symlinks
  and replaces PATH; RunInterposer validates args and delegates via sudo
- Pool name, image path, and mountpoint are now hardcoded constants
- Remove ZpoolCreateArgs, Zpool struct, and CLI flags for pool config
- Remove logmockzfs/ shell scripts (logzfsenv, zfs wrapper)
- Simplify Makefile: no more logmockzfs invocation or root check
- Add -no-interposer flag for direct execution as root
- Safety: block -a (all) flags without pool reference, validate
  mountpoint paths against traversal, command-aware flag parsing

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

1 participant