Changeset View
Changeset View
Standalone View
Standalone View
sddmauthhelper.cpp
Show All 33 Lines | |||||
34 | #include <KConfigGroup> | 34 | #include <KConfigGroup> | ||
35 | #include <KLocalizedString> | 35 | #include <KLocalizedString> | ||
36 | #include <KTar> | 36 | #include <KTar> | ||
37 | #include <KUser> | 37 | #include <KUser> | ||
38 | #include <KZip> | 38 | #include <KZip> | ||
39 | 39 | | |||
40 | static QSharedPointer<KConfig> openConfig(const QString &filePath) | 40 | static QSharedPointer<KConfig> openConfig(const QString &filePath) | ||
41 | { | 41 | { | ||
42 | // if the sddm.conf.d folder doesn't exist we fail to set the right permissions for kde_settings.conf | ||||
43 | QFileInfo fileLocation(filePath); | ||||
44 | QDir dir(fileLocation.absolutePath()); | ||||
45 | if (!dir.exists()) { | ||||
46 | QDir().mkpath(dir.path()); | ||||
47 | } | ||||
42 | QFile file(filePath); | 48 | QFile file(filePath); | ||
43 | if(!file.exists()) { | 49 | if(!file.exists()) { | ||
44 | // If we are creating the config file, ensure it is world-readable: if | 50 | // If we are creating the config file, ensure it is world-readable: if | ||
45 | // we don't do that, KConfig will create a file which is only readable | 51 | // we don't do that, KConfig will create a file which is only readable | ||
46 | // by root | 52 | // by root | ||
47 | file.open(QIODevice::WriteOnly); | 53 | file.open(QIODevice::WriteOnly); | ||
48 | file.close(); | 54 | file.close(); | ||
49 | file.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOther); | 55 | file.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOther); | ||
50 | } | 56 | } | ||
57 | // in case the file has already been created with wrong permissions | ||||
58 | else if (!(file.permissions() & QFile::ReadOwner & QFile::WriteOwner & QFile::ReadGroup & QFile::ReadOther)) { | ||||
59 | file.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOther); | ||||
60 | } | ||||
61 | | ||||
51 | return QSharedPointer<KConfig>(new KConfig(file.fileName(), KConfig::SimpleConfig)); | 62 | return QSharedPointer<KConfig>(new KConfig(file.fileName(), KConfig::SimpleConfig)); | ||
52 | } | 63 | } | ||
53 | 64 | | |||
54 | void SddmAuthHelper::copyFile(const QString &source, const QString &destination) | 65 | void SddmAuthHelper::copyFile(const QString &source, const QString &destination) | ||
55 | { | 66 | { | ||
56 | KUser sddmUser(QStringLiteral("sddm")); | 67 | KUser sddmUser(QStringLiteral("sddm")); | ||
57 | 68 | | |||
58 | if (QFile::exists(destination)) { | 69 | if (QFile::exists(destination)) { | ||
▲ Show 20 Lines • Show All 341 Lines • Show Last 20 Lines |