Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/engine/strat_engine/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ use crate::{
// The maximum allowable size of the thinpool metadata device
const MAX_META_SIZE: MetaBlocks = MetaBlocks(255 * ((1 << 14) - 64));

const EXECUTABLES_PATHS: [&str; 4] = ["/usr/sbin", "/sbin", "/usr/bin", "/bin"];

/// Find the executable with the given name by looking in likely locations.
/// Return None if no executable was found.
/// Search an explicit list of directories rather than the user's PATH
Expand All @@ -49,7 +47,7 @@ const EXECUTABLES_PATHS: [&str; 4] = ["/usr/sbin", "/sbin", "/usr/bin", "/bin"];
fn find_executable(name: &str) -> Option<PathBuf> {
EXECUTABLES_PATHS
.iter()
.map(|pre| [pre, name].iter().collect::<PathBuf>())
.map(|pre| [pre, &name.into()].iter().collect::<PathBuf>())
.find(|path| path.exists())
}

Expand Down Expand Up @@ -126,6 +124,13 @@ lazy_static! {
.iter()
.cloned()
.collect();
static ref EXECUTABLES_PATHS: Vec<PathBuf> = match std::option_env!("EXECUTABLES_PATHS") {
Some(paths) => std::env::split_paths(paths).collect(),
None => ["/usr/sbin", "/sbin", "/usr/bin", "/bin"]
.iter()
.map(|p| p.into())
.collect(),
};
}

/// Verify that all exectuables that the engine might invoke are available at some
Expand All @@ -139,7 +144,7 @@ pub fn verify_executables() -> StratisResult<()> {
name,
EXECUTABLES_PATHS
.iter()
.map(|p| format!("\"{}\"", p))
.map(|p| format!("\"{}\"", p.display()))
.collect::<Vec<_>>()
.join(", "),
))),
Expand Down