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"
|
#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()
|
void MainWindow::reportABug()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[reportABug]";
|
if (debug) qDebug() << "[MainWindow]" << "[reportABug]";
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QTimer>
|
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
@ -306,6 +305,7 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
|||||||
if (args[QString("default")].toBool())
|
if (args[QString("default")].toBool())
|
||||||
settingsWin->setDefault();
|
settingsWin->setDefault();
|
||||||
configuration = settingsWin->getSettings();
|
configuration = settingsWin->getSettings();
|
||||||
|
delete settingsWin;
|
||||||
QMap<QString, QString> optionsDict = parseOptions(args[QString("options")].toString());
|
QMap<QString, QString> optionsDict = parseOptions(args[QString("options")].toString());
|
||||||
for (int i=0; i<optionsDict.keys().count(); i++)
|
for (int i=0; i<optionsDict.keys().count(); i++)
|
||||||
configuration[optionsDict.keys()[i]] = optionsDict[optionsDict.keys()[i]];
|
configuration[optionsDict.keys()[i]] = optionsDict[optionsDict.keys()[i]];
|
||||||
@ -316,9 +316,6 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
|||||||
useHelper = false;
|
useHelper = false;
|
||||||
configuration[QString("USE_HELPER")] = QString("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
|
// update translation
|
||||||
qApp->removeTranslator(translator);
|
qApp->removeTranslator(translator);
|
||||||
@ -326,10 +323,9 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
|||||||
args[QString("options")].toString());
|
args[QString("options")].toString());
|
||||||
translator->load(QString(":/translations/") + language);
|
translator->load(QString(":/translations/") + language);
|
||||||
qApp->installTranslator(translator);
|
qApp->installTranslator(translator);
|
||||||
// update settingsWin
|
|
||||||
delete settingsWin;
|
|
||||||
|
|
||||||
createObjects();
|
createObjects();
|
||||||
|
checkHelperStatus();
|
||||||
createActions();
|
createActions();
|
||||||
|
|
||||||
// tray
|
// 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)
|
QString MainWindow::checkStatus(const bool statusBool, const bool nullFalse)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[checkStatus]";
|
if (debug) qDebug() << "[MainWindow]" << "[checkStatus]";
|
||||||
|
@ -95,7 +95,6 @@ public slots:
|
|||||||
void setHiddenName(const QString name);
|
void setHiddenName(const QString name);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void checkHelperStatus();
|
|
||||||
void reportABug();
|
void reportABug();
|
||||||
// menu update slots
|
// menu update slots
|
||||||
void setMenuActionsShown(const bool state = true);
|
void setMenuActionsShown(const bool state = true);
|
||||||
@ -151,6 +150,7 @@ private:
|
|||||||
NetctlProfile *netctlProfile = nullptr;
|
NetctlProfile *netctlProfile = nullptr;
|
||||||
WpaSup *wpaCommand = nullptr;
|
WpaSup *wpaCommand = nullptr;
|
||||||
bool checkExternalApps(const QString apps);
|
bool checkExternalApps(const QString apps);
|
||||||
|
bool checkHelperStatus();
|
||||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||||
void createActions();
|
void createActions();
|
||||||
void createDBusSession();
|
void createDBusSession();
|
||||||
|
@ -2,18 +2,14 @@
|
|||||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||||
<busconfig>
|
<busconfig>
|
||||||
|
|
||||||
<!-- only root can own the service -->
|
|
||||||
<policy user="root">
|
|
||||||
<allow own="org.netctlgui.helper"/>
|
|
||||||
</policy>
|
|
||||||
|
|
||||||
<!-- allow everything to users of the group "network" -->
|
<!-- allow everything to users of the group "network" -->
|
||||||
<policy group="network">
|
<policy group="network">
|
||||||
|
<allow own="org.netctlgui.helper"/>
|
||||||
<allow send_destination="org.netctlgui.helper"/>
|
<allow send_destination="org.netctlgui.helper"/>
|
||||||
<allow receive_sender="org.netctlgui.helper"/>
|
<allow receive_sender="org.netctlgui.helper"/>
|
||||||
</policy>
|
</policy>
|
||||||
<policy user="root">
|
<policy user="root">
|
||||||
|
<allow own="org.netctlgui.helper"/>
|
||||||
<allow send_destination="org.netctlgui.helper"/>
|
<allow send_destination="org.netctlgui.helper"/>
|
||||||
<allow receive_sender="org.netctlgui.helper"/>
|
<allow receive_sender="org.netctlgui.helper"/>
|
||||||
</policy>
|
</policy>
|
||||||
|
@ -79,17 +79,14 @@ int main(int argc, char *argv[])
|
|||||||
(args[QString("version")].toBool()) ||
|
(args[QString("version")].toBool()) ||
|
||||||
(args[QString("error")].toBool()))
|
(args[QString("error")].toBool()))
|
||||||
args[QString("nodaemon")] = true;
|
args[QString("nodaemon")] = true;
|
||||||
// heck euid
|
// check euid
|
||||||
if (geteuid() != 0) {
|
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;
|
.arg(QString::number(geteuid())).toUtf8().data() << endl;
|
||||||
cout << QCoreApplication::translate("NetctlHelper", "See security notes for more details.")
|
cout << QCoreApplication::translate("NetctlHelper", "See security notes for more details.")
|
||||||
.toUtf8().data() << endl;
|
.toUtf8().data() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// detach from console
|
|
||||||
if (!args[QString("nodaemon")].toBool())
|
|
||||||
daemon(0, 0);
|
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
QCoreApplication::setSetuidAllowed(true);
|
QCoreApplication::setSetuidAllowed(true);
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,6 +36,8 @@ NetctlHelper::NetctlHelper(QObject *parent, QMap<QString, QVariant> args)
|
|||||||
debug(args[QString("debug")].toBool())
|
debug(args[QString("debug")].toBool())
|
||||||
{
|
{
|
||||||
updateConfiguration();
|
updateConfiguration();
|
||||||
|
if (!args[QString("nodaemon")].toBool())
|
||||||
|
daemon(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include "netctl.h"
|
#include "netctl.h"
|
||||||
#include "ui_about.h"
|
#include "ui_about.h"
|
||||||
@ -930,7 +929,7 @@ void Netctl::configChanged()
|
|||||||
formatLine[1] = QString("</p></body></html>");
|
formatLine[1] = QString("</p></body></html>");
|
||||||
|
|
||||||
if (useHelper) startHelper();
|
if (useHelper) startHelper();
|
||||||
QTimer::singleShot(1000, this, SLOT(checkHelperStatus()));
|
checkHelperStatus();
|
||||||
connectToEngine();
|
connectToEngine();
|
||||||
setAssociatedApplication(paths[QString("gui")]);
|
setAssociatedApplication(paths[QString("gui")]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user