From 1212fc79f7110934f44bbfc2b78ebb0bc072db19 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 25 Sep 2022 18:49:42 +0300 Subject: [PATCH] generic: adjust to authorization changes Signed-off-by: Ivailo Monev --- dolphin/src/dolphinpart.cpp | 1 - kate/addons/kate/konsole/kateconsole.cpp | 1 - kate/addons/kate/mailfiles/katemailfiles.cpp | 4 - .../kate/textfilter/plugin_katetextfilter.cpp | 2 - kcmshell/main.cpp | 3 - kcontrol/dateandtime/helper.cpp | 13 +-- kcontrol/dateandtime/helper.h | 8 +- kcontrol/dateandtime/main.cpp | 27 +++--- kcontrol/kfontinst/dbus/FontInst.cpp | 25 +++-- kcontrol/kfontinst/dbus/Helper.cpp | 11 +-- kcontrol/kfontinst/dbus/Helper.h | 14 ++- .../workspaceoptions/workspaceoptions.cpp | 2 - kgreeter/kcm/kgreeterconfig.cpp | 32 ++++--- kgreeter/kcm/kgreeterhelper.cpp | 16 ++-- kgreeter/kcm/kgreeterhelper.h | 9 +- konsole/desktop/konsole.desktop | 1 - konsole/desktop/konsolehere.desktop | 1 - konsole/desktop/konsolepart.desktop | 2 - konsole/desktop/konsolerun.desktop | 1 - krunner/krunnerapp.cpp | 11 +-- ksmserver/server.cpp | 39 ++++---- .../shorturi/kshorturifilter.cpp | 18 ---- kwin/useractions.cpp | 13 +-- libs/konq/konq_operations.cpp | 1 - libs/konq/konq_popupmenu.cpp | 1 - libs/ksysguard/processcore/helper.cpp | 35 +++---- libs/ksysguard/processcore/helper.h | 18 ++-- .../processui/ksysguardprocesslist.cpp | 70 +++++++------- .../applets/kickoff/core/applicationmodel.cpp | 1 - plasma/applets/kickoff/core/leavemodel.cpp | 50 ++++------ .../containmentactions/contextmenu/menu.cpp | 17 +--- .../powermanagement/powermanagementjob.cpp | 16 +--- plasma/design/security | 3 - plasma/runners/sessions/sessionrunner.cpp | 42 +++------ plasma/runners/sessions/sessionrunner.h | 1 - plasma/toolboxes/desktoptoolbox.cpp | 29 ++---- soliduiserver/soliduiserver.cpp | 93 +++++++++---------- soliduiserver/soliduiserver_helper.cpp | 80 +++++++--------- soliduiserver/soliduiserver_helper.h | 16 ++-- systemsettings/core/ModuleView.cpp | 17 +--- 40 files changed, 285 insertions(+), 459 deletions(-) diff --git a/dolphin/src/dolphinpart.cpp b/dolphin/src/dolphinpart.cpp index 80c55e73..7c0382ec 100644 --- a/dolphin/src/dolphinpart.cpp +++ b/dolphin/src/dolphinpart.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/kate/addons/kate/konsole/kateconsole.cpp b/kate/addons/kate/konsole/kateconsole.cpp index 6fc49261..26212f8f 100644 --- a/kate/addons/kate/konsole/kateconsole.cpp +++ b/kate/addons/kate/konsole/kateconsole.cpp @@ -48,7 +48,6 @@ #include #include #include -#include K_PLUGIN_FACTORY(KateKonsoleFactory, registerPlugin();) K_EXPORT_PLUGIN(KateKonsoleFactory(KAboutData("katekonsole","katekonsoleplugin",ki18n("Konsole"), "0.1", ki18n("Embedded Konsole"), KAboutData::License_LGPL_V2)) ) diff --git a/kate/addons/kate/mailfiles/katemailfiles.cpp b/kate/addons/kate/mailfiles/katemailfiles.cpp index 4b9bcfc9..a09a0d91 100644 --- a/kate/addons/kate/mailfiles/katemailfiles.cpp +++ b/kate/addons/kate/mailfiles/katemailfiles.cpp @@ -27,21 +27,17 @@ #include #include #include - #include #include #include - #include #include #include #include #include - #include #include #include -#include K_PLUGIN_FACTORY(KateMailFilesFactory, registerPlugin();) K_EXPORT_PLUGIN(KateMailFilesFactory(KAboutData("katemailfilesplugin","katemailfilesplugin",ki18n("Mail Files"), "0.1", ki18n("Support mailing files"), KAboutData::License_LGPL_V2)) ) diff --git a/kate/addons/kate/textfilter/plugin_katetextfilter.cpp b/kate/addons/kate/textfilter/plugin_katetextfilter.cpp index ae957bb6..906e17e8 100644 --- a/kate/addons/kate/textfilter/plugin_katetextfilter.cpp +++ b/kate/addons/kate/textfilter/plugin_katetextfilter.cpp @@ -34,9 +34,7 @@ #include #include #include - #include -#include #include #include diff --git a/kcmshell/main.cpp b/kcmshell/main.cpp index d2bbbe1e..cda93444 100644 --- a/kcmshell/main.cpp +++ b/kcmshell/main.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -65,8 +64,6 @@ static void listModules() it != services.end(); ++it) { const KService::Ptr s = (*it); - if (!KAuthorized::authorizeControlModule(s->menuId())) - continue; m_modules.append(s); } diff --git a/kcontrol/dateandtime/helper.cpp b/kcontrol/dateandtime/helper.cpp index 0e9be3f7..d856f5eb 100644 --- a/kcontrol/dateandtime/helper.cpp +++ b/kcontrol/dateandtime/helper.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -159,7 +158,7 @@ ClockHelper::CH_Error ClockHelper::tzreset() return NoError; } -ActionReply ClockHelper::save(const QVariantMap &args) +int ClockHelper::save(const QVariantMap &args) { bool _ntp = args.value("ntp").toBool(); bool _date = args.value("date").toBool(); @@ -179,13 +178,7 @@ ActionReply ClockHelper::save(const QVariantMap &args) if( _tzreset ) ret |= tzreset(); - if (ret == NoError) { - return ActionReply::SuccessReply; - } else { - ActionReply reply(ActionReply::HelperError); - reply.setErrorCode(ret); - return reply; - } + return ret; } -KDE4_AUTH_HELPER_MAIN("org.kde.kcontrol.kcmclock", ClockHelper) +K_AUTH_MAIN("org.kde.kcontrol.kcmclock", ClockHelper) diff --git a/kcontrol/dateandtime/helper.h b/kcontrol/dateandtime/helper.h index 5ba7fb3b..4821a2e7 100644 --- a/kcontrol/dateandtime/helper.h +++ b/kcontrol/dateandtime/helper.h @@ -21,11 +21,9 @@ #ifndef CLOCK_HELPER_H #define CLOCK_HELPER_H -#include +#include -using namespace KAuth; - -class ClockHelper : public QObject +class ClockHelper : public KAuthorization { Q_OBJECT @@ -39,7 +37,7 @@ class ClockHelper : public QObject }; public slots: - ActionReply save(const QVariantMap &map); + int save(const QVariantMap &map); private: CH_Error ntp(const QStringList& ntpServers, bool ntpEnabled); diff --git a/kcontrol/dateandtime/main.cpp b/kcontrol/dateandtime/main.cpp index faf30293..8bb21f90 100644 --- a/kcontrol/dateandtime/main.cpp +++ b/kcontrol/dateandtime/main.cpp @@ -32,14 +32,13 @@ #include #include #include +#include #include "moc_main.cpp" #include "dtime.h" #include "helper.h" -#include - K_PLUGIN_FACTORY(KlockModuleFactory, registerPlugin();) K_EXPORT_PLUGIN(KlockModuleFactory("kcmkclock")) @@ -76,7 +75,11 @@ KclockModule::KclockModule(QWidget *parent, const QVariantList &) setButtons(Help|Apply); - setNeedsAuthorization(true); + + if (!KAuthorization::isAuthorized("org.kde.kcontrol.kcmclock")) { + setUseRootOnlyMessage(true); + setRootOnlyMessage(i18n("You are not allowed to save the configuration")); + } } void KclockModule::save() @@ -86,19 +89,17 @@ void KclockModule::save() QVariantMap helperargs; dtime->save( helperargs ); - Action *action = authAction(); - action->setArguments(helperargs); + int reply = KAuthorization::execute( + "org.kde.kcontrol.kcmclock", "save", helperargs + ); - ActionReply reply = action->execute(); - - if (reply.failed()) { - if (reply.type() == ActionReply::KAuthError) { - KMessageBox::error(this, i18n("Unable to authenticate/execute the action: %1, %2", reply.errorCode(), reply.errorDescription())); + if (reply != KAuthorization::NoError) { + if (reply < KAuthorization::NoError) { + KMessageBox::error(this, i18n("Unable to authenticate/execute the action: %1", KAuthorization::errorString(reply))); } else { - dtime->processHelperErrors(reply.errorCode()); + dtime->processHelperErrors(reply); } - } - else { + } else { QDBusMessage msg = QDBusMessage::createSignal("/org/kde/kcmshell_clock", "org.kde.kcmshell_clock", "clockUpdated"); QDBusConnection::sessionBus().send(msg); } diff --git a/kcontrol/kfontinst/dbus/FontInst.cpp b/kcontrol/kfontinst/dbus/FontInst.cpp index 2bf3f0a5..d32bfb5f 100644 --- a/kcontrol/kfontinst/dbus/FontInst.cpp +++ b/kcontrol/kfontinst/dbus/FontInst.cpp @@ -26,8 +26,7 @@ #include #include -#include -#include +#include #include #include #include @@ -947,24 +946,22 @@ bool FontInst::findFont(const QString &family, quint32 style, EFolder folder, int FontInst::performAction(const QVariantMap &args) { - KAuth::Action action("org.kde.fontinst.manage"); - - action.setHelperID("org.kde.fontinst"); - action.setArguments(args); KFI_DBUG << "Call " << args["method"].toString() << " on helper"; itsFontListTimer->stop(); itsConnectionsTimer->stop(); - KAuth::ActionReply reply = action.execute(); + int reply = KAuthorization::execute( + "org.kde.fontinst", "manage", args + ); - switch(reply.type()) + switch(reply) { - case KAuth::ActionReply::KAuthError: - KFI_DBUG << "KAuth failed - error code:" << reply.errorCode(); + case KAuthorization::AuthorizationError: + KFI_DBUG << "KAuth failed - error code:" << reply; return KIO::ERR_COULD_NOT_AUTHENTICATE; - case KAuth::ActionReply::HelperError: - KFI_DBUG << "Helper failed - error code:" << reply.errorCode(); - return (int)reply.errorCode(); - case KAuth::ActionReply::Success: + case KAuthorization::HelperError: + KFI_DBUG << "Helper failed - error code:" << reply; + return reply; + case KAuthorization::NoError: KFI_DBUG << "Success!"; } diff --git a/kcontrol/kfontinst/dbus/Helper.cpp b/kcontrol/kfontinst/dbus/Helper.cpp index b0833dc0..c624504e 100644 --- a/kcontrol/kfontinst/dbus/Helper.cpp +++ b/kcontrol/kfontinst/dbus/Helper.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,7 @@ #define KFI_DBUG kDebug() << time(0L) -KDE4_AUTH_HELPER_MAIN("org.kde.fontinst", KFI::Helper) +K_AUTH_MAIN("org.kde.fontinst", KFI::Helper) namespace KFI { @@ -109,7 +108,7 @@ Helper::~Helper() theFontFolder.saveDisabled(); } -ActionReply Helper::manage(const QVariantMap &args) +int Helper::manage(const QVariantMap &args) { int result=KIO::ERR_UNSUPPORTED_ACTION; QString method=args["method"].toString(); @@ -134,11 +133,9 @@ ActionReply Helper::manage(const QVariantMap &args) KFI_DBUG << "Uknown action"; if(FontInst::STATUS_OK==result) - return ActionReply::SuccessReply; + return KAuthorization::NoError; - ActionReply reply(ActionReply::HelperError); - reply.setErrorCode(result); - return reply; + return result; } int Helper::install(const QVariantMap &args) diff --git a/kcontrol/kfontinst/dbus/Helper.h b/kcontrol/kfontinst/dbus/Helper.h index f0750335..728643a8 100644 --- a/kcontrol/kfontinst/dbus/Helper.h +++ b/kcontrol/kfontinst/dbus/Helper.h @@ -24,29 +24,27 @@ * Boston, MA 02110-1301, USA. */ -#include #include -#include -using namespace KAuth; +#include namespace KFI { -class Helper : public QObject +class Helper : public KAuthorization { Q_OBJECT - public: +public: Helper(); ~Helper(); - public Q_SLOTS: +public Q_SLOTS: - ActionReply manage(const QVariantMap &args); + int manage(const QVariantMap &args); - private: +private: int install(const QVariantMap &args); int uninstall(const QVariantMap &args); diff --git a/kcontrol/workspaceoptions/workspaceoptions.cpp b/kcontrol/workspaceoptions/workspaceoptions.cpp index 2262a0d2..e5a4a36c 100644 --- a/kcontrol/workspaceoptions/workspaceoptions.cpp +++ b/kcontrol/workspaceoptions/workspaceoptions.cpp @@ -31,8 +31,6 @@ #include #include -using namespace KAuth; - K_PLUGIN_FACTORY(WorkspaceOptionsModuleFactory, registerPlugin();) K_EXPORT_PLUGIN(WorkspaceOptionsModuleFactory("kcmworkspaceoptions")) diff --git a/kgreeter/kcm/kgreeterconfig.cpp b/kgreeter/kcm/kgreeterconfig.cpp index 911125c0..0e16552f 100644 --- a/kgreeter/kcm/kgreeterconfig.cpp +++ b/kgreeter/kcm/kgreeterconfig.cpp @@ -24,12 +24,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -62,7 +62,10 @@ KCMGreeter::KCMGreeter(QWidget* parent, const QVariantList& args) about->addAuthor(ki18n("Ivailo Monev"), KLocalizedString(), "xakepa10@gmail.com"); setAboutData(about); - setNeedsAuthorization(true); + if (!KAuthorization::isAuthorized("org.kde.kcontrol.kcmkgreeter")) { + setUseRootOnlyMessage(true); + setRootOnlyMessage(i18n("You are not allowed to save the configuration")); + } load(); @@ -146,19 +149,20 @@ void KCMGreeter::load() void KCMGreeter::save() { - KAuth::Action kgreeteraction("org.kde.kcontrol.kcmkgreeter.save"); - kgreeteraction.setHelperID("org.kde.kcontrol.kcmkgreeter"); - kgreeteraction.addArgument("font", fontchooser->font().toString()); - kgreeteraction.addArgument("style", stylesbox->itemData(stylesbox->currentIndex()).toString()); - kgreeteraction.addArgument("colorscheme", colorsbox->itemData(colorsbox->currentIndex()).toString()); - kgreeteraction.addArgument("cursortheme", cursorbox->itemData(cursorbox->currentIndex()).toString()); - kgreeteraction.addArgument("background", backgroundrequester->url().path()); - kgreeteraction.addArgument("rectangle", rectanglerequester->url().path()); - KAuth::ActionReply kgreeterreply = kgreeteraction.execute(); - // qDebug() << kgreeterreply.errorCode() << kgreeterreply.errorDescription(); + QVariantMap kgreeterarguments; + kgreeterarguments.insert("font", fontchooser->font().toString()); + kgreeterarguments.insert("style", stylesbox->itemData(stylesbox->currentIndex()).toString()); + kgreeterarguments.insert("colorscheme", colorsbox->itemData(colorsbox->currentIndex()).toString()); + kgreeterarguments.insert("cursortheme", cursorbox->itemData(cursorbox->currentIndex()).toString()); + kgreeterarguments.insert("background", backgroundrequester->url().path()); + kgreeterarguments.insert("rectangle", rectanglerequester->url().path()); + int kgreeterreply = KAuthorization::execute( + "org.kde.kcontrol.kcmkgreeter", "save", kgreeterarguments + ); + // qDebug() << kgreeterreply; - if (kgreeterreply != KAuth::ActionReply::SuccessReply) { - KMessageBox::error(this, kgreeterreply.errorDescription()); + if (kgreeterreply != KAuthorization::NoError) { + KMessageBox::error(this, i18n("Could not save settings")); } enableTest(true); diff --git a/kgreeter/kcm/kgreeterhelper.cpp b/kgreeter/kcm/kgreeterhelper.cpp index 253d795d..bcff550c 100644 --- a/kgreeter/kcm/kgreeterhelper.cpp +++ b/kgreeter/kcm/kgreeterhelper.cpp @@ -19,16 +19,16 @@ #include "kgreeterhelper.h" #include -#include +#include #include "config-workspace.h" -ActionReply KGreeterHelper::save(const QVariantMap ¶meters) +int KGreeterHelper::save(const QVariantMap ¶meters) { if (!parameters.contains("font") || !parameters.contains("style") || !parameters.contains("colorscheme") || !parameters.contains("cursortheme") || !parameters.contains("background") || !parameters.contains("rectangle")) { - return KAuth::ActionReply::HelperErrorReply; + return KAuthorization::HelperError; } QString colorscheme = parameters.value("colorscheme").toString(); @@ -48,13 +48,11 @@ ActionReply KGreeterHelper::save(const QVariantMap ¶meters) kgreetersettings.setValue("greeter/background", parameters.value("background")); kgreetersettings.setValue("greeter/rectangle", parameters.value("rectangle")); if (kgreetersettings.status() != QSettings::NoError) { - KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError); - errorreply.setErrorDescription("Could not save settings"); - errorreply.setErrorCode(1); - return errorreply; + kWarning() << "Could not save settings"; + return KAuthorization::HelperError; } - return KAuth::ActionReply::SuccessReply; + return KAuthorization::NoError; } -KDE4_AUTH_HELPER_MAIN("org.kde.kcontrol.kcmkgreeter", KGreeterHelper) +K_AUTH_MAIN("org.kde.kcontrol.kcmkgreeter", KGreeterHelper) diff --git a/kgreeter/kcm/kgreeterhelper.h b/kgreeter/kcm/kgreeterhelper.h index 2b9c0ee9..deed403e 100644 --- a/kgreeter/kcm/kgreeterhelper.h +++ b/kgreeter/kcm/kgreeterhelper.h @@ -19,16 +19,13 @@ #ifndef KGREETERHELPER_H #define KGREETERHELPER_H -#include +#include -// methods return type must be ActionReply otherwise QMetaObject::invokeMethod() fails -using namespace KAuth; - -class KGreeterHelper : public QObject +class KGreeterHelper : public KAuthorization { Q_OBJECT public slots: - ActionReply save(const QVariantMap ¶meters); + int save(const QVariantMap ¶meters); }; #endif // KGREETERHELPER_H diff --git a/konsole/desktop/konsole.desktop b/konsole/desktop/konsole.desktop index 860d89b9..52dfd929 100755 --- a/konsole/desktop/konsole.desktop +++ b/konsole/desktop/konsole.desktop @@ -9,7 +9,6 @@ Actions=NewWindow; X-DocPath=konsole/index.html X-DBUS-StartupType=Multi X-KDE-StartupNotify=true -X-KDE-AuthorizeAction=shell_access Name=Konsole Name[af]=Konsole diff --git a/konsole/desktop/konsolehere.desktop b/konsole/desktop/konsolehere.desktop index 2bcec0e8..85f04d12 100644 --- a/konsole/desktop/konsolehere.desktop +++ b/konsole/desktop/konsolehere.desktop @@ -3,7 +3,6 @@ Type=Service X-KDE-ServiceTypes=KonqPopupMenu/Plugin MimeType=inode/directory; Actions=openTerminalHere; -X-KDE-AuthorizeAction=shell_access [Desktop Action openTerminalHere] TryExec=konsole diff --git a/konsole/desktop/konsolepart.desktop b/konsole/desktop/konsolepart.desktop index 0e13773f..86ef6111 100644 --- a/konsole/desktop/konsolepart.desktop +++ b/konsole/desktop/konsolepart.desktop @@ -10,8 +10,6 @@ X-KDE-BrowserView-Toggable=true X-KDE-BrowserView-ToggableView-Orientation=horizontal X-KDE-BrowserView-FollowActive=true -X-KDE-AuthorizeAction=shell_access - Name=Terminal Emulator Name[af]=Terminaal Emulasie Name[ar]=محاكي طرفية diff --git a/konsole/desktop/konsolerun.desktop b/konsole/desktop/konsolerun.desktop index 44ec3eae..8b02b690 100644 --- a/konsole/desktop/konsolerun.desktop +++ b/konsole/desktop/konsolerun.desktop @@ -3,7 +3,6 @@ Type=Service X-KDE-ServiceTypes=KonqPopupMenu/Plugin MimeType=application/x-executable; Actions=runInKonsole; -X-KDE-AuthorizeAction=shell_access [Desktop Action runInKonsole] TryExec=konsole diff --git a/krunner/krunnerapp.cpp b/krunner/krunnerapp.cpp index 9983b66f..eb78b71e 100644 --- a/krunner/krunnerapp.cpp +++ b/krunner/krunnerapp.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -128,12 +127,10 @@ void KRunnerApp::initialize() a->setGlobalShortcut(KShortcut(Qt::CTRL+Qt::Key_Escape)); connect(a, SIGNAL(triggered(bool)), SLOT(showTaskManager())); - if (KAuthorized::authorize(QLatin1String("switch_user"))) { - a = m_actionCollection->addAction(QLatin1String("Switch User")); - a->setText(i18n("Switch User")); - a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_Insert)); - connect(a, SIGNAL(triggered(bool)), SLOT(switchUser())); - } + a = m_actionCollection->addAction(QLatin1String("Switch User")); + a->setText(i18n("Switch User")); + a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_Insert)); + connect(a, SIGNAL(triggered(bool)), SLOT(switchUser())); //Setup the interface after we have set up the actions switch (KRunnerSettings::interface()) { diff --git a/ksmserver/server.cpp b/ksmserver/server.cpp index eae35a78..57c4f758 100644 --- a/ksmserver/server.cpp +++ b/ksmserver/server.cpp @@ -64,7 +64,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include -#include #include #include #include @@ -1015,29 +1014,27 @@ void KSMServer::wmChanged() void KSMServer::setupShortcuts() { - if (KAuthorized::authorize("logout")) { - KActionCollection* actionCollection = new KActionCollection(this); - KAction* a; - a = actionCollection->addAction("Log Out"); - a->setText(i18n("Log Out")); - a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_Delete)); - connect(a, SIGNAL(triggered(bool)), SLOT(defaultLogout())); + KActionCollection* actionCollection = new KActionCollection(this); + KAction* a; + a = actionCollection->addAction("Log Out"); + a->setText(i18n("Log Out")); + a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_Delete)); + connect(a, SIGNAL(triggered(bool)), SLOT(defaultLogout())); - a = actionCollection->addAction("Log Out Without Confirmation"); - a->setText(i18n("Log Out Without Confirmation")); - a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Delete)); - connect(a, SIGNAL(triggered(bool)), SLOT(logoutWithoutConfirmation())); + a = actionCollection->addAction("Log Out Without Confirmation"); + a->setText(i18n("Log Out Without Confirmation")); + a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Delete)); + connect(a, SIGNAL(triggered(bool)), SLOT(logoutWithoutConfirmation())); - a = actionCollection->addAction("Halt Without Confirmation"); - a->setText(i18n("Halt Without Confirmation")); - a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_PageDown)); - connect(a, SIGNAL(triggered(bool)), SLOT(haltWithoutConfirmation())); + a = actionCollection->addAction("Halt Without Confirmation"); + a->setText(i18n("Halt Without Confirmation")); + a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_PageDown)); + connect(a, SIGNAL(triggered(bool)), SLOT(haltWithoutConfirmation())); - a = actionCollection->addAction("Reboot Without Confirmation"); - a->setText(i18n("Reboot Without Confirmation")); - a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_PageUp)); - connect(a, SIGNAL(triggered(bool)), SLOT(rebootWithoutConfirmation())); - } + a = actionCollection->addAction("Reboot Without Confirmation"); + a->setText(i18n("Reboot Without Confirmation")); + a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_PageUp)); + connect(a, SIGNAL(triggered(bool)), SLOT(rebootWithoutConfirmation())); } void KSMServer::defaultLogout() diff --git a/kurifilter-plugins/shorturi/kshorturifilter.cpp b/kurifilter-plugins/shorturi/kshorturifilter.cpp index 9ea07e59..81e7b1fe 100644 --- a/kurifilter-plugins/shorturi/kshorturifilter.cpp +++ b/kurifilter-plugins/shorturi/kshorturifilter.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -347,15 +346,6 @@ bool KShortUriFilter::filterUri( KUriFilterData& data ) const u.setRef(ref); u.setQuery(query); - if (!KAuthorized::authorizeUrlAction( QLatin1String("open"), KUrl(), u)) - { - // No authorization, we pretend it's a file will get - // an access denied error later on. - setFilteredUri( data, u ); - setUriType( data, KUriFilterData::LocalFile ); - return true; - } - // Can be abs path to file or directory, or to executable with args bool isDir = S_ISDIR( buff.st_mode ); if( !isDir && access ( QFile::encodeName(path).data(), X_OK) == 0 ) @@ -477,14 +467,6 @@ bool KShortUriFilter::filterUri( KUriFilterData& data ) const u.setPath(path); u.setRef(ref); - if (!KAuthorized::authorizeUrlAction( QL1S("open"), KUrl(), u)) - { - // No authorization, we pretend it exists and will get - // an access denied error later on. - setFilteredUri( data, u ); - setUriType( data, KUriFilterData::LocalFile ); - return true; - } //kDebug(7023) << "fileNotFound -> ERROR"; setErrorMsg( data, i18n( "The file or folder %1 does not exist.", data.uri().prettyUrl() ) ); setUriType( data, KUriFilterData::Error ); diff --git a/kwin/useractions.cpp b/kwin/useractions.cpp index df1d3c57..24c22bc1 100755 --- a/kwin/useractions.cpp +++ b/kwin/useractions.cpp @@ -68,7 +68,6 @@ along with this program. If not, see . #include #include #include -#include #include #include @@ -137,8 +136,6 @@ bool UserActionsMenu::isMenuClient(const Client *c) const void UserActionsMenu::show(const QRect &pos, const QWeakPointer &cl) { - if (!KAuthorized::authorizeKAction("kwin_rmb")) - return; if (cl.isNull()) return; if (isShown()) // recursion @@ -214,10 +211,10 @@ void UserActionsMenu::helperDialog(const QString& message, const QWeakPointeraddAction(i18n("S&pecial Application Settings...")); action->setIcon(KIcon("preferences-system-windows-actions")); action->setData(Options::ApplicationRulesOp); - if (!KGlobal::config()->isImmutable() && - !KAuthorized::authorizeControlModules(configModules(true)).isEmpty()) { + if (!KGlobal::config()->isImmutable()) { advancedMenu->addSeparator(); action = advancedMenu->addAction(i18nc("Entry in context menu of window decoration to open the configuration module of KWin", "Window &Manager Settings...")); diff --git a/libs/konq/konq_operations.cpp b/libs/konq/konq_operations.cpp index 207c679b..862f0521 100644 --- a/libs/konq/konq_operations.cpp +++ b/libs/konq/konq_operations.cpp @@ -49,7 +49,6 @@ #include // For doDrop #include -#include #include #include #include diff --git a/libs/konq/konq_popupmenu.cpp b/libs/konq/konq_popupmenu.cpp index a4cd5958..02d9bf73 100644 --- a/libs/konq/konq_popupmenu.cpp +++ b/libs/konq/konq_popupmenu.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/libs/ksysguard/processcore/helper.cpp b/libs/ksysguard/processcore/helper.cpp index 04a7b2d8..ca7d6098 100644 --- a/libs/ksysguard/processcore/helper.cpp +++ b/libs/ksysguard/processcore/helper.cpp @@ -23,19 +23,18 @@ #include "helper.h" #include "processes_local_p.h" -#include - KSysGuardProcessListHelper::KSysGuardProcessListHelper() { qRegisterMetaType >(); } /* The functions here run as ROOT. So be careful. DO NOT TRUST THE INPUTS TO BE SANE. */ -#define GET_PID(i) parameters.value(QString("pid%1").arg(i), -1).toLongLong(); if(pid < 0) return KAuth::ActionReply::HelperErrorReply; +#define GET_PID(i) parameters.value(QString("pid%1").arg(i), -1).toLongLong(); if(pid < 0) return KAuthorization::HelperError; -KAuth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) { +int KSysGuardProcessListHelper::renice(QVariantMap parameters) +{ if(!parameters.contains("nicevalue") || !parameters.contains("pidcount")) - return KAuth::ActionReply::HelperErrorReply; + return KAuthorization::HelperError; KSysGuard::ProcessesLocal processes; int niceValue = parameters.value("nicevalue").toInt(); @@ -45,15 +44,17 @@ KAuth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) { qlonglong pid = GET_PID(i); success = processes.setNiceness(pid, niceValue) && success; } - if(success) - return KAuth::ActionReply::SuccessReply; - else - return KAuth::ActionReply::HelperErrorReply; + if (success) { + return KAuthorization::NoError; + } + return KAuthorization::HelperError; } -KAuth::ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameters) { - if(!parameters.contains("cpuScheduler") || !parameters.contains("cpuSchedulerPriority") || !parameters.contains("pidcount")) - return KAuth::ActionReply::HelperErrorReply; +int KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameters) +{ + if (!parameters.contains("cpuScheduler") || !parameters.contains("cpuSchedulerPriority") || !parameters.contains("pidcount")) { + return KAuthorization::HelperError; + } KSysGuard::ProcessesLocal processes; int cpuScheduler = parameters.value("cpuScheduler").toInt(); @@ -65,11 +66,11 @@ KAuth::ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap pa qlonglong pid = GET_PID(i); success = processes.setScheduler(pid, cpuScheduler, cpuSchedulerPriority) && success; } - if(success) - return KAuth::ActionReply::SuccessReply; - else - return KAuth::ActionReply::HelperErrorReply; + if (success) { + return KAuthorization::NoError; + } + return KAuthorization::HelperError; } -KDE4_AUTH_HELPER_MAIN("org.kde.ksysguard.processlisthelper", KSysGuardProcessListHelper) +K_AUTH_MAIN("org.kde.ksysguard.processlisthelper", KSysGuardProcessListHelper) diff --git a/libs/ksysguard/processcore/helper.h b/libs/ksysguard/processcore/helper.h index b1f26460..c34cda58 100644 --- a/libs/ksysguard/processcore/helper.h +++ b/libs/ksysguard/processcore/helper.h @@ -20,21 +20,19 @@ */ -#include -#include - -using namespace KAuth; +#include /* The functions here run as ROOT. So be careful. */ -class KSysGuardProcessListHelper : public QObject { +class KSysGuardProcessListHelper : public KAuthorization +{ Q_OBJECT - public: - KSysGuardProcessListHelper(); +public: + KSysGuardProcessListHelper(); - public Q_SLOTS: - ActionReply renice(QVariantMap parameters); - ActionReply changecpuscheduler(QVariantMap parameters); +public Q_SLOTS: + int renice(QVariantMap parameters); + int changecpuscheduler(QVariantMap parameters); }; Q_DECLARE_METATYPE( QList ) diff --git a/libs/ksysguard/processui/ksysguardprocesslist.cpp b/libs/ksysguard/processui/ksysguardprocesslist.cpp index af2ec748..5976a5fe 100644 --- a/libs/ksysguard/processui/ksysguardprocesslist.cpp +++ b/libs/ksysguard/processui/ksysguardprocesslist.cpp @@ -46,9 +46,7 @@ #include //For SIGTERM -#include -#include -#include +#include #include #include #include @@ -187,9 +185,6 @@ struct KSysGuardProcessListPrivate { /** The number rows and their children for the given parent in the mFilterModel model */ int totalRowCount(const QModelIndex &parent) const; - /** Helper function to setup 'action' with the given pids */ - void setupKAuthAction(KAuth::Action *action, const QList & pids) const; - /** fire a timer event if we are set to use our internal timer*/ void fireTimerEvent(); @@ -389,16 +384,6 @@ int KSysGuardProcessListPrivate::totalRowCount(const QModelIndex &parent ) const return total; } -void KSysGuardProcessListPrivate::setupKAuthAction(KAuth::Action *action, const QList & pids) const -{ - action->setHelperID("org.kde.ksysguard.processlisthelper"); - - int processCount = pids.count(); - for(int i = 0; i < processCount; i++) { - action->addArgument(QString("pid%1").arg(i), pids[i]); - } - action->addArgument("pidcount", processCount); -} void KSysGuardProcessList::selectionChanged() { int numSelected = d->mUi->treeView->selectionModel()->selectedRows().size(); @@ -1010,18 +995,24 @@ bool KSysGuardProcessList::reniceProcesses(const QList &pids, int nic if(unreniced_pids.isEmpty()) return true; //All processes were reniced successfully if(!d->mModel.isLocalhost()) return false; //We can't use kauth to renice non-localhost processes + QVariantMap actionarguments; + int processCount = unreniced_pids.count(); + for(int i = 0; i < processCount; i++) { + actionarguments.insert(QString("pid%1").arg(i), unreniced_pids[i]); + } + actionarguments.insert("pidcount", processCount); + actionarguments.insert("nicevalue", niceValue); + int reply = KAuthorization::execute( + "org.kde.ksysguard.processlisthelper", "renice", actionarguments + ); - KAuth::Action action("org.kde.ksysguard.processlisthelper.renice"); - action.setParentWidget(window()); - d->setupKAuthAction(&action, unreniced_pids); - action.addArgument("nicevalue", niceValue); - KAuth::ActionReply reply = action.execute(); - - if (reply == KAuth::ActionReply::SuccessReply) { + if (reply == KAuthorization::NoError) { updateList(); - } else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) { - KMessageBox::sorry(this, i18n("You do not have the permission to renice the process and there " - "was a problem trying to run as root. Error %1 %2", reply.errorCode(), reply.errorDescription())); + } else if (reply == KAuthorization::AuthorizationError) { + KMessageBox::sorry(this, i18n("You do not have the permission to crenice the process.")); + return false; + } else { + KMessageBox::sorry(this, i18n("There was a problem trying to renice the process")); return false; } return true; @@ -1135,18 +1126,25 @@ bool KSysGuardProcessList::changeCpuScheduler(const QList< long long> &pids, KSy if(unchanged_pids.isEmpty()) return true; if(!d->mModel.isLocalhost()) return false; //We can't use KAuth to affect non-localhost processes - KAuth::Action action("org.kde.ksysguard.processlisthelper.changecpuscheduler"); - action.setParentWidget(window()); - d->setupKAuthAction(&action, unchanged_pids); - action.addArgument("cpuScheduler", (int)newCpuSched); - action.addArgument("cpuSchedulerPriority", newCpuSchedPriority); - KAuth::ActionReply reply = action.execute(); + QVariantMap actionarguments; + int processCount = unchanged_pids.count(); + for(int i = 0; i < processCount; i++) { + actionarguments.insert(QString("pid%1").arg(i), unchanged_pids[i]); + } + actionarguments.insert("pidcount", processCount); + actionarguments.insert("cpuScheduler", (int)newCpuSched); + actionarguments.insert("cpuSchedulerPriority", newCpuSchedPriority); + int reply = KAuthorization::execute( + "org.kde.ksysguard.processlisthelper", "changecpuscheduler", actionarguments + ); - if (reply == KAuth::ActionReply::SuccessReply) { + if (reply == KAuthorization::NoError) { updateList(); - } else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) { - KMessageBox::sorry(this, i18n("You do not have the permission to change the CPU Scheduler for the process and there " - "was a problem trying to run as root. Error %1 %2", reply.errorCode(), reply.errorDescription())); + } else if (reply == KAuthorization::AuthorizationError) { + KMessageBox::sorry(this, i18n("You do not have the permission to change the CPU Scheduler for the process.")); + return false; + } else { + KMessageBox::sorry(this, i18n("There was a problem trying to change the CPU Scheduler for the process")); return false; } return true; diff --git a/plasma/applets/kickoff/core/applicationmodel.cpp b/plasma/applets/kickoff/core/applicationmodel.cpp index aaaa9915..3840eb3f 100644 --- a/plasma/applets/kickoff/core/applicationmodel.cpp +++ b/plasma/applets/kickoff/core/applicationmodel.cpp @@ -29,7 +29,6 @@ #include // KDE -#include #include #include #include diff --git a/plasma/applets/kickoff/core/leavemodel.cpp b/plasma/applets/kickoff/core/leavemodel.cpp index b9034fbe..31ae1095 100644 --- a/plasma/applets/kickoff/core/leavemodel.cpp +++ b/plasma/applets/kickoff/core/leavemodel.cpp @@ -24,7 +24,6 @@ #include // KDE -#include #include #include #include @@ -119,29 +118,22 @@ void LeaveModel::updateModel() QStandardItem *sessionOptions = new QStandardItem(i18n("Session")); // Logout - const bool canLogout = KAuthorized::authorizeKAction("logout") && KAuthorized::authorize("logout"); - if (canLogout) { - QStandardItem *logoutOption = createStandardItem("leave:/logoutonly"); - sessionOptions->appendRow(logoutOption); - } + QStandardItem *logoutOption = createStandardItem("leave:/logoutonly"); + sessionOptions->appendRow(logoutOption); // Lock - if (KAuthorized::authorizeKAction("lock_screen")) { - QStandardItem *lockOption = createStandardItem("leave:/lock"); - sessionOptions->appendRow(lockOption); - } + QStandardItem *lockOption = createStandardItem("leave:/lock"); + sessionOptions->appendRow(lockOption); // Save Session - if (canLogout) { - KConfigGroup c(KSharedConfig::openConfig("ksmserverrc", KConfig::NoGlobals), "General"); - if (c.readEntry("loginMode") == "restoreSavedSession") { - QStandardItem *saveSessionOption = createStandardItem("leave:/savesession"); - sessionOptions->appendRow(saveSessionOption); - } + KConfigGroup c(KSharedConfig::openConfig("ksmserverrc", KConfig::NoGlobals), "General"); + if (c.readEntry("loginMode") == "restoreSavedSession") { + QStandardItem *saveSessionOption = createStandardItem("leave:/savesession"); + sessionOptions->appendRow(saveSessionOption); } // Switch User - if (KDisplayManager().isSwitchable() && KAuthorized::authorize(QLatin1String("switch_user"))) { + if (KDisplayManager().isSwitchable()) { QStandardItem *switchUserOption = createStandardItem("leave:/switch"); sessionOptions->appendRow(switchUserOption); } @@ -170,20 +162,18 @@ void LeaveModel::updateModel() addSystemSession = true; } - if (canLogout) { - if (KWorkSpace::canShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeReboot)) { - // Restart - QStandardItem *restartOption = createStandardItem("leave:/restart"); - systemOptions->appendRow(restartOption); - addSystemSession = true; - } + if (KWorkSpace::canShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeReboot)) { + // Restart + QStandardItem *restartOption = createStandardItem("leave:/restart"); + systemOptions->appendRow(restartOption); + addSystemSession = true; + } - if (KWorkSpace::canShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeHalt)) { - // Shutdown - QStandardItem *shutDownOption = createStandardItem("leave:/shutdown"); - systemOptions->appendRow(shutDownOption); - addSystemSession = true; - } + if (KWorkSpace::canShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeHalt)) { + // Shutdown + QStandardItem *shutDownOption = createStandardItem("leave:/shutdown"); + systemOptions->appendRow(shutDownOption); + addSystemSession = true; } appendRow(sessionOptions); diff --git a/plasma/containmentactions/contextmenu/menu.cpp b/plasma/containmentactions/contextmenu/menu.cpp index 7fd8d7df..281f4079 100644 --- a/plasma/containmentactions/contextmenu/menu.cpp +++ b/plasma/containmentactions/contextmenu/menu.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -167,13 +166,9 @@ QAction *ContextMenu::action(const QString &name) } else if (name == "_run_command") { return m_runCommandAction; } else if (name == "_lock_screen") { - if (KAuthorized::authorizeKAction("lock_screen")) { - return m_lockScreenAction; - } + return m_lockScreenAction; } else if (name == "_logout") { - if (KAuthorized::authorizeKAction("logout")) { - return m_logoutAction; - } + return m_logoutAction; } else { //FIXME: remove action: make removal of current activity possible return c->action(name); @@ -190,10 +185,6 @@ void ContextMenu::runCommand() void ContextMenu::lockScreen() { - if (!KAuthorized::authorizeKAction("lock_screen")) { - return; - } - QString interface("org.freedesktop.ScreenSaver"); org::freedesktop::ScreenSaver screensaver(interface, "/ScreenSaver", QDBusConnection::sessionBus()); @@ -220,10 +211,6 @@ void ContextMenu::startLogout() void ContextMenu::logout() { - if (!KAuthorized::authorizeKAction("logout")) { - return; - } - KWorkSpace::requestShutDown(); } diff --git a/plasma/dataengines/powermanagement/powermanagementjob.cpp b/plasma/dataengines/powermanagement/powermanagementjob.cpp index 1cde1aa8..64271efa 100644 --- a/plasma/dataengines/powermanagement/powermanagementjob.cpp +++ b/plasma/dataengines/powermanagement/powermanagementjob.cpp @@ -21,8 +21,6 @@ #include #include -#include - // kde-workspace/libs #include @@ -49,15 +47,11 @@ void PowerManagementJob::start() //kDebug() << "starting operation ... " << operation; if (operation == "lockScreen") { - if (KAuthorized::authorizeKAction("lock_screen")) { - const QString interface("org.freedesktop.ScreenSaver"); - QDBusInterface screensaver(interface, "/ScreenSaver"); - screensaver.asyncCall("Lock"); - setResult(true); - return; - } - kDebug() << "operation denied " << operation; - setResult(false); +#warning TODO: error check + const QString interface("org.freedesktop.ScreenSaver"); + QDBusInterface screensaver(interface, "/ScreenSaver"); + screensaver.asyncCall("Lock"); + setResult(true); return; } else if (operation == "suspend" || operation == "suspendToRam") { if (!Solid::PowerManagement::supportedSleepStates().contains(Solid::PowerManagement::SuspendState)) { diff --git a/plasma/design/security b/plasma/design/security index f3dee85e..5f2827f5 100644 --- a/plasma/design/security +++ b/plasma/design/security @@ -43,9 +43,6 @@ enforced security This is security that doesn't rely on plasmoid developers. Mostly it's about disabling access to features via the scripting API, so that plasmoids using that API absolutely cannot use the disabled features. -it'd be nice if we could use KAuthorized to enforce some stuff on the c++ applets... I tried, but didn't get anywhere. - - misc ---- diff --git a/plasma/runners/sessions/sessionrunner.cpp b/plasma/runners/sessions/sessionrunner.cpp index 2424d7f5..c603a024 100644 --- a/plasma/runners/sessions/sessionrunner.cpp +++ b/plasma/runners/sessions/sessionrunner.cpp @@ -18,8 +18,6 @@ #include "sessionrunner.h" - -#include #include #include #include @@ -38,18 +36,13 @@ SessionRunner::SessionRunner(QObject *parent, const QVariantList &args) setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation); - m_canLogout = KAuthorized::authorizeKAction("logout") && KAuthorized::authorize("logout"); - if (m_canLogout) { - addSyntax(Plasma::RunnerSyntax(i18nc("log out command", "logout"), - i18n("Logs out, exiting the current desktop session"))); - addSyntax(Plasma::RunnerSyntax(i18nc("shutdown computer command", "shutdown"), - i18n("Turns off the computer"))); - } + addSyntax(Plasma::RunnerSyntax(i18nc("log out command", "logout"), + i18n("Logs out, exiting the current desktop session"))); + addSyntax(Plasma::RunnerSyntax(i18nc("shutdown computer command", "shutdown"), + i18n("Turns off the computer"))); - if (KAuthorized::authorizeKAction("lock_screen") && m_canLogout) { - addSyntax(Plasma::RunnerSyntax(i18nc("lock screen command", "lock"), - i18n("Locks the current sessions and starts the screen saver"))); - } + addSyntax(Plasma::RunnerSyntax(i18nc("lock screen command", "lock"), + i18n("Locks the current sessions and starts the screen saver"))); Plasma::RunnerSyntax rebootSyntax(i18nc("restart computer command", "restart"), i18n("Reboots the computer")); rebootSyntax.addExampleQuery(i18nc("restart computer command", "reboot")); @@ -76,10 +69,6 @@ SessionRunner::~SessionRunner() void SessionRunner::matchCommands(QList &matches, const QString& term) { - if (!m_canLogout) { - return; - } - if (term.compare(i18nc("log out command","logout"), Qt::CaseInsensitive) == 0 || term.compare(i18n("log out"), Qt::CaseInsensitive) == 0) { Plasma::QueryMatch match(this); @@ -107,15 +96,13 @@ void SessionRunner::matchCommands(QList &matches, const QStr match.setRelevance(0.9); matches << match; } else if (term.compare(i18nc("lock screen command","lock"), Qt::CaseInsensitive) == 0) { - if (KAuthorized::authorizeKAction("lock_screen")) { - Plasma::QueryMatch match(this); - match.setText(i18n("Lock the screen")); - match.setIcon(KIcon("system-lock-screen")); - match.setData(LockAction); - match.setType(Plasma::QueryMatch::ExactMatch); - match.setRelevance(0.9); - matches << match; - } + Plasma::QueryMatch match(this); + match.setText(i18n("Lock the screen")); + match.setIcon(KIcon("system-lock-screen")); + match.setData(LockAction); + match.setType(Plasma::QueryMatch::ExactMatch); + match.setRelevance(0.9); + matches << match; } } @@ -155,8 +142,7 @@ void SessionRunner::match(Plasma::RunnerContext &context) term.compare(i18n("switch user"), Qt::CaseInsensitive) == 0 || term.compare(i18n("new session"), Qt::CaseInsensitive) == 0; - if (switchUser && - KAuthorized::authorizeKAction("start_new_session") && dm.isSwitchable()) { + if (switchUser && dm.isSwitchable()) { Plasma::QueryMatch match(this); match.setType(Plasma::QueryMatch::ExactMatch); match.setIcon(KIcon("system-switch-user")); diff --git a/plasma/runners/sessions/sessionrunner.h b/plasma/runners/sessions/sessionrunner.h index 04196aa3..2b76bea3 100644 --- a/plasma/runners/sessions/sessionrunner.h +++ b/plasma/runners/sessions/sessionrunner.h @@ -46,7 +46,6 @@ class SessionRunner : public Plasma::AbstractRunner QString m_triggerWord; KDisplayManager dm; - bool m_canLogout; }; K_EXPORT_PLASMA_RUNNER(sessions, SessionRunner) diff --git a/plasma/toolboxes/desktoptoolbox.cpp b/plasma/toolboxes/desktoptoolbox.cpp index 08e47a4e..e342eed0 100644 --- a/plasma/toolboxes/desktoptoolbox.cpp +++ b/plasma/toolboxes/desktoptoolbox.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -175,19 +174,15 @@ void DesktopToolBox::init() this, SLOT(updateTheming())); Plasma::ToolTipManager::self()->registerWidget(this); - if (KAuthorized::authorizeKAction("logout")) { - QAction *action = new QAction(i18n("Leave..."), this); - action->setIcon(KIcon("system-shutdown")); - connect(action, SIGNAL(triggered()), this, SLOT(startLogout())); - addTool(action); - } + QAction *action = new QAction(i18n("Leave..."), this); + action->setIcon(KIcon("system-shutdown")); + connect(action, SIGNAL(triggered()), this, SLOT(startLogout())); + addTool(action); - if (KAuthorized::authorizeKAction("lock_screen")) { - QAction *action = new QAction(i18n("Lock Screen"), this); - action->setIcon(KIcon("system-lock-screen")); - connect(action, SIGNAL(triggered(bool)), this, SLOT(lockScreen())); - addTool(action); - } + action = new QAction(i18n("Lock Screen"), this); + action->setIcon(KIcon("system-lock-screen")); + connect(action, SIGNAL(triggered(bool)), this, SLOT(lockScreen())); + addTool(action); } QSize DesktopToolBox::cornerSize() const @@ -780,10 +775,6 @@ void DesktopToolBox::lockScreen() setShowing(false); } - if (!KAuthorized::authorizeKAction("lock_screen")) { - return; - } - const QString interface("org.freedesktop.ScreenSaver"); QDBusInterface screensaver(interface, "/ScreenSaver"); screensaver.asyncCall("Lock"); @@ -813,10 +804,6 @@ void DesktopToolBox::startLogout() void DesktopToolBox::logout() { - if (!KAuthorized::authorizeKAction("logout")) { - return; - } - KWorkSpace::requestShutDown(); } diff --git a/soliduiserver/soliduiserver.cpp b/soliduiserver/soliduiserver.cpp index 8cf573be..7fb1535c 100644 --- a/soliduiserver/soliduiserver.cpp +++ b/soliduiserver/soliduiserver.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -53,21 +53,18 @@ static int doMount(const QString &deviceuuid, const QString &devicenode, const Q return int(Solid::ErrorType::OperationFailed); } - KAuth::Action mountaction("org.kde.soliduiserver.mountunmounthelper.mount"); - mountaction.setHelperID("org.kde.soliduiserver.mountunmounthelper"); - mountaction.addArgument("device", devicenode); - mountaction.addArgument("mountpoint", mountpoint); - mountaction.addArgument("fstype", devicefstype); - KAuth::ActionReply mountreply = mountaction.execute(); - // qDebug() << "mount" << mountreply.errorCode() << mountreply.errorDescription(); + QVariantMap mountarguments; + mountarguments.insert("device", devicenode); + mountarguments.insert("mountpoint", mountpoint); + mountarguments.insert("fstype", devicefstype); + int mountreply = KAuthorization::execute( + "org.kde.soliduiserver.mountunmounthelper", "mount", mountarguments + ); + // qDebug() << "mount" << mountreply; - if (mountreply == KAuth::ActionReply::SuccessReply) { + if (mountreply == KAuthorization::NoError) { return int(Solid::ErrorType::NoError); - } - - if (mountreply == KAuth::ActionReply::UserCancelled) { - return int(Solid::ErrorType::UserCanceled); - } else if (mountreply == KAuth::ActionReply::AuthorizationDenied) { + } else if (mountreply == KAuthorization::AuthorizationError) { return int(Solid::ErrorType::UnauthorizedOperation); } return int(Solid::ErrorType::OperationFailed); @@ -75,19 +72,16 @@ static int doMount(const QString &deviceuuid, const QString &devicenode, const Q static int doUnmount(const QString &devicemountpoint) { - KAuth::Action unmountaction("org.kde.soliduiserver.mountunmounthelper.unmount"); - unmountaction.setHelperID("org.kde.soliduiserver.mountunmounthelper"); - unmountaction.addArgument("mountpoint", devicemountpoint); - KAuth::ActionReply unmountreply = unmountaction.execute(); - // qDebug() << "unmount" << unmountreply.errorCode() << unmountreply.errorDescription(); + QVariantMap unmountarguments; + unmountarguments.insert("mountpoint", devicemountpoint); + int unmountreply = KAuthorization::execute( + "org.kde.soliduiserver.mountunmounthelper", "unmount", unmountarguments + ); + // qDebug() << "unmount" << unmountreply; - if (unmountreply == KAuth::ActionReply::SuccessReply) { + if (unmountreply == KAuthorization::NoError) { return int(Solid::ErrorType::NoError); - } - - if (unmountreply == KAuth::ActionReply::UserCancelled) { - return int(Solid::ErrorType::UserCanceled); - } else if (unmountreply == KAuth::ActionReply::AuthorizationDenied) { + } else if (unmountreply == KAuthorization::AuthorizationError) { return int(Solid::ErrorType::UnauthorizedOperation); } return int(Solid::ErrorType::OperationFailed); @@ -201,20 +195,18 @@ int SolidUiServer::mountDevice(const QString &udi) return int(Solid::ErrorType::UserCanceled); } - KAuth::Action cryptopenaction("org.kde.soliduiserver.mountunmounthelper.cryptopen"); - cryptopenaction.setHelperID("org.kde.soliduiserver.mountunmounthelper"); - cryptopenaction.addArgument("device", devicenode); - cryptopenaction.addArgument("name", deviceuuid); - cryptopenaction.addArgument("password", passworddialog.password().toLocal8Bit().toHex()); - KAuth::ActionReply cryptopenreply = cryptopenaction.execute(); + QVariantMap cryptopenarguments; + cryptopenarguments.insert("device", devicenode); + cryptopenarguments.insert("name", deviceuuid); + cryptopenarguments.insert("password", passworddialog.password().toLocal8Bit().toHex()); + int cryptopenreply = KAuthorization::execute( + "org.kde.soliduiserver.mountunmounthelper", "cryptopen", cryptopenarguments + ); + // qDebug() << "cryptopen" << cryptopenreply; - // qDebug() << "cryptopen" << cryptopenreply.errorCode() << cryptopenreply.errorDescription(); - - if (cryptopenreply == KAuth::ActionReply::UserCancelled) { - return int(Solid::ErrorType::UserCanceled); - } else if (cryptopenreply == KAuth::ActionReply::AuthorizationDenied) { + if (cryptopenreply == KAuthorization::AuthorizationError) { return int(Solid::ErrorType::UnauthorizedOperation); - } else if (cryptopenreply != KAuth::ActionReply::SuccessReply) { + } else if (cryptopenreply != KAuthorization::NoError) { return int(Solid::ErrorType::OperationFailed); } @@ -228,10 +220,11 @@ int SolidUiServer::mountDevice(const QString &udi) const int mountresult = doMount(deviceuuid, devicenode, storagevolume->fsType()); if (mountresult != int(Solid::ErrorType::NoError) && didcryptopen) { - KAuth::Action cryptcloseaction("org.kde.soliduiserver.mountunmounthelper.cryptclose"); - cryptcloseaction.setHelperID("org.kde.soliduiserver.mountunmounthelper"); - cryptcloseaction.addArgument("name", deviceuuid); - cryptcloseaction.execute(); + QVariantMap cryptclosearguments; + cryptclosearguments.insert("name", deviceuuid); + (void)KAuthorization::execute( + "org.kde.soliduiserver.mountunmounthelper", "cryptclose", cryptclosearguments + ); } return mountresult; } @@ -251,18 +244,16 @@ int SolidUiServer::unmountDevice(const QString &udi) } if (storagevolume->usage() == Solid::StorageVolume::Encrypted) { - KAuth::Action cryptcloseaction("org.kde.soliduiserver.mountunmounthelper.cryptclose"); - cryptcloseaction.setHelperID("org.kde.soliduiserver.mountunmounthelper"); - cryptcloseaction.addArgument("name", storagevolume->uuid()); - KAuth::ActionReply cryptclosereply = cryptcloseaction.execute(); + QVariantMap cryptclosearguments; + cryptclosearguments.insert("name", storagevolume->uuid()); + int cryptclosereply = KAuthorization::execute( + "org.kde.soliduiserver.mountunmounthelper", "cryptclose", cryptclosearguments + ); + // qDebug() << "cryptclose" << cryptclosereply; - // qDebug() << "cryptclose" << cryptclosereply.errorCode() << cryptclosereply.errorDescription(); - - if (cryptclosereply == KAuth::ActionReply::UserCancelled) { - return int(Solid::ErrorType::UserCanceled); - } else if (cryptclosereply == KAuth::ActionReply::AuthorizationDenied) { + if (cryptclosereply == KAuthorization::AuthorizationError) { return int(Solid::ErrorType::UnauthorizedOperation); - } else if (cryptclosereply != KAuth::ActionReply::SuccessReply) { + } else if (cryptclosereply != KAuthorization::NoError) { return int(Solid::ErrorType::OperationFailed); } } diff --git a/soliduiserver/soliduiserver_helper.cpp b/soliduiserver/soliduiserver_helper.cpp index ef447015..51f53a42 100644 --- a/soliduiserver/soliduiserver_helper.cpp +++ b/soliduiserver/soliduiserver_helper.cpp @@ -18,7 +18,6 @@ #include "soliduiserver_helper.h" -#include #include #include @@ -31,18 +30,16 @@ # include #endif -KAuth::ActionReply SolidUiServerHelper::cryptopen(const QVariantMap ¶meters) +int SolidUiServerHelper::cryptopen(const QVariantMap ¶meters) { if (!parameters.contains("device") || !parameters.contains("name") || !parameters.contains("password")) { - return KAuth::ActionReply::HelperErrorReply; + return KAuthorization::HelperError; } const QString cryptbin = KStandardDirs::findRootExe("cryptsetup"); if (cryptbin.isEmpty()) { - KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError); - errorreply.setErrorDescription("cryptsetup is missing"); - errorreply.setErrorCode(1); - return errorreply; + kWarning() << "cryptsetup is missing"; + return KAuthorization::HelperError; } const QString device = parameters.value("device").toString(); @@ -57,30 +54,26 @@ KAuth::ActionReply SolidUiServerHelper::cryptopen(const QVariantMap ¶meters) cryptproc.waitForFinished(); if (cryptproc.exitCode() == 0) { - return KAuth::ActionReply::SuccessReply; + return KAuthorization::NoError; } QString crypterror = cryptproc.readAllStandardError(); if (crypterror.isEmpty()) { crypterror = cryptproc.readAllStandardOutput(); } - KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError); - errorreply.setErrorDescription(crypterror); - errorreply.setErrorCode(cryptproc.exitCode()); - return errorreply; + kWarning() << crypterror; + return KAuthorization::HelperError; } -KAuth::ActionReply SolidUiServerHelper::cryptclose(const QVariantMap ¶meters) +int SolidUiServerHelper::cryptclose(const QVariantMap ¶meters) { if (!parameters.contains("name")) { - return KAuth::ActionReply::HelperErrorReply; + return KAuthorization::HelperError; } const QString cryptbin = KStandardDirs::findRootExe("cryptsetup"); if (cryptbin.isEmpty()) { - KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError); - errorreply.setErrorDescription("cryptsetup is missing"); - errorreply.setErrorCode(1); - return errorreply; + kWarning() << "cryptsetup is missing"; + return KAuthorization::HelperError; } const QString name = parameters.value("name").toString(); @@ -91,23 +84,21 @@ KAuth::ActionReply SolidUiServerHelper::cryptclose(const QVariantMap ¶meters cryptproc.waitForFinished(); if (cryptproc.exitCode() == 0) { - return KAuth::ActionReply::SuccessReply; + return KAuthorization::NoError; } QString crypterror = cryptproc.readAllStandardError(); if (crypterror.isEmpty()) { crypterror = cryptproc.readAllStandardOutput(); } - KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError); - errorreply.setErrorDescription(crypterror); - errorreply.setErrorCode(cryptproc.exitCode()); - return errorreply; + kWarning() << crypterror; + return KAuthorization::HelperError; } -KAuth::ActionReply SolidUiServerHelper::mount(const QVariantMap ¶meters) +int SolidUiServerHelper::mount(const QVariantMap ¶meters) { if (!parameters.contains("device") || !parameters.contains("mountpoint") || !parameters.contains("fstype")) { - return KAuth::ActionReply::HelperErrorReply; + return KAuthorization::HelperError; } const QString device = parameters.value("device").toString(); @@ -138,14 +129,11 @@ KAuth::ActionReply SolidUiServerHelper::mount(const QVariantMap ¶meters) 0, NULL ); if (mountresult == 0) { - return KAuth::ActionReply::SuccessReply; + return KAuthorization::NoError; } const int savederrno = errno; - // qDebug() << Q_FUNC_INFO << qt_error_string(savederrno); - KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError); - errorreply.setErrorDescription(qt_error_string(savederrno)); - errorreply.setErrorCode(savederrno); - return errorreply; + kWarning() << qt_error_string(savederrno); + return KAuthorization::HelperError; } #endif // Q_OS_LINUX @@ -156,22 +144,20 @@ KAuth::ActionReply SolidUiServerHelper::mount(const QVariantMap ¶meters) mountproc.waitForFinished(); if (mountproc.exitCode() == 0) { - return KAuth::ActionReply::SuccessReply; + return KAuthorization::NoError; } QString mounterror = mountproc.readAllStandardError(); if (mounterror.isEmpty()) { mounterror = mountproc.readAllStandardOutput(); } - KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError); - errorreply.setErrorDescription(mounterror); - errorreply.setErrorCode(mountproc.exitCode()); - return errorreply; + kWarning() << mounterror; + return KAuthorization::HelperError; } -KAuth::ActionReply SolidUiServerHelper::unmount(const QVariantMap ¶meters) +int SolidUiServerHelper::unmount(const QVariantMap ¶meters) { if (!parameters.contains("mountpoint")) { - return KAuth::ActionReply::HelperErrorReply; + return KAuthorization::HelperError; } const QString mountpoint = parameters.value("mountpoint").toString(); @@ -180,13 +166,11 @@ KAuth::ActionReply SolidUiServerHelper::unmount(const QVariantMap ¶meters) const QByteArray mountpointbytes = mountpoint.toLocal8Bit();; const int umountresult = ::umount2(mountpointbytes.constData(), MNT_DETACH); if (umountresult == 0) { - return KAuth::ActionReply::SuccessReply; + return KAuthorization::NoError; } const int savederrno = errno; - KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError); - errorreply.setErrorDescription(qt_error_string(savederrno)); - errorreply.setErrorCode(savederrno); - return errorreply; + kWarning() << qt_error_string(savederrno); + return KAuthorization::HelperError; #else const QStringList umountargs = QStringList() << mountpoint; QProcess umountproc; @@ -195,17 +179,15 @@ KAuth::ActionReply SolidUiServerHelper::unmount(const QVariantMap ¶meters) umountproc.waitForFinished(); if (umountproc.exitCode() == 0) { - return KAuth::ActionReply::SuccessReply; + return KAuthorization::NoError; } QString umounterror = umountproc.readAllStandardError(); if (umounterror.isEmpty()) { umounterror = umountproc.readAllStandardOutput(); } - KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError); - errorreply.setErrorDescription(umounterror); - errorreply.setErrorCode(umountproc.exitCode()); - return errorreply; + kWarning() << umounterror; + return KAuthorization::HelperError; #endif // Q_OS_LINUX } -KDE4_AUTH_HELPER_MAIN("org.kde.soliduiserver.mountunmounthelper", SolidUiServerHelper) +K_AUTH_MAIN("org.kde.soliduiserver.mountunmounthelper", SolidUiServerHelper) diff --git a/soliduiserver/soliduiserver_helper.h b/soliduiserver/soliduiserver_helper.h index ffcb177d..bba97352 100644 --- a/soliduiserver/soliduiserver_helper.h +++ b/soliduiserver/soliduiserver_helper.h @@ -19,20 +19,16 @@ #ifndef SOLIDUISERVER_HELPER_H #define SOLIDUISERVER_HELPER_H -#include -#include +#include -// methods return type must be ActionReply otherwise QMetaObject::invokeMethod() fails -using namespace KAuth; - -class SolidUiServerHelper : public QObject +class SolidUiServerHelper : public KAuthorization { Q_OBJECT public Q_SLOTS: - ActionReply cryptopen(const QVariantMap ¶meters); - ActionReply cryptclose(const QVariantMap ¶meters); - ActionReply mount(const QVariantMap ¶meters); - ActionReply unmount(const QVariantMap ¶meters); + int cryptopen(const QVariantMap ¶meters); + int cryptclose(const QVariantMap ¶meters); + int mount(const QVariantMap ¶meters); + int unmount(const QVariantMap ¶meters); }; #endif // SOLIDUISERVER_HELPER_H diff --git a/systemsettings/core/ModuleView.cpp b/systemsettings/core/ModuleView.cpp index 2b9f4f5d..ba99ce59 100644 --- a/systemsettings/core/ModuleView.cpp +++ b/systemsettings/core/ModuleView.cpp @@ -35,14 +35,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include "MenuItem.h" @@ -156,10 +154,6 @@ void ModuleView::addModule( KCModuleInfo *module ) kWarning() << "ModuleInfo has no associated KService" ; return; } - if ( !KAuthorized::authorizeControlModule( module->service()->menuId() ) ) { - kWarning() << "Not authorised to load module" ; - return; - } if( module->service()->noDisplay() ) { return; } @@ -263,7 +257,6 @@ bool ModuleView::resolveChanges(KCModuleProxy * currentProxy) void ModuleView::closeModules() { d->pageChangeSupressed = true; - d->mApply->setAuthAction( 0 ); // Ensure KAuth knows that authentication is now pointless... QMap::iterator page = d->mModules.begin(); QMap::iterator pageEnd = d->mModules.end(); for ( ; page != pageEnd; ++page ) { @@ -341,23 +334,15 @@ void ModuleView::activeModuleChanged(KPageWidgetItem * current, KPageWidgetItem void ModuleView::stateChanged() { KCModuleProxy * activeModule = d->mPages.value( d->mPageWidget->currentPage() ); - KAuth::Action * moduleAction = 0; bool change = false; if( activeModule ) { change = activeModule->changed(); - disconnect( d->mApply, SIGNAL(authorized(KAuth::Action*)), this, SLOT(moduleSave()) ); disconnect( d->mApply, SIGNAL(clicked()), this, SLOT(moduleSave()) ); - if( activeModule->realModule()->authAction() ) { - connect( d->mApply, SIGNAL(authorized(KAuth::Action*)), this, SLOT(moduleSave()) ); - moduleAction = activeModule->realModule()->authAction(); - } else { - connect( d->mApply, SIGNAL(clicked()), this, SLOT(moduleSave()) ); - } + connect( d->mApply, SIGNAL(clicked()), this, SLOT(moduleSave()) ); } updatePageIconHeader( d->mPageWidget->currentPage() ); - d->mApply->setAuthAction( moduleAction ); d->mApply->setEnabled( change ); d->mReset->setEnabled( change ); emit moduleChanged( change );