diff --git a/src/client/commands.rs b/src/client/commands.rs index c7538fd..8dbdbec 100644 --- a/src/client/commands.rs +++ b/src/client/commands.rs @@ -171,6 +171,10 @@ pub async fn handle_command( } } +/// Handle an unexpected or erroneous response from the server. +/// +/// This function checks the provided response and returns an appropriate error message. +/// It is typically used in `match` branches for expecting a specific response type from the server. pub fn erroneous_server_response( response: Option>, ) -> anyhow::Result<()> { @@ -190,6 +194,11 @@ pub fn erroneous_server_response( } } +/// Print a hint about which name prefixes the user is authorized to manage +/// by querying the server for valid name prefixes. +/// +/// This function should be used when an authorization error occurs, +/// to help the user understand which databases or users they are allowed to manage. pub async fn print_authorization_owner_hint( server_connection: &mut ClientToServerMessageStream, ) -> anyhow::Result<()> { diff --git a/src/core/bootstrap.rs b/src/core/bootstrap.rs index 9189da8..ee9b78c 100644 --- a/src/core/bootstrap.rs +++ b/src/core/bootstrap.rs @@ -176,6 +176,8 @@ pub fn drop_privs() -> anyhow::Result<()> { Ok(()) } +/// Bootstrap an internal server by forking a child process to run the server, giving it +/// the other half of a Unix socket pair to communicate with the client process. fn bootstrap_internal_server_and_drop_privs( config_path: Option, ) -> anyhow::Result { @@ -237,6 +239,10 @@ fn invoke_server_with_config(config_path: PathBuf) -> anyhow::Result anyhow::Result { @@ -262,8 +268,10 @@ async fn construct_single_connection_mysql_pool( Ok(pool) } -/// Run the server in the forked child process. +/// Run a single server session in the forked process. +/// /// This function will not return, but will exit the process with a success code. +/// The function assumes that it's caller has already forked the process. fn run_forked_server( config_path: PathBuf, server_socket: StdUnixStream,