fix user fetching logic
This commit is contained in:
parent
10bd9a67c2
commit
ee69213cdf
@ -14,7 +14,6 @@ extern "C" {
|
||||
#include <QListWidget>
|
||||
#include <QTranslator>
|
||||
#include <notifications.hpp>
|
||||
#include <platformbackend.hpp>
|
||||
#include <worker/worker.hpp>
|
||||
|
||||
bool verbose = false;
|
||||
|
@ -20,7 +20,7 @@ bool PlatformBackend::filenameValid(QString name) {
|
||||
}
|
||||
|
||||
QString PlatformBackend::getCurrentUser() {
|
||||
auto pwent = getpwent();
|
||||
auto pwent = getpwuid(getuid());
|
||||
if (!pwent) {
|
||||
if (qEnvironmentVariableIsSet("USER"))
|
||||
return QString::fromLocal8Bit(qgetenv("USER"));
|
||||
|
@ -50,7 +50,7 @@ QString PlatformBackend::getCurrentUser() {
|
||||
DWORD username_len = UNLEN + 1;
|
||||
QString userName;
|
||||
if (GetUserName(username, &username_len)) {
|
||||
userName = QString::fromWCharArray(username, username_len);
|
||||
userName = QString::fromWCharArray(username, username_len - 1);
|
||||
}
|
||||
delete[] username;
|
||||
return userName;
|
||||
|
@ -60,7 +60,7 @@ bool PlatformBackend::filenameValid(QString name) {
|
||||
}
|
||||
|
||||
QString PlatformBackend::getCurrentUser() {
|
||||
auto pwent = getpwent();
|
||||
auto pwent = getpwuid(getuid());
|
||||
if (!pwent) {
|
||||
if (qEnvironmentVariableIsSet("USER"))
|
||||
return QString::fromLocal8Bit(qgetenv("USER"));
|
||||
|
Loading…
Reference in New Issue
Block a user