From b745fa3fec3d70b4bafa2288b9903861164cd8c8 Mon Sep 17 00:00:00 2001 From: Kangsu Kim Date: Thu, 7 Feb 2019 20:46:16 +0900 Subject: [PATCH] Handle some auth failures neutral Related #54 --- owl-daemon/src/handler/exploit.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/owl-daemon/src/handler/exploit.rs b/owl-daemon/src/handler/exploit.rs index bbc5482..097afd2 100644 --- a/owl-daemon/src/handler/exploit.rs +++ b/owl-daemon/src/handler/exploit.rs @@ -464,40 +464,41 @@ fn add_to_task_queue(resource: &DaemonResource, exploit: &Exploit) -> Result<(), .then(move |result| { if let Ok(con) = db_pool.get() { let con = &*con; - let failed = result.is_err(); - let exploit_update_message = result.unwrap_or_else(|err| { + let (exploit_update_message, failed) = result.map( + |exploit_update_message| (exploit_update_message, false) + ).unwrap_or_else(|err| { info!(target: "exploit", "[ExploitTask] Failed: {}", exploit_task.id); if let Error::ExploitError(err) = err { match err { ExploitError::ExploitProcessError(err) => { - (ExploitStatus::ExploitProcessError, err.to_string()) + ((ExploitStatus::ExploitProcessError, err.to_string()), true) }, ExploitError::ExploitReturnCodeNotZero { return_code, stderr, - } => ( + } => (( ExploitStatus::ExploitReturnCodeNotZero, format!("code {:?}: {}", return_code, stderr), - ), + ), true), ExploitError::ExploitTimeout(err) => { - (ExploitStatus::ExploitProcessError, err.to_string()) + ((ExploitStatus::ExploitProcessError, err.to_string()), true) }, ExploitError::AuthProcessError(err) => { - (ExploitStatus::AuthProcessError, err.to_string()) + ((ExploitStatus::AuthProcessError, err.to_string()), false) }, ExploitError::AuthReturnCodeNotZero { return_code, stderr, - } => ( + } => (( ExploitStatus::AuthReturnCodeNotZero, format!("code {:?}: {}", return_code, stderr), - ), + ), false), ExploitError::WrongFlag(flag) => { - (ExploitStatus::WrongFlag, flag) + ((ExploitStatus::WrongFlag, flag), true) }, } } else { - (ExploitStatus::UnknownFailure, err.to_string()) + ((ExploitStatus::UnknownFailure, err.to_string()), false) } }); @@ -521,7 +522,7 @@ pub fn run_exploit( let con: &PgConnection = &*resource.db_pool.get()?; let exploit_name = params.name; - let wait_for_exploit = params.wait; + let _wait_for_exploit = params.wait; let exploit = exploits::table .filter(exploits::name.eq(exploit_name))