Repository navigation
output: support FIFO destinations for text, keylog and pcapng - #1102
Conversation
Allow local consumers to receive capture output without intermediate regular files. Accept pre-created FIFOs while preserving JSON Lines, NSS keylog and pcapng formats through the existing shared writer. Open FIFOs without blocking, bound writes and flushes to five seconds, and retain the first failure through close. Skip fsync only for FIFOs, keeping regular-file durability and destination alias checks intact. Add unit and strict TLS E2E coverage and document reader startup and reload requirements. Fixes #1100
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| flags := os.O_CREATE | os.O_WRONLY | ||
| // Nonblocking open fails promptly when a FIFO has no reader and lets Go's | ||
| // poller enforce write deadlines. It does not change regular-file I/O. | ||
| flags := os.O_CREATE | os.O_WRONLY | unix.O_NONBLOCK |
There was a problem hiding this comment.
🔴 User-owned /tmp FIFOs block capture
For a user-created FIFO in /tmp, NewFileWriter passes O_CREATE even when eCapture runs via sudo. With fs.protected_fifos enabled, Linux rejects the open when neither the caller nor the directory owner owns the FIFO. Capture fails to start even with a reader connected.
Learn more
Linux’s fs.protected_fifos check applies to opens that include O_CREAT, even when the FIFO already exists and the caller is root. The check covers sticky world-writable directories at setting 1 and also sticky group-writable directories at setting 2. Both CreateJSONSink and CreateEventSink reach the shared file writer. Their validation accepts a FIFO, but startup fails when the open returns EACCES.
Example: Alice creates a mode-0600 FIFO in root-owned /tmp, starts a reader, and runs eCapture via sudo with that path as --keylogfile. With fs.protected_fifos=1, the writer cannot open the FIFO despite the connected reader.
Recommended fix: Open existing FIFO destinations with O_WRONLY|O_NONBLOCK, without O_CREATE or O_TRUNC. Preserve the existing creation, append, and truncation behavior for regular files, and verify the type of the opened FIFO handle before use. Add a cross-owner regression test for a sticky directory with FIFO protection enabled.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
🔧 Debug Build Complete (PR #1102) 📦 Direct Download Links (GitHub login required):
Each link downloads a single ⏰ Files will be retained for 7 days, please download and test promptly. Build targets: Linux (amd64/arm64/loong64) and Android (amd64/arm64). Available packages are listed above. |
FIFO keylog output in #1100 reached
fsyncand failed withEINVAL; current destination validation rejects FIFOs entirely. This change accepts pre-created FIFOs for--output,--keylogfileand--pcapfileusing the existing shared writer.--output, raw NSS for--keylogfile, and raw pcapng for--pcapfile.fsync; regular-file synchronization is unchanged.Validation on Linux ARM64:
make allwith CO-RE and non-CO-RE assets.go test -race -tags=ebpfassets,dynamic ./...and production-tag golangci-lint: passed, zero lint issues.Runtime validation used CO-RE on Linux ARM64. Android, x86_64 and non-CO-RE runtime capture were not tested.
Fixes #1100.