Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:16.0:Staging:A
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 faaff11bc4aaddc471bc3ee2d0a79d72f4a0cda7 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 dea06ef..8f453a8 100644 --- a/sddmauthhelper.cpp +++ b/sddmauthhelper.cpp @@ -17,6 +17,8 @@ #include <QMimeDatabase> #include <QMimeType> #include <QSharedPointer> +#include <QSaveFile> +#include <QRegularExpression> #include <KArchive> #include <KConfig> @@ -281,6 +283,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 a928823..74ab3c9 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("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("AutoLogin").readEntry("Session"); + return m_defaultConfig->group("AutoLogin").readEntry("Session", "default.desktop"); } bool SddmSettingsBase::defaultRelogin() const -- 2.41.0
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