Skip to content

Commit afd6d1c

Browse files
committed
Fix login with UTF-8 user names
Passing user names to C functions using qPrintable() discards UTF-8 characters, better use qUtf8Printable() instead. Closes #365
1 parent dccb275 commit afd6d1c

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

src/daemon/Display.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ namespace SDDM {
340340
m_auth->request()->prompts()[0]->setResponse(qPrintable(m_passPhrase));
341341
m_auth->request()->done();
342342
} else if (m_auth->request()->prompts().length() == 2) {
343-
m_auth->request()->prompts()[0]->setResponse(qPrintable(m_auth->user()));
343+
m_auth->request()->prompts()[0]->setResponse(qUtf8Printable(m_auth->user()));
344344
m_auth->request()->prompts()[1]->setResponse(qPrintable(m_passPhrase));
345345
m_auth->request()->done();
346346
}

src/helper/Backend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace SDDM {
5454

5555
bool Backend::openSession() {
5656
struct passwd *pw;
57-
pw = getpwnam(qPrintable(qobject_cast<HelperApp*>(parent())->user()));
57+
pw = getpwnam(qUtf8Printable(qobject_cast<HelperApp*>(parent())->user()));
5858
if (pw) {
5959
QProcessEnvironment env = m_app->session()->processEnvironment();
6060
env.insert("HOME", pw->pw_dir);

src/helper/UserSession.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace SDDM {
110110
}
111111
}
112112

113-
const char *username = qobject_cast<HelperApp*>(parent())->user().toLocal8Bit();
113+
const char *username = qUtf8Printable(qobject_cast<HelperApp*>(parent())->user());
114114
struct passwd *pw = getpwnam(username);
115115
if (setgid(pw->pw_gid) != 0) {
116116
qCritical() << "setgid(" << pw->pw_gid << ") failed for user: " << username;

src/helper/backend/PamHandle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace SDDM {
142142
if (user.isEmpty())
143143
m_result = pam_start(qPrintable(service), NULL, &m_conv, &m_handle);
144144
else
145-
m_result = pam_start(qPrintable(service), qPrintable(user), &m_conv, &m_handle);
145+
m_result = pam_start(qPrintable(service), qUtf8Printable(user), &m_conv, &m_handle);
146146
if (m_result != PAM_SUCCESS) {
147147
qWarning() << "[PAM] start" << pam_strerror(m_handle, m_result);
148148
return false;

src/helper/backend/PasswdBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace SDDM {
6666
}
6767
}
6868

69-
struct passwd *pw = getpwnam(qPrintable(m_user));
69+
struct passwd *pw = getpwnam(qUtf8Printable(m_user));
7070
if (!pw) {
7171
m_app->error(QString("Wrong user/password combination"), Auth::ERROR_AUTHENTICATION);
7272
return false;

0 commit comments

Comments
 (0)