Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:16.0:Staging:B
sddm-kcm6
0002-Read-and-write-autologin-user-to-etc-sysco...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0002-Read-and-write-autologin-user-to-etc-sysconfig-displ.patch of Package sddm-kcm6
From 957d6a8d4dc546e64d39c7d49599e67ab4be6b38 Mon Sep 17 00:00:00 2001 From: Fabian Vogt <fabian@ritter-vogt.de> Date: Tue, 19 Jan 2021 20:45:33 +0100 Subject: [PATCH] Read and write autologin user to /etc/sysconfig/displaymanager That's where SDDM reads from. --- sddmauthhelper.cpp | 30 ++++++++++++++++++++++++++++++ src/sddmsettingsbase.cpp | 6 ++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/sddmauthhelper.cpp b/sddmauthhelper.cpp index 2a38b40..0702465 100644 --- a/sddmauthhelper.cpp +++ b/sddmauthhelper.cpp @@ -19,6 +19,8 @@ #include <QMimeDatabase> #include <QMimeType> #include <QSharedPointer> +#include <QSaveFile> +#include <QRegularExpression> #include <KArchive> #include <KCompressionDevice> @@ -310,6 +312,34 @@ ActionReply SddmAuthHelper::save(const QVariantMap &args) QString groupName = configFields[1]; QString keyName = configFields[2]; + if (groupName == QLatin1String("Autologin") && keyName == QLatin1String("User")) { + QString sysconfFileName = QStringLiteral("/etc/sysconfig/displaymanager"); + QFile sysconf(sysconfFileName); + QSaveFile newconf(sysconfFileName); + if (!sysconf.open(QIODevice::ReadOnly) || !newconf.open(QIODevice::WriteOnly)) { + return ActionReply::HelperErrorReply(); + } + + QString sysconfData = QString::fromUtf8(sysconf.readAll()); + if (sysconfData.isEmpty()) { + return ActionReply::HelperErrorReply(); + } + + QRegularExpression re(QStringLiteral("^DISPLAYMANAGER_AUTOLOGIN=.*$"), QRegularExpression::MultilineOption); + auto match = re.match(sysconfData); + if (!match.hasMatch()) { + return ActionReply::HelperErrorReply(); + } + + sysconfData.replace(match.capturedStart(), match.capturedLength(), + QStringLiteral("DISPLAYMANAGER_AUTOLOGIN=\"%0\"").arg(iterator.value().toString())); + + QByteArray newData = sysconfData.toUtf8(); + if (newconf.write(newData) != newData.length() || !newconf.commit()) { + return ActionReply::HelperErrorReply(); + } + } + // if there is an identical keyName in "sddm.conf" we want to delete it so SDDM doesn't read from the old file // hierarchically SDDM prefers "etc/sddm.conf" to "/etc/sddm.conf.d/some_file.conf" diff --git a/src/sddmsettingsbase.cpp b/src/sddmsettingsbase.cpp index e6e4af0..cbf3b3d 100644 --- a/src/sddmsettingsbase.cpp +++ b/src/sddmsettingsbase.cpp @@ -9,6 +9,7 @@ #include <QDebug> #include <QDir> +#include <QSettings> #include <algorithm> @@ -45,12 +46,13 @@ unsigned int SddmSettingsBase::defaultMaximumUid() const QString SddmSettingsBase::defaultUser() const { - return m_defaultConfig->group(QStringLiteral("AutoLogin")).readEntry("User"); + QSettings sysconfSettings(QStringLiteral("/etc/sysconfig/displaymanager"), QSettings::IniFormat); + return sysconfSettings.value(QStringLiteral("DISPLAYMANAGER_AUTOLOGIN")).toString(); } QString SddmSettingsBase::defaultSession() const { - return m_defaultConfig->group(QStringLiteral("AutoLogin")).readEntry("Session"); + return m_defaultConfig->group(QStringLiteral("AutoLogin")).readEntry("Session", "default.desktop"); } bool SddmSettingsBase::defaultRelogin() const -- 2.45.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor