feat: allow unknown fields in ssh2 configuration file (#181)

This commit is contained in:
Christian Visintin
2023-05-10 09:27:54 +02:00
committed by GitHub
parent 5a67fc7b0e
commit b4fa50a666
5 changed files with 17 additions and 12 deletions

View File

@@ -7,7 +7,7 @@ use std::path::PathBuf;
use remotefs::RemoteFs;
use remotefs_aws_s3::AwsS3Fs;
use remotefs_ftp::FtpFs;
use remotefs_ssh::{ScpFs, SftpFs, SshOpts};
use remotefs_ssh::{ScpFs, SftpFs, SshConfigParseRule, SshOpts};
use super::params::{AwsS3Params, GenericProtocolParams};
use super::{FileTransferProtocol, ProtocolParams};
@@ -110,7 +110,10 @@ impl Builder {
opts = opts.password(password);
}
if let Some(config_path) = config_client.get_ssh_config() {
opts = opts.config_file(PathBuf::from(config_path));
opts = opts.config_file(
PathBuf::from(config_path),
SshConfigParseRule::ALLOW_UNKNOWN_FIELDS,
);
}
opts
}

View File

@@ -7,7 +7,7 @@ use std::collections::HashMap;
use std::path::{Path, PathBuf};
// Ext
use remotefs_ssh::SshKeyStorage as SshKeyStorageTrait;
use remotefs_ssh::{SshConfigParseRule, SshKeyStorage as SshKeyStorageTrait};
use ssh2_config::SshConfig;
use super::config_client::ConfigClient;
@@ -43,7 +43,7 @@ impl SshKeyStorage {
.map_err(|e| format!("failed to open {path}: {e}"))
.map(BufReader::new)?;
SshConfig::default()
.parse(&mut reader)
.parse(&mut reader, SshConfigParseRule::ALLOW_UNKNOWN_FIELDS)
.map_err(|e| format!("Failed to parse ssh2 config: {e}"))
}