platformtest: replace logmockzfs with safety interposer#920
Draft
platformtest: replace logmockzfs with safety interposer#920
Conversation
…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]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
logmockzfswrapper with a Go-native multi-personality binary (busybox-style) that acts as a safety interposer forzfs/zpoolcommandsZpoolCreateArgs/Zpoolstructs-no-interposerflag for direct execution as root (symlinks to real binaries, no sudo)How it works
SetupInterposerPathcreates a temp directory with symlinks and replacesPATH: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
zfsorzpool(viaargv[0]), the binary validates that all commands reference the test poolzreplplatformtestbefore delegating throughsudo. Safety checks include:-a(all) flag without explicit pool reference-tis arg-taking forzfs, boolean forzpool)chmodTest plan
-no-interposerflag works when running as root🤖 Generated with Claude Code