cargo fmt + clippy
This commit is contained in:
parent
3556eb37ea
commit
d1d06514a9
|
@ -56,11 +56,11 @@ The Y/N-values corresponds to the following mysql privileges:
|
|||
/// Please consider using the newer mysqladm command instead.
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
bin_name = "mysql-dbadm",
|
||||
version,
|
||||
about,
|
||||
disable_help_subcommand = true,
|
||||
verbatim_doc_comment,
|
||||
bin_name = "mysql-dbadm",
|
||||
version,
|
||||
about,
|
||||
disable_help_subcommand = true,
|
||||
verbatim_doc_comment
|
||||
)]
|
||||
pub struct Args {
|
||||
#[command(subcommand)]
|
||||
|
|
|
@ -32,11 +32,11 @@ use crate::{
|
|||
/// Please consider using the newer mysqladm command instead.
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
bin_name = "mysql-useradm",
|
||||
version,
|
||||
about,
|
||||
disable_help_subcommand = true,
|
||||
verbatim_doc_comment,
|
||||
bin_name = "mysql-useradm",
|
||||
version,
|
||||
about,
|
||||
disable_help_subcommand = true,
|
||||
verbatim_doc_comment
|
||||
)]
|
||||
pub struct Args {
|
||||
#[command(subcommand)]
|
||||
|
|
|
@ -32,15 +32,18 @@ pub fn drop_privs() -> anyhow::Result<()> {
|
|||
|
||||
/// This function is used to bootstrap the connection to the server.
|
||||
/// This can happen in two ways:
|
||||
///
|
||||
/// 1. If a socket path is provided, or exists in the default location,
|
||||
/// the function will connect to the socket and authenticate with the
|
||||
/// server to ensure that the server knows the uid of the client.
|
||||
///
|
||||
/// 2. If a config path is provided, or exists in the default location,
|
||||
/// and the config is readable, the function will assume it is either
|
||||
/// setuid or setgid, and will fork a child process to run the server
|
||||
/// with the provided config. The server will exit silently by itself
|
||||
/// when it is done, and this function will only return for the client
|
||||
/// with the socket for the server.
|
||||
///
|
||||
/// If neither of these options are available, the function will fail.
|
||||
pub fn bootstrap_server_connection_and_drop_privileges(
|
||||
server_socket_path: Option<PathBuf>,
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -109,17 +109,17 @@ fn main() -> anyhow::Result<()> {
|
|||
env_logger::init();
|
||||
|
||||
#[cfg(feature = "mysql-admutils-compatibility")]
|
||||
if let Some(_) = handle_mysql_admutils_command()? {
|
||||
if handle_mysql_admutils_command()?.is_some() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let args: Args = Args::parse();
|
||||
|
||||
if let Some(_) = handle_server_command(&args)? {
|
||||
if handle_server_command(&args)?.is_some() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Some(_) = handle_generate_completions_command(&args)? {
|
||||
if handle_generate_completions_command(&args)?.is_some() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
@ -139,8 +139,8 @@ fn handle_mysql_admutils_command() -> anyhow::Result<Option<()>> {
|
|||
});
|
||||
|
||||
match argv0.as_deref() {
|
||||
Some("mysql-dbadm") => mysql_dbadm::main().map(|result| Some(result)),
|
||||
Some("mysql-useradm") => mysql_useradm::main().map(|result| Some(result)),
|
||||
Some("mysql-dbadm") => mysql_dbadm::main().map(Some),
|
||||
Some("mysql-useradm") => mysql_useradm::main().map(Some),
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,8 +141,7 @@ pub async fn create_mysql_connection_from_config(
|
|||
) -> anyhow::Result<MySqlConnection> {
|
||||
log_config(config);
|
||||
|
||||
let mut mysql_options = MySqlConnectOptions::new()
|
||||
.database("mysql");
|
||||
let mut mysql_options = MySqlConnectOptions::new().database("mysql");
|
||||
|
||||
if let Some(username) = &config.username {
|
||||
mysql_options = mysql_options.username(username);
|
||||
|
@ -168,6 +167,8 @@ pub async fn create_mysql_connection_from_config(
|
|||
.await
|
||||
{
|
||||
Ok(connection) => connection.context("Failed to connect to the database"),
|
||||
Err(_) => Err(anyhow!("Timed out after 2 seconds")).context("Failed to connect to the database"),
|
||||
Err(_) => {
|
||||
Err(anyhow!("Timed out after 2 seconds")).context("Failed to connect to the database")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue