|
|
|
@ -13,10 +13,10 @@
|
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
|
|
use crate::Config; |
|
|
|
|
use dialog::{backends::Zenity, DialogBox}; |
|
|
|
|
use std::{ |
|
|
|
|
io::{Error, ErrorKind, Result}, |
|
|
|
|
path::{PathBuf, MAIN_SEPARATOR}, |
|
|
|
|
process::Command, |
|
|
|
|
}; |
|
|
|
|
use tokio::{ |
|
|
|
|
fs::{remove_file, File}, |
|
|
|
@ -119,6 +119,29 @@ pub(crate) async fn run(config: Config) -> Result<()> {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Print dialog
|
|
|
|
|
if !dont_ask { |
|
|
|
|
let mut zenity = Zenity::new(); |
|
|
|
|
zenity.set_icon("question"); |
|
|
|
|
zenity.set_width(360); |
|
|
|
|
let choice = dialog::Question::new(&format!( |
|
|
|
|
"Do you want to accept\n{}\n({} bytes)?", |
|
|
|
|
filename.display(), |
|
|
|
|
file_size |
|
|
|
|
)) |
|
|
|
|
.title("Yodle!") |
|
|
|
|
.show_with(&zenity) |
|
|
|
|
.expect("Could not display dialog box"); |
|
|
|
|
if choice != dialog::Choice::Yes { |
|
|
|
|
info!( |
|
|
|
|
"{} failed: rejected {}", |
|
|
|
|
peer_addr, |
|
|
|
|
filename.file_name().as_ref().unwrap().to_string_lossy() |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
debug!( |
|
|
|
|
"{} status: receiving {} ({} bytes)", |
|
|
|
|
peer_addr, |
|
|
|
@ -126,23 +149,6 @@ pub(crate) async fn run(config: Config) -> Result<()> {
|
|
|
|
|
file_size |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if !dont_ask { |
|
|
|
|
match Command::new("ssh-askpass") |
|
|
|
|
.arg(&format!( |
|
|
|
|
"Yo! Do you want to accept {} ({} bytes)?", |
|
|
|
|
filename.display(), |
|
|
|
|
file_size |
|
|
|
|
)) |
|
|
|
|
.output() |
|
|
|
|
{ |
|
|
|
|
Ok(output) if output.status.success() => {} |
|
|
|
|
_ => { |
|
|
|
|
info!("{} failed: rejected file", peer_addr); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Create output file
|
|
|
|
|
let file = match File::create(&filename).await { |
|
|
|
|
Ok(f) => f, |
|
|
|
|