diff --git a/src/constants.rs b/src/constants.rs index 79b82de..9ac72fa 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -179,8 +179,8 @@ pub const STATUS_SUBMENU_PAYOUT: &str = "The total amount of payouts received pub const STATUS_SUBMENU_XMR: &str = "The total of XMR mined via P2Pool across all time"; pub const STATUS_SUBMENU_LATEST: &str = "Sort the logs latest to oldest"; pub const STATUS_SUBMENU_OLDEST: &str = "Sort the logs oldest to latest"; -pub const STATUS_SUBMENU_BIGGEST: &str = "Sort the logs by biggest payouts first"; -pub const STATUS_SUBMENU_SMALLEST: &str = "Sort the logs by smallest payouts first"; +pub const STATUS_SUBMENU_BIGGEST: &str = "Sort the logs by the biggest payouts first"; +pub const STATUS_SUBMENU_SMALLEST: &str = "Sort the logs by the smallest payouts first"; // Gupax pub const GUPAX_UPDATE: &str = "Check for updates on Gupax, P2Pool, and XMRig via GitHub's API and upgrade automatically"; diff --git a/src/disk.rs b/src/disk.rs index ad001db..4a6eadd 100644 --- a/src/disk.rs +++ b/src/disk.rs @@ -51,6 +51,8 @@ use crate::{ P2poolRegex, }; use log::*; +#[cfg(target_family = "unix")] +use std::os::unix::fs::PermissionsExt; //---------------------------------------------------------------------------------------------------- Const // State file @@ -133,6 +135,26 @@ pub fn get_gupax_data_path() -> Result { } } +pub fn set_unix_750_perms(path: &PathBuf) -> Result<(), TomlError> { + #[cfg(target_os = "windows")] + return Ok(()); + #[cfg(target_family = "unix")] + match fs::set_permissions(path, fs::Permissions::from_mode(0o750)) { + Ok(_) => { info!("OS | Unix 750 permissions on path [{}] ... OK", path.display()); Ok(()) }, + Err(e) => { error!("OS | Unix 750 permissions on path [{}] ... FAIL ... {}", path.display(), e); Err(TomlError::Io(e)) }, + } +} + +pub fn set_unix_660_perms(path: &PathBuf) -> Result<(), TomlError> { + #[cfg(target_os = "windows")] + return Ok(()); + #[cfg(target_family = "unix")] + match fs::set_permissions(path, fs::Permissions::from_mode(0o660)) { + Ok(_) => { info!("OS | Unix 660 permissions on path [{}] ... OK", path.display()); Ok(()) }, + Err(e) => { error!("OS | Unix 660 permissions on path [{}] ... FAIL ... {}", path.display(), e); Err(TomlError::Io(e)) }, + } +} + pub fn get_gupax_p2pool_path(os_data_path: &PathBuf) -> PathBuf { let mut gupax_p2pool_dir = os_data_path.clone(); gupax_p2pool_dir.push(GUPAX_P2POOL_API_DIRECTORY); @@ -142,9 +164,10 @@ pub fn get_gupax_p2pool_path(os_data_path: &PathBuf) -> PathBuf { pub fn create_gupax_dir(path: &PathBuf) -> Result<(), TomlError> { // Create Gupax directory match fs::create_dir_all(path) { - Ok(_) => { info!("OS | Create data path ... OK"); Ok(()) }, - Err(e) => { error!("OS | Create data path ... FAIL ... {}", e); Err(TomlError::Io(e)) }, + Ok(_) => info!("OS | Create data path ... OK"), + Err(e) => { error!("OS | Create data path ... FAIL ... {}", e); return Err(TomlError::Io(e)) }, } + set_unix_750_perms(&path) } pub fn create_gupax_p2pool_dir(path: &PathBuf) -> Result<(), TomlError> { @@ -1156,6 +1179,7 @@ mod test { [status] submenu = "P2pool" + payout_view = "Oldest" monero_enabled = true manual_hash = false hashrate = 1241.23 diff --git a/src/status.rs b/src/status.rs index 7861b80..e238ab9 100644 --- a/src/status.rs +++ b/src/status.rs @@ -142,17 +142,19 @@ pub fn show(&mut self, sys: &Arc>, p2pool_api: &Arc