Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ pub struct SshOpts {
parse_rules: ParseRule,
/// Ssh agent configuration for authentication
ssh_agent_identity: Option<SshAgentIdentity>,
/// do not use any shell command when doing SCP operations
/// to make sure to be compatible with non unix systems
pure_scp: bool,
}

impl SshOpts {
Expand All @@ -125,6 +128,7 @@ impl SshOpts {
methods: Vec::default(),
parse_rules: ParseRule::STRICT,
ssh_agent_identity: None,
pure_scp: false,
}
}

Expand Down Expand Up @@ -166,6 +170,13 @@ impl SshOpts {
self
}

/// do not use any shell command when doing SCP operations
/// to make sure to be compatible with non unix systems
pub fn pure_scp(mut self, pure_scp: bool) -> Self {
self.pure_scp = pure_scp;
self
}

/// Set SSH configuration file to read
///
/// The supported options are:
Expand Down
20 changes: 12 additions & 8 deletions src/ssh/scp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,13 @@ where
"Connection established: {}",
banner.as_deref().unwrap_or("")
);
// Get working directory
debug!("Getting working directory...");
self.wrkdir = session
.cmd("pwd")
.map(|(_rc, output)| PathBuf::from(output.as_str().trim()))?;
if !self.opts.pure_scp {
// Get working directory
debug!("Getting working directory...");
self.wrkdir = session
.cmd("pwd")
.map(|(_rc, output)| PathBuf::from(output.as_str().trim()))?;
}
// Set session
self.session = Some(session);
info!(
Expand Down Expand Up @@ -667,9 +669,11 @@ where
self.check_connection()?;
let path = path_utils::absolutize(self.wrkdir.as_path(), path);
debug!("Opening file {} for read", path.display());
// check if file exists
if !self.exists(path.as_path()).ok().unwrap_or(false) {
return Err(RemoteError::new(RemoteErrorType::NoSuchFileOrDirectory));
if !self.opts.pure_scp {
// check if file exists
if !self.exists(path.as_path()).ok().unwrap_or(false) {
return Err(RemoteError::new(RemoteErrorType::NoSuchFileOrDirectory));
}
}
trace!("blocked channel");
match self.session.as_mut().unwrap().scp_recv(path.as_path()) {
Expand Down