parent
954e5c84eb
commit
cb1d68a8ef
@ -1,102 +0,0 @@
|
|||||||
From b8ef20b8bc6b9636449f602e10ac49d39b2abc79 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Aleix Pol <aleixpol@kde.org>
|
|
||||||
Date: Thu, 26 Jan 2023 18:04:12 +0100
|
|
||||||
Subject: [PATCH] Allow recovering from tty switching failures
|
|
||||||
|
|
||||||
If we fail to switch tty when showing the greeter, exit saying so then
|
|
||||||
switch back to tty 1 and try launching the Display again.
|
|
||||||
|
|
||||||
Fixes #1636
|
|
||||||
---
|
|
||||||
src/auth/Auth.h | 1 +
|
|
||||||
src/daemon/Display.cpp | 9 +++++----
|
|
||||||
src/daemon/Greeter.cpp | 7 ++++---
|
|
||||||
src/daemon/Greeter.h | 1 +
|
|
||||||
src/helper/UserSession.cpp | 2 +-
|
|
||||||
5 files changed, 12 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/auth/Auth.h b/src/auth/Auth.h
|
|
||||||
index 0e39f69..66a9ec9 100644
|
|
||||||
--- a/src/auth/Auth.h
|
|
||||||
+++ b/src/auth/Auth.h
|
|
||||||
@@ -86,6 +86,7 @@ namespace SDDM {
|
|
||||||
HELPER_SESSION_ERROR,
|
|
||||||
HELPER_OTHER_ERROR,
|
|
||||||
HELPER_DISPLAYSERVER_ERROR,
|
|
||||||
+ HELPER_TTY_ERROR,
|
|
||||||
};
|
|
||||||
Q_ENUM(HelperExitStatus)
|
|
||||||
|
|
||||||
diff --git a/src/daemon/Display.cpp b/src/daemon/Display.cpp
|
|
||||||
index c2437c7..b6b5728 100644
|
|
||||||
--- a/src/daemon/Display.cpp
|
|
||||||
+++ b/src/daemon/Display.cpp
|
|
||||||
@@ -149,10 +149,11 @@ namespace SDDM {
|
|
||||||
connect(this, &Display::loginFailed, m_socketServer, &SocketServer::loginFailed);
|
|
||||||
connect(this, &Display::loginSucceeded, m_socketServer, &SocketServer::loginSucceeded);
|
|
||||||
|
|
||||||
- connect(m_greeter, &Greeter::failed,
|
|
||||||
- QCoreApplication::instance(), [] {
|
|
||||||
- QCoreApplication::instance()->exit(23);
|
|
||||||
- });
|
|
||||||
+ connect(m_greeter, &Greeter::failed, this, &Display::stop);
|
|
||||||
+ connect(m_greeter, &Greeter::ttyFailed, this, [this] {
|
|
||||||
+ VirtualTerminal::jumpToVt(1, true);
|
|
||||||
+ stop();
|
|
||||||
+ });
|
|
||||||
connect(m_greeter, &Greeter::displayServerFailed, this, &Display::displayServerFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/daemon/Greeter.cpp b/src/daemon/Greeter.cpp
|
|
||||||
index eadae5a..ea9ad81 100644
|
|
||||||
--- a/src/daemon/Greeter.cpp
|
|
||||||
+++ b/src/daemon/Greeter.cpp
|
|
||||||
@@ -32,6 +32,7 @@
|
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
|
||||||
#include <QtCore/QProcess>
|
|
||||||
+#include <VirtualTerminal.h>
|
|
||||||
|
|
||||||
namespace SDDM {
|
|
||||||
Greeter::Greeter(Display *parent)
|
|
||||||
@@ -312,9 +313,9 @@ namespace SDDM {
|
|
||||||
|
|
||||||
if (status == Auth::HELPER_DISPLAYSERVER_ERROR) {
|
|
||||||
Q_EMIT displayServerFailed();
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (status == Auth::HELPER_SESSION_ERROR) {
|
|
||||||
+ } else if (status == Auth::HELPER_TTY_ERROR) {
|
|
||||||
+ Q_EMIT ttyFailed();
|
|
||||||
+ } else if (status == Auth::HELPER_SESSION_ERROR) {
|
|
||||||
Q_EMIT failed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/src/daemon/Greeter.h b/src/daemon/Greeter.h
|
|
||||||
index 5a69ccd..3a6295c 100644
|
|
||||||
--- a/src/daemon/Greeter.h
|
|
||||||
+++ b/src/daemon/Greeter.h
|
|
||||||
@@ -62,6 +62,7 @@ namespace SDDM {
|
|
||||||
void authError(const QString &message, Auth::Error error);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
+ void ttyFailed();
|
|
||||||
void failed();
|
|
||||||
void displayServerFailed();
|
|
||||||
|
|
||||||
diff --git a/src/helper/UserSession.cpp b/src/helper/UserSession.cpp
|
|
||||||
index 39ff9ad..1bd9959 100644
|
|
||||||
--- a/src/helper/UserSession.cpp
|
|
||||||
+++ b/src/helper/UserSession.cpp
|
|
||||||
@@ -180,7 +180,7 @@ namespace SDDM {
|
|
||||||
if (ioctl(STDIN_FILENO, TIOCSCTTY) < 0) {
|
|
||||||
const auto error = strerror(errno);
|
|
||||||
qCritical().nospace() << "Failed to take control of " << ttyString << " (" << QFileInfo(ttyString).owner() << "): " << error;
|
|
||||||
- exit(Auth::HELPER_OTHER_ERROR);
|
|
||||||
+ exit(Auth::HELPER_TTY_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.39.1
|
|
||||||
|
|
@ -1,155 +0,0 @@
|
|||||||
From df564d59533f9556d20f1141bf01de705cce3bf4 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Aleksei Bavshin <alebastr89@gmail.com>
|
|
||||||
Date: Wed, 2 Feb 2022 23:08:59 -0800
|
|
||||||
Subject: [PATCH] WaylandHelper: support non-default display names
|
|
||||||
|
|
||||||
Weston v10[1] and some wlroots-based compositors[2][3] decided to stop
|
|
||||||
using `wayland-0`.
|
|
||||||
Extend WaylandSocketWatcher to look for any socket matching the
|
|
||||||
`wayland-?` pattern and pass the `WAYLAND_DISPLAY` to the greeter.
|
|
||||||
|
|
||||||
[1]: https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/486
|
|
||||||
[2]: https://github.com/swaywm/sway/commit/65a751a21f61b30808b7e703257c6ca3b71f50eb
|
|
||||||
[3]: https://github.com/WayfireWM/wayfire/commit/4ee4f3f259be00fd9a3c26960e8fce91ec526290
|
|
||||||
---
|
|
||||||
src/helper/waylandhelper.cpp | 5 +++-
|
|
||||||
src/helper/waylandsocketwatcher.cpp | 37 +++++++++++++++++------------
|
|
||||||
src/helper/waylandsocketwatcher.h | 4 ++--
|
|
||||||
3 files changed, 28 insertions(+), 18 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/helper/waylandhelper.cpp b/src/helper/waylandhelper.cpp
|
|
||||||
index 39952cb99..66d6b0796 100644
|
|
||||||
--- a/src/helper/waylandhelper.cpp
|
|
||||||
+++ b/src/helper/waylandhelper.cpp
|
|
||||||
@@ -119,7 +119,6 @@ void WaylandHelper::startGreeter(const QString &cmd)
|
|
||||||
m_greeterProcess = new QProcess(this);
|
|
||||||
m_greeterProcess->setProgram(args.takeFirst());
|
|
||||||
m_greeterProcess->setArguments(args);
|
|
||||||
- m_greeterProcess->setProcessEnvironment(m_environment);
|
|
||||||
connect(m_greeterProcess, &QProcess::readyReadStandardError, this, [this] {
|
|
||||||
qWarning() << m_greeterProcess->readAllStandardError();
|
|
||||||
});
|
|
||||||
@@ -132,6 +131,8 @@ void WaylandHelper::startGreeter(const QString &cmd)
|
|
||||||
QCoreApplication::instance()->quit();
|
|
||||||
});
|
|
||||||
if (m_watcher->status() == WaylandSocketWatcher::Started) {
|
|
||||||
+ m_environment.insert(QStringLiteral("WAYLAND_DISPLAY"), m_watcher->socketName());
|
|
||||||
+ m_greeterProcess->setProcessEnvironment(m_environment);
|
|
||||||
m_greeterProcess->start();
|
|
||||||
} else if (m_watcher->status() == WaylandSocketWatcher::Failed) {
|
|
||||||
Q_EMIT failed();
|
|
||||||
@@ -139,6 +140,8 @@ void WaylandHelper::startGreeter(const QString &cmd)
|
|
||||||
connect(m_watcher, &WaylandSocketWatcher::failed, this, &WaylandHelper::failed);
|
|
||||||
connect(m_watcher, &WaylandSocketWatcher::started, this, [this] {
|
|
||||||
m_watcher->stop();
|
|
||||||
+ m_environment.insert(QStringLiteral("WAYLAND_DISPLAY"), m_watcher->socketName());
|
|
||||||
+ m_greeterProcess->setProcessEnvironment(m_environment);
|
|
||||||
m_greeterProcess->start();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
diff --git a/src/helper/waylandsocketwatcher.cpp b/src/helper/waylandsocketwatcher.cpp
|
|
||||||
index 316690935..837bb189d 100644
|
|
||||||
--- a/src/helper/waylandsocketwatcher.cpp
|
|
||||||
+++ b/src/helper/waylandsocketwatcher.cpp
|
|
||||||
@@ -18,6 +18,7 @@
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
+#include <unistd.h>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
|
|
||||||
@@ -28,8 +29,9 @@ namespace SDDM {
|
|
||||||
WaylandSocketWatcher::WaylandSocketWatcher(QObject *parent )
|
|
||||||
: QObject(parent)
|
|
||||||
, m_runtimeDir(QDir(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation)))
|
|
||||||
- , m_socketPath(m_runtimeDir.absoluteFilePath(QLatin1String("wayland-0")))
|
|
||||||
{
|
|
||||||
+ m_runtimeDir.setFilter(QDir::Files | QDir::System);
|
|
||||||
+ m_runtimeDir.setNameFilters(QStringList() << QLatin1String("wayland-?"));
|
|
||||||
}
|
|
||||||
|
|
||||||
WaylandSocketWatcher::Status WaylandSocketWatcher::status() const
|
|
||||||
@@ -37,9 +39,9 @@ WaylandSocketWatcher::Status WaylandSocketWatcher::status() const
|
|
||||||
return m_status;
|
|
||||||
}
|
|
||||||
|
|
||||||
-QString WaylandSocketWatcher::socketPath() const
|
|
||||||
+QString WaylandSocketWatcher::socketName() const
|
|
||||||
{
|
|
||||||
- return m_socketPath;
|
|
||||||
+ return m_socketName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaylandSocketWatcher::start()
|
|
||||||
@@ -53,8 +55,7 @@ void WaylandSocketWatcher::start()
|
|
||||||
// Time is up and a socket was not found
|
|
||||||
if (!m_watcher.isNull())
|
|
||||||
m_watcher->deleteLater();
|
|
||||||
- qWarning("Wayland socket watcher for \"%s\" timed out",
|
|
||||||
- qPrintable(m_socketPath));
|
|
||||||
+ qWarning("Wayland socket watcher timed out");
|
|
||||||
m_status = Failed;
|
|
||||||
Q_EMIT failed();
|
|
||||||
});
|
|
||||||
@@ -62,22 +63,28 @@ void WaylandSocketWatcher::start()
|
|
||||||
// Check if the socket exists
|
|
||||||
connect(m_watcher, &QFileSystemWatcher::directoryChanged, this,
|
|
||||||
[this](const QString &path) {
|
|
||||||
- qDebug() << "Directory" << path << "has changed, checking for" << m_socketPath;
|
|
||||||
+ qDebug() << "Directory" << path << "has changed, checking for Wayland socket";
|
|
||||||
|
|
||||||
- if (QFile::exists(m_socketPath)) {
|
|
||||||
- m_timer.stop();
|
|
||||||
- if (!m_watcher.isNull())
|
|
||||||
- m_watcher->deleteLater();
|
|
||||||
- m_status = Started;
|
|
||||||
- Q_EMIT started();
|
|
||||||
+ m_runtimeDir.refresh();
|
|
||||||
+ const QFileInfoList fileInfoList = m_runtimeDir.entryInfoList();
|
|
||||||
+ for (const QFileInfo &fileInfo : fileInfoList) {
|
|
||||||
+ if (fileInfo.ownerId() == ::getuid()) {
|
|
||||||
+ qDebug() << "Found Wayland socket" << fileInfo.absoluteFilePath();
|
|
||||||
+ m_timer.stop();
|
|
||||||
+ if (!m_watcher.isNull())
|
|
||||||
+ m_watcher->deleteLater();
|
|
||||||
+ m_socketName = fileInfo.fileName();
|
|
||||||
+ m_status = Started;
|
|
||||||
+ Q_EMIT started();
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Watch for runtime directory changes
|
|
||||||
if (!m_runtimeDir.exists() || !m_watcher->addPath(m_runtimeDir.absolutePath())) {
|
|
||||||
- qWarning("Cannot watch directory \"%s\" for Wayland socket \"%s\"",
|
|
||||||
- qPrintable(m_runtimeDir.absolutePath()),
|
|
||||||
- qPrintable(m_socketPath));
|
|
||||||
+ qWarning("Cannot watch directory \"%s\" for Wayland socket",
|
|
||||||
+ qPrintable(m_runtimeDir.absolutePath()));
|
|
||||||
m_watcher->deleteLater();
|
|
||||||
m_status = Failed;
|
|
||||||
Q_EMIT failed();
|
|
||||||
diff --git a/src/helper/waylandsocketwatcher.h b/src/helper/waylandsocketwatcher.h
|
|
||||||
index dfc5d214a..0032c1866 100644
|
|
||||||
--- a/src/helper/waylandsocketwatcher.h
|
|
||||||
+++ b/src/helper/waylandsocketwatcher.h
|
|
||||||
@@ -41,7 +41,7 @@ class WaylandSocketWatcher : public QObject
|
|
||||||
explicit WaylandSocketWatcher(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
Status status() const;
|
|
||||||
- QString socketPath() const;
|
|
||||||
+ QString socketName() const;
|
|
||||||
|
|
||||||
void start();
|
|
||||||
void stop();
|
|
||||||
@@ -54,7 +54,7 @@ class WaylandSocketWatcher : public QObject
|
|
||||||
private:
|
|
||||||
Status m_status = Stopped;
|
|
||||||
QDir m_runtimeDir;
|
|
||||||
- QString m_socketPath;
|
|
||||||
+ QString m_socketName;
|
|
||||||
QTimer m_timer;
|
|
||||||
QPointer<QFileSystemWatcher> m_watcher;
|
|
||||||
};
|
|
Loading…
Reference in new issue