diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 3e4fe27..13672b7 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -1,6 +1,7 @@ #[macro_use] extern crate rust_embed; +pub mod startup_helpers; pub mod lightclient; pub mod grpcconnector; pub mod lightwallet; diff --git a/lib/src/startup_helpers.rs b/lib/src/startup_helpers.rs new file mode 100644 index 0000000..0b8e4bd --- /dev/null +++ b/lib/src/startup_helpers.rs @@ -0,0 +1,20 @@ +pub fn report_permission_error() { + let user = std::env::var("USER").expect( + "Unexpected error reading value of $USER!"); + let home = std::env::var("HOME").expect( + "Unexpected error reading value of $HOME!"); + let current_executable = std::env::current_exe() + .expect("Unexpected error reporting executable path!"); + eprintln!("USER: {}", user); + eprintln!("HOME: {}", home); + eprintln!("Executable: {}", current_executable.display()); + if home == "/" { + eprintln!("User {} must have permission to write to '{}.zcash/' .", + user, + home); + } else { + eprintln!("User {} must have permission to write to '{}/.zcash/' .", + user, + home); + } +} diff --git a/src/main.rs b/src/main.rs index 96fde21..d9b0ecc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::io::{Result, Error, ErrorKind}; use std::sync::Arc; use std::sync::mpsc::{channel, Sender, Receiver}; -use zecwalletlitelib::{commands, +use zecwalletlitelib::{commands, startup_helpers, lightclient::{self, LightClient, LightClientConfig}, }; @@ -111,12 +111,17 @@ pub fn main() { let dangerous = matches.is_present("dangerous"); let nosync = matches.is_present("nosync"); - let (command_tx, resp_rx) = match startup(server, dangerous, seed, !nosync, command.is_none()) { Ok(c) => c, Err(e) => { eprintln!("Error during startup: {}", e); error!("Error during startup: {}", e); + match e.raw_os_error() { + Some(13) => { + startup_helpers::report_permission_error(); + }, + _ => eprintln!("Something else!") + } return; } };