Skip to content

Commit

Permalink
fix ssh-cfg propagation to cfg file
Browse files Browse the repository at this point in the history
  • Loading branch information
bertiqwerty committed Nov 12, 2024
1 parent 9a9b748 commit ec00d34
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions rvimage/src/rvlib/control/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,10 @@ impl Control {
let file_path =
file_selected_idx.and_then(|fsidx| self.paths_navigator.file_path(fsidx).cloned());
let open_folder = self.opened_folder().cloned();
let ssh_cfg = self.cfg_of_opened_folder().map(|cfg| cfg.ssh_cfg());
let connection_data = match &ssh_cfg {
Some(ssh_cfg) => ConnectionData::Ssh(ssh_cfg.clone()),
None => ConnectionData::None,
let connection_data = if self.reader.is_some() {
ConnectionData::Ssh(self.cfg.ssh_cfg())
} else {
ConnectionData::None
};
let export_folder = self
.cfg_of_opened_folder()
Expand All @@ -526,7 +526,7 @@ impl Control {
file_path,
file_selected_idx,
connection_data,
ssh_cfg,
Some(self.cfg.ssh_cfg()),
open_folder,
export_folder,
MetaDataFlags {
Expand Down
1 change: 1 addition & 0 deletions rvimage/src/rvlib/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl MainEventLoop {
&mut self.world.data.tools_data_map,
find_active_tool(&self.tools),
);
self.world.data.meta_data.ssh_cfg = Some(self.ctrl.cfg.ssh_cfg());
if project_loaded {
for t in &mut self.tools {
self.world = t.deactivate(mem::take(&mut self.world));
Expand Down
1 change: 1 addition & 0 deletions rvimage/src/rvlib/menu/cfg_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ fn settings_popup(ui: &mut Ui, cfg: &mut Cfg, are_tools_active: &mut bool) -> Cl
tracing::error!("could not open editor. {:?}", edit::get_editor());
}
if let Some(cfg_) = trace_ok_err(cfg::read_cfg_gen::<Cfg>(&tmppath)) {
tracing::info!("config updated with new settings");
*cfg = cfg_;
}
if let Err(e) = cfg::write_cfg(cfg) {
Expand Down
13 changes: 6 additions & 7 deletions rvimage/src/rvlib/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,12 @@ pub fn auth(ssh_cfg: &SshCfg) -> RvResult<Session> {
let mut sess = Session::new().map_err(to_rv)?;
sess.set_tcp_stream(tcp);
sess.handshake().map_err(to_rv)?;
sess.userauth_pubkey_file(
&ssh_cfg.usr.user,
None,
Path::new(&ssh_cfg.usr.ssh_identity_file_path),
None,
)
.map_err(to_rv)?;
let keyfile = Path::new(&ssh_cfg.usr.ssh_identity_file_path);
if !keyfile.exists() {
return Err(rverr!("could not find private key file {keyfile:?}"));
}
sess.userauth_pubkey_file(&ssh_cfg.usr.user, None, keyfile, None)
.map_err(to_rv)?;
assert!(sess.authenticated());
Ok(sess)
}
1 change: 1 addition & 0 deletions rvimage/src/rvlib/tools_data/coco_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ pub fn read_coco(
}
ExportPathConnection::Ssh => {
if let Some(ssh_cfg) = &meta_data.ssh_cfg {
tracing::info!("creating session based on {:?}", meta_data.ssh_cfg);
let sess = ssh::auth(ssh_cfg)?;
let read_bytes = ssh::download(path_to_str(&coco_file.path)?, &sess)?;
let s = String::from_utf8(read_bytes).map_err(to_rv)?;
Expand Down

0 comments on commit ec00d34

Please sign in to comment.