Skip to content

test(observer): slice 7d Linux LD_PRELOAD integration test (#551) - #568

Merged
zackees merged 1 commit into
mainfrom
hooks
Jun 22, 2026
Merged

zackees merged 1 commit into
mainfrom
hooks

Conversation

@zackees

@zackees zackees commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

Mirror of slice 7a (Windows) for Linux. Builds the slice 4 interposer cdylib on demand, writes a probe file in a tempdir, spawns `sh -c "cat probe.txt"` with LD_PRELOAD set via slice 6e's `inject_via_env`, captures stderr on a background thread, and asserts that a RPO_HOOK line appears containing the probe path.

Stronger assertion than Windows can make today

The Linux test asserts the specific probe path appears in a RPO_HOOK line — proving the detour fires on a real (non-diagnostic) file-open call. The Windows equivalent (slice 7a/7b) can only assert "some RPO_HOOK line fires" because cmd's `type` builtin doesn't appear to use `kernel32!CreateFileW`. Slice 7c will fix that with a Rust fixture binary that explicitly calls `CreateFileW`.

Verification (docker rust:1.85-slim)

```
$ docker run --rm -v "$PWD:/work" -w /work rust:1.85-slim sh -c
"cargo test -p running-process-observer --features embed-helper --test interposer_integration_linux"
running 1 test
test interposer_so_fires_rpo_hook_via_ld_preload ... ok
test result: ok. 1 passed; 0 failed; 0 ignored
```

Where this leaves #551

🤖 Generated with Claude Code

Mirror of slice 7a (Windows) but driven by LD_PRELOAD instead of
CreateRemoteThread. Linux doesn't need an injection vehicle: the
dynamic linker reads the env var at process startup and loads the
interposer .so before main(), so the slice 4 symbol shadows
(open/openat/close/write/unlink/rename) are in effect for every
libc call from the spawned process and its descendants.

Test scenario:
- Build the slice 4 interposer cdylib on demand via cargo.
- Write a probe file in a tempdir.
- Spawn `sh -c "cat probe.txt"` with LD_PRELOAD set to the
  interposer via slice 6e's inject_via_env().
- Capture child stderr on a background thread.
- Assert a RPO_HOOK line appears AND contains the probe path —
  stronger assertion than slice 7a/7b's Windows version (which
  can only assert "some RPO_HOOK fires", pending slice 7c's
  investigation of why cmd's `type` doesn't go through
  kernel32!CreateFileW).

Verified in docker rust:1.85-slim:
  test interposer_so_fires_rpo_hook_via_ld_preload ... ok
  test result: ok. 1 passed; 0 failed; 0 ignored.

Closes the Linux half of the slice 7 acceptance criterion.

Co-Authored-By: Claude Opus 4.7 (1M context) <[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