Update to snapshot release and use Wayland by default

- Update to snapshot release
- Drop upstreamed patches
- Drop Xauth patch due to inability to apply it
- Update status on remaining patches
- Add support for using a Wayland greeter
- Clean up Wayland conditionals
epel9
Neal Gompa 3 years ago
parent 9a6847db53
commit 88af790e7e

3
.gitignore vendored

@ -5,3 +5,6 @@
/0035-Prevent-duplicate-session-name.patch
/0037-Fix-build.patch
/sddm-0.19.0.tar.gz
/sddm-bfdb51415020962513c2a51ae836297cd8a60016.tar.gz
/sddm-6b8e837f3c1c0339c10db6719b1f33aa662a80ed.tar.gz
/sddm-85cbf3f2cda66f8deadea5f1e2e627a466aba885.tar.gz

@ -1,4 +1,4 @@
From 77a1f3148f515ae7c9b65f45dafe85bc58348ff9 Mon Sep 17 00:00:00 2001
From 57f91b5f23fcaacaaafd5d8263f65ed58d0cdf15 Mon Sep 17 00:00:00 2001
From: Jeremy Linton <jeremy.linton@arm.com>
Date: Fri, 22 Oct 2021 14:51:54 -0500
Subject: [PATCH] Delay for logind, and fallback to seat0
@ -13,7 +13,7 @@ if none of the seats appear to be graphical. Presumably
there are some graphics on the machine, otherwise
why run sddm? Wait a bit, and create seat0 anyway. If
this fails the output from Xorg should tell us why. This
is generally a better strategy than what happens a goodly
is generally a better strategy than what happens a good
amount of time now, where sddm is started and silent about
why the screen is blank.
@ -25,7 +25,7 @@ Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
3 files changed, 44 insertions(+), 10 deletions(-)
diff --git a/src/daemon/LogindDBusTypes.cpp b/src/daemon/LogindDBusTypes.cpp
index 011bb7f..e19f1db 100644
index 011bb7f..6255c69 100644
--- a/src/daemon/LogindDBusTypes.cpp
+++ b/src/daemon/LogindDBusTypes.cpp
@@ -8,6 +8,8 @@
@ -51,9 +51,9 @@ index 011bb7f..e19f1db 100644
- sessionIfaceName = QStringLiteral("org.freedesktop.login1.Session");
- userIfaceName = QStringLiteral("org.freedesktop.login1.User");
- return;
+ // Fedora _should_ have a systemd-logind running, although because it takes a few moments to restart after
+ // systemctl isolate calls, it may not yet be running. Wait a few seconds for it, while blocking everything else.
+#ifdef HAVE_SYSTEMD
+ // systemd-logind should be running, although because it takes a few moments to restart after
+ // systemctl isolate calls, it may not yet be running. Wait a few seconds for it, while blocking everything else.
+ int logind_wait_seconds = 50;
+ while (logind_wait_seconds--) {
+ if (QDBusConnection::systemBus().interface()->isServiceRegistered(QStringLiteral("org.freedesktop.login1"))) {
@ -134,5 +134,5 @@ index b2f9796..aa43047 100644
}
--
2.32.0
2.33.1

@ -1,637 +0,0 @@
From 592ad41960589ea537c3641e39b8947d77389026 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Wed, 21 Aug 2019 16:32:03 +0200
Subject: [PATCH] Redesign Xauth handling
This commit moves Xauthority handling over to libXau.
Advantage is that this allows use of FamilyWild, is faster, more reliable
and easier to read. However, we lose the ability to merge the new cookie into
an existing Xauthority file, so support for using a non-temporary file is
dropped. Even if merging was implemented manually, use of FamilyWild would
"infect" such a file and break it for DMs which don't write it.
---
CMakeLists.txt | 3 ++
data/man/sddm.conf.rst.in | 8 ----
data/man/sddm.rst.in | 4 ++
src/auth/Auth.cpp | 6 +--
src/auth/Auth.h | 6 +--
src/common/Configuration.h | 2 -
src/common/XauthUtils.cpp | 82 ++++++++++++++++++++++++++++++++
src/common/XauthUtils.h | 16 +++++++
src/daemon/CMakeLists.txt | 3 ++
src/daemon/XorgDisplayServer.cpp | 45 ++----------------
src/daemon/XorgDisplayServer.h | 4 +-
src/helper/Backend.cpp | 7 ---
src/helper/CMakeLists.txt | 8 +++-
src/helper/HelperApp.cpp | 4 +-
src/helper/HelperApp.h | 4 +-
src/helper/UserSession.cpp | 67 +++++++++++++-------------
src/helper/UserSession.h | 2 +
17 files changed, 166 insertions(+), 105 deletions(-)
create mode 100644 src/common/XauthUtils.cpp
create mode 100644 src/common/XauthUtils.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e52e0e9..fc3f2ce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -88,6 +88,9 @@ add_feature_info("PAM" PAM_FOUND "PAM support")
include(CheckFunctionExists)
check_function_exists(getspnam HAVE_GETSPNAM)
+# XAU
+pkg_check_modules(LIBXAU REQUIRED "xau")
+
# XCB
find_package(XCB REQUIRED)
diff --git a/data/man/sddm.conf.rst.in b/data/man/sddm.conf.rst.in
index bee0768..e91280a 100644
--- a/data/man/sddm.conf.rst.in
+++ b/data/man/sddm.conf.rst.in
@@ -110,10 +110,6 @@ OPTIONS
Path of the Xephyr.
Default value is "/usr/bin/Xephyr".
-`XauthPath=`
- Path of the Xauth.
- Default value is "/usr/bin/xauth".
-
`SessionDir=`
Path of the directory containing session files.
Default value is "/usr/share/xsessions".
@@ -128,10 +124,6 @@ OPTIONS
Path to the user session log file, relative to the home directory.
Default value is ".local/share/sddm/xorg-session.log".
-`UserAuthFile=`
- Path to the Xauthority file, relative to the home directory.
- Default value is ".Xauthority".
-
`DisplayCommand=`
Path of script to execute when starting the display server.
Default value is "@DATA_INSTALL_DIR@/scripts/Xsetup".
diff --git a/data/man/sddm.rst.in b/data/man/sddm.rst.in
index 6403368..a542e3b 100644
--- a/data/man/sddm.rst.in
+++ b/data/man/sddm.rst.in
@@ -34,6 +34,10 @@ Distributions without pam and systemd will need to put the **sddm** user
into the **video** group, otherwise errors regarding GL and drm devices
might be experienced.
+For X11 sessions, the cookie for X authorization is written into a
+temporary file inside @RUNTIME_DIR@, owned and only accessible by the
+user.
+
OPTIONS
=======
diff --git a/src/auth/Auth.cpp b/src/auth/Auth.cpp
index caca314..c2228ae 100644
--- a/src/auth/Auth.cpp
+++ b/src/auth/Auth.cpp
@@ -64,7 +64,7 @@ namespace SDDM {
QLocalSocket *socket { nullptr };
QString sessionPath { };
QString user { };
- QString cookie { };
+ QByteArray cookie { };
bool autologin { false };
bool greeter { false };
QProcessEnvironment environment { };
@@ -266,7 +266,7 @@ namespace SDDM {
return d->greeter;
}
- const QString& Auth::cookie() const {
+ const QByteArray& Auth::cookie() const {
return d->cookie;
}
@@ -298,7 +298,7 @@ namespace SDDM {
d->environment.insert(key, value);
}
- void Auth::setCookie(const QString& cookie) {
+ void Auth::setCookie(const QByteArray& cookie) {
if (cookie != d->cookie) {
d->cookie = cookie;
Q_EMIT cookieChanged();
diff --git a/src/auth/Auth.h b/src/auth/Auth.h
index 87f5f44..38d63fc 100644
--- a/src/auth/Auth.h
+++ b/src/auth/Auth.h
@@ -54,7 +54,7 @@ namespace SDDM {
Q_PROPERTY(bool autologin READ autologin WRITE setAutologin NOTIFY autologinChanged)
Q_PROPERTY(bool greeter READ isGreeter WRITE setGreeter NOTIFY greeterChanged)
Q_PROPERTY(bool verbose READ verbose WRITE setVerbose NOTIFY verboseChanged)
- Q_PROPERTY(QString cookie READ cookie WRITE setCookie NOTIFY cookieChanged)
+ Q_PROPERTY(QByteArray cookie READ cookie WRITE setCookie NOTIFY cookieChanged)
Q_PROPERTY(QString user READ user WRITE setUser NOTIFY userChanged)
Q_PROPERTY(QString session READ session WRITE setSession NOTIFY sessionChanged)
Q_PROPERTY(AuthRequest* request READ request NOTIFY requestChanged)
@@ -90,7 +90,7 @@ namespace SDDM {
bool autologin() const;
bool isGreeter() const;
bool verbose() const;
- const QString &cookie() const;
+ const QByteArray &cookie() const;
const QString &user() const;
const QString &session() const;
AuthRequest *request();
@@ -149,7 +149,7 @@ namespace SDDM {
* Set the display server cookie, to be inserted into the user's $XAUTHORITY
* @param cookie cookie data
*/
- void setCookie(const QString &cookie);
+ void setCookie(const QByteArray &cookie);
public Q_SLOTS:
/**
diff --git a/src/common/Configuration.h b/src/common/Configuration.h
index cf44a62..a7e0585 100644
--- a/src/common/Configuration.h
+++ b/src/common/Configuration.h
@@ -63,11 +63,9 @@ namespace SDDM {
Entry(ServerPath, QString, _S("/usr/bin/X"), _S("Path to X server binary"));
Entry(ServerArguments, QString, _S("-nolisten tcp"), _S("Arguments passed to the X server invocation"));
Entry(XephyrPath, QString, _S("/usr/bin/Xephyr"), _S("Path to Xephyr binary"));
- Entry(XauthPath, QString, _S("/usr/bin/xauth"), _S("Path to xauth binary"));
Entry(SessionDir, QString, _S("/usr/share/xsessions"), _S("Directory containing available X sessions"));
Entry(SessionCommand, QString, _S(SESSION_COMMAND), _S("Path to a script to execute when starting the desktop session"));
Entry(SessionLogFile, QString, _S(".local/share/sddm/xorg-session.log"), _S("Path to the user session log file"));
- Entry(UserAuthFile, QString, _S(".Xauthority"), _S("Path to the Xauthority file"));
Entry(DisplayCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xsetup"), _S("Path to a script to execute when starting the display server"));
Entry(DisplayStopCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xstop"), _S("Path to a script to execute when stopping the display server"));
Entry(MinimumVT, int, MINIMUM_VT, _S("The lowest virtual terminal number that will be used."));
diff --git a/src/common/XauthUtils.cpp b/src/common/XauthUtils.cpp
new file mode 100644
index 0000000..da1c691
--- /dev/null
+++ b/src/common/XauthUtils.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+ * SPDX-FileCopyrightText: 2020 Fabian Vogt <fvogt@suse.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ ***************************************************************************/
+
+#include <limits.h>
+#include <unistd.h>
+#include <X11/Xauth.h>
+
+#include <random>
+
+#include <QString>
+
+#include "XauthUtils.h"
+
+namespace SDDM { namespace Xauth {
+ QByteArray generateCookie()
+ {
+ std::random_device rd;
+ std::mt19937 gen(rd());
+ std::uniform_int_distribution<> dis(0, 0xFF);
+
+ QByteArray cookie;
+ cookie.reserve(16);
+
+ for(int i = 0; i < 16; i++)
+ cookie[i] = dis(gen);
+
+ return cookie;
+ }
+
+ bool writeCookieToFile(const QString &filename, const QString &display, QByteArray cookie)
+ {
+ if(display.size() < 2 || display[0] != QLatin1Char(':') || cookie.count() != 16)
+ return false;
+
+ // Truncate the file. We don't support merging like the xauth tool does.
+ FILE * const authFp = fopen(qPrintable(filename), "wb");
+ if (authFp == nullptr)
+ return false;
+
+ char localhost[HOST_NAME_MAX + 1] = "";
+ if (gethostname(localhost, HOST_NAME_MAX) < 0)
+ strcpy(localhost, "localhost");
+
+ ::Xauth auth = {};
+ char cookieName[] = "MIT-MAGIC-COOKIE-1";
+
+ // Skip the ':'
+ QByteArray displayNumberUtf8 = display.midRef(1).toUtf8();
+
+ auth.family = FamilyLocal;
+ auth.address = localhost;
+ auth.address_length = strlen(auth.address);
+ auth.number = displayNumberUtf8.data();
+ auth.number_length = displayNumberUtf8.size();
+ auth.name = cookieName;
+ auth.name_length = sizeof(cookieName) - 1;
+ auth.data = cookie.data();
+ auth.data_length = cookie.count();
+
+ if (XauWriteAuth(authFp, &auth) == 0) {
+ fclose(authFp);
+ return false;
+ }
+
+ // Write the same entry again, just with FamilyWild
+ auth.family = FamilyWild;
+ auth.address_length = 0;
+ if (XauWriteAuth(authFp, &auth) == 0) {
+ fclose(authFp);
+ return false;
+ }
+
+ bool success = fflush(authFp) != EOF;
+
+ fclose(authFp);
+
+ return success;
+ }
+}}
diff --git a/src/common/XauthUtils.h b/src/common/XauthUtils.h
new file mode 100644
index 0000000..112d003
--- /dev/null
+++ b/src/common/XauthUtils.h
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#ifndef SDDM_XAUTHUTILS_H
+#define SDDM_XAUTHUTILS_H
+
+class QString;
+class QByteArray;
+
+namespace SDDM {
+ namespace Xauth {
+ QByteArray generateCookie();
+ bool writeCookieToFile(const QString &filename, const QString &display, QByteArray cookie);
+ }
+}
+
+#endif // SDDM_XAUTHUTILS_H
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt
index 86d014b..9145607 100644
--- a/src/daemon/CMakeLists.txt
+++ b/src/daemon/CMakeLists.txt
@@ -2,6 +2,7 @@ include_directories(
"${CMAKE_SOURCE_DIR}/src/common"
"${CMAKE_SOURCE_DIR}/src/auth"
"${CMAKE_BINARY_DIR}/src/common"
+ ${LIBXAU_INCLUDE_DIRS}
"${LIBXCB_INCLUDE_DIR}"
)
@@ -13,6 +14,7 @@ set(DAEMON_SOURCES
${CMAKE_SOURCE_DIR}/src/common/ThemeMetadata.cpp
${CMAKE_SOURCE_DIR}/src/common/Session.cpp
${CMAKE_SOURCE_DIR}/src/common/SocketWriter.cpp
+ ${CMAKE_SOURCE_DIR}/src/common/XauthUtils.cpp
${CMAKE_SOURCE_DIR}/src/auth/Auth.cpp
${CMAKE_SOURCE_DIR}/src/auth/AuthPrompt.cpp
${CMAKE_SOURCE_DIR}/src/auth/AuthRequest.cpp
@@ -64,6 +66,7 @@ target_link_libraries(sddm
Qt5::DBus
Qt5::Network
Qt5::Qml
+ ${LIBXAU_LIBRARIES}
${LIBXCB_LIBRARIES})
if(PAM_FOUND)
target_link_libraries(sddm ${PAM_LIBRARIES})
diff --git a/src/daemon/XorgDisplayServer.cpp b/src/daemon/XorgDisplayServer.cpp
index 5f93a1b..148ebcc 100644
--- a/src/daemon/XorgDisplayServer.cpp
+++ b/src/daemon/XorgDisplayServer.cpp
@@ -25,6 +25,7 @@
#include "Display.h"
#include "SignalHandler.h"
#include "Seat.h"
+#include "XauthUtils.h"
#include <QDebug>
#include <QFile>
@@ -55,17 +56,7 @@ namespace SDDM {
m_authPath = QStringLiteral("%1/%2").arg(authDir).arg(QUuid::createUuid().toString());
// generate cookie
- std::random_device rd;
- std::mt19937 gen(rd());
- std::uniform_int_distribution<> dis(0, 15);
-
- // resever 32 bytes
- m_cookie.reserve(32);
-
- // create a random hexadecimal number
- const char *digits = "0123456789abcdef";
- for (int i = 0; i < 32; ++i)
- m_cookie[i] = digits[dis(gen)];
+ m_cookie = Xauth::generateCookie();
}
XorgDisplayServer::~XorgDisplayServer() {
@@ -84,35 +75,10 @@ namespace SDDM {
return QStringLiteral("x11");
}
- const QString &XorgDisplayServer::cookie() const {
+ const QByteArray &XorgDisplayServer::cookie() const {
return m_cookie;
}
- bool XorgDisplayServer::addCookie(const QString &file) {
- // log message
- qDebug() << "Adding cookie to" << file;
-
- // Touch file
- QFile file_handler(file);
- file_handler.open(QIODevice::Append);
- file_handler.close();
-
- QString cmd = QStringLiteral("%1 -f %2 -q").arg(mainConfig.X11.XauthPath.get()).arg(file);
-
- // execute xauth
- FILE *fp = popen(qPrintable(cmd), "w");
-
- // check file
- if (!fp)
- return false;
- fprintf(fp, "remove %s\n", qPrintable(m_display));
- fprintf(fp, "add %s . %s\n", qPrintable(m_display), qPrintable(m_cookie));
- fprintf(fp, "exit\n");
-
- // close pipe
- return pclose(fp) == 0;
- }
-
bool XorgDisplayServer::start() {
// check flag
if (m_started)
@@ -130,8 +96,7 @@ namespace SDDM {
// generate auth file.
// For the X server's copy, the display number doesn't matter.
// An empty file would result in no access control!
- m_display = QStringLiteral(":0");
- if(!addCookie(m_authPath)) {
+ if(!Xauth::writeCookieToFile(m_authPath, QStringLiteral(":0"), m_cookie)) {
qCritical() << "Failed to write xauth file";
return false;
}
@@ -229,7 +194,7 @@ namespace SDDM {
// The file is also used by the greeter, which does care about the
// display number. Write the proper entry, if it's different.
if(m_display != QStringLiteral(":0")) {
- if(!addCookie(m_authPath)) {
+ if(!Xauth::writeCookieToFile(m_authPath, m_display, m_cookie)) {
qCritical() << "Failed to write xauth file";
return false;
}
diff --git a/src/daemon/XorgDisplayServer.h b/src/daemon/XorgDisplayServer.h
index e97a0b5..05e0a4c 100644
--- a/src/daemon/XorgDisplayServer.h
+++ b/src/daemon/XorgDisplayServer.h
@@ -38,7 +38,7 @@ namespace SDDM {
QString sessionType() const;
- const QString &cookie() const;
+ const QByteArray &cookie() const;
bool addCookie(const QString &file);
@@ -50,7 +50,7 @@ namespace SDDM {
private:
QString m_authPath;
- QString m_cookie;
+ QByteArray m_cookie;
QProcess *process { nullptr };
diff --git a/src/helper/Backend.cpp b/src/helper/Backend.cpp
index a324b39..a053310 100644
--- a/src/helper/Backend.cpp
+++ b/src/helper/Backend.cpp
@@ -68,13 +68,6 @@ namespace SDDM {
env.insert(QStringLiteral("SHELL"), QString::fromLocal8Bit(pw->pw_shell));
env.insert(QStringLiteral("USER"), QString::fromLocal8Bit(pw->pw_name));
env.insert(QStringLiteral("LOGNAME"), QString::fromLocal8Bit(pw->pw_name));
- if (env.contains(QStringLiteral("DISPLAY")) && !env.contains(QStringLiteral("XAUTHORITY"))) {
- // determine Xauthority path
- QString value = QStringLiteral("%1/%2")
- .arg(QString::fromLocal8Bit(pw->pw_dir))
- .arg(mainConfig.X11.UserAuthFile.get());
- env.insert(QStringLiteral("XAUTHORITY"), value);
- }
#if defined(Q_OS_FREEBSD)
/* get additional environment variables via setclassenvironment();
this needs to be done here instead of in UserSession::setupChildProcess
diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt
index 8914ea7..81b939b 100644
--- a/src/helper/CMakeLists.txt
+++ b/src/helper/CMakeLists.txt
@@ -3,6 +3,7 @@ include(CheckLibraryExists)
include_directories(
"${CMAKE_SOURCE_DIR}/src/common"
"${CMAKE_SOURCE_DIR}/src/auth"
+ ${LIBXAU_INCLUDE_DIRS}
)
include_directories("${CMAKE_BINARY_DIR}/src/common")
@@ -10,6 +11,7 @@ set(HELPER_SOURCES
${CMAKE_SOURCE_DIR}/src/common/Configuration.cpp
${CMAKE_SOURCE_DIR}/src/common/ConfigReader.cpp
${CMAKE_SOURCE_DIR}/src/common/SafeDataStream.cpp
+ ${CMAKE_SOURCE_DIR}/src/common/XauthUtils.cpp
Backend.cpp
HelperApp.cpp
UserSession.cpp
@@ -41,7 +43,11 @@ else()
endif()
add_executable(sddm-helper ${HELPER_SOURCES})
-target_link_libraries(sddm-helper Qt5::Network Qt5::DBus Qt5::Qml)
+target_link_libraries(sddm-helper
+ Qt5::Network
+ Qt5::DBus
+ Qt5::Qml
+ ${LIBXAU_LIBRARIES})
if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
# On FreeBSD (possibly other BSDs as well), we want to use
# setusercontext() to set up the login configuration from login.conf
diff --git a/src/helper/HelperApp.cpp b/src/helper/HelperApp.cpp
index 672359a..4ad9cbd 100644
--- a/src/helper/HelperApp.cpp
+++ b/src/helper/HelperApp.cpp
@@ -237,7 +237,7 @@ namespace SDDM {
str >> m >> env >> m_cookie;
if (m != AUTHENTICATED) {
env = QProcessEnvironment();
- m_cookie = QString();
+ m_cookie = {};
qCritical() << "Received a wrong opcode instead of AUTHENTICATED:" << m;
}
return env;
@@ -263,7 +263,7 @@ namespace SDDM {
return m_user;
}
- const QString& HelperApp::cookie() const {
+ const QByteArray& HelperApp::cookie() const {
return m_cookie;
}
diff --git a/src/helper/HelperApp.h b/src/helper/HelperApp.h
index 3742df1..d417494 100644
--- a/src/helper/HelperApp.h
+++ b/src/helper/HelperApp.h
@@ -40,7 +40,7 @@ namespace SDDM {
UserSession *session();
const QString &user() const;
- const QString &cookie() const;
+ const QByteArray &cookie() const;
public slots:
Request request(const Request &request);
@@ -62,7 +62,7 @@ namespace SDDM {
QLocalSocket *m_socket { nullptr };
QString m_user { };
// TODO: get rid of this in a nice clean way along the way with moving to user session X server
- QString m_cookie { };
+ QByteArray m_cookie { };
/*!
\brief Write utmp/wtmp/btmp records when a user logs in
diff --git a/src/helper/UserSession.cpp b/src/helper/UserSession.cpp
index c9a8a20..4096edc 100644
--- a/src/helper/UserSession.cpp
+++ b/src/helper/UserSession.cpp
@@ -20,9 +20,11 @@
*/
#include "Configuration.h"
+#include "Constants.h"
#include "UserSession.h"
#include "HelperApp.h"
#include "VirtualTerminal.h"
+#include "XauthUtils.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -45,11 +47,35 @@ namespace SDDM {
}
bool UserSession::start() {
- QProcessEnvironment env = qobject_cast<HelperApp*>(parent())->session()->processEnvironment();
+ QProcessEnvironment env = processEnvironment();
if (env.value(QStringLiteral("XDG_SESSION_CLASS")) == QLatin1String("greeter")) {
QProcess::start(m_path);
} else if (env.value(QStringLiteral("XDG_SESSION_TYPE")) == QLatin1String("x11")) {
+ // Create the Xauthority file
+ QByteArray cookie = qobject_cast<HelperApp*>(parent())->cookie();
+ if (cookie.isEmpty())
+ return false;
+
+ m_xauthFile.setFileTemplate(QStringLiteral(RUNTIME_DIR "/xauth_XXXXXX"));
+
+ if (!m_xauthFile.open()) {
+ qCritical() << "Could not create the Xauthority file";
+ return false;
+ }
+
+ QString display = processEnvironment().value(QStringLiteral("DISPLAY"));
+ qDebug() << "Adding cookie to" << m_xauthFile.fileName();
+
+ if (!Xauth::writeCookieToFile(m_xauthFile.fileName(), display, cookie)) {
+ qCritical() << "Failed to write the Xauthority file";
+ m_xauthFile.close();
+ return false;
+ }
+
+ env.insert(QStringLiteral("XAUTHORITY"), m_xauthFile.fileName());
+ setProcessEnvironment(env);
+
const QString cmd = QStringLiteral("%1 \"%2\"").arg(mainConfig.X11.SessionCommand.get()).arg(m_path);
qInfo() << "Starting:" << cmd;
QProcess::start(cmd);
@@ -155,6 +181,11 @@ namespace SDDM {
exit(Auth::HELPER_OTHER_ERROR);
}
+ const int xauthHandle = m_xauthFile.handle();
+ if (xauthHandle != -1 && fchown(xauthHandle, pw.pw_uid, pw.pw_gid) != 0) {
+ qCritical() << "fchown failed for" << m_xauthFile.fileName();
+ exit(Auth::HELPER_OTHER_ERROR);
+ }
#ifdef USE_PAM
// fetch ambient groups from PAM's environment;
@@ -259,40 +290,6 @@ namespace SDDM {
} else {
qWarning() << "Could not redirect stdout";
}
-
- // set X authority for X11 sessions only
- if (sessionType != QLatin1String("x11"))
- return;
- QString cookie = qobject_cast<HelperApp*>(parent())->cookie();
- if (!cookie.isEmpty()) {
- QString file = processEnvironment().value(QStringLiteral("XAUTHORITY"));
- QString display = processEnvironment().value(QStringLiteral("DISPLAY"));
- qDebug() << "Adding cookie to" << file;
-
-
- // create the path
- QFileInfo finfo(file);
- QDir().mkpath(finfo.absolutePath());
-
- QFile file_handler(file);
- file_handler.open(QIODevice::Append);
- file_handler.close();
-
- QString cmd = QStringLiteral("%1 -f %2 -q").arg(mainConfig.X11.XauthPath.get()).arg(file);
-
- // execute xauth
- FILE *fp = popen(qPrintable(cmd), "w");
-
- // check file
- if (!fp)
- return;
- fprintf(fp, "remove %s\n", qPrintable(display));
- fprintf(fp, "add %s . %s\n", qPrintable(display), qPrintable(cookie));
- fprintf(fp, "exit\n");
-
- // close pipe
- pclose(fp);
- }
}
void UserSession::setCachedProcessId(qint64 pid) {
diff --git a/src/helper/UserSession.h b/src/helper/UserSession.h
index 7069084..0ae627d 100644
--- a/src/helper/UserSession.h
+++ b/src/helper/UserSession.h
@@ -25,6 +25,7 @@
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QProcess>
+#include <QtCore/QTemporaryFile>
namespace SDDM {
class HelperApp;
@@ -59,6 +60,7 @@ namespace SDDM {
private:
QString m_path { };
qint64 m_cachedProcessId;
+ QTemporaryFile m_xauthFile;
};
}
--
2.29.2

@ -1,619 +0,0 @@
From fbdf20d59d1c63cd2b8fd78efb3125478a2ea07c Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Wed, 21 Aug 2019 16:32:03 +0200
Subject: [PATCH] Redesign Xauth handling
This commit moves Xauthority handling over to libXau.
Advantage is that this allows use of FamilyWild, is faster, more reliable
and easier to read. However, we lose the ability to merge the new cookie into
an existing Xauthority file, so support for using a non-temporary file is
dropped. Even if merging was implemented manually, use of FamilyWild would
"infect" such a file and break it for DMs which don't write it.
Unfortunately, a hack in UserSession is required to get XAUTHORITY into
the process environment. The Xauthority file has to be created as the target
user, but that's only possible in setupChildProcess(). In there, changes to
processEnvironment() to set XAUTHORITY to the generated path are not effective,
so configure the process to inherit the environment instead and use qputenv.
---
CMakeLists.txt | 3 ++
data/man/sddm.conf.rst.in | 8 ----
src/auth/Auth.cpp | 6 +--
src/auth/Auth.h | 6 +--
src/common/Configuration.h | 2 -
src/common/XauthUtils.cpp | 82 ++++++++++++++++++++++++++++++++
src/common/XauthUtils.h | 16 +++++++
src/daemon/CMakeLists.txt | 3 ++
src/daemon/XorgDisplayServer.cpp | 45 ++----------------
src/daemon/XorgDisplayServer.h | 4 +-
src/helper/Backend.cpp | 7 ---
src/helper/CMakeLists.txt | 8 +++-
src/helper/HelperApp.cpp | 4 +-
src/helper/HelperApp.h | 4 +-
src/helper/UserSession.cpp | 53 +++++++++++----------
src/helper/UserSession.h | 9 ++++
16 files changed, 165 insertions(+), 95 deletions(-)
create mode 100644 src/common/XauthUtils.cpp
create mode 100644 src/common/XauthUtils.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e52e0e9..fc3f2ce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -88,6 +88,9 @@ add_feature_info("PAM" PAM_FOUND "PAM support")
include(CheckFunctionExists)
check_function_exists(getspnam HAVE_GETSPNAM)
+# XAU
+pkg_check_modules(LIBXAU REQUIRED "xau")
+
# XCB
find_package(XCB REQUIRED)
diff --git a/data/man/sddm.conf.rst.in b/data/man/sddm.conf.rst.in
index bee0768..e91280a 100644
--- a/data/man/sddm.conf.rst.in
+++ b/data/man/sddm.conf.rst.in
@@ -110,10 +110,6 @@ OPTIONS
Path of the Xephyr.
Default value is "/usr/bin/Xephyr".
-`XauthPath=`
- Path of the Xauth.
- Default value is "/usr/bin/xauth".
-
`SessionDir=`
Path of the directory containing session files.
Default value is "/usr/share/xsessions".
@@ -128,10 +124,6 @@ OPTIONS
Path to the user session log file, relative to the home directory.
Default value is ".local/share/sddm/xorg-session.log".
-`UserAuthFile=`
- Path to the Xauthority file, relative to the home directory.
- Default value is ".Xauthority".
-
`DisplayCommand=`
Path of script to execute when starting the display server.
Default value is "@DATA_INSTALL_DIR@/scripts/Xsetup".
diff --git a/src/auth/Auth.cpp b/src/auth/Auth.cpp
index caca314..c2228ae 100644
--- a/src/auth/Auth.cpp
+++ b/src/auth/Auth.cpp
@@ -64,7 +64,7 @@ namespace SDDM {
QLocalSocket *socket { nullptr };
QString sessionPath { };
QString user { };
- QString cookie { };
+ QByteArray cookie { };
bool autologin { false };
bool greeter { false };
QProcessEnvironment environment { };
@@ -266,7 +266,7 @@ namespace SDDM {
return d->greeter;
}
- const QString& Auth::cookie() const {
+ const QByteArray& Auth::cookie() const {
return d->cookie;
}
@@ -298,7 +298,7 @@ namespace SDDM {
d->environment.insert(key, value);
}
- void Auth::setCookie(const QString& cookie) {
+ void Auth::setCookie(const QByteArray& cookie) {
if (cookie != d->cookie) {
d->cookie = cookie;
Q_EMIT cookieChanged();
diff --git a/src/auth/Auth.h b/src/auth/Auth.h
index 87f5f44..38d63fc 100644
--- a/src/auth/Auth.h
+++ b/src/auth/Auth.h
@@ -54,7 +54,7 @@ namespace SDDM {
Q_PROPERTY(bool autologin READ autologin WRITE setAutologin NOTIFY autologinChanged)
Q_PROPERTY(bool greeter READ isGreeter WRITE setGreeter NOTIFY greeterChanged)
Q_PROPERTY(bool verbose READ verbose WRITE setVerbose NOTIFY verboseChanged)
- Q_PROPERTY(QString cookie READ cookie WRITE setCookie NOTIFY cookieChanged)
+ Q_PROPERTY(QByteArray cookie READ cookie WRITE setCookie NOTIFY cookieChanged)
Q_PROPERTY(QString user READ user WRITE setUser NOTIFY userChanged)
Q_PROPERTY(QString session READ session WRITE setSession NOTIFY sessionChanged)
Q_PROPERTY(AuthRequest* request READ request NOTIFY requestChanged)
@@ -90,7 +90,7 @@ namespace SDDM {
bool autologin() const;
bool isGreeter() const;
bool verbose() const;
- const QString &cookie() const;
+ const QByteArray &cookie() const;
const QString &user() const;
const QString &session() const;
AuthRequest *request();
@@ -149,7 +149,7 @@ namespace SDDM {
* Set the display server cookie, to be inserted into the user's $XAUTHORITY
* @param cookie cookie data
*/
- void setCookie(const QString &cookie);
+ void setCookie(const QByteArray &cookie);
public Q_SLOTS:
/**
diff --git a/src/common/Configuration.h b/src/common/Configuration.h
index cf44a62..a7e0585 100644
--- a/src/common/Configuration.h
+++ b/src/common/Configuration.h
@@ -63,11 +63,9 @@ namespace SDDM {
Entry(ServerPath, QString, _S("/usr/bin/X"), _S("Path to X server binary"));
Entry(ServerArguments, QString, _S("-nolisten tcp"), _S("Arguments passed to the X server invocation"));
Entry(XephyrPath, QString, _S("/usr/bin/Xephyr"), _S("Path to Xephyr binary"));
- Entry(XauthPath, QString, _S("/usr/bin/xauth"), _S("Path to xauth binary"));
Entry(SessionDir, QString, _S("/usr/share/xsessions"), _S("Directory containing available X sessions"));
Entry(SessionCommand, QString, _S(SESSION_COMMAND), _S("Path to a script to execute when starting the desktop session"));
Entry(SessionLogFile, QString, _S(".local/share/sddm/xorg-session.log"), _S("Path to the user session log file"));
- Entry(UserAuthFile, QString, _S(".Xauthority"), _S("Path to the Xauthority file"));
Entry(DisplayCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xsetup"), _S("Path to a script to execute when starting the display server"));
Entry(DisplayStopCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xstop"), _S("Path to a script to execute when stopping the display server"));
Entry(MinimumVT, int, MINIMUM_VT, _S("The lowest virtual terminal number that will be used."));
diff --git a/src/common/XauthUtils.cpp b/src/common/XauthUtils.cpp
new file mode 100644
index 0000000..da1c691
--- /dev/null
+++ b/src/common/XauthUtils.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+ * SPDX-FileCopyrightText: 2020 Fabian Vogt <fvogt@suse.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ ***************************************************************************/
+
+#include <limits.h>
+#include <unistd.h>
+#include <X11/Xauth.h>
+
+#include <random>
+
+#include <QString>
+
+#include "XauthUtils.h"
+
+namespace SDDM { namespace Xauth {
+ QByteArray generateCookie()
+ {
+ std::random_device rd;
+ std::mt19937 gen(rd());
+ std::uniform_int_distribution<> dis(0, 0xFF);
+
+ QByteArray cookie;
+ cookie.reserve(16);
+
+ for(int i = 0; i < 16; i++)
+ cookie[i] = dis(gen);
+
+ return cookie;
+ }
+
+ bool writeCookieToFile(const QString &filename, const QString &display, QByteArray cookie)
+ {
+ if(display.size() < 2 || display[0] != QLatin1Char(':') || cookie.count() != 16)
+ return false;
+
+ // Truncate the file. We don't support merging like the xauth tool does.
+ FILE * const authFp = fopen(qPrintable(filename), "wb");
+ if (authFp == nullptr)
+ return false;
+
+ char localhost[HOST_NAME_MAX + 1] = "";
+ if (gethostname(localhost, HOST_NAME_MAX) < 0)
+ strcpy(localhost, "localhost");
+
+ ::Xauth auth = {};
+ char cookieName[] = "MIT-MAGIC-COOKIE-1";
+
+ // Skip the ':'
+ QByteArray displayNumberUtf8 = display.midRef(1).toUtf8();
+
+ auth.family = FamilyLocal;
+ auth.address = localhost;
+ auth.address_length = strlen(auth.address);
+ auth.number = displayNumberUtf8.data();
+ auth.number_length = displayNumberUtf8.size();
+ auth.name = cookieName;
+ auth.name_length = sizeof(cookieName) - 1;
+ auth.data = cookie.data();
+ auth.data_length = cookie.count();
+
+ if (XauWriteAuth(authFp, &auth) == 0) {
+ fclose(authFp);
+ return false;
+ }
+
+ // Write the same entry again, just with FamilyWild
+ auth.family = FamilyWild;
+ auth.address_length = 0;
+ if (XauWriteAuth(authFp, &auth) == 0) {
+ fclose(authFp);
+ return false;
+ }
+
+ bool success = fflush(authFp) != EOF;
+
+ fclose(authFp);
+
+ return success;
+ }
+}}
diff --git a/src/common/XauthUtils.h b/src/common/XauthUtils.h
new file mode 100644
index 0000000..112d003
--- /dev/null
+++ b/src/common/XauthUtils.h
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#ifndef SDDM_XAUTHUTILS_H
+#define SDDM_XAUTHUTILS_H
+
+class QString;
+class QByteArray;
+
+namespace SDDM {
+ namespace Xauth {
+ QByteArray generateCookie();
+ bool writeCookieToFile(const QString &filename, const QString &display, QByteArray cookie);
+ }
+}
+
+#endif // SDDM_XAUTHUTILS_H
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt
index 86d014b..9145607 100644
--- a/src/daemon/CMakeLists.txt
+++ b/src/daemon/CMakeLists.txt
@@ -2,6 +2,7 @@ include_directories(
"${CMAKE_SOURCE_DIR}/src/common"
"${CMAKE_SOURCE_DIR}/src/auth"
"${CMAKE_BINARY_DIR}/src/common"
+ ${LIBXAU_INCLUDE_DIRS}
"${LIBXCB_INCLUDE_DIR}"
)
@@ -13,6 +14,7 @@ set(DAEMON_SOURCES
${CMAKE_SOURCE_DIR}/src/common/ThemeMetadata.cpp
${CMAKE_SOURCE_DIR}/src/common/Session.cpp
${CMAKE_SOURCE_DIR}/src/common/SocketWriter.cpp
+ ${CMAKE_SOURCE_DIR}/src/common/XauthUtils.cpp
${CMAKE_SOURCE_DIR}/src/auth/Auth.cpp
${CMAKE_SOURCE_DIR}/src/auth/AuthPrompt.cpp
${CMAKE_SOURCE_DIR}/src/auth/AuthRequest.cpp
@@ -64,6 +66,7 @@ target_link_libraries(sddm
Qt5::DBus
Qt5::Network
Qt5::Qml
+ ${LIBXAU_LIBRARIES}
${LIBXCB_LIBRARIES})
if(PAM_FOUND)
target_link_libraries(sddm ${PAM_LIBRARIES})
diff --git a/src/daemon/XorgDisplayServer.cpp b/src/daemon/XorgDisplayServer.cpp
index 5f93a1b..148ebcc 100644
--- a/src/daemon/XorgDisplayServer.cpp
+++ b/src/daemon/XorgDisplayServer.cpp
@@ -25,6 +25,7 @@
#include "Display.h"
#include "SignalHandler.h"
#include "Seat.h"
+#include "XauthUtils.h"
#include <QDebug>
#include <QFile>
@@ -55,17 +56,7 @@ namespace SDDM {
m_authPath = QStringLiteral("%1/%2").arg(authDir).arg(QUuid::createUuid().toString());
// generate cookie
- std::random_device rd;
- std::mt19937 gen(rd());
- std::uniform_int_distribution<> dis(0, 15);
-
- // resever 32 bytes
- m_cookie.reserve(32);
-
- // create a random hexadecimal number
- const char *digits = "0123456789abcdef";
- for (int i = 0; i < 32; ++i)
- m_cookie[i] = digits[dis(gen)];
+ m_cookie = Xauth::generateCookie();
}
XorgDisplayServer::~XorgDisplayServer() {
@@ -84,35 +75,10 @@ namespace SDDM {
return QStringLiteral("x11");
}
- const QString &XorgDisplayServer::cookie() const {
+ const QByteArray &XorgDisplayServer::cookie() const {
return m_cookie;
}
- bool XorgDisplayServer::addCookie(const QString &file) {
- // log message
- qDebug() << "Adding cookie to" << file;
-
- // Touch file
- QFile file_handler(file);
- file_handler.open(QIODevice::Append);
- file_handler.close();
-
- QString cmd = QStringLiteral("%1 -f %2 -q").arg(mainConfig.X11.XauthPath.get()).arg(file);
-
- // execute xauth
- FILE *fp = popen(qPrintable(cmd), "w");
-
- // check file
- if (!fp)
- return false;
- fprintf(fp, "remove %s\n", qPrintable(m_display));
- fprintf(fp, "add %s . %s\n", qPrintable(m_display), qPrintable(m_cookie));
- fprintf(fp, "exit\n");
-
- // close pipe
- return pclose(fp) == 0;
- }
-
bool XorgDisplayServer::start() {
// check flag
if (m_started)
@@ -130,8 +96,7 @@ namespace SDDM {
// generate auth file.
// For the X server's copy, the display number doesn't matter.
// An empty file would result in no access control!
- m_display = QStringLiteral(":0");
- if(!addCookie(m_authPath)) {
+ if(!Xauth::writeCookieToFile(m_authPath, QStringLiteral(":0"), m_cookie)) {
qCritical() << "Failed to write xauth file";
return false;
}
@@ -229,7 +194,7 @@ namespace SDDM {
// The file is also used by the greeter, which does care about the
// display number. Write the proper entry, if it's different.
if(m_display != QStringLiteral(":0")) {
- if(!addCookie(m_authPath)) {
+ if(!Xauth::writeCookieToFile(m_authPath, m_display, m_cookie)) {
qCritical() << "Failed to write xauth file";
return false;
}
diff --git a/src/daemon/XorgDisplayServer.h b/src/daemon/XorgDisplayServer.h
index e97a0b5..05e0a4c 100644
--- a/src/daemon/XorgDisplayServer.h
+++ b/src/daemon/XorgDisplayServer.h
@@ -38,7 +38,7 @@ namespace SDDM {
QString sessionType() const;
- const QString &cookie() const;
+ const QByteArray &cookie() const;
bool addCookie(const QString &file);
@@ -50,7 +50,7 @@ namespace SDDM {
private:
QString m_authPath;
- QString m_cookie;
+ QByteArray m_cookie;
QProcess *process { nullptr };
diff --git a/src/helper/Backend.cpp b/src/helper/Backend.cpp
index a324b39..a053310 100644
--- a/src/helper/Backend.cpp
+++ b/src/helper/Backend.cpp
@@ -68,13 +68,6 @@ namespace SDDM {
env.insert(QStringLiteral("SHELL"), QString::fromLocal8Bit(pw->pw_shell));
env.insert(QStringLiteral("USER"), QString::fromLocal8Bit(pw->pw_name));
env.insert(QStringLiteral("LOGNAME"), QString::fromLocal8Bit(pw->pw_name));
- if (env.contains(QStringLiteral("DISPLAY")) && !env.contains(QStringLiteral("XAUTHORITY"))) {
- // determine Xauthority path
- QString value = QStringLiteral("%1/%2")
- .arg(QString::fromLocal8Bit(pw->pw_dir))
- .arg(mainConfig.X11.UserAuthFile.get());
- env.insert(QStringLiteral("XAUTHORITY"), value);
- }
#if defined(Q_OS_FREEBSD)
/* get additional environment variables via setclassenvironment();
this needs to be done here instead of in UserSession::setupChildProcess
diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt
index 8914ea7..81b939b 100644
--- a/src/helper/CMakeLists.txt
+++ b/src/helper/CMakeLists.txt
@@ -3,6 +3,7 @@ include(CheckLibraryExists)
include_directories(
"${CMAKE_SOURCE_DIR}/src/common"
"${CMAKE_SOURCE_DIR}/src/auth"
+ ${LIBXAU_INCLUDE_DIRS}
)
include_directories("${CMAKE_BINARY_DIR}/src/common")
@@ -10,6 +11,7 @@ set(HELPER_SOURCES
${CMAKE_SOURCE_DIR}/src/common/Configuration.cpp
${CMAKE_SOURCE_DIR}/src/common/ConfigReader.cpp
${CMAKE_SOURCE_DIR}/src/common/SafeDataStream.cpp
+ ${CMAKE_SOURCE_DIR}/src/common/XauthUtils.cpp
Backend.cpp
HelperApp.cpp
UserSession.cpp
@@ -41,7 +43,11 @@ else()
endif()
add_executable(sddm-helper ${HELPER_SOURCES})
-target_link_libraries(sddm-helper Qt5::Network Qt5::DBus Qt5::Qml)
+target_link_libraries(sddm-helper
+ Qt5::Network
+ Qt5::DBus
+ Qt5::Qml
+ ${LIBXAU_LIBRARIES})
if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
# On FreeBSD (possibly other BSDs as well), we want to use
# setusercontext() to set up the login configuration from login.conf
diff --git a/src/helper/HelperApp.cpp b/src/helper/HelperApp.cpp
index 672359a..4ad9cbd 100644
--- a/src/helper/HelperApp.cpp
+++ b/src/helper/HelperApp.cpp
@@ -237,7 +237,7 @@ namespace SDDM {
str >> m >> env >> m_cookie;
if (m != AUTHENTICATED) {
env = QProcessEnvironment();
- m_cookie = QString();
+ m_cookie = {};
qCritical() << "Received a wrong opcode instead of AUTHENTICATED:" << m;
}
return env;
@@ -263,7 +263,7 @@ namespace SDDM {
return m_user;
}
- const QString& HelperApp::cookie() const {
+ const QByteArray& HelperApp::cookie() const {
return m_cookie;
}
diff --git a/src/helper/HelperApp.h b/src/helper/HelperApp.h
index 3742df1..d417494 100644
--- a/src/helper/HelperApp.h
+++ b/src/helper/HelperApp.h
@@ -40,7 +40,7 @@ namespace SDDM {
UserSession *session();
const QString &user() const;
- const QString &cookie() const;
+ const QByteArray &cookie() const;
public slots:
Request request(const Request &request);
@@ -62,7 +62,7 @@ namespace SDDM {
QLocalSocket *m_socket { nullptr };
QString m_user { };
// TODO: get rid of this in a nice clean way along the way with moving to user session X server
- QString m_cookie { };
+ QByteArray m_cookie { };
/*!
\brief Write utmp/wtmp/btmp records when a user logs in
diff --git a/src/helper/UserSession.cpp b/src/helper/UserSession.cpp
index c9a8a20..e55e69e 100644
--- a/src/helper/UserSession.cpp
+++ b/src/helper/UserSession.cpp
@@ -23,6 +23,7 @@
#include "UserSession.h"
#include "HelperApp.h"
#include "VirtualTerminal.h"
+#include "XauthUtils.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -35,6 +36,8 @@
#include <fcntl.h>
#include <sched.h>
+#include <QStandardPaths>
+
namespace SDDM {
UserSession::UserSession(HelperApp *parent)
: QProcess(parent) {
@@ -260,38 +263,38 @@ namespace SDDM {
qWarning() << "Could not redirect stdout";
}
+ // Drop the current environment
+ for (QString key : QProcessEnvironment::systemEnvironment().keys())
+ qunsetenv(qPrintable(key));
+
+ // Apply the new one. This has the nice effect that XDG_RUNTIME_DIR etc are effective
+ for (QString key : processEnvironment().keys())
+ qputenv(qPrintable(key), processEnvironment().value(key).toLocal8Bit());
+
// set X authority for X11 sessions only
if (sessionType != QLatin1String("x11"))
return;
- QString cookie = qobject_cast<HelperApp*>(parent())->cookie();
- if (!cookie.isEmpty()) {
- QString file = processEnvironment().value(QStringLiteral("XAUTHORITY"));
- QString display = processEnvironment().value(QStringLiteral("DISPLAY"));
- qDebug() << "Adding cookie to" << file;
-
-
- // create the path
- QFileInfo finfo(file);
- QDir().mkpath(finfo.absolutePath());
- QFile file_handler(file);
- file_handler.open(QIODevice::Append);
- file_handler.close();
-
- QString cmd = QStringLiteral("%1 -f %2 -q").arg(mainConfig.X11.XauthPath.get()).arg(file);
+ QByteArray cookie = qobject_cast<HelperApp*>(parent())->cookie();
+ if (cookie.isEmpty())
+ return;
- // execute xauth
- FILE *fp = popen(qPrintable(cmd), "w");
+ QString dir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+ if (!dir.isEmpty()) {
+ m_xauthFile.setFileTemplate(dir + QStringLiteral("/xauth_XXXXXX"));
+ m_xauthFile.open();
+ }
- // check file
- if (!fp)
- return;
- fprintf(fp, "remove %s\n", qPrintable(display));
- fprintf(fp, "add %s . %s\n", qPrintable(display), qPrintable(cookie));
- fprintf(fp, "exit\n");
+ if (m_xauthFile.fileName().isEmpty())
+ qWarning() << "Could not create the Xauthority file";
+ else {
+ QString display = processEnvironment().value(QStringLiteral("DISPLAY"));
+ qDebug() << "Adding cookie to" << m_xauthFile.fileName();
- // close pipe
- pclose(fp);
+ if (!Xauth::writeCookieToFile(m_xauthFile.fileName(), display, cookie))
+ qWarning() << "Failed to write the Xauthority file";
+ else
+ qputenv("XAUTHORITY", m_xauthFile.fileName().toUtf8());
}
}
diff --git a/src/helper/UserSession.h b/src/helper/UserSession.h
index 7069084..23776f4 100644
--- a/src/helper/UserSession.h
+++ b/src/helper/UserSession.h
@@ -25,6 +25,7 @@
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QProcess>
+#include <QtCore/QTemporaryFile>
namespace SDDM {
class HelperApp;
@@ -53,12 +54,20 @@ namespace SDDM {
*/
qint64 cachedProcessId();
+ /* Hack! QProcess does not allow changing processEnvironment by
+ setupChildProcess(), but this is needed for creating XAUTHORITY.
+ So inherit the caller's environment and apply the assignments manually. */
+ QProcessEnvironment processEnvironment() { return m_processEnv; }
+ void setProcessEnvironment(QProcessEnvironment env) { m_processEnv = env; }
+
protected:
void setupChildProcess();
private:
QString m_path { };
qint64 m_cachedProcessId;
+ QProcessEnvironment m_processEnv;
+ QTemporaryFile m_xauthFile;
};
}
--
2.25.1

@ -1,44 +0,0 @@
From 0f207a9cc6c0fda8ff47f53598404e1c878f7610 Mon Sep 17 00:00:00 2001
From: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Date: Tue, 20 Mar 2018 18:22:39 +0100
Subject: [PATCH] Remove suffix for Wayland session
Some desktops like GNOME specify which windowing system is in use
with the Name entry of their desktop file.
For Wayland-only desktops such as Liri this information is
redundant and so is for X11-only window managers.
Do not append the Wayland suffix and let desktops handle it
themeselves.
[ChangeLog][Greeter] Remove suffix for Wayland sessions
---
src/common/Session.cpp | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/src/common/Session.cpp b/src/common/Session.cpp
index 2d7b04f..cb4cef7 100644
--- a/src/common/Session.cpp
+++ b/src/common/Session.cpp
@@ -157,15 +157,8 @@ namespace SDDM {
if (current_section != QLatin1String("Desktop Entry"))
continue; // We are only interested in the "Desktop Entry" section
- if (line.startsWith(QLatin1String("Name="))) {
- if (type == WaylandSession)
- if (line.mid(5).endsWith(QLatin1String(" (Wayland)")))
- m_displayName = QObject::tr("%1").arg(line.mid(5));
- else
- m_displayName = QObject::tr("%1 (Wayland)").arg(line.mid(5));
- else
- m_displayName = line.mid(5);
- }
+ if (line.startsWith(QLatin1String("Name=")))
+ m_displayName = line.mid(5);
if (line.startsWith(QLatin1String("Comment=")))
m_comment = line.mid(8);
if (line.startsWith(QLatin1String("Exec=")))
--
2.25.1

@ -1,118 +0,0 @@
From 42c51761cc82edbaa50d702a4614e179ad4bcd63 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Thu, 12 Nov 2020 20:30:55 +0100
Subject: [PATCH] Retry starting the display server
Even if the CanGraphical property of a Seat is true, it's possible that it's
still too early for X to start, as it might need some driver or device which
isn't present yet.
Fixes #1316
---
src/daemon/Seat.cpp | 23 ++++++++++++++++++-----
src/daemon/Seat.h | 4 +++-
src/daemon/XorgDisplayServer.cpp | 10 ++++++----
3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/src/daemon/Seat.cpp b/src/daemon/Seat.cpp
index eef26da..838c222 100644
--- a/src/daemon/Seat.cpp
+++ b/src/daemon/Seat.cpp
@@ -28,6 +28,7 @@
#include <QDebug>
#include <QFile>
+#include <QTimer>
#include <functional>
@@ -52,7 +53,7 @@ namespace SDDM {
return m_name;
}
- bool Seat::createDisplay(int terminalId) {
+ void Seat::createDisplay(int terminalId) {
//reload config if needed
mainConfig.load();
@@ -84,12 +85,24 @@ namespace SDDM {
m_displays << display;
// start the display
- if (!display->start()) {
- qCritical() << "Could not start Display server on vt" << terminalId;
- return false;
+ startDisplay(display);
+ }
+
+ void Seat::startDisplay(Display *display, int tryNr) {
+ if (display->start())
+ return;
+
+ // It's possible that the system isn't ready yet (driver not loaded,
+ // device not enumerated, ...). It's not possible to tell when that changes,
+ // so try a few times with a delay in between.
+ qWarning() << "Attempt" << tryNr << "starting the Display server on vt" << display->terminalId() << "failed";
+
+ if(tryNr >= 3) {
+ qCritical() << "Could not start Display server on vt" << display->terminalId();
+ return;
}
- return true;
+ QTimer::singleShot(2000, display, [=] { startDisplay(display, tryNr + 1); });
}
void Seat::removeDisplay(Display* display) {
diff --git a/src/daemon/Seat.h b/src/daemon/Seat.h
index bf22566..f9fe733 100644
--- a/src/daemon/Seat.h
+++ b/src/daemon/Seat.h
@@ -35,13 +35,15 @@ namespace SDDM {
const QString &name() const;
public slots:
- bool createDisplay(int terminalId = -1);
+ void createDisplay(int terminalId = -1);
void removeDisplay(SDDM::Display* display);
private slots:
void displayStopped();
private:
+ void startDisplay(SDDM::Display *display, int tryNr = 1);
+
QString m_name;
QVector<Display *> m_displays;
diff --git a/src/daemon/XorgDisplayServer.cpp b/src/daemon/XorgDisplayServer.cpp
index e60c022..5f40fe8 100644
--- a/src/daemon/XorgDisplayServer.cpp
+++ b/src/daemon/XorgDisplayServer.cpp
@@ -248,6 +248,12 @@ namespace SDDM {
}
void XorgDisplayServer::finished() {
+ // clean up
+ if (process) {
+ process->deleteLater();
+ process = nullptr;
+ }
+
// check flag
if (!m_started)
return;
@@ -283,10 +289,6 @@ namespace SDDM {
displayStopScript->deleteLater();
displayStopScript = nullptr;
- // clean up
- process->deleteLater();
- process = nullptr;
-
// remove authority file
QFile::remove(m_authPath);
--
2.31.1

@ -1,35 +0,0 @@
From e81dfcd6913c4fbd1801597168291b1e396633d8 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Wed, 6 Jan 2021 16:00:34 +0100
Subject: [PATCH 16/18] Fix sessions being started as the wrong type on
autologin
For autologin, the last session is used, which contains a full path.
Display::findSessionEntry didn't handle that correctly, which led to
X11 sessions getting started as Wayland ones (or the other way around
before 994fa67).
Fixes #1348
---
src/daemon/Display.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/daemon/Display.cpp b/src/daemon/Display.cpp
index b95f6e5..9f1fabc 100644
--- a/src/daemon/Display.cpp
+++ b/src/daemon/Display.cpp
@@ -245,6 +245,11 @@ namespace SDDM {
}
bool Display::findSessionEntry(const QDir &dir, const QString &name) const {
+ // Given an absolute path: Check that it matches dir
+ const QFileInfo fileInfo(name);
+ if (fileInfo.isAbsolute() && fileInfo.absolutePath() != dir.absolutePath())
+ return false;
+
QString fileName = name;
// append extension
--
2.29.2

@ -1,39 +0,0 @@
From bc5a18f34c0881929a6b2e5d3993971c4f692f4f Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa13@gmail.com>
Date: Sun, 17 Jan 2021 11:48:28 -0500
Subject: [PATCH 18/18] wayland-session: Ensure $SHELL remains correctly set
In some circumstances, the effort of setting the environment
correctly can wind up clobbering the user-specified shell. To
work around this issue, capture the shell setting in a variable
and set it back at the end of environment and profile setup.
---
data/scripts/wayland-session | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/data/scripts/wayland-session b/data/scripts/wayland-session
index de4f519..1f90554 100755
--- a/data/scripts/wayland-session
+++ b/data/scripts/wayland-session
@@ -6,6 +6,10 @@
# Copyright (C) 2001-2005 Oswald Buddenhagen <ossi@kde.org>
# Note that the respective logout scripts are not sourced.
+
+# Backup the user shell setting into SDDM specific variable
+SDDM_USER_SHELL=$SHELL
+
case $SHELL in
*/bash)
[ -z "$BASH" ] && exec $SHELL $0 "$@"
@@ -50,4 +54,7 @@ case $SHELL in
;;
esac
+# Restore user shell setting that may have been clobbered by setting environment
+export SHELL=$SDDM_USER_SHELL
+
exec $@
--
2.29.2

@ -1,216 +0,0 @@
From 308fd0df2583b02251f0d80c397ccbf9fa7a9e04 Mon Sep 17 00:00:00 2001
From: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Date: Sun, 28 Feb 2021 12:07:33 +0100
Subject: [PATCH] Allocate VT for the display
Replace the old crude algorithm to find the next available VT with a
more reliable method using the VT_OPENQRY ioctl.
General.MinimumVT setting is now obsolete and it's no longer used.
---
CMakeLists.txt | 4 ----
data/man/sddm.conf.rst.in | 2 +-
src/common/Configuration.h | 1 -
src/common/Constants.h.in | 1 -
src/daemon/Display.cpp | 8 +++++---
src/daemon/Display.h | 2 +-
src/daemon/Seat.cpp | 38 +++-----------------------------------
src/daemon/Seat.h | 3 +--
8 files changed, 11 insertions(+), 48 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e52e0e90..9614b4e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -141,7 +141,6 @@ if(SYSTEMD_FOUND)
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SYSTEM_UNIT_DIR ${SYSTEMD_SYSTEM_UNIT_DIR})
endif()
- set(MINIMUM_VT 1)
set(HALT_COMMAND "/usr/bin/systemctl poweroff")
set(REBOOT_COMMAND "/usr/bin/systemctl reboot")
else()
@@ -159,7 +158,6 @@ if(ELOGIND_FOUND)
add_definitions(-DHAVE_ELOGIND)
set(CMAKE_AUTOMOC_MOC_OPTIONS -DHAVE_ELOGIND)
- set(MINIMUM_VT 7)
set(HALT_COMMAND "/usr/bin/loginctl poweroff")
set(REBOOT_COMMAND "/usr/bin/loginctl reboot")
endif()
@@ -171,10 +169,8 @@ if (NOT ELOGIND_FOUND AND NOT SYSTEMD_FOUND)
# commands for shutdown and reboot. On FreeBSD, there are
# normally more getty's running than on Linux.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
- set(MINIMUM_VT 9)
set(HALT_COMMAND "/sbin/shutdown -p now")
else()
- set(MINIMUM_VT 7)
set(HALT_COMMAND "/sbin/shutdown -h -P now")
endif()
set(REBOOT_COMMAND "/sbin/shutdown -r now")
diff --git a/data/man/sddm.conf.rst.in b/data/man/sddm.conf.rst.in
index bee07681..1061540c 100644
--- a/data/man/sddm.conf.rst.in
+++ b/data/man/sddm.conf.rst.in
@@ -144,7 +144,7 @@ OPTIONS
Minimum virtual terminal number that will be used
by the first display. Virtual terminal number will
increase as new displays added.
- Default value is @MINIMUM_VT@.
+ This setting is no longer available since SDDM v0.20.
`EnableHiDPI=`
Enables Qt's automatic HiDPI scaling.
diff --git a/src/common/Configuration.h b/src/common/Configuration.h
index cf44a629..b7987198 100644
--- a/src/common/Configuration.h
+++ b/src/common/Configuration.h
@@ -70,7 +70,6 @@ namespace SDDM {
Entry(SessionLogFile, QString, _S(".local/share/sddm/xorg-session.log"), _S("Path to the user session log file"));
Entry(DisplayCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xsetup"), _S("Path to a script to execute when starting the display server"));
Entry(DisplayStopCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xstop"), _S("Path to a script to execute when stopping the display server"));
- Entry(MinimumVT, int, MINIMUM_VT, _S("The lowest virtual terminal number that will be used."));
Entry(EnableHiDPI, bool, false, _S("Enable Qt's automatic high-DPI scaling"));
);
diff --git a/src/common/Constants.h.in b/src/common/Constants.h.in
index e174b5bf..48051288 100644
--- a/src/common/Constants.h.in
+++ b/src/common/Constants.h.in
@@ -37,7 +37,6 @@
#define SYSTEM_CONFIG_DIR "@SYSTEM_CONFIG_DIR@"
#define LOG_FILE "@LOG_FILE@"
-#define MINIMUM_VT @MINIMUM_VT@
#define UID_MIN @UID_MIN@
#define UID_MAX @UID_MAX@
diff --git a/src/daemon/Display.cpp b/src/daemon/Display.cpp
index a65df3f0..dbef510d 100644
--- a/src/daemon/Display.cpp
+++ b/src/daemon/Display.cpp
@@ -45,17 +45,19 @@
#include "Login1Manager.h"
#include "Login1Session.h"
-
+#include "VirtualTerminal.h"
namespace SDDM {
- Display::Display(const int terminalId, Seat *parent) : QObject(parent),
- m_terminalId(terminalId),
+ Display::Display(Seat *parent) : QObject(parent),
m_auth(new Auth(this)),
m_displayServer(new XorgDisplayServer(this)),
m_seat(parent),
m_socketServer(new SocketServer(this)),
m_greeter(new Greeter(this)) {
+ // Allocate vt
+ m_terminalId = VirtualTerminal::setUpNewVt();
+
// respond to authentication requests
m_auth->setVerbose(true);
connect(m_auth, &Auth::requestChanged, this, &Display::slotRequestChanged);
diff --git a/src/daemon/Display.h b/src/daemon/Display.h
index e68bc128..9db954d1 100644
--- a/src/daemon/Display.h
+++ b/src/daemon/Display.h
@@ -41,7 +41,7 @@ namespace SDDM {
Q_OBJECT
Q_DISABLE_COPY(Display)
public:
- explicit Display(int terminalId, Seat *parent);
+ explicit Display(Seat *parent);
~Display();
QString displayId() const;
diff --git a/src/daemon/Seat.cpp b/src/daemon/Seat.cpp
index 838c2221..a2f3d0c3 100644
--- a/src/daemon/Seat.cpp
+++ b/src/daemon/Seat.cpp
@@ -33,18 +33,6 @@
#include <functional>
namespace SDDM {
- int findUnused(int minimum, std::function<bool(const int)> used) {
- // initialize with minimum
- int number = minimum;
-
- // find unused
- while (used(number))
- number++;
-
- // return number;
- return number;
- }
-
Seat::Seat(const QString &name, QObject *parent) : QObject(parent), m_name(name) {
createDisplay();
}
@@ -53,30 +41,13 @@ namespace SDDM {
return m_name;
}
- void Seat::createDisplay(int terminalId) {
+ void Seat::createDisplay() {
//reload config if needed
mainConfig.load();
- if (m_name == QLatin1String("seat0")) {
- if (terminalId == -1) {
- // find unused terminal
- terminalId = findUnused(mainConfig.X11.MinimumVT.get(), [&](const int number) {
- return m_terminalIds.contains(number);
- });
- }
-
- // mark terminal as used
- m_terminalIds << terminalId;
-
- // log message
- qDebug() << "Adding new display" << "on vt" << terminalId << "...";
- }
- else {
- qDebug() << "Adding new VT-less display...";
- }
-
// create a new display
- Display *display = new Display(terminalId, this);
+ qDebug() << "Adding new display...";
+ Display *display = new Display(this);
// restart display on stop
connect(display, &Display::stopped, this, &Seat::displayStopped);
@@ -112,9 +83,6 @@ namespace SDDM {
// remove display from list
m_displays.removeAll(display);
- // mark display and terminal ids as unused
- m_terminalIds.removeAll(display->terminalId());
-
// stop the display
display->blockSignals(true);
display->stop();
diff --git a/src/daemon/Seat.h b/src/daemon/Seat.h
index f9fe7331..685eaedd 100644
--- a/src/daemon/Seat.h
+++ b/src/daemon/Seat.h
@@ -35,7 +35,7 @@ namespace SDDM {
const QString &name() const;
public slots:
- void createDisplay(int terminalId = -1);
+ void createDisplay();
void removeDisplay(SDDM::Display* display);
private slots:
@@ -47,7 +47,6 @@ namespace SDDM {
QString m_name;
QVector<Display *> m_displays;
- QVector<int> m_terminalIds;
};
}

@ -1,163 +0,0 @@
From 3c92e9206dc2e17fa5dc13f37be2926e9131ce94 Mon Sep 17 00:00:00 2001
From: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Date: Sun, 7 Mar 2021 17:36:11 +0100
Subject: [PATCH] Stop the helper process
Make sure the helper process is stopped when shutting down.
---
src/auth/Auth.cpp | 9 +++++++++
src/auth/Auth.h | 5 +++++
src/{daemon => common}/SignalHandler.cpp | 0
src/{daemon => common}/SignalHandler.h | 0
src/daemon/CMakeLists.txt | 3 ++-
src/daemon/Greeter.cpp | 2 ++
src/helper/CMakeLists.txt | 2 ++
src/helper/HelperApp.cpp | 14 +++++++++++++-
src/helper/HelperApp.h | 2 ++
9 files changed, 35 insertions(+), 2 deletions(-)
rename src/{daemon => common}/SignalHandler.cpp (100%)
rename src/{daemon => common}/SignalHandler.h (100%)
diff --git a/src/auth/Auth.cpp b/src/auth/Auth.cpp
index caca3146..042d938b 100644
--- a/src/auth/Auth.cpp
+++ b/src/auth/Auth.cpp
@@ -358,6 +358,15 @@ namespace SDDM {
args << QStringLiteral("--greeter");
d->child->start(QStringLiteral("%1/sddm-helper").arg(QStringLiteral(LIBEXEC_INSTALL_DIR)), args);
}
+
+ void Auth::stop()
+ {
+ if (d->child->state() != QProcess::NotRunning) {
+ d->child->terminate();
+ if (!d->child->waitForFinished(5000))
+ d->child->kill();
+ }
+ }
}
#include "Auth.moc"
diff --git a/src/auth/Auth.h b/src/auth/Auth.h
index 87f5f440..c3ce1a62 100644
--- a/src/auth/Auth.h
+++ b/src/auth/Auth.h
@@ -157,6 +157,11 @@ namespace SDDM {
*/
void start();
+ /**
+ * Stops the process.
+ */
+ void stop();
+
Q_SIGNALS:
void autologinChanged();
void greeterChanged();
diff --git a/src/daemon/SignalHandler.cpp b/src/common/SignalHandler.cpp
similarity index 100%
rename from src/daemon/SignalHandler.cpp
rename to src/common/SignalHandler.cpp
diff --git a/src/daemon/SignalHandler.h b/src/common/SignalHandler.h
similarity index 100%
rename from src/daemon/SignalHandler.h
rename to src/common/SignalHandler.h
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt
index 86d014be..4660a2f2 100644
--- a/src/daemon/CMakeLists.txt
+++ b/src/daemon/CMakeLists.txt
@@ -13,6 +13,8 @@ set(DAEMON_SOURCES
${CMAKE_SOURCE_DIR}/src/common/Session.cpp
${CMAKE_SOURCE_DIR}/src/common/SocketWriter.cpp
+ ${CMAKE_SOURCE_DIR}/src/common/SignalHandler.cpp
+ ${CMAKE_SOURCE_DIR}/src/common/SignalHandler.h
${CMAKE_SOURCE_DIR}/src/common/XauthUtils.cpp
${CMAKE_SOURCE_DIR}/src/auth/Auth.cpp
${CMAKE_SOURCE_DIR}/src/auth/AuthPrompt.cpp
${CMAKE_SOURCE_DIR}/src/auth/AuthRequest.cpp
@@ -27,7 +29,6 @@ set(DAEMON_SOURCES
PowerManager.cpp
Seat.cpp
SeatManager.cpp
- SignalHandler.cpp
SocketServer.cpp
)
diff --git a/src/daemon/Greeter.cpp b/src/daemon/Greeter.cpp
index 436ecc3d..3b0ab2c3 100644
--- a/src/daemon/Greeter.cpp
+++ b/src/daemon/Greeter.cpp
@@ -225,6 +225,8 @@ namespace SDDM {
// wait for finished
if (!m_process->waitForFinished(5000))
m_process->kill();
+ } else {
+ m_auth->stop();
}
}
diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt
index 8914ea75..f63dcc92 100644
--- a/src/helper/CMakeLists.txt
+++ b/src/helper/CMakeLists.txt
@@ -10,6 +10,8 @@ set(HELPER_SOURCES
${CMAKE_SOURCE_DIR}/src/common/ConfigReader.cpp
${CMAKE_SOURCE_DIR}/src/common/SafeDataStream.cpp
+ ${CMAKE_SOURCE_DIR}/src/common/SignalHandler.cpp
+ ${CMAKE_SOURCE_DIR}/src/common/SignalHandler.h
${CMAKE_SOURCE_DIR}/src/common/XauthUtils.cpp
Backend.cpp
HelperApp.cpp
UserSession.cpp
diff --git a/src/helper/HelperApp.cpp b/src/helper/HelperApp.cpp
index 672359ae..12c3206e 100644
--- a/src/helper/HelperApp.cpp
+++ b/src/helper/HelperApp.cpp
@@ -22,7 +22,7 @@
#include "Backend.h"
#include "UserSession.h"
#include "SafeDataStream.h"
-
+#include "SignalHandler.h"
#include "MessageHandler.h"
#include "VirtualTerminal.h"
@@ -50,6 +50,18 @@ namespace SDDM {
, m_socket(new QLocalSocket(this)) {
qInstallMessageHandler(HelperMessageHandler);
+ m_signalHandler = new SignalHandler(this);
+ m_signalHandler->initialize();
+ connect(m_signalHandler, &SignalHandler::sigintReceived, this, &HelperApp::quit);
+ connect(m_signalHandler, &SignalHandler::sigtermReceived, this, &HelperApp::quit);
+
+ connect(this, &QCoreApplication::aboutToQuit, this, [this] {
+ m_session->terminate();
+ if (!m_session->waitForFinished(5000))
+ m_session->kill();
+ m_backend->closeSession();
+ });
+
QTimer::singleShot(0, this, SLOT(setUp()));
}
diff --git a/src/helper/HelperApp.h b/src/helper/HelperApp.h
index 3742df12..d08fd37b 100644
--- a/src/helper/HelperApp.h
+++ b/src/helper/HelperApp.h
@@ -31,6 +31,7 @@ class QLocalSocket;
namespace SDDM {
class Backend;
class UserSession;
+ class SignalHandler;
class HelperApp : public QCoreApplication
{
Q_OBJECT
@@ -63,6 +64,7 @@ namespace SDDM {
QString m_user { };
// TODO: get rid of this in a nice clean way along the way with moving to user session X server
QByteArray m_cookie { };
+ SignalHandler *m_signalHandler = nullptr;
/*!
\brief Write utmp/wtmp/btmp records when a user logs in

@ -1,8 +1,8 @@
From 0b5040a887459a974bb4a3a4512a8392daa0eb66 Mon Sep 17 00:00:00 2001
From 7168262e2174046e335c445e72504758dbf7049b Mon Sep 17 00:00:00 2001
From: Jeremy Linton <jeremy.linton@arm.com>
Date: Mon, 25 Oct 2021 14:56:14 -0500
Subject: [PATCH] greeter: Do not populate Wayland sessions if they are to be
hidden
Subject: [PATCH] greeter: Do not populate Wayland sessions if /dev/dri does
not exist
Check for /dev/dri which should indicate that the Wayland will work
on this hardware.
@ -13,7 +13,7 @@ Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/greeter/SessionModel.cpp b/src/greeter/SessionModel.cpp
index 1953c76..b1f3296 100644
index a0eb3b1..92f6d1a 100644
--- a/src/greeter/SessionModel.cpp
+++ b/src/greeter/SessionModel.cpp
@@ -22,6 +22,7 @@
@ -24,11 +24,11 @@ index 1953c76..b1f3296 100644
#include <QVector>
#include <QProcessEnvironment>
#include <QFileSystemWatcher>
@@ -39,18 +40,25 @@ namespace SDDM {
@@ -40,19 +41,26 @@ namespace SDDM {
};
SessionModel::SessionModel(QObject *parent) : QAbstractListModel(parent), d(new SessionModelPrivate()) {
+ // Check for flag to hide Wayland sessions
+ // Check for flag to show Wayland sessions
+ bool dri_active = QFileInfo::exists(QStringLiteral("/dev/dri"));
+
// initial population
@ -42,10 +42,11 @@ index 1953c76..b1f3296 100644
// refresh everytime a file is changed, added or removed
QFileSystemWatcher *watcher = new QFileSystemWatcher(this);
connect(watcher, &QFileSystemWatcher::directoryChanged, [this](const QString &path) {
+ // Recheck for flag to hide Wayland sessions
+ // Recheck for flag to show Wayland sessions
+ bool dri_active = QFileInfo::exists(QStringLiteral("/dev/dri"));
beginResetModel();
d->sessions.clear();
d->displayNames.clear();
- populate(Session::WaylandSession, mainConfig.Wayland.SessionDir.get());
+ if (dri_active)
+ populate(Session::WaylandSession, mainConfig.Wayland.SessionDir.get());
@ -53,5 +54,5 @@ index 1953c76..b1f3296 100644
endResetModel();
});
--
2.32.0
2.33.1

@ -1,8 +1,17 @@
diff --git a/src/common/Configuration.h b/src/common/Configuration.h
index a7e0585..36cf9d0 100644
index cdffde3..0272e2c 100644
--- a/src/common/Configuration.h
+++ b/src/common/Configuration.h
@@ -47,7 +47,7 @@ namespace SDDM {
@@ -38,7 +38,7 @@ namespace SDDM {
// Name Type Default value Description
// TODO: Change default to x11-user in a future release
- Entry(DisplayServer, QString, _S("x11"), _S("Which display server should be used.\n"
+ Entry(DisplayServer, QString, _S("wayland"), _S("Which display server should be used.\n"
"Valid values are: x11, x11-user, wayland."));
Entry(HaltCommand, QString, _S(HALT_COMMAND), _S("Halt command"));
Entry(RebootCommand, QString, _S(REBOOT_COMMAND), _S("Reboot command"));
@@ -51,7 +51,7 @@ namespace SDDM {
// Name Entries (but it's a regular class again)
Section(Theme,
Entry(ThemeDir, QString, _S(DATA_INSTALL_DIR "/themes"), _S("Theme directory path"));
@ -11,21 +20,22 @@ index a7e0585..36cf9d0 100644
Entry(FacesDir, QString, _S(DATA_INSTALL_DIR "/faces"), _S("Global directory for user avatars\n"
"The files should be named <username>.face.icon"));
Entry(CursorTheme, QString, QString(), _S("Cursor theme used in the greeter"));
@@ -65,9 +65,9 @@ namespace SDDM {
Entry(XephyrPath, QString, _S("/usr/bin/Xephyr"), _S("Path to Xephyr binary"));
@@ -71,10 +71,10 @@ namespace SDDM {
Entry(XauthPath, QString, _S("/usr/bin/xauth"), _S("Path to xauth binary"));
Entry(SessionDir, QString, _S("/usr/share/xsessions"), _S("Directory containing available X sessions"));
Entry(SessionCommand, QString, _S(SESSION_COMMAND), _S("Path to a script to execute when starting the desktop session"));
- Entry(SessionLogFile, QString, _S(".local/share/sddm/xorg-session.log"), _S("Path to the user session log file"));
+ Entry(SessionLogFile, QString, _S(".cache/xsession-errors"), _S("Path to the user session log file"));
Entry(UserAuthFile, QString, _S(".Xauthority"), _S("Path to the Xauthority file"));
- Entry(DisplayCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xsetup"), _S("Path to a script to execute when starting the display server"));
- Entry(DisplayStopCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xstop"), _S("Path to a script to execute when stopping the display server"));
+ Entry(SessionLogFile, QString, _S(".cache/xsession-errors"), _S("Path to the user session log file"));
+ Entry(DisplayCommand, QString, _S(SYS_CONFIG_DIR "/sddm/Xsetup"), _S("Path to a script to execute when starting the display server"));
+ Entry(DisplayStopCommand, QString, _S(SYS_CONFIG_DIR "/sddm/Xstop"), _S("Path to a script to execute when stopping the display server"));
Entry(EnableHiDPI, bool, false, _S("Enable Qt's automatic high-DPI scaling"));
);
@@ -75,7 +75,7 @@ namespace SDDM {
Section(Wayland,
@@ -82,12 +82,12 @@ namespace SDDM {
Entry(CompositorCommand, QString, _S("weston --shell=fullscreen-shell.so"), _S("Path of the Wayland compositor to execute when starting the greeter"));
Entry(SessionDir, QString, _S("/usr/share/wayland-sessions"), _S("Directory containing available Wayland sessions"));
Entry(SessionCommand, QString, _S(WAYLAND_SESSION_COMMAND), _S("Path to a script to execute when starting the desktop session"));
- Entry(SessionLogFile, QString, _S(".local/share/sddm/wayland-session.log"),_S("Path to the user session log file"));
@ -33,3 +43,9 @@ index a7e0585..36cf9d0 100644
Entry(EnableHiDPI, bool, false, _S("Enable Qt's automatic high-DPI scaling"));
);
Section(Users,
- Entry(DefaultPath, QString, _S("/usr/local/bin:/usr/bin:/bin"), _S("Default $PATH for logged in users"));
+ Entry(DefaultPath, QString, _S("/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"), _S("Default $PATH for logged in users"));
Entry(MinimumUid, int, UID_MIN, _S("Minimum user id for displayed users"));
Entry(MaximumUid, int, UID_MAX, _S("Maximum user id for displayed users"));
Entry(HideUsers, QStringList, QStringList(), _S("Comma-separated list of users that should not be listed"));

@ -0,0 +1,2 @@
[General]
DisplayServer=x11

@ -25,7 +25,7 @@
#RebootCommand=/usr/bin/systemctl reboot
# Control x11/wayland startup
# DisplayServer=x11
# DisplayServer=wayland
[Theme]
# Current theme name

@ -1,61 +1,58 @@
%undefine __cmake_in_source_build
# Control wayland by default
%if (0%{?fedora} && 0%{?fedora} < 34) || (0%{?rhel} && 0%{?rhel} < 9)
# Control Plasma Wayland by default
%if 0%{?rhel} && 0%{?rhel} < 9
%bcond_with wayland_default
%else
%bcond_without wayland_default
%endif
# Control SDDM Wayland by default
%if (0%{?fedora} && 0%{?fedora} < 36) || (0%{?rhel} && 0%{?rhel} < 9)
%bcond_with sddm_wayland_default
%else
%bcond_without sddm_wayland_default
%endif
%global commit 85cbf3f2cda66f8deadea5f1e2e627a466aba885
%global commitdate 20220130
%global shortcommit %(c=%{commit}; echo ${c:0:7})
Name: sddm
Version: 0.19.0
Release: 19%{?dist}
Version: 0.19.0%{?commitdate:^git%{commitdate}.%{shortcommit}}
Release: 1%{?dist}
License: GPLv2+
Summary: QML based X11 desktop manager
Summary: QML based desktop and login manager
Url: https://github.com/sddm/sddm
%if 0%{?commitdate}
Source0: %{url}/archive/%{commit}/%{name}-%{commit}.tar.gz
%else
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
%endif
## upstream patches
Patch16: 0016-Fix-sessions-being-started-as-the-wrong-type-on-auto.patch
Patch18: 0018-wayland-session-Ensure-SHELL-remains-correctly-set.patch
## upstreamable patches
# From: https://github.com/sddm/sddm/pull/997
Patch051: 0001-Remove-suffix-for-Wayland-session.patch
# From: https://github.com/sddm/sddm/pull/1230
Patch052: 0001-Redesign-Xauth-handling.patch
# newer(?) pristine one from upstream PR has xauth locking issues wrt RUNTIME_DIR
#Patch52: 0001-Redesign-Xauth-handling-1.patch
# https://github.com/sddm/sddm/commit/42c5176 plus the first two
# commits from:
# https://github.com/sddm/sddm/pull/1371
# Fixes several (but not all) issues with session switching:
# https://bugzilla.redhat.com/show_bug.cgi?id=1929643
Patch053: 0001-Retry-starting-the-display-server.patch
Patch054: 3c92e9206dc2e17fa5dc13f37be2926e9131ce94.patch
Patch055: 308fd0df2583b02251f0d80c397ccbf9fa7a9e04.patch
## downstream patches
Patch101: sddm-0.19.0-fedora_config.patch
# sddm.service: +EnvironmentFile=-/etc/sysconfig/sddm
Patch103: sddm-0.18.0-environment_file.patch
# Disable wayland sessions when /dev/dri doesn't exist
# https://bugzilla.redhat.com/1952431
# https://bugzilla.redhat.com/show_bug.cgi?id=2016788
# https://bugzilla.redhat.com/show_bug.cgi?id=2016310
Patch104: sddm-0.19.0-allow-hiding-wayland-sessions.patch
# Submitted: https://github.com/sddm/sddm/pull/1489
Patch10: sddm-0.20.0-allow-hiding-wayland-sessions.patch
# Fix race with logind restart, and start seat0 if !CanGraphical on timer
# https://bugzilla.redhat.com/show_bug.cgi?id=2011991
# https://bugzilla.redhat.com/show_bug.cgi?id=2016310
Patch105: 0001-Delay-for-logind-and-fallback-to-seat0.patch
# Submmited: https://github.com/sddm/sddm/pull/1494
Patch11: 0001-Delay-for-logind-and-fallback-to-seat0.patch
## downstream patches
Patch101: sddm-0.20.0-fedora_config.patch
# sddm.service: +EnvironmentFile=-/etc/sysconfig/sddm
Patch103: sddm-0.18.0-environment_file.patch
# Shamelessly stolen from gdm
Source11: sddm.pam
@ -71,6 +68,9 @@ Source15: README.scripts
Source16: sddm.sysconfig
# systemd sysusers config
Source18: sddm-systemd-sysusers.conf
# sddm x11 override config
Source19: sddm-x11.conf
Provides: service(graphical-login) = sddm
@ -103,20 +103,51 @@ Requires: system-logos
%endif
Requires: systemd
Requires: xorg-x11-xinit
%ifnarch s390 s390x
Requires: xorg-x11-server-Xorg
Suggests: qt5-qtvirtualkeyboard%{?_isa}
%endif
%{?systemd_requires}
Requires(pre): shadow-utils
# Virtual dependency for sddm greeter setup
Requires: sddm-greeter-displayserver
%if ! %{with sddm_wayland_default}
Suggests: sddm-x11
%else
Suggests: sddm-wayland-generic
%endif
%description
SDDM is a modern display manager for X11 aiming to be fast, simple and
SDDM is a modern graphical display manager aiming to be fast, simple and
beautiful. It uses modern technologies like QtQuick, which in turn gives the
designer the ability to create smooth, animated user interfaces.
%package wayland-generic
Summary: Generic Wayland SDDM greeter configuration
Provides: sddm-greeter-displayserver
Conflicts: sddm-greeter-displayserver
Requires: weston
Requires: %{name} = %{version}-%{release}
BuildArch: noarch
%description wayland-generic
This package contains configuration and dependencies for SDDM
to use Weston for the greeter display server.
This is the generic default Wayland configuration provided
by SDDM.
%package x11
Summary: X11 SDDM greeter configuration
Provides: sddm-greeter-displayserver
Conflicts: sddm-greeter-displayserver
Requires: xorg-x11-server-Xorg
Requires: %{name} = %{version}-%{release}
BuildArch: noarch
%description x11
This package contains configuration and dependencies for SDDM
to use X11 for the greeter display server.
%package themes
Summary: SDDM Themes
# for upgrade path
@ -128,7 +159,7 @@ A collection of sddm themes, including: elarun, maldives, maya
%prep
%autosetup -p1
%autosetup -p1 %{?commitdate:-n %{name}-%{commit}}
%if 0%{?fedora}
#FIXME/TODO: use version on filesystem instead of using a bundled copy
@ -155,6 +186,7 @@ ls -sh src/greeter/theme/background.png
%cmake_install
mkdir -p %{buildroot}%{_sysconfdir}/sddm.conf.d
mkdir -p %{buildroot}%{_prefix}/lib/sddm/sddm.conf.d
install -Dpm 644 %{SOURCE11} %{buildroot}%{_sysconfdir}/pam.d/sddm
install -Dpm 644 %{SOURCE12} %{buildroot}%{_sysconfdir}/pam.d/sddm-autologin
install -Dpm 644 %{SOURCE13} %{buildroot}%{_tmpfilesdir}/sddm.conf
@ -162,6 +194,7 @@ install -Dpm 644 %{SOURCE14} %{buildroot}%{_sysconfdir}/sddm.conf
install -Dpm 644 %{SOURCE15} %{buildroot}%{_datadir}/sddm/scripts/README.scripts
install -Dpm 644 %{SOURCE16} %{buildroot}%{_sysconfdir}/sysconfig/sddm
install -Dpm 644 %{SOURCE18} %{buildroot}%{_sysusersdir}/sddm.conf
install -Dpm 644 %{SOURCE19} %{buildroot}%{_prefix}/lib/sddm/sddm.conf.d/x11.conf
mkdir -p %{buildroot}/run/sddm
mkdir -p %{buildroot}%{_localstatedir}/lib/sddm
mkdir -p %{buildroot}%{_sysconfdir}/sddm/
@ -221,6 +254,7 @@ fi
%doc README.md CONTRIBUTORS
%dir %{_sysconfdir}/sddm/
%dir %{_sysconfdir}/sddm.conf.d
%dir %{_prefix}/lib/sddm/sddm.conf.d
%config(noreplace) %{_sysconfdir}/sddm/*
%config(noreplace) %{_sysconfdir}/sddm.conf
%config(noreplace) %{_sysconfdir}/pam.d/sddm
@ -232,6 +266,8 @@ fi
%{_bindir}/sddm
%{_bindir}/sddm-greeter
%{_libexecdir}/sddm-helper
%{_libexecdir}/sddm-helper-start-wayland
%{_libexecdir}/sddm-helper-start-x11user
%{_tmpfilesdir}/sddm.conf
%{_sysusersdir}/sddm.conf
%attr(0711, root, sddm) %dir /run/sddm
@ -250,6 +286,12 @@ fi
%{_mandir}/man5/sddm.conf.5*
%{_mandir}/man5/sddm-state.conf.5*
%files wayland-generic
# No files since default configuration
%files x11
%{_prefix}/lib/sddm/sddm.conf.d/x11.conf
%files themes
%{_datadir}/sddm/themes/elarun/
%{_datadir}/sddm/themes/maldives/
@ -257,6 +299,14 @@ fi
%changelog
* Sun Jan 30 2022 Neal Gompa <ngompa@fedoraproject.org> - 0.19.0^git20220130.85cbf3f-1
- Update to snapshot release
- Drop upstreamed patches
- Drop Xauth patch due to inability to apply it
- Update status on remaining patches
- Add support for using a Wayland greeter
- Clean up Wayland conditionals
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.19.0-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

@ -1 +1 @@
SHA512 (sddm-0.19.0.tar.gz) = f4de3d2da844caa8c5639ec39d4f41305d4fcad9ca29fe381c2c1d4b1bba0e54d47b8644e2c72d41fe9d11f3792959c3dd14f76d9ebc0de2b8ab7675c3e9acf7
SHA512 (sddm-85cbf3f2cda66f8deadea5f1e2e627a466aba885.tar.gz) = f37e09cc6713498c995c6299f8f0777e6deeec451c1e0490aba39d5d54785eae99d73b6b890557dccc6db54ac82e435d0e3bde8331c08d5151b2ffca25693c84

Loading…
Cancel
Save