From a780c6d982154c0bbb16ea16346caef88f98489c Mon Sep 17 00:00:00 2001 From: Anderson Toshiyuki Sasaki Date: Tue, 13 Jun 2023 14:57:14 +0200 Subject: [PATCH] revocation: Parse revocation actions flexibly Make the accepted list format more flexible by parsing with the keylime::list_parser. Fixes: #489, #440 Signed-off-by: Anderson Toshiyuki Sasaki --- keylime-agent/src/revocation.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/keylime-agent/src/revocation.rs b/keylime-agent/src/revocation.rs index 37a7d088..025a9299 100644 --- a/keylime-agent/src/revocation.rs +++ b/keylime-agent/src/revocation.rs @@ -7,6 +7,7 @@ use crate::config::{AgentConfig, KeylimeConfig}; use crate::crypto; use crate::error::*; use crate::secure_mount; +use keylime::list_parser::parse_list; use log::*; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -196,11 +197,7 @@ fn run_revocation_actions( // The actions from the configuration file takes precedence over the actions from the // actions_list file let actions = config_actions.unwrap_or_default(); - let mut action_list = actions - .split(',') - .map(|script| script.trim()) - .filter(|script| !script.is_empty()) - .collect::>(); + let mut action_list = parse_list(&actions)?; let action_data; let unzipped = mount.join("unzipped"); let action_file = unzipped.join("action_list"); @@ -209,10 +206,7 @@ fn run_revocation_actions( action_data = std::fs::read_to_string(&action_file) .expect("unable to read action_list"); - let file_actions = action_data - .split('\n') - .map(|script| script.trim()) - .filter(|script| !script.is_empty()); + let file_actions = parse_list(&action_data)?; action_list.extend(file_actions); } else { @@ -240,7 +234,7 @@ fn run_revocation_actions( ); error!("{}", msg); return Err(Error::Script( - String::from(action), + action.to_string(), e.exe_code()?, e.stderr()?, ));