Debian Codegraph @

src/helper/helperkiller.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/helper/helperkiller.cpp`/
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "helperkiller.h"cxx . . $ `<file>/src/helper/helperkiller.h`/
5
6 #include "helperids.h"cxx . . $ `<file>/src/helper/helperids.h`/
7 #include "polkit.h"cxx . . $ `<file>/src/helper/polkit.h`/
8 #include <QCoreApplication>
9 #include <QDBusConnection>
10 #include <QDBusMessage>
11 #include <QProcess>
12 #include <QString>
13 #include <QStringList>
14 #include <QTimer>
15 #include <exception>
16 #include <signal.h>
17 #include <string>
18
19 HelperKillercxx . . $ HelperKiller#::HelperKillercxx . . $ HelperKiller#HelperKiller(cc6a52b634b3d446).(QObjectcxx . . $ QObject# *parent) noexcept
20 : QDBusAbstractAdaptorcxx . . $ QDBusAbstractAdaptor#(parent)
21 {
22 }
23
24 HelperKillercxx . . $ HelperKiller#::~cxx . . $ HelperKiller#`~HelperKiller`(ced63f7c635d850d).HelperKillercxx . . $ HelperKiller#() = default;
25
26 bool HelperKillercxx . . $ HelperKiller#::startcxx . . $ HelperKiller#start(88cf1e7c0a6f9f8e).(QDBusMessagecxx . . $ QDBusMessage# const &message) const
27 {
28 if (!isAuthorizedcxx . . $ HelperKiller#isAuthorized(88cf1e7c0a6f9f8e).(message))
29 return false;
30
31 QProcesscxx . . $ QProcess# cmdcxx . . $ QProcess#QProcess(749de1b6ae65bddd).;
32 cmd.startcxx . . $ QProcess#start(df994297e51edc6b).(QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!("pidof"), QStringListcxx . . $ QStringList#(HELPER_EXEcxx . . $ `src/helper/helperids.h:22:9`!));
33
34 bool result = cmd.waitForFinishedcxx . . $ QProcess#waitForFinished(83c267b20bac841a).();
35 if (result) {
36 try {
37 auto output = cmd.readAllStandardOutputcxx . . $ QProcess#readAllStandardOutput(b3c286cec66e09f4).().toStdStringcxx . . $ QByteArray#toStdString(219584694fe2b248).();
38 int pid = stdcxx . . $ std/::stoicxx . . $ std/__cxx11/stoi(ffee248579a0a688).(output);
39 result = kill(pid, SIGKILLcxx . . $ `<external>/11773118241360591791/signum-generic.h:59:9`!) == 0;
40 }
41 catch (stdcxx . . $ std/::exception const &) {
42 result = false;
43 }
44 }
45
46 QTimercxx . . $ QTimer#::singleShotcxx . . $ QTimer#singleShot(aa6a4c6cfc6f625a).(0, QCoreApplicationcxx . . $ QCoreApplication#::instancecxx . . $ QCoreApplication#instance(fc464b6fd63b8c1).(), &QCoreApplicationcxx . . $ QCoreApplication#::quitcxx . . $ QCoreApplication#quit(49f6e7a06ebc5aa8).);
47
48 return result;
49 }
50
51 bool HelperKillercxx . . $ HelperKiller#::isAuthorizedcxx . . $ HelperKiller#isAuthorized(88cf1e7c0a6f9f8e).(QDBusMessagecxx . . $ QDBusMessage# const &message) const
52 {
53 auto subject = Polkitcxx . . $ Polkit/::BusNameSubjectcxx . . $ Polkit/BusNameSubject#{message.servicecxx . . $ QDBusMessage#service(6ef7b6c27b00b43d).().toStdStringcxx . . $ QString#toStdString(219584694fe2b248).()};
54 return Polkitcxx . . $ Polkit/::checkAuthorizationSynccxx . . $ Polkit/checkAuthorizationSync(da9f429a3fd357d7).(POLKIT_HELPER_KILLER_ACTIONcxx . . $ `src/helper/helperids.h:7:9`!, subject) ==
55 Polkitcxx . . $ Polkit/::AuthResultcxx . . $ Polkit/AuthResult#::Yescxx . . $ Polkit/AuthResult#Yes.;
56 }
57
58 bool initDBusForHelperKillerServicecxx . . $ initDBusForHelperKillerService(967f3292d4f23d29).(QObjectcxx . . $ QObject# *obj)
59 {
60 QDBusConnectioncxx . . $ QDBusConnection# bus = QDBusConnectioncxx . . $ QDBusConnection#::systemBuscxx . . $ QDBusConnection#systemBus(45d475f1888103b2).();
61 return bus.isConnectedcxx . . $ QDBusConnection#isConnected(50ce9a9e25b4a850).() &&
62 bus.registerObjectcxx . . $ QDBusConnection#registerObject(3ca2fdce2ef96dc8).(QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_KILLER_PATHcxx . . $ `src/helper/helperids.h:10:9`!), obj) &&
63 bus.registerServicecxx . . $ QDBusConnection#registerService(e1defb592416720d).(QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_KILLER_SERVICEcxx . . $ `src/helper/helperids.h:8:9`!));
64 }
65
66 bool endDBusForHelperKillerServicecxx . . $ endDBusForHelperKillerService(c9857a73d68e59ba).()
67 {
68 QDBusConnectioncxx . . $ QDBusConnection# bus = QDBusConnectioncxx . . $ QDBusConnection#::systemBuscxx . . $ QDBusConnection#systemBus(45d475f1888103b2).();
69 bus.unregisterObjectcxx . . $ QDBusConnection#unregisterObject(1667c585e463f5a5).(QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_KILLER_PATHcxx . . $ `src/helper/helperids.h:10:9`!));
70 return bus.unregisterServicecxx . . $ QDBusConnection#unregisterService(e1defb592416720d).(QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_KILLER_SERVICEcxx . . $ `src/helper/helperids.h:8:9`!));
71 }
72
73 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv)
74 {
75 QCoreApplicationcxx . . $ QCoreApplication# appcxx . . $ QCoreApplication#QCoreApplication(6e9b1c7df49e191d).(argc, argv);
76 new HelperKillercxx . . $ HelperKiller#(&app);
77
78 if (!initDBusForHelperKillerServicecxx . . $ initDBusForHelperKillerService(967f3292d4f23d29).(&app))
79 exit(1);
80
81 app.execcxx . . $ QCoreApplication#exec(b126dc7c1de90089).();
82
83 if (!endDBusForHelperKillerServicecxx . . $ endDBusForHelperKillerService(c9857a73d68e59ba).())
84 exit(1);
85
86 return 0;
87 }