SHA256
More verbose err, and setting up /usr/bin /usr/lib to env paths.
This commit is contained in:
@@ -227,6 +227,31 @@ pub fn prepare_env() -> Result<(), ExecCommandError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// MUST be done before spawning any threads or async runtimes
|
||||
pub fn set_env_vars_unsafe() -> () {
|
||||
use std::env;
|
||||
// 1. Define your custom paths
|
||||
let custom_bin = "/usr/bin";
|
||||
let custom_lib = "/usr/lib";
|
||||
|
||||
// 2. Retrieve existing paths to append/prepend (optional but recommended)
|
||||
let existing_path = env::var("PATH").unwrap_or_else(|_| String::new());
|
||||
let existing_ld_path = env::var("LD_LIBRARY_PATH").unwrap_or_else(|_| String::new());
|
||||
|
||||
// 3. Construct new path strings
|
||||
// Prepend custom paths so they take precedence
|
||||
let new_path = format!("{}:{}", custom_bin, existing_path);
|
||||
let new_ld_path = format!("{}:{}", custom_lib, existing_ld_path);
|
||||
|
||||
// 4. Set environment variables (UNSAFE in Rust 2024+)
|
||||
// MUST be done before spawning any threads or async runtimes
|
||||
unsafe {
|
||||
env::set_var("PATH", new_path);
|
||||
env::set_var("LD_LIBRARY_PATH", new_ld_path);
|
||||
}
|
||||
}
|
||||
|
||||
// # Mount the real root filesystem
|
||||
pub fn mount_bee_root(mount_point: &str, dev_name: &str) -> Result<(), ExecCommandError> {
|
||||
exec_command("mount", &vec!["-o", "ro", dev_name, mount_point])?;
|
||||
|
||||
Reference in New Issue
Block a user