From 4739982c66115aadf92ad4205df2ea12adbeefe8 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 19 Oct 2021 09:32:47 -0400 Subject: [PATCH] LibCore: Change Account::set_password to take a SecretString This matches the API of Account::authenticate. The only caller to this API is the passwd utility, which already has the new password stored as a SecretString. --- Userland/Libraries/LibCore/Account.cpp | 4 ++-- Userland/Libraries/LibCore/Account.h | 2 +- Userland/Utilities/passwd.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibCore/Account.cpp b/Userland/Libraries/LibCore/Account.cpp index d46bb80731f..106773b7021 100644 --- a/Userland/Libraries/LibCore/Account.cpp +++ b/Userland/Libraries/LibCore/Account.cpp @@ -188,9 +188,9 @@ bool Account::login() const return true; } -void Account::set_password(const char* password) +void Account::set_password(SecretString const& password) { - m_password_hash = crypt(password, get_salt().characters()); + m_password_hash = crypt(password.characters(), get_salt().characters()); } void Account::set_password_enabled(bool enabled) diff --git a/Userland/Libraries/LibCore/Account.h b/Userland/Libraries/LibCore/Account.h index d0c3360575b..ade6fec5c04 100644 --- a/Userland/Libraries/LibCore/Account.h +++ b/Userland/Libraries/LibCore/Account.h @@ -45,7 +45,7 @@ public: // Setters only affect in-memory copy of password. // You must call sync to apply changes. - void set_password(const char* password); + void set_password(SecretString const& password); void set_password_enabled(bool enabled); void set_home_directory(const char* home_directory) { m_home_directory = home_directory; } void set_uid(uid_t uid) { m_uid = uid; } diff --git a/Userland/Utilities/passwd.cpp b/Userland/Utilities/passwd.cpp index 12032a0c89e..952d9b29144 100644 --- a/Userland/Utilities/passwd.cpp +++ b/Userland/Utilities/passwd.cpp @@ -121,7 +121,7 @@ int main(int argc, char** argv) return 1; } - target_account.set_password(new_password.value().characters()); + target_account.set_password(new_password.value()); } if (pledge("stdio wpath rpath cpath fattr", nullptr) < 0) {