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