123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- diff --git a/processcore/CMakeLists.txt b/processcore/CMakeLists.txt
- index 9fef4ec..939d055 100644
- --- a/processcore/CMakeLists.txt
- +++ b/processcore/CMakeLists.txt
- @@ -41,18 +41,18 @@ install( FILES processes.h process.h DESTINATION ${INCLUDE_INSTALL_DIR}/ksysguar
- #------ KAuth stuff
-
- # Auth example helper
- -# set(ksysguardprocesslist_helper_srcs
- -# helper.cpp
- -# process.cpp
- -# processes_local_p.cpp
- -# processes_base_p.cpp)
- -#
- -# add_executable(ksysguardprocesslist_helper ${ksysguardprocesslist_helper_srcs})
- -# target_link_libraries(ksysguardprocesslist_helper )
- -# install(TARGETS ksysguardprocesslist_helper DESTINATION ${LIBEXEC_INSTALL_DIR})
- -#
- -# kauth_install_helper_files(ksysguardprocesslist_helper org.kde.ksysguard.processlisthelper root)
- -# kauth_install_actions(org.kde.ksysguard.processlisthelper actions.actions)
- -#
- -# set_target_properties(ksysguardprocesslist_helper PROPERTIES COMPILE_FLAGS "-Wall -ggdb")
- +set(ksysguardprocesslist_helper_srcs
- + helper.cpp
- + process.cpp
- + processes_local_p.cpp
- + processes_base_p.cpp)
- +
- +add_executable(ksysguardprocesslist_helper ${ksysguardprocesslist_helper_srcs})
- +target_link_libraries(ksysguardprocesslist_helper Qt5::Core KF5::Auth KF5::I18n)
- +install(TARGETS ksysguardprocesslist_helper DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
- +
- +kauth_install_helper_files(ksysguardprocesslist_helper org.kde.ksysguard.processlisthelper root)
- +kauth_install_actions(org.kde.ksysguard.processlisthelper actions.actions)
- +
- +set_target_properties(ksysguardprocesslist_helper PROPERTIES COMPILE_FLAGS "-Wall -ggdb")
-
- diff --git a/processcore/helper.cpp b/processcore/helper.cpp
- index 6c1f570..c34ab1e 100644
- --- a/processcore/helper.cpp
- +++ b/processcore/helper.cpp
- @@ -23,24 +23,26 @@
- #include "helper.h"
- #include "processes_local_p.h"
-
- +using namespace KAuth;
- +
- KSysGuardProcessListHelper::KSysGuardProcessListHelper()
- {
- qRegisterMetaType<QList<long long> >();
- }
-
- /* 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).toULongLong(); if(pid < 0) return KAuth::ActionReply::HelperErrorReply;
- -KAuth::ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters) {
- - KAuth::ActionReply errorReply(KAuth::ActionReply::HelperError);
- +#define GET_PID(i) parameters.value(QString("pid%1").arg(i), -1).toULongLong(); if(pid < 0) return ActionReply(ActionReply::HelperErrorType);
- +ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters) {
- + ActionReply reply(ActionReply::HelperErrorType);
- if(!parameters.contains("signal")) {
- - errorReply.setErrorDescription("Internal error - no signal parameter was passed to the helper");
- - errorReply.setErrorCode(1);
- - return errorReply;
- + reply.setErrorDescription("Internal error - no signal parameter was passed to the helper");
- + reply.setErrorCode(static_cast<ActionReply::Error>(1));
- + return reply;
- }
- if(!parameters.contains("pidcount")) {
- - errorReply.setErrorDescription("Internal error - no pidcount parameter was passed to the helper");
- - errorReply.setErrorCode(2);
- - return errorReply;
- + reply.setErrorDescription("Internal error - no pidcount parameter was passed to the helper");
- + reply.setErrorCode(static_cast<ActionReply::Error>(2));
- + return reply;
- }
-
- KSysGuard::ProcessesLocal processes;
- @@ -56,17 +58,17 @@ KAuth::ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters
- success = successForThisPid && success;
- }
- if(success) {
- - return KAuth::ActionReply::SuccessReply;
- + return ActionReply::SuccessReply();
- } else {
- - errorReply.setErrorDescription(QString("Could not send signal to: ") + errorList.join(", "));
- - errorReply.setErrorCode(0);
- - return errorReply;
- + reply.setErrorDescription(QString("Could not send signal to: ") + errorList.join(", "));
- + reply.setErrorCode(static_cast<ActionReply::Error>(0));
- + return reply;
- }
- }
-
- -KAuth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
- +ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
- if(!parameters.contains("nicevalue") || !parameters.contains("pidcount"))
- - return KAuth::ActionReply::HelperErrorReply;
- + return ActionReply(ActionReply::HelperErrorType);
-
- KSysGuard::ProcessesLocal processes;
- int niceValue = qvariant_cast<int>(parameters.value("nicevalue"));
- @@ -77,14 +79,14 @@ KAuth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
- success = processes.setNiceness(pid, niceValue) && success;
- }
- if(success)
- - return KAuth::ActionReply::SuccessReply;
- + return ActionReply::SuccessReply();
- else
- - return KAuth::ActionReply::HelperErrorReply;
- + return ActionReply(ActionReply::HelperErrorType);
- }
-
- -KAuth::ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap parameters) {
- +ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap parameters) {
- if(!parameters.contains("ioScheduler") || !parameters.contains("ioSchedulerPriority") || !parameters.contains("pidcount"))
- - return KAuth::ActionReply::HelperErrorReply;
- + return ActionReply(ActionReply::HelperErrorType);
-
- KSysGuard::ProcessesLocal processes;
- int ioScheduler = qvariant_cast<int>(parameters.value("ioScheduler"));
- @@ -96,14 +98,14 @@ KAuth::ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap par
- success = processes.setIoNiceness(pid, ioScheduler, ioSchedulerPriority) && success;
- }
- if(success)
- - return KAuth::ActionReply::SuccessReply;
- + return ActionReply::SuccessReply();
- else
- - return KAuth::ActionReply::HelperErrorReply;
- + return ActionReply(ActionReply::HelperErrorType);
-
- }
- -KAuth::ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameters) {
- +ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameters) {
- if(!parameters.contains("cpuScheduler") || !parameters.contains("cpuSchedulerPriority") || !parameters.contains("pidcount"))
- - return KAuth::ActionReply::HelperErrorReply;
- + return ActionReply(ActionReply::HelperErrorType);
-
- KSysGuard::ProcessesLocal processes;
- int cpuScheduler = qvariant_cast<int>(parameters.value("cpuScheduler"));
- @@ -116,9 +118,9 @@ KAuth::ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap pa
- success = processes.setScheduler(pid, cpuScheduler, cpuSchedulerPriority) && success;
- }
- if(success)
- - return KAuth::ActionReply::SuccessReply;
- + return ActionReply::SuccessReply();
- else
- - return KAuth::ActionReply::HelperErrorReply;
- + return ActionReply(ActionReply::HelperErrorType);
-
- }
- KAUTH_HELPER_MAIN("org.kde.ksysguard.processlisthelper", KSysGuardProcessListHelper)
- diff --git a/processcore/processes_linux_p.cpp b/processcore/processes_linux_p.cpp
- index 65b8dfd..0cff0e8 100644
- --- a/processcore/processes_linux_p.cpp
- +++ b/processcore/processes_linux_p.cpp
- @@ -22,7 +22,7 @@
- #include "processes_local_p.h"
- #include "process.h"
-
- -#include <klocale.h>
- +#include <klocalizedstring.h>
-
- #include <QFile>
- #include <QHash>
- diff --git a/processui/ksysguardprocesslist.cpp b/processui/ksysguardprocesslist.cpp
- index 1651a0a..ba9d8c9 100644
- --- a/processui/ksysguardprocesslist.cpp
- +++ b/processui/ksysguardprocesslist.cpp
- @@ -48,6 +48,9 @@
- #include <signal.h> //For SIGTERM
-
- #include <kauth.h>
- +#include <kauthaction.h>
- +#include <kauthactionreply.h>
- +#include <kauthobjectdecorator.h>
- #include <klocale.h>
- #include <kmessagebox.h>
- #include <kdialog.h>
- @@ -188,7 +191,7 @@ struct KSysGuardProcessListPrivate {
- int totalRowCount(const QModelIndex &parent) const;
-
- /** Helper function to setup 'action' with the given pids */
- - void setupKAuthAction(KAuth::Action *action, const QList<long long> & pids) const;
- + void setupKAuthAction(KAuth::Action &action, const QList<long long> & pids) const;
-
- /** fire a timer event if we are set to use our internal timer*/
- void fireTimerEvent();
- @@ -392,15 +395,15 @@ int KSysGuardProcessListPrivate::totalRowCount(const QModelIndex &parent ) const
- return total;
- }
-
- -void KSysGuardProcessListPrivate::setupKAuthAction(KAuth::Action *action, const QList<long long> & pids) const
- +void KSysGuardProcessListPrivate::setupKAuthAction(KAuth::Action &action, const QList<long long> & pids) const
- {
- - action->setHelperId("org.kde.ksysguard.processlisthelper");
- + 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(QString("pid%1").arg(i), pids[i]);
- }
- - action->addArgument("pidcount", processCount);
- + action.addArgument("pidcount", processCount);
- }
- void KSysGuardProcessList::selectionChanged()
- {
- @@ -1023,23 +1026,19 @@ bool KSysGuardProcessList::reniceProcesses(const QList<long long> &pids, int nic
-
-
- #warning KAuth needs porting, but docu is not adjusted, no idea how to do it
- -#if 0
- - KAuth::Action *action = new KAuth::Action("org.kde.ksysguard.processlisthelper.renice");
- - action->setParentWidget(window());
- + 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();
- + action.addArgument("nicevalue", niceValue);
- + KAuth::ExecuteJob *job = action.execute();
-
- - if (reply == KAuth::ActionReply::SuccessReply) {
- + if (job->exec()) {
- updateList();
- - delete action;
- - } else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) {
- + } else if (!job->exec()) {
- 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()));
- - delete action;
- + "was a problem trying to run as root. Error %1 %2", job->error(), job->errorString()));
- return false;
- }
- -#endif
- return true;
- }
-
- @@ -1189,26 +1188,22 @@ bool KSysGuardProcessList::changeIoScheduler(const QList< long long> &pids, KSys
- if(!d->mModel.isLocalhost()) return false; //We can't use kauth to affect non-localhost processes
-
- #warning KAuth needs porting, but docu is not adjusted, no idea how to do it
- -#if 0
- - KAuth::Action *action = new KAuth::Action("org.kde.ksysguard.processlisthelper.changeioscheduler");
- - action->setParentWidget(window());
- + KAuth::Action action("org.kde.ksysguard.processlisthelper.changeioscheduler");
- + action.setParentWidget(window());
-
- d->setupKAuthAction( action, unchanged_pids);
- - action->addArgument("ioScheduler", (int)newIoSched);
- - action->addArgument("ioSchedulerPriority", newIoSchedPriority);
- + action.addArgument("ioScheduler", (int)newIoSched);
- + action.addArgument("ioSchedulerPriority", newIoSchedPriority);
-
- - KAuth::ActionReply reply = action->execute();
- + KAuth::ExecuteJob *job = action.execute();
-
- - if (reply == KAuth::ActionReply::SuccessReply) {
- + if (job->exec()) {
- updateList();
- - delete action;
- - } else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) {
- + } else if (!job->exec()) {
- KMessageBox::sorry(this, i18n("You do not have the permission to change the I/O priority of the process and there "
- - "was a problem trying to run as root. Error %1 %2", reply.errorCode(), reply.errorDescription()));
- - delete action;
- + "was a problem trying to run as root. Error %1 %2", job->error(), job->errorString()));
- return false;
- }
- -#endif
- return true;
- }
-
- @@ -1226,24 +1221,20 @@ bool KSysGuardProcessList::changeCpuScheduler(const QList< long long> &pids, KSy
- if(!d->mModel.isLocalhost()) return false; //We can't use KAuth to affect non-localhost processes
-
- #warning KAuth needs porting, but docu is not adjusted, no idea how to do it
- -#if 0
- - KAuth::Action *action = new KAuth::Action("org.kde.ksysguard.processlisthelper.changecpuscheduler");
- - action->setParentWidget(window());
- + 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();
- + action.addArgument("cpuScheduler", (int)newCpuSched);
- + action.addArgument("cpuSchedulerPriority", newCpuSchedPriority);
- + KAuth::ExecuteJob *job = action.execute();
-
- - if (reply == KAuth::ActionReply::SuccessReply) {
- + if (job->exec()) {
- updateList();
- - delete action;
- - } else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) {
- + } else if (!job->exec()) {
- 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()));
- - delete action;
- + "was a problem trying to run as root. Error %1 %2", job->error(), job->errorString()));
- return false;
- }
- -#endif
- return true;
- }
-
- @@ -1262,26 +1253,20 @@ bool KSysGuardProcessList::killProcesses(const QList< long long> &pids, int sig)
- if(!d->mModel.isLocalhost()) return false; //We can't elevate privileges to kill non-localhost processes
-
- #warning KAuth needs porting, but docu is not adjusted, no idea how to do it
- -#if 0
- KAuth::Action action("org.kde.ksysguard.processlisthelper.sendsignal");
- action.setParentWidget(window());
- - d->setupKAuthAction( &action, unkilled_pids);
- + //action.setHelperId("org.kde.ksysguard.processlisthelper");
- + d->setupKAuthAction( action, unkilled_pids);
- action.addArgument("signal", sig);
- - KAuth::ActionReply reply = action.execute();
- + KAuth::ExecuteJob *job = action.execute();
-
- - if (reply == KAuth::ActionReply::SuccessReply) {
- + if (job->exec()) {
- updateList();
- - } else if (reply.type() == KAuth::ActionReply::HelperError) {
- - if (reply.errorCode() > 0)
- - KMessageBox::sorry(this, i18n("You do not have the permission to kill the process and there "
- - "was a problem trying to run as root. %1", reply.errorDescription()));
- - return false;
- - } else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) {
- + } else if (!job->exec()) {
- KMessageBox::sorry(this, i18n("You do not have the permission to kill the process and there "
- - "was a problem trying to run as root. Error %1 %2", reply.errorCode(), reply.errorDescription()));
- + "was a problem trying to run as root. Error %1 %2", job->error(), job->errorString()));
- return false;
- }
- -#endif
- return true;
- }
-
|