diff --git a/sddmauthhelper.cpp b/sddmauthhelper.cpp --- a/sddmauthhelper.cpp +++ b/sddmauthhelper.cpp @@ -67,6 +67,14 @@ ActionReply SddmAuthHelper::sync(const QVariantMap &args) { + // initial check for sddm user; abort if user not present + // we have to check with QString and isEmpty() instead of QDir and exists() because + // QDir returns "." and true for exists() in the case of a non-existent user; + QString sddmHomeDirPath = KUser("sddm").homeDir(); + if (sddmHomeDirPath.isEmpty()) { + return ActionReply::HelperErrorReply(); + } + // create SDDM config directory if it does not exist QDir sddmConfigLocation(args[QStringLiteral("sddmUserConfig")].toString()); if (!sddmConfigLocation.exists()) { @@ -151,6 +159,14 @@ ActionReply SddmAuthHelper::reset(const QVariantMap &args) { + // initial check for sddm user; abort if user not present + // we have to check with QString and isEmpty() instead of QDir and exists() because + // QDir returns "." and true for exists() in the case of a non-existent user; + QString sddmHomeDirPath = KUser("sddm").homeDir(); + if (sddmHomeDirPath.isEmpty()) { + return ActionReply::HelperErrorReply(); + } + QDir sddmConfigLocation(args[QStringLiteral("sddmUserConfig")].toString()); QDir fontconfigDir(args[QStringLiteral("sddmUserConfig")].toString() + QStringLiteral("/fontconfig")); diff --git a/src/advanceconfig.cpp b/src/advanceconfig.cpp --- a/src/advanceconfig.cpp +++ b/src/advanceconfig.cpp @@ -147,6 +147,15 @@ void AdvanceConfig::syncSettingsChanged() { + // initial check for sddm user; abort if user not present + // we have to check with QString and isEmpty() instead of QDir and exists() because + // QDir returns "." and true for exists() in the case of a non-existent user; + QString sddmHomeDirPath = KUser("sddm").homeDir(); + if (sddmHomeDirPath.isEmpty()) { + KMessageBox::error(this, QStringLiteral("Cannot proceed, user 'sddm' does not exist. Please check your SDDM install.")); + return; + } + // read Plasma values KConfig cursorConfig(QStringLiteral("kcminputrc")); KConfigGroup cursorConfigGroup(&cursorConfig, "Mouse"); @@ -162,10 +171,10 @@ QString numLock = numLockConfigGroup.readEntry("NumLock"); // define paths + const QString sddmUserConfigPath = sddmHomeDirPath + QStringLiteral("/.config"); const QString fontconfigPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("fontconfig"), QStandardPaths::LocateDirectory); const QString kdeglobalsPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("kdeglobals")); const QString plasmarcPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("plasmarc")); - const QString sddmUserConfigPath = KUser("sddm").homeDir() + QStringLiteral("/.config"); // send values and paths to helper, debug if it fails QVariantMap args; @@ -251,8 +260,17 @@ void AdvanceConfig::resetSettingsChanged() { + // initial check for sddm user; abort if user not present + // we have to check with QString and isEmpty() instead of QDir and exists() because + // QDir returns "." and true for exists() in the case of a non-existent user + QString sddmHomeDirPath = KUser("sddm").homeDir(); + if (sddmHomeDirPath.isEmpty()) { + KMessageBox::error(this, QStringLiteral("Cannot proceed, user 'sddm' does not exist. Please check your SDDM install.")); + return; + } + // define paths - const QString sddmUserConfigPath = KUser("sddm").homeDir() + QStringLiteral("/.config"); + const QString sddmUserConfigPath = sddmHomeDirPath + QStringLiteral("/.config"); // send paths to helper QVariantMap args;