Skip to content

Conversation

@ccxcz
Copy link

@ccxcz ccxcz commented Jul 26, 2025

Remove closefrom() call which breaks user-provided command when it relies on inherited file descriptors.
This is a regression introduced in commit 66e9868 which introduces closefrom() call closing all file descriptors above stderr (or open socket) which breaks file descriptor inheritance for any processes spawned by ssh-agent, is undocumented behavior, is mismatched from how upstream ssh-agent behaves and has no benefit.

ssh-agent allows specifying arbitrary commands to be run:

  1. immediately, conventionally for user session to which the lifetime of ssh-agent is tied to
  2. for prompting for passphrases and confirmations using the ssh-askpass protocol

Either of those can rely on pre-opened file descriptors as a means of communication or access control, especially in restricted environments (pledge, capsicum, seccomp-based sandboxes) where arbitrary open() and connect() are not available.
When running user-provided commands it's best practice to change the inherited process state as little as possible.

Remove closefrom() call which breaks user-provided command when it
relies on inherited file descriptors.
Fixes https://bugzilla.mindrot.org/show_bug.cgi?id=3835
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