diff --git a/sddmauthhelper.cpp b/sddmauthhelper.cpp --- a/sddmauthhelper.cpp +++ b/sddmauthhelper.cpp @@ -67,8 +67,17 @@ 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()) { + qDebug() << "Cannot proceed, user 'sddm' does not exist. Please check your SDDM install."; + return ActionReply::HelperErrorReply(); + } + // create SDDM config directory if it does not exist - QDir sddmConfigLocation(args[QStringLiteral("sddmUserConfig")].toString()); + QDir sddmConfigLocation(sddmHomeDirPath + QStringLiteral("/.config")); if (!sddmConfigLocation.exists()) { QDir().mkpath(sddmConfigLocation.path()); } @@ -151,7 +160,16 @@ ActionReply SddmAuthHelper::reset(const QVariantMap &args) { - QDir sddmConfigLocation(args[QStringLiteral("sddmUserConfig")].toString()); + // 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()) { + qDebug() << "Cannot proceed, user 'sddm' does not exist. Please check your SDDM install."; + return ActionReply::HelperErrorReply(); + } + + QDir sddmConfigLocation(sddmHomeDirPath + QStringLiteral("/.config")); QDir fontconfigDir(args[QStringLiteral("sddmUserConfig")].toString() + QStringLiteral("/fontconfig")); fontconfigDir.removeRecursively(); diff --git a/src/advancedconfig.cpp b/src/advancedconfig.cpp --- a/src/advancedconfig.cpp +++ b/src/advancedconfig.cpp @@ -148,6 +148,15 @@ void AdvancedConfig::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"); @@ -166,7 +175,6 @@ 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; @@ -225,13 +233,6 @@ qDebug() << "Cannot find plasmarc file."; } - if (!sddmUserConfigPath.isEmpty()) { - args[QStringLiteral("sddmUserConfig")] = sddmUserConfigPath; - } - else { - qDebug() << "Cannot find SDDM user directory."; - } - KAuth::Action syncAction(QStringLiteral("org.kde.kcontrol.kcmsddm.sync")); syncAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); syncAction.setArguments(args); @@ -252,20 +253,22 @@ void AdvancedConfig::resetSettingsChanged() { - // define paths - const QString sddmUserConfigPath = KUser("sddm").homeDir() + QStringLiteral("/.config"); + // 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; + } // send paths to helper QVariantMap args; - args[QStringLiteral("sddmUserConfig")] = sddmUserConfigPath; - args[QStringLiteral("kde_settings.conf")] = QString {QLatin1String(SDDM_CONFIG_DIR "/") + QStringLiteral("kde_settings.conf")}; args[QStringLiteral("sddm.conf")] = QLatin1String(SDDM_CONFIG_FILE); - args[QStringLiteral("sddmUserConfig")] = sddmUserConfigPath; - args[QStringLiteral("kde_settings.conf/Theme/CursorTheme")] = QVariant(); args[QStringLiteral("kde_settings.conf/X11/ServerArguments")] = QVariant();