mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
auth: Use getpwuid(getuid()) instead of getlogin() (#204)
* Making changes * Replacing struct with auto keyword * Removing the extra semicolon * ran clang-format
This commit is contained in:
parent
b50acfaf94
commit
54da0cae0f
2 changed files with 8 additions and 4 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include "../helpers/Log.hpp"
|
#include "../helpers/Log.hpp"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <pwd.h>
|
||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
#if __has_include(<security/pam_misc.h>)
|
#if __has_include(<security/pam_misc.h>)
|
||||||
#include <security/pam_misc.h>
|
#include <security/pam_misc.h>
|
||||||
|
@ -38,10 +39,11 @@ std::shared_ptr<CPassword::SVerificationResult> CPassword::verify(const std::str
|
||||||
|
|
||||||
std::thread([this, result, pass]() {
|
std::thread([this, result, pass]() {
|
||||||
auto auth = [&](std::string auth) -> bool {
|
auto auth = [&](std::string auth) -> bool {
|
||||||
const pam_conv localConv = {conv, (void*)pass.c_str()};
|
const pam_conv localConv = {conv, (void*)pass.c_str()};
|
||||||
pam_handle_t* handle = NULL;
|
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) {
|
if (ret != PAM_SUCCESS) {
|
||||||
result->success = false;
|
result->success = false;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "../../core/hyprlock.hpp"
|
#include "../../core/hyprlock.hpp"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
|
||||||
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 190100
|
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 190100
|
||||||
#pragma comment(lib, "date-tz")
|
#pragma comment(lib, "date-tz")
|
||||||
|
@ -82,7 +83,8 @@ static std::string getTime() {
|
||||||
|
|
||||||
IWidget::SFormatResult IWidget::formatString(std::string in) {
|
IWidget::SFormatResult IWidget::formatString(std::string in) {
|
||||||
|
|
||||||
char* username = getlogin();
|
auto uidPassword = getpwuid(getuid());
|
||||||
|
char* username = uidPassword->pw_name;
|
||||||
|
|
||||||
if (!username)
|
if (!username)
|
||||||
Debug::log(ERR, "Error in formatString, username null. Errno: ", errno);
|
Debug::log(ERR, "Error in formatString, username null. Errno: ", errno);
|
||||||
|
|
Loading…
Reference in a new issue