Changeset View
Changeset View
Standalone View
Standalone View
src/runtime/kwalletd/main.cpp
Show All 27 Lines | |||||
28 | #include <KConfigGroup> | 28 | #include <KConfigGroup> | ||
29 | #include <KDBusService> | 29 | #include <KDBusService> | ||
30 | 30 | | |||
31 | #include <stdio.h> | 31 | #include <stdio.h> | ||
32 | 32 | | |||
33 | #include "backend/kwalletbackend.h" //For the hash size | 33 | #include "backend/kwalletbackend.h" //For the hash size | ||
34 | #include "kwalletd.h" | 34 | #include "kwalletd.h" | ||
35 | #include "kwalletd_version.h" | 35 | #include "kwalletd_version.h" | ||
36 | #include "migrationagent.h" | | |||
37 | 36 | | |||
38 | #ifndef Q_OS_WIN | 37 | #ifndef Q_OS_WIN | ||
39 | #include <sys/types.h> | 38 | #include <sys/types.h> | ||
40 | #include <sys/socket.h> | 39 | #include <sys/socket.h> | ||
41 | #include <sys/un.h> | 40 | #include <sys/un.h> | ||
42 | #include <unistd.h> | 41 | #include <unistd.h> | ||
43 | 42 | | |||
44 | #define BSIZE 1000 | 43 | #define BSIZE 1000 | ||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 180 | KAboutData aboutdata(I18N_NOOP("kwalletd"), | |||
186 | i18n("(C) 2002-2013, The KDE Developers")); | 185 | i18n("(C) 2002-2013, The KDE Developers")); | ||
187 | aboutdata.addAuthor(i18n("Valentin Rusu"), i18n("Maintainer, GPG backend support"), QStringLiteral("kde@rusu.info")); | 186 | aboutdata.addAuthor(i18n("Valentin Rusu"), i18n("Maintainer, GPG backend support"), QStringLiteral("kde@rusu.info")); | ||
188 | aboutdata.addAuthor(i18n("Michael Leupold"), i18n("Former Maintainer"), QStringLiteral("lemma@confuego.org")); | 187 | aboutdata.addAuthor(i18n("Michael Leupold"), i18n("Former Maintainer"), QStringLiteral("lemma@confuego.org")); | ||
189 | aboutdata.addAuthor(i18n("George Staikos"), i18n("Former maintainer"), QStringLiteral("staikos@kde.org")); | 188 | aboutdata.addAuthor(i18n("George Staikos"), i18n("Former maintainer"), QStringLiteral("staikos@kde.org")); | ||
190 | aboutdata.addAuthor(i18n("Thiago Maceira"), i18n("D-Bus Interface"), QStringLiteral("thiago@kde.org")); | 189 | aboutdata.addAuthor(i18n("Thiago Maceira"), i18n("D-Bus Interface"), QStringLiteral("thiago@kde.org")); | ||
191 | 190 | | |||
192 | KDBusService dbusUniqueInstance(KDBusService::Unique); | 191 | KDBusService dbusUniqueInstance(KDBusService::Unique); | ||
193 | 192 | | |||
194 | KWalletD walletd; | | |||
195 | MigrationAgent migrationAgent(&walletd, hash); | | |||
196 | | ||||
197 | // NOTE: the command should be parsed only after KDBusService instantiation | 193 | // NOTE: the command should be parsed only after KDBusService instantiation | ||
198 | QCommandLineParser cmdParser; | 194 | QCommandLineParser cmdParser; | ||
199 | aboutdata.setupCommandLine(&cmdParser); | 195 | aboutdata.setupCommandLine(&cmdParser); | ||
200 | cmdParser.process(app); | 196 | cmdParser.process(app); | ||
201 | 197 | | |||
202 | aboutdata.setProgramIconName(QStringLiteral("kwalletmanager")); | 198 | aboutdata.setProgramIconName(QStringLiteral("kwalletmanager")); | ||
203 | 199 | | |||
204 | app.setQuitOnLastWindowClosed(false); | 200 | app.setQuitOnLastWindowClosed(false); | ||
205 | auto disableSessionManagement = [](QSessionManager &sm) { | 201 | auto disableSessionManagement = [](QSessionManager &sm) { | ||
206 | sm.setRestartHint(QSessionManager::RestartNever); | 202 | sm.setRestartHint(QSessionManager::RestartNever); | ||
207 | }; | 203 | }; | ||
208 | QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); | 204 | QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); | ||
209 | QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); | 205 | QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); | ||
210 | 206 | | |||
211 | // check if kwallet is disabled | 207 | // check if kwallet is disabled | ||
212 | if (!isWalletEnabled()) { | 208 | if (!isWalletEnabled()) { | ||
213 | qCDebug(KWALLETD_LOG) << "kwalletd is disabled!"; | 209 | qCDebug(KWALLETD_LOG) << "kwalletd is disabled!"; | ||
214 | return (0); | 210 | return (0); | ||
215 | } | 211 | } | ||
216 | 212 | | |||
217 | qCDebug(KWALLETD_LOG) << "kwalletd5 started"; | 213 | qCDebug(KWALLETD_LOG) << "kwalletd5 started"; | ||
218 | 214 | | |||
219 | #ifndef Q_OS_WIN | 215 | #ifndef Q_OS_WIN | ||
220 | if (hash) { | 216 | if (hash) { | ||
217 | KWalletD walletd; | ||||
221 | QByteArray passHash(hash, PBKDF2_SHA512_KEYSIZE); | 218 | QByteArray passHash(hash, PBKDF2_SHA512_KEYSIZE); | ||
222 | int wallet = walletd.pamOpen(KWallet::Wallet::LocalWallet(), passHash, 0); | 219 | int wallet = walletd.pamOpen(KWallet::Wallet::LocalWallet(), passHash, 0); | ||
223 | if (wallet < 0) { | 220 | if (wallet < 0) { | ||
224 | qWarning() << "Wallet failed to get opened by PAM, error code is" << wallet; | 221 | qWarning() << "Wallet failed to get opened by PAM, error code is" << wallet; | ||
225 | } else { | 222 | } else { | ||
226 | qCDebug(KWALLETD_LOG) << "Wallet opened by PAM"; | 223 | qCDebug(KWALLETD_LOG) << "Wallet opened by PAM"; | ||
227 | } | 224 | } | ||
228 | free(hash); | 225 | free(hash); | ||
229 | } | 226 | } | ||
230 | #endif | 227 | #endif | ||
231 | 228 | | |||
232 | return app.exec(); | 229 | return app.exec(); | ||
233 | } | 230 | } |