mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
moved helper daemonization
add abillity to own users org.netctlgui.helper service
This commit is contained in:
parent
80f6ccf1d1
commit
3e0ae6d4cc
@ -41,20 +41,6 @@
|
||||
#include "wirelesswidget.h"
|
||||
|
||||
|
||||
void MainWindow::checkHelperStatus()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkHelperStatus]";
|
||||
|
||||
if (useHelper) useHelper = isHelperActive();
|
||||
if (useHelper)
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Update"),
|
||||
QList<QVariant>(), true, debug);
|
||||
if (isHelperServiceActive())
|
||||
configuration[QString("CLOSE_HELPER")] = QString("false");
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::reportABug()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[reportABug]";
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QTimer>
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
|
||||
@ -306,6 +305,7 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||
if (args[QString("default")].toBool())
|
||||
settingsWin->setDefault();
|
||||
configuration = settingsWin->getSettings();
|
||||
delete settingsWin;
|
||||
QMap<QString, QString> optionsDict = parseOptions(args[QString("options")].toString());
|
||||
for (int i=0; i<optionsDict.keys().count(); i++)
|
||||
configuration[optionsDict.keys()[i]] = optionsDict[optionsDict.keys()[i]];
|
||||
@ -316,9 +316,6 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||
useHelper = false;
|
||||
configuration[QString("USE_HELPER")] = QString("false");
|
||||
}
|
||||
// some helper fixs
|
||||
// because interface will be created with a delay
|
||||
QTimer::singleShot(1000, this, SLOT(checkHelperStatus()));
|
||||
|
||||
// update translation
|
||||
qApp->removeTranslator(translator);
|
||||
@ -326,10 +323,9 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||
args[QString("options")].toString());
|
||||
translator->load(QString(":/translations/") + language);
|
||||
qApp->installTranslator(translator);
|
||||
// update settingsWin
|
||||
delete settingsWin;
|
||||
|
||||
createObjects();
|
||||
checkHelperStatus();
|
||||
createActions();
|
||||
|
||||
// tray
|
||||
|
@ -283,6 +283,20 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all"))
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::checkHelperStatus()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkHelperStatus]";
|
||||
|
||||
if (useHelper) useHelper = isHelperActive();
|
||||
if (useHelper)
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Update"),
|
||||
QList<QVariant>(), true, debug);
|
||||
if (isHelperServiceActive())
|
||||
configuration[QString("CLOSE_HELPER")] = QString("false");
|
||||
}
|
||||
|
||||
|
||||
QString MainWindow::checkStatus(const bool statusBool, const bool nullFalse)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkStatus]";
|
||||
|
@ -95,7 +95,6 @@ public slots:
|
||||
void setHiddenName(const QString name);
|
||||
|
||||
private slots:
|
||||
void checkHelperStatus();
|
||||
void reportABug();
|
||||
// menu update slots
|
||||
void setMenuActionsShown(const bool state = true);
|
||||
@ -151,6 +150,7 @@ private:
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
bool checkExternalApps(const QString apps);
|
||||
bool checkHelperStatus();
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
void createActions();
|
||||
void createDBusSession();
|
||||
|
@ -2,18 +2,14 @@
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
|
||||
<!-- only root can own the service -->
|
||||
<policy user="root">
|
||||
<allow own="org.netctlgui.helper"/>
|
||||
</policy>
|
||||
|
||||
<!-- allow everything to users of the group "network" -->
|
||||
<policy group="network">
|
||||
<allow own="org.netctlgui.helper"/>
|
||||
<allow send_destination="org.netctlgui.helper"/>
|
||||
<allow receive_sender="org.netctlgui.helper"/>
|
||||
</policy>
|
||||
<policy user="root">
|
||||
<allow own="org.netctlgui.helper"/>
|
||||
<allow send_destination="org.netctlgui.helper"/>
|
||||
<allow receive_sender="org.netctlgui.helper"/>
|
||||
</policy>
|
||||
|
@ -79,17 +79,14 @@ int main(int argc, char *argv[])
|
||||
(args[QString("version")].toBool()) ||
|
||||
(args[QString("error")].toBool()))
|
||||
args[QString("nodaemon")] = true;
|
||||
// heck euid
|
||||
// check euid
|
||||
if (geteuid() != 0) {
|
||||
cout << QCoreApplication::translate("NetctlHelper", "The helper is running with EUID %1. Some functions will not be available.")
|
||||
cout << QCoreApplication::translate("NetctlHelper", "The helper is running with EUID %1. Functions will not be available.")
|
||||
.arg(QString::number(geteuid())).toUtf8().data() << endl;
|
||||
cout << QCoreApplication::translate("NetctlHelper", "See security notes for more details.")
|
||||
.toUtf8().data() << endl;
|
||||
}
|
||||
|
||||
// detach from console
|
||||
if (!args[QString("nodaemon")].toBool())
|
||||
daemon(0, 0);
|
||||
#if QT_VERSION >= 0x050000
|
||||
QCoreApplication::setSetuidAllowed(true);
|
||||
#endif
|
||||
|
@ -36,6 +36,8 @@ NetctlHelper::NetctlHelper(QObject *parent, QMap<QString, QVariant> args)
|
||||
debug(args[QString("debug")].toBool())
|
||||
{
|
||||
updateConfiguration();
|
||||
if (!args[QString("nodaemon")].toBool())
|
||||
daemon(0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QTimer>
|
||||
|
||||
#include "netctl.h"
|
||||
#include "ui_about.h"
|
||||
@ -930,7 +929,7 @@ void Netctl::configChanged()
|
||||
formatLine[1] = QString("</p></body></html>");
|
||||
|
||||
if (useHelper) startHelper();
|
||||
QTimer::singleShot(1000, this, SLOT(checkHelperStatus()));
|
||||
checkHelperStatus();
|
||||
connectToEngine();
|
||||
setAssociatedApplication(paths[QString("gui")]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user