From 5519c4c28933d1ca7a4db8668c46b4b91194c762 Mon Sep 17 00:00:00 2001 From: fufesou Date: Mon, 23 Mar 2026 16:50:57 +0800 Subject: [PATCH] fix(password): set_salt, comments and logs Signed-off-by: fufesou --- src/config.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/config.rs b/src/config.rs index 2922906f4..eac5e6282 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1339,6 +1339,9 @@ impl Config { !CONFIG.read().unwrap().password.is_empty() } + // This shouldn't happen under normal circumstances because the salt + // should be automatically generated when migrating to hash storage. + // Actually, it is better to avoid calling set_salt at all. pub fn set_salt(salt: &str) { let mut config = CONFIG.write().unwrap(); if salt == config.salt { @@ -1346,15 +1349,9 @@ impl Config { } if !password_is_empty_or_not_hashed(&config.password) { if config.salt.is_empty() { - // This shouldn't happen under normal circumstances because the salt - // should be automatically generated when migrating to hash storage. - // However, if it does occur, it's best to log the error, - // even though this will result in logging many duplicate error messages. - log::warn!("Salt is empty but permanent password is hashed"); + log::warn!("Salt is empty but permanent password is hashed and salt is empty"); } else { - log::error!( - "Refusing to set salt because permanent password is hashed and salt is empty" - ); + log::error!("Refusing to set salt because permanent password is hashed"); return; } }