diff --git a/src/core/common.rs b/src/core/common.rs index fae8d99..7890f30 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -4,6 +4,7 @@ use nix::unistd::{Group as LibcGroup, User as LibcUser}; #[cfg(not(target_os = "macos"))] use std::ffi::CString; +use std::fmt; pub const DEFAULT_CONFIG_PATH: &str = "/etc/muscl/config.toml"; pub const DEFAULT_SOCKET_PATH: &str = "/run/muscl/muscl.sock"; @@ -24,6 +25,12 @@ pub struct UnixUser { pub groups: Vec, } +impl fmt::Display for UnixUser { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.username) + } +} + // TODO: these functions are somewhat critical, and should have integration tests #[cfg(target_os = "macos")] diff --git a/src/server/command.rs b/src/server/command.rs index c515a2d..bac0e4a 100644 --- a/src/server/command.rs +++ b/src/server/command.rs @@ -91,9 +91,9 @@ pub async fn handle_command( } if auto_detected_systemd_mode { - tracing::info!("Running in systemd mode, auto-detected"); + tracing::debug!("Running in systemd mode, auto-detected"); } else { - tracing::info!("Running in systemd mode"); + tracing::debug!("Running in systemd mode"); } } else { let subscriber = tracing_subscriber::Registry::default() @@ -111,7 +111,7 @@ pub async fn handle_command( trace_server_prelude(); - tracing::info!("Running in standalone mode"); + tracing::debug!("Running in standalone mode"); } let config_path = config_path.unwrap_or_else(|| PathBuf::from(DEFAULT_CONFIG_PATH)); diff --git a/src/server/session_handler.rs b/src/server/session_handler.rs index 3ba0341..c479929 100644 --- a/src/server/session_handler.rs +++ b/src/server/session_handler.rs @@ -77,7 +77,13 @@ pub async fn session_handler( } }; - session_handler_with_unix_user(socket, &unix_user, db_pool).await + tracing::info!("Accepted connection from user: {}", unix_user); + + let result = session_handler_with_unix_user(socket, &unix_user, db_pool).await; + + tracing::info!("Finished handling requests for connection from user: {}", unix_user); + + result } pub async fn session_handler_with_unix_user( @@ -143,7 +149,12 @@ async fn session_handler_with_db_connection( } request => request.to_owned(), }; - tracing::info!("Received request: {:#?}", request_to_display); + + if request_to_display != Request::Exit { + tracing::info!("Received request: {:#?}", request_to_display); + } else { + tracing::debug!("Received request: {:#?}", request_to_display); + } let response = match request { Request::CheckAuthorization(dbs_or_users) => { @@ -237,7 +248,7 @@ async fn session_handler_with_db_connection( } response => response.to_owned(), }; - tracing::info!("Response: {:#?}", response_to_display); + tracing::debug!("Response: {:#?}", response_to_display); stream.send(response).await?; stream.flush().await?;