diff --git a/Cargo.lock b/Cargo.lock index 85fbd707b..41740d6e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3981,6 +3981,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-clap-utils 0.22.0", "solana-logger 0.22.0", "unix_socket2 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "users 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/net/remote/remote-node.sh b/net/remote/remote-node.sh index 6cd7bfb6d..ed33ae82a 100755 --- a/net/remote/remote-node.sh +++ b/net/remote/remote-node.sh @@ -129,7 +129,7 @@ cat >> ~/solana/on-reboot < sys-tuner.log 2>&1 & + sudo RUST_LOG=info ~solana/.cargo/bin/solana-sys-tuner --user $(whoami) > sys-tuner.log 2>&1 & echo \$! > sys-tuner.pid ( diff --git a/sys-tuner/Cargo.toml b/sys-tuner/Cargo.toml index 39b48b730..b38c84e7f 100644 --- a/sys-tuner/Cargo.toml +++ b/sys-tuner/Cargo.toml @@ -14,6 +14,7 @@ clap = "2.33.0" log = "0.4.8" libc = "0.2.66" semver = "0.9.0" +solana-clap-utils = { path = "../clap-utils", version = "0.22.0" } solana-logger = { path = "../logger", version = "0.22.0" } [target."cfg(unix)".dependencies] diff --git a/sys-tuner/src/main.rs b/sys-tuner/src/main.rs index 688c475d6..23c5467db 100644 --- a/sys-tuner/src/main.rs +++ b/sys-tuner/src/main.rs @@ -1,3 +1,4 @@ +use clap::{crate_description, crate_name, value_t_or_exit, App, Arg}; use log::*; #[cfg(target_os = "linux")] @@ -66,6 +67,23 @@ fn tune_system(uid: u32) { #[cfg(unix)] fn main() { solana_logger::setup(); + let matches = App::new(crate_name!()) + .about(crate_description!()) + .version(solana_clap_utils::version!()) + .arg( + Arg::with_name("user") + .long("user") + .value_name("user name") + .takes_value(true) + .required(true) + .help("Username of the peer process"), + ) + .get_matches(); + + let user = value_t_or_exit!(matches, "user", String); + + info!("Tune will service requests only from user {}", user); + unsafe { libc::umask(0o077) }; if let Err(e) = std::fs::remove_file(solana_sys_tuner::SOLANA_SYS_TUNER_PATH) { if e.kind() != std::io::ErrorKind::NotFound { @@ -79,7 +97,7 @@ fn main() { let peer_uid; // set socket permission - if let Some(user) = users::get_user_by_name("solana") { + if let Some(user) = users::get_user_by_name(&user) { peer_uid = user.uid(); info!("UID for solana is {}", peer_uid); nix::unistd::chown( @@ -89,7 +107,7 @@ fn main() { ) .expect("Expected to change UID of the socket file"); } else { - panic!("Could not find UID for solana user"); + panic!("Could not find UID for {:?} user", user); } info!("Waiting for tuning requests");