pub trait ExecStreamHandler: Send + Sync {
// Required methods
fn claims(&self, command: &str) -> bool;
fn run(
&self,
user: &str,
env: &SessionEnv,
command: &str,
stream: ChannelStream,
) -> Result<()>;
}Expand description
Server-side hook called when a client sends an "exec" channel request,
before the synchronous CommandHandler runs. Lets a stream-mode
handler (SCP, custom RPC) claim the channel and drive it as a real
bidirectional pipe rather than the buffer-and-return shape of
CommandHandler::handle.
The dispatcher consults the overlay in two phases:
claimsis called synchronously in the connection thread with just the command string. Returntrueto claim the request — the dispatcher then sendsrequest_success, registers a per-channel runtime, and hands off torun.runexecutes on a dedicated thread per claimed channel, with a liveChannelStreamit canRead/Writeuntil the transaction finishes. Dropping the stream emitsEOF+Closeto the peer.
Both hooks run in the per-connection process after the
Config::on_session_open drop-to-user has already happened, so
handlers see the authenticated user’s filesystem permissions.
Required Methods§
Sourcefn claims(&self, command: &str) -> bool
fn claims(&self, command: &str) -> bool
Cheap synchronous decision based on the command string only.
Return true to claim; false to fall through to the buffered
CommandHandler.
Sourcefn run(
&self,
user: &str,
env: &SessionEnv,
command: &str,
stream: ChannelStream,
) -> Result<()>
fn run( &self, user: &str, env: &SessionEnv, command: &str, stream: ChannelStream, ) -> Result<()>
Execute the claimed command on a dedicated thread. The handler
owns stream until it returns; on return the stream drops,
emitting EOF+Close automatically. env is a snapshot of the
session-level environment at the time of the claim.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".