mirror of https://github.com/buster-so/buster.git
os fix on ssh tunneling
This commit is contained in:
parent
1b16398413
commit
d8ea573c56
|
@ -4,9 +4,10 @@ use std::{
|
||||||
fs,
|
fs,
|
||||||
io::Write,
|
io::Write,
|
||||||
net::TcpListener,
|
net::TcpListener,
|
||||||
os::unix::fs::PermissionsExt,
|
|
||||||
process::{Child, Command},
|
process::{Child, Command},
|
||||||
};
|
};
|
||||||
|
#[cfg(unix)]
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
pub fn establish_ssh_tunnel(
|
pub fn establish_ssh_tunnel(
|
||||||
|
@ -61,29 +62,32 @@ pub fn establish_ssh_tunnel(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut perms = match fs::metadata(temp_ssh_key.path()) {
|
#[cfg(unix)]
|
||||||
Ok(p) => p.permissions(),
|
{
|
||||||
Err(e) => {
|
let mut perms = match fs::metadata(temp_ssh_key.path()) {
|
||||||
tracing::error!(
|
Ok(p) => p.permissions(),
|
||||||
"There was a problem while getting the metadata of the temp file: {}",
|
Err(e) => {
|
||||||
e
|
tracing::error!(
|
||||||
);
|
"There was a problem while getting the metadata of the temp file: {}",
|
||||||
return Err(anyhow!(e));
|
e
|
||||||
}
|
);
|
||||||
};
|
return Err(anyhow!(e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
perms.set_mode(0o600);
|
perms.set_mode(0o600);
|
||||||
|
|
||||||
match fs::set_permissions(temp_ssh_key.path(), perms) {
|
match fs::set_permissions(temp_ssh_key.path(), perms) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
"There was a problem while setting the permissions of the temp file: {}",
|
"There was a problem while setting the permissions of the temp file: {}",
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
return Err(anyhow!(e));
|
return Err(anyhow!(e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let ssh_tunnel = match Command::new("ssh")
|
let ssh_tunnel = match Command::new("ssh")
|
||||||
.arg("-T")
|
.arg("-T")
|
||||||
|
|
Loading…
Reference in New Issue