From 25c4c6f3e996ccdc5044ef4260847f331323798b Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 2 Dec 2025 15:40:54 +0900 Subject: [PATCH] server: read mysql password from file --- src/server/config.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/server/config.rs b/src/server/config.rs index fdfdf90..6ed0f20 100644 --- a/src/server/config.rs +++ b/src/server/config.rs @@ -41,7 +41,15 @@ impl MysqlConfig { options = options.username(username); } - if let Some(password) = &self.password { + if let Some(password_file) = &self.password_file { + let password = fs::read_to_string(password_file) + .with_context(|| { + format!("Failed to read MySQL password file at {:?}", password_file) + })? + .trim() + .to_owned(); + options = options.password(&password); + } else if let Some(password) = &self.password { options = options.password(password); }