SHA256
More verbose err, and setting up /usr/bin /usr/lib to env paths.
This commit is contained in:
+5
-2
@@ -92,10 +92,10 @@ fn mount_and_check_snaps() -> Result<NyanitState, ExecCommandError> {
|
||||
|
||||
fn init_stage() -> Result<NyanitState, ExecCommandError> {
|
||||
// mount sysfss
|
||||
nyan_system::prepare_env()?;
|
||||
nyan_system::prepare_env().map_err(|ex| format!("prepare_env error: {}", ex))?;
|
||||
|
||||
// check if device is encrypted
|
||||
if nyan_system::bzzpss_dev_encrypted(ROOT_DEV)? {
|
||||
if nyan_system::bzzpss_dev_encrypted(ROOT_DEV).map_err(|ex| format!("Error checking if device is encrypted: {}", ex))? {
|
||||
// if encrypted return EnterPassword so used get promted for pass
|
||||
return Ok(NyanitState::EnterPassword);
|
||||
}
|
||||
@@ -337,7 +337,10 @@ impl NyanitTUI<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn main() -> ExitCode {
|
||||
nyan_system::set_env_vars_unsafe();
|
||||
let mut app = NyanitTUI::new().unwrap();
|
||||
app.run().unwrap();
|
||||
// Terminal restores automatically when `stdout` (RawTerminal) is dropped
|
||||
|
||||
@@ -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