Skip to content

Commit 6a0e0f7

Browse files
committed
Set pam items depending on session type
Set PAM_XDISPLAY only for x11 and in that case set PAM_TTY to the display, and set PAM_TTY to the VT for wayland sessions. Issue: #419
1 parent 1c59688 commit 6a0e0f7

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/helper/backend/PamBackend.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,21 @@ namespace SDDM {
248248
m_app->error(m_pam->errorString(), Auth::ERROR_AUTHENTICATION);
249249
return false;
250250
}
251+
251252
QProcessEnvironment sessionEnv = m_app->session()->processEnvironment();
252-
QString display = sessionEnv.value("DISPLAY");
253-
if (!display.isEmpty()) {
253+
if (sessionEnv.value("XDG_SESSION_TYPE") == QStringLiteral("x11")) {
254+
QString display = sessionEnv.value("DISPLAY");
255+
if (!display.isEmpty()) {
254256
#ifdef PAM_XDISPLAY
255-
m_pam->setItem(PAM_XDISPLAY, qPrintable(display));
257+
m_pam->setItem(PAM_XDISPLAY, qPrintable(display));
256258
#endif
257-
m_pam->setItem(PAM_TTY, qPrintable(display));
259+
m_pam->setItem(PAM_TTY, qPrintable(display));
260+
}
261+
} else if (sessionEnv.value("XDG_SESSION_TYPE") == QStringLiteral("wayland")) {
262+
QString tty = QString("/dev/tty%1").arg(sessionEnv.value("XDG_VTNR"));
263+
m_pam->setItem(PAM_TTY, qPrintable(tty));
258264
}
265+
259266
if (!m_pam->putEnv(sessionEnv)) {
260267
m_app->error(m_pam->errorString(), Auth::ERROR_INTERNAL);
261268
return false;

0 commit comments

Comments
 (0)