Skip to content

output: support FIFO destinations for text, keylog and pcapng - #1102

Merged
cfc4n merged 1 commit into
masterfrom
bugfix/fifo-output-support
Nov 27, 2026
Merged

cfc4n merged 1 commit into
masterfrom
bugfix/fifo-output-support

Conversation

@cfc4n

@cfc4n cfc4n commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

FIFO keylog output in #1100 reached fsync and failed with EINVAL; current destination validation rejects FIFOs entirely. This change accepts pre-created FIFOs for --output, --keylogfile and --pcapfile using the existing shared writer.

  • Preserve v2 JSON Lines for --output, raw NSS for --keylogfile, and raw pcapng for --pcapfile.
  • Require a reader before capture starts, bound FIFO writes/flushes to five seconds, and retain the first error through close. FIFO flush drains buffered bytes without fsync; regular-file synchronization is unchanged.
  • Preserve destination alias checks and reject FIFO rotation. Document EOF handling across native capture reloads; automatic reconnection is not added.
  • Add unit coverage and maintained OpenSSL FIFO E2E cases without changing probe code, event layouts or pcapng encoding.

Validation on Linux ARM64:

  • Clean make all with CO-RE and non-CO-RE assets.
  • Full go test -race -tags=ebpfassets,dynamic ./... and production-tag golangci-lint: passed, zero lint issues.
  • Shell syntax and ShellCheck: passed.
  • Full OpenSSL E2E: 30/30 passed, including all three FIFO modes.
  • Final FIFO cases: 3/3 passed; keylog and pcapng independently decrypt both TLS 1.2 and TLS 1.3, and text uses the SDK's live pcapng-decoded output.
  • Nine additional real CLI checks passed: no reader, reader disconnect and stalled reader for each mode all exit nonzero.

Runtime validation used CO-RE on Linux ARM64. Android, x86_64 and non-CO-RE runtime capture were not tested.

Fixes #1100.


Devin Review

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
Copilot AI balanced review requested due to automatic review settings November 27, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@github-actions

Copy link
Copy Markdown

🔧 Debug Build Complete (PR #1102)

📦 Direct Download Links (GitHub login required):

Each link downloads a single .tar.gz package; extract it once to get the executable.

⏰ 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.

@cfc4n
cfc4n merged commit ad6e592 into master Nov 27, 2026
15 of 18 checks passed
@cfc4n
cfc4n deleted the bugfix/fifo-output-support branch November 27, 2026 14:57
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.

Invalid argument error caused by keylog handler when using FIFO output and TLS 1.2

2 participants