fix user fetching logic

This commit is contained in:
ArsenArsen 2018-02-25 22:29:31 +01:00
parent 10bd9a67c2
commit ee69213cdf
No known key found for this signature in database
GPG Key ID: 683D2F43B0CA4BD2
4 changed files with 3 additions and 4 deletions

View File

@ -14,7 +14,6 @@ extern "C" {
#include <QListWidget>
#include <QTranslator>
#include <notifications.hpp>
#include <platformbackend.hpp>
#include <worker/worker.hpp>
bool verbose = false;

View File

@ -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"));

View File

@ -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;

View File

@ -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"));