diff --git a/src/core/Password.cpp b/src/core/Password.cpp index bea5038..f1c3653 100644 --- a/src/core/Password.cpp +++ b/src/core/Password.cpp @@ -3,6 +3,7 @@ #include "../helpers/Log.hpp" #include +#include #include #if __has_include() #include @@ -38,10 +39,11 @@ std::shared_ptr CPassword::verify(const std::str std::thread([this, result, pass]() { auto auth = [&](std::string auth) -> bool { - const pam_conv localConv = {conv, (void*)pass.c_str()}; - pam_handle_t* handle = NULL; + const pam_conv localConv = {conv, (void*)pass.c_str()}; + pam_handle_t* handle = NULL; + auto uidPassword = getpwuid(getuid()); - int ret = pam_start(auth.c_str(), getlogin(), &localConv, &handle); + int ret = pam_start(auth.c_str(), uidPassword->pw_name, &localConv, &handle); if (ret != PAM_SUCCESS) { result->success = false; diff --git a/src/renderer/widgets/IWidget.cpp b/src/renderer/widgets/IWidget.cpp index 9483839..d9519de 100644 --- a/src/renderer/widgets/IWidget.cpp +++ b/src/renderer/widgets/IWidget.cpp @@ -4,6 +4,7 @@ #include "../../core/hyprlock.hpp" #include #include +#include #if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 190100 #pragma comment(lib, "date-tz") @@ -82,7 +83,8 @@ static std::string getTime() { IWidget::SFormatResult IWidget::formatString(std::string in) { - char* username = getlogin(); + auto uidPassword = getpwuid(getuid()); + char* username = uidPassword->pw_name; if (!username) Debug::log(ERR, "Error in formatString, username null. Errno: ", errno);