mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
intermediate commit
This commit is contained in:
parent
6a3e3b14b3
commit
6b7d5d3800
8
sources/3rdparty/task/taskadds.cpp
vendored
8
sources/3rdparty/task/taskadds.cpp
vendored
@ -19,19 +19,19 @@
|
||||
#include "taskadds.h"
|
||||
|
||||
|
||||
TaskResult runTask(const QString cmd, const bool sudo)
|
||||
TaskResult runTask(const QString cmd, const bool useSuid)
|
||||
{
|
||||
return Task::await<TaskResult>( [ & ]() {
|
||||
TaskResult r;
|
||||
if (sudo) {
|
||||
QProcess command;
|
||||
if (useSuid) {
|
||||
RootProcess command;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
r.exitCode = command.exitCode();
|
||||
r.output = command.readAllStandardOutput();
|
||||
}
|
||||
else {
|
||||
RootProcess command;
|
||||
QProcess command;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
r.exitCode = command.exitCode();
|
||||
|
2
sources/3rdparty/task/taskadds.h
vendored
2
sources/3rdparty/task/taskadds.h
vendored
@ -40,7 +40,7 @@ struct TaskResult
|
||||
int exitCode;
|
||||
QByteArray output;
|
||||
};
|
||||
TaskResult runTask(const QString cmd, const bool sudo = false);
|
||||
TaskResult runTask(const QString cmd, const bool useSuid = true);
|
||||
|
||||
|
||||
#endif /* TASKADDS_H */
|
||||
|
@ -39,6 +39,9 @@ option (BUILD_DOCS "Build documentation and install headers" ON)
|
||||
if (BUILD_DOCS)
|
||||
set (BUILD_LIBRARY ON)
|
||||
endif ()
|
||||
# FIXME: dbus path
|
||||
set (DBUS_SYSTEMCONF_PATH "/etc/dbus-1/system.d/" CACHE STRING "Path to dbus system configuration files")
|
||||
set (SYSTEMD_SERVICE_PATH "lib/systemd/system" CACHE STRING "Path to systemd services")
|
||||
|
||||
# flags
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
@ -114,6 +114,10 @@ QStringList ErrorWindow::getMessage(const int mess)
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Could not find ESSID");
|
||||
break;
|
||||
case 19:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Could not run helper");
|
||||
break;
|
||||
default:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Unknown error");
|
||||
@ -135,57 +139,24 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
|
||||
QMessageBox::Icon icon;
|
||||
switch(mess) {
|
||||
case 1:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 2:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 3:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 4:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 5:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 6:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 7:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 8:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 9:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 10:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 11:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 12:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 13:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 14:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 15:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 16:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 17:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 18:
|
||||
case 19:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
default:
|
||||
|
@ -36,9 +36,9 @@ using namespace std;
|
||||
bool restoreExistSession()
|
||||
{
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(QString(DBUS_SERVICE),
|
||||
QString(DBUS_OBJECT_PATH),
|
||||
QString(DBUS_INTERFACE),
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_SERVICE,
|
||||
DBUS_OBJECT_PATH,
|
||||
DBUS_INTERFACE,
|
||||
QString("Restore"));
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
|
@ -24,12 +24,9 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
#include "aboutwindow.h"
|
||||
#include "bridgewidget.h"
|
||||
#include "errorwindow.h"
|
||||
@ -44,6 +41,7 @@
|
||||
#include "passwdwidget.h"
|
||||
#include "pppoewidget.h"
|
||||
#include "settingswindow.h"
|
||||
#include "taskadds.h"
|
||||
#include "trayicon.h"
|
||||
#include "tunnelwidget.h"
|
||||
#include "tuntapwidget.h"
|
||||
@ -115,6 +113,8 @@ MainWindow::~MainWindow()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[~MainWindow]";
|
||||
|
||||
if ((useHelper) && (configuration[QString("CLOSE_HELPER")] == QString("true")))
|
||||
forceStopHelper();
|
||||
deleteObjects();
|
||||
}
|
||||
|
||||
@ -185,27 +185,29 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all"))
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]";
|
||||
|
||||
QStringList commandLine;
|
||||
commandLine.append("which");
|
||||
commandLine.append(configuration[QString("SUDO_PATH")]);
|
||||
QStringList cmd;
|
||||
cmd.append("which");
|
||||
cmd.append(configuration[QString("SUDO_PATH")]);
|
||||
if ((apps == QString("helper")) || (apps == QString("all"))) {
|
||||
cmd.append(configuration[QString("HELPER_PATH")]);
|
||||
}
|
||||
if ((apps == QString("netctl")) || (apps == QString("all"))) {
|
||||
commandLine.append(configuration[QString("NETCTL_PATH")]);
|
||||
commandLine.append(configuration[QString("NETCTLAUTO_PATH")]);
|
||||
cmd.append(configuration[QString("NETCTL_PATH")]);
|
||||
cmd.append(configuration[QString("NETCTLAUTO_PATH")]);
|
||||
}
|
||||
if ((apps == QString("systemctl")) || (apps == QString("all"))) {
|
||||
commandLine.append(configuration[QString("SYSTEMCTL_PATH")]);
|
||||
cmd.append(configuration[QString("SYSTEMCTL_PATH")]);
|
||||
}
|
||||
if ((apps == QString("wpasup")) || (apps == QString("all"))) {
|
||||
commandLine.append(configuration[QString("WPACLI_PATH")]);
|
||||
commandLine.append(configuration[QString("WPASUP_PATH")]);
|
||||
cmd.append(configuration[QString("WPACLI_PATH")]);
|
||||
cmd.append(configuration[QString("WPASUP_PATH")]);
|
||||
}
|
||||
QProcess command;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Run cmd" << commandLine.join(QChar(' '));
|
||||
command.start(commandLine.join(QChar(' ')));
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Cmd returns" << command.exitCode();
|
||||
|
||||
if (command.exitCode() != 0)
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Run cmd" << cmd.join(QChar(' '));
|
||||
TaskResult process = runTask(cmd.join(QChar(' ')), false);
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
if (process.exitCode != 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@ -283,12 +285,16 @@ void MainWindow::createDBusSession()
|
||||
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]";
|
||||
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
if (!bus.registerService(QString(DBUS_SERVICE)))
|
||||
if (!bus.registerService(DBUS_SERVICE)) {
|
||||
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register service";
|
||||
if (!bus.registerObject(QString(DBUS_OBJECT_PATH),
|
||||
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << bus.lastError().message();
|
||||
}
|
||||
if (!bus.registerObject(DBUS_OBJECT_PATH,
|
||||
new NetctlGuiAdaptor(this),
|
||||
QDBusConnection::ExportAllContents))
|
||||
QDBusConnection::ExportAllContents)) {
|
||||
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register GUI object";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << bus.lastError().message();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -296,8 +302,16 @@ void MainWindow::createObjects()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[createObjects]";
|
||||
|
||||
// error messages
|
||||
errorWin = new ErrorWindow(this, debug);
|
||||
// backend
|
||||
createDBusSession();
|
||||
if (useHelper)
|
||||
if (!forceStartHelper()) {
|
||||
errorWin->showWindow(19, QString("[MainWindow] : [createObjects]"));
|
||||
useHelper = false;
|
||||
}
|
||||
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlProfile = new NetctlProfile(debug, configuration);
|
||||
wpaCommand = new WpaSup(debug, configuration);
|
||||
@ -311,7 +325,6 @@ void MainWindow::createObjects()
|
||||
ui->tableWidget_wifi->setColumnHidden(3, true);
|
||||
ui->tableWidget_wifi->setColumnHidden(4, true);
|
||||
aboutWin = new AboutWindow(this, debug);
|
||||
errorWin = new ErrorWindow(this, debug);
|
||||
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
|
||||
settingsWin = new SettingsWindow(this, debug, configPath);
|
||||
// profile widgets
|
||||
@ -344,8 +357,8 @@ void MainWindow::deleteObjects()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[deleteObjects]";
|
||||
|
||||
QDBusConnection::sessionBus().unregisterObject(QString(DBUS_OBJECT_PATH));
|
||||
QDBusConnection::sessionBus().unregisterService(QString(DBUS_SERVICE));
|
||||
QDBusConnection::sessionBus().unregisterObject(DBUS_OBJECT_PATH);
|
||||
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
if (wpaCommand != nullptr) delete wpaCommand;
|
||||
@ -382,14 +395,29 @@ void MainWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
|
||||
|
||||
QList<QVariant> MainWindow::sendDBusRequest(const QString service, const QString path,
|
||||
const QString interface, const QString cmd)
|
||||
const QString interface, const QString cmd,
|
||||
bool system)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Service" << service;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Path" << path;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Interface" << interface;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "is system bus" << system;
|
||||
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
QList<QVariant> arguments;
|
||||
if (system) {
|
||||
QDBusConnection bus = QDBusConnection::systemBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||
QDBusMessage response = bus.call(request);
|
||||
arguments = response.arguments();
|
||||
}
|
||||
else {
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||
QDBusMessage response = bus.call(request);
|
||||
arguments = response.arguments();
|
||||
}
|
||||
|
||||
return arguments;
|
||||
}
|
||||
@ -425,6 +453,49 @@ QMap<QString, QString> MainWindow::parseOptions(const QString options)
|
||||
}
|
||||
|
||||
|
||||
QList<netctlProfileInfo> MainWindow::parseOutputNetctl(const QList<QVariant> raw)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[parseOutputNetctl]";
|
||||
|
||||
QList<netctlProfileInfo> profileInfo;
|
||||
if (raw.size() == 0)
|
||||
return profileInfo;
|
||||
for (int i=0; i<raw[0].toStringList().count(); i++) {
|
||||
netctlProfileInfo profile;
|
||||
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
|
||||
profile.name = info[0];
|
||||
profile.description = info[1];
|
||||
profile.active = info[2].toInt();
|
||||
profile.enabled = info[3].toInt();
|
||||
profileInfo.append(profile);
|
||||
}
|
||||
|
||||
return profileInfo;
|
||||
}
|
||||
|
||||
|
||||
QList<netctlWifiInfo> MainWindow::parseOutputWifi(const QList<QVariant> raw)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[parseOutputNetctl]";
|
||||
|
||||
QList<netctlWifiInfo> wifiInfo;
|
||||
if (raw.size() == 0)
|
||||
return wifiInfo;
|
||||
for (int i=0; i<raw[0].toStringList().count(); i++) {
|
||||
netctlWifiInfo wifi;
|
||||
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
|
||||
wifi.name = info[0];
|
||||
wifi.security = info[1];
|
||||
wifi.signal = info[2];
|
||||
wifi.active = info[3].toInt();
|
||||
wifi.exists = info[4].toInt();
|
||||
wifiInfo.append(wifi);
|
||||
}
|
||||
|
||||
return wifiInfo;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::reportABug()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[reportABug]";
|
||||
@ -505,27 +576,38 @@ void MainWindow::showSettingsWindow()
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::forceStartHelper()
|
||||
bool MainWindow::forceStartHelper()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[forceStartHelper]";
|
||||
if (!checkExternalApps(QString("helper"))) {
|
||||
errorWin->showWindow(1, QString("[MainWindow] : [forceStartHelper]"));
|
||||
return false;
|
||||
}
|
||||
|
||||
QProcess process;
|
||||
QString cmd = configuration[QString("HELPER_PATH")] + QString(" -c ") + configPath;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, false);
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
process.startDetached(cmd);
|
||||
return isHelperActive();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::forceStopHelper()
|
||||
bool MainWindow::forceStopHelper()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[forceStartHelper]";
|
||||
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Close"));
|
||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Close"));
|
||||
|
||||
if (responce.size() == 1)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::startHelper()
|
||||
bool MainWindow::startHelper()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[startHelper]";
|
||||
|
||||
@ -569,6 +651,11 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||
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]];
|
||||
if ((configuration[QString("USE_HELPER")] == QString("true")) &&
|
||||
(checkExternalApps(QString("helper"))))
|
||||
useHelper = true;
|
||||
else
|
||||
useHelper = false;
|
||||
|
||||
// update translation
|
||||
qApp->removeTranslator(translator);
|
||||
@ -645,12 +732,13 @@ void MainWindow::updateMainTab()
|
||||
return errorWin->showWindow(1, QString("[MainWindow] : [updateMainTab]"));
|
||||
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QList<netctlProfileInfo> profiles = netctlCommand->getProfileList();
|
||||
|
||||
if (netctlCommand->isNetctlAutoRunning())
|
||||
ui->widget_netctlAuto->setHidden(false);
|
||||
ui->widget_netctlAuto->setHidden(!netctlCommand->isNetctlAutoRunning());
|
||||
QList<netctlProfileInfo> profiles;
|
||||
if (useHelper)
|
||||
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("ProfileList")));
|
||||
else
|
||||
ui->widget_netctlAuto->setHidden(true);
|
||||
profiles = netctlCommand->getProfileList();
|
||||
|
||||
ui->tableWidget_main->setSortingEnabled(false);
|
||||
ui->tableWidget_main->selectRow(-1);
|
||||
@ -1611,6 +1699,7 @@ void MainWindow::wifiTabStart()
|
||||
if (ui->tableWidget_wifi->currentItem() == 0)
|
||||
return;
|
||||
|
||||
ui->tabWidget->setDisabled(true);
|
||||
// name is hidden
|
||||
if (ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() == QString("<hidden>")) {
|
||||
hiddenNetwork = true;
|
||||
@ -1627,7 +1716,6 @@ void MainWindow::wifiTabStart()
|
||||
}
|
||||
|
||||
// name isn't hidden
|
||||
ui->tabWidget->setDisabled(true);
|
||||
hiddenNetwork = false;
|
||||
QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text();
|
||||
if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 4)->text().isEmpty()) {
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class AboutWindow;
|
||||
class BridgeWidget;
|
||||
@ -31,9 +33,7 @@ class GeneralWidget;
|
||||
class IpWidget;
|
||||
class MacvlanWidget;
|
||||
class MobileWidget;
|
||||
class Netctl;
|
||||
class NetctlAutoWindow;
|
||||
class NetctlProfile;
|
||||
class PasswdWidget;
|
||||
class PppoeWidget;
|
||||
class SettingsWindow;
|
||||
@ -42,7 +42,6 @@ class TunnelWidget;
|
||||
class TuntapWidget;
|
||||
class VlanWidget;
|
||||
class WirelessWidget;
|
||||
class WpaSup;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -72,9 +71,9 @@ public slots:
|
||||
void showNetctlAutoWindow();
|
||||
void showSettingsWindow();
|
||||
// helper
|
||||
void forceStartHelper();
|
||||
void forceStopHelper();
|
||||
void startHelper();
|
||||
bool forceStartHelper();
|
||||
bool forceStopHelper();
|
||||
bool startHelper();
|
||||
// main
|
||||
void setTab(int tab);
|
||||
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
@ -147,16 +146,20 @@ private:
|
||||
void deleteObjects();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
||||
const QString interface, const QString cmd);
|
||||
const QString interface, const QString cmd,
|
||||
const bool system = true);
|
||||
void setIconsToTabs();
|
||||
QString configPath;
|
||||
bool debug;
|
||||
bool debug = false;
|
||||
bool hiddenNetwork;
|
||||
bool isDaemon;
|
||||
bool isDaemon = false;
|
||||
bool useHelper = true;
|
||||
QTranslator *translator = nullptr;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
QMap<QString, QString> parseOptions(const QString options);
|
||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw);
|
||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw);
|
||||
};
|
||||
|
||||
|
||||
|
@ -116,9 +116,9 @@ QString infoMessage()
|
||||
{
|
||||
QString infoMessage = QString("");
|
||||
// build information
|
||||
infoMessage += QApplication::translate("MainWindow", "Build date: %1").
|
||||
infoMessage += QCoreApplication::translate("NetctlHelper", "Build date: %1").
|
||||
arg(QString(BUILD_DATE));
|
||||
infoMessage += QString("\n%1:\n").arg(QApplication::translate("MainWindow", "cmake flags"));
|
||||
infoMessage += QString("\n%1:\n").arg(QCoreApplication::translate("NetctlHelper", "cmake flags"));
|
||||
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1 \\\n").arg(QString(CMAKE_BUILD_TYPE));
|
||||
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1 \\\n").arg(QString(CMAKE_INSTALL_PREFIX));
|
||||
infoMessage += QString("\t-DBUILD_DOCS=%1 \\\n").arg(QString(PROJECT_BUILD_DOCS));
|
||||
@ -128,12 +128,14 @@ QString infoMessage()
|
||||
infoMessage += QString("\t-DBUILD_DATAENGINE=%1 \\\n").arg(QString(PROJECT_BUILD_DATAENGINE));
|
||||
infoMessage += QString("\t-DBUILD_PLASMOID=%1\n").arg(QString(PROJECT_BUILD_PLASMOID));
|
||||
// transport information
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "DBus configuration"));
|
||||
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("NetctlHelper", "DBus configuration"));
|
||||
infoMessage += QString("\tDBUS_SERVICE=%1\n").arg(QString(DBUS_SERVICE));
|
||||
infoMessage += QString("\tDBUS_INTERFACE=%1\n").arg(QString(DBUS_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_OBJECT_PATH=%1\n").arg(QString(DBUS_OBJECT_PATH));
|
||||
infoMessage += QString("\tDBUS_HELPER_SERVICE=%1\n").arg(QString(DBUS_HELPER_SERVICE));
|
||||
infoMessage += QString("\tDBUS_HELPER_INTERFACE=%1\n").arg(QString(DBUS_HELPER_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_CONTROL_PATH=%1\n").arg(QString(DBUS_CONTROL_PATH));
|
||||
infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH));
|
||||
infoMessage += QString("\tDBUS_OBJECT_PATH=%1\n").arg(QString(DBUS_OBJECT_PATH));
|
||||
|
||||
return infoMessage;
|
||||
}
|
||||
|
1
sources/gui/src/task.h
Symbolic link
1
sources/gui/src/task.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../3rdparty/task/task.h
|
1
sources/gui/src/taskadds.cpp
Symbolic link
1
sources/gui/src/taskadds.cpp
Symbolic link
@ -0,0 +1 @@
|
||||
../../3rdparty/task/taskadds.cpp
|
1
sources/gui/src/taskadds.h
Symbolic link
1
sources/gui/src/taskadds.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../3rdparty/task/taskadds.h
|
@ -10,3 +10,5 @@ set (TARGETS "")
|
||||
set (HEADERS "")
|
||||
|
||||
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
|
||||
install (FILES org.netctlgui.helper.conf DESTINATION ${DBUS_SYSTEMCONF_PATH})
|
||||
install (FILES netctlgui-helper.service DESTINATION ${SYSTEMD_SERVICE_PATH})
|
||||
|
8
sources/helper/netctlgui-helper.service
Normal file
8
sources/helper/netctlgui-helper.service
Normal file
@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=netctlgui-helper daemon
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/netctlgui-helper
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
20
sources/helper/org.netctlgui.helper.conf
Normal file
20
sources/helper/org.netctlgui.helper.conf
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
|
||||
<!-- Only root or user avahi can own the service -->
|
||||
<policy user="root">
|
||||
<allow own="org.netctlgui.helper"/>
|
||||
</policy>
|
||||
|
||||
<!-- Allow everything, including access to SetHostName to users of the group "users" -->
|
||||
<policy group="users">
|
||||
<allow send_destination="org.netctlgui.helper"/>
|
||||
<allow receive_sender="org.netctlgui.helper"/>
|
||||
</policy>
|
||||
<policy user="root">
|
||||
<allow send_destination="org.netctlgui.helper"/>
|
||||
<allow receive_sender="org.netctlgui.helper"/>
|
||||
</policy>
|
||||
</busconfig>
|
@ -20,6 +20,7 @@
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -33,10 +34,10 @@ using namespace std;
|
||||
|
||||
bool checkExistSession()
|
||||
{
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(QString(DBUS_HELPER_SERVICE),
|
||||
QString(DBUS_CONTROL_PATH),
|
||||
QString(DBUS_HELPER_INTERFACE),
|
||||
QDBusConnection bus = QDBusConnection::systemBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE,
|
||||
DBUS_CONTROL_PATH,
|
||||
DBUS_HELPER_INTERFACE,
|
||||
QString("Active"));
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
@ -46,6 +47,9 @@ bool checkExistSession()
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// setuid(getuid());
|
||||
// qDebug() << getuid();
|
||||
// qDebug() << geteuid();
|
||||
// detach from console
|
||||
bool isDaemon = true;
|
||||
for (int i=0; i<argc; i++)
|
||||
|
@ -90,9 +90,11 @@ QString infoMessage()
|
||||
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("NetctlHelper", "DBus configuration"));
|
||||
infoMessage += QString("\tDBUS_SERVICE=%1\n").arg(QString(DBUS_SERVICE));
|
||||
infoMessage += QString("\tDBUS_INTERFACE=%1\n").arg(QString(DBUS_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_OBJECT_PATH=%1\n").arg(QString(DBUS_OBJECT_PATH));
|
||||
infoMessage += QString("\tDBUS_HELPER_SERVICE=%1\n").arg(QString(DBUS_HELPER_SERVICE));
|
||||
infoMessage += QString("\tDBUS_HELPER_INTERFACE=%1\n").arg(QString(DBUS_HELPER_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_CONTROL_PATH=%1\n").arg(QString(DBUS_CONTROL_PATH));
|
||||
infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH));
|
||||
infoMessage += QString("\tDBUS_OBJECT_PATH=%1\n").arg(QString(DBUS_OBJECT_PATH));
|
||||
|
||||
return infoMessage;
|
||||
}
|
||||
|
@ -18,7 +18,9 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusError>
|
||||
#include <QDebug>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
@ -50,9 +52,12 @@ QMap<QString, QString> NetctlHelper::getDefault()
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[getDefault]";
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
settings[QString("CLOSE_HELPER")] = QString("false");
|
||||
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
||||
settings[QString("CTRL_GROUP")] = QString("users");
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
settings[QString("HELPER_PATH")] = QString("/usr/bin/netctlgui-helper");
|
||||
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
|
||||
settings[QString("LANGUAGE")] = QString("en");
|
||||
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
|
||||
@ -66,6 +71,7 @@ QMap<QString, QString> NetctlHelper::getDefault()
|
||||
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
|
||||
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
|
||||
settings[QString("SYSTRAY")] = QString("true");
|
||||
settings[QString("USE_HELPER")] = QString("true");
|
||||
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
|
||||
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
|
||||
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
|
||||
@ -116,17 +122,26 @@ void NetctlHelper::createInterface()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]";
|
||||
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
if (!bus.registerService(QString(DBUS_HELPER_SERVICE)))
|
||||
QDBusConnection bus = QDBusConnection::systemBus();
|
||||
if (!bus.registerService(DBUS_HELPER_SERVICE)) {
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]" << ":" << "Could not register service";
|
||||
if (!bus.registerObject(QString(DBUS_LIB_PATH),
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]" << ":" << bus.lastError().message();
|
||||
return quitHelper();
|
||||
}
|
||||
if (!bus.registerObject(DBUS_LIB_PATH,
|
||||
new NetctlAdaptor(this, configuration),
|
||||
QDBusConnection::ExportAllContents))
|
||||
QDBusConnection::ExportAllContents)) {
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]" << ":" << "Could not register library object";
|
||||
if (!bus.registerObject(QString(DBUS_CONTROL_PATH),
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]" << ":" << bus.lastError().message();
|
||||
return quitHelper();
|
||||
}
|
||||
if (!bus.registerObject(DBUS_CONTROL_PATH,
|
||||
new ControlAdaptor(this, configuration),
|
||||
QDBusConnection::ExportAllContents))
|
||||
QDBusConnection::ExportAllContents)) {
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]" << ":" << "Could not register control object";
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]" << ":" << bus.lastError().message();
|
||||
return quitHelper();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -134,9 +149,9 @@ void NetctlHelper::deleteInterface()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[deleteInterface]";
|
||||
|
||||
QDBusConnection::sessionBus().unregisterObject(QString(DBUS_LIB_PATH));
|
||||
QDBusConnection::sessionBus().unregisterObject(QString(DBUS_CONTROL_PATH));
|
||||
QDBusConnection::sessionBus().unregisterService(QString(DBUS_HELPER_SERVICE));
|
||||
QDBusConnection::systemBus().unregisterObject(DBUS_LIB_PATH);
|
||||
QDBusConnection::systemBus().unregisterObject(DBUS_CONTROL_PATH);
|
||||
QDBusConnection::systemBus().unregisterService(DBUS_HELPER_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
* @brief Netctl class constructor
|
||||
* @param debugCmd show debug messages
|
||||
* @param settings default settings. Needed keys are
|
||||
* FORCE_SUDO (force to use sudo),
|
||||
* IFACE_DIR (path to directory with interfaces),
|
||||
* PREFERED_IFACE (prefered interface for WiFi),
|
||||
* NETCTL_PATH (path to netctl command),
|
||||
@ -244,9 +245,13 @@ private:
|
||||
*/
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
/**
|
||||
* @brief show debug messages
|
||||
* @brief show debug messages. Default is false
|
||||
*/
|
||||
bool debug;
|
||||
bool debug = false;
|
||||
/**
|
||||
* @brief use RootProcess instead of QProcess. Default is true
|
||||
*/
|
||||
bool useSuid = true;
|
||||
/**
|
||||
* @brief directory with interfaces. Default is "/sys/class/net/"
|
||||
*/
|
||||
@ -254,27 +259,27 @@ private:
|
||||
/**
|
||||
* @brief prefered interface for WiFi. Default is ""
|
||||
*/
|
||||
QString mainInterface;
|
||||
QString mainInterface = QString("");
|
||||
/**
|
||||
* @brief path to netctl command. Default is "/usr/bin/netctl"
|
||||
*/
|
||||
QString netctlCommand;
|
||||
QString netctlCommand = QString("/usr/bin/netctl");
|
||||
/**
|
||||
* @brief path to netctl-auto command. Default is "/usr/bin/netctl-auto"
|
||||
*/
|
||||
QString netctlAutoCommand;
|
||||
QString netctlAutoCommand = QString("/usr/bin/netctl-auto");
|
||||
/**
|
||||
* @brief netctl-auto service name. Default is "netctl-auto"
|
||||
*/
|
||||
QString netctlAutoService;
|
||||
QString netctlAutoService = QString("netctl-auto");
|
||||
/**
|
||||
* @brief path to sudo command. Default is "/usr/bin/kdesu"
|
||||
*/
|
||||
QString sudoCommand;
|
||||
QString sudoCommand = QString("/usr/bin/kdesu");
|
||||
/**
|
||||
* @brief path to systemctl command. Default is "/usr/bin/systemctl"
|
||||
*/
|
||||
QString systemctlCommand;
|
||||
QString systemctlCommand = QString("/usr/bin/systemctl");
|
||||
// functions
|
||||
/**
|
||||
* @brief method which calls command
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
* @brief NetctlProfile class constructor
|
||||
* @param debugCmd show debug messages
|
||||
* @param settings default settings. Needed keys are
|
||||
* FORCE_SUDO (force to use sudo),
|
||||
* PROFILE_DIR (path to directory which contains profiles),
|
||||
* SUDO_PATH (path to sudo command)
|
||||
*/
|
||||
@ -89,9 +90,13 @@ public:
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief show debug messages
|
||||
* @brief show debug messages. Default is false
|
||||
*/
|
||||
bool debug;
|
||||
bool debug = false;
|
||||
/**
|
||||
* @brief use RootProcess instead of QProcess. Default is true
|
||||
*/
|
||||
bool useSuid = true;
|
||||
/**
|
||||
* @brief directory which contains profiles. Default is "/etc/netctl"
|
||||
*/
|
||||
@ -99,7 +104,7 @@ private:
|
||||
/**
|
||||
* @brief path to sudo command. Default is "/usr/bin/kdesu"
|
||||
*/
|
||||
QString sudoCommand;
|
||||
QString sudoCommand = QString("/usr/bin/kdesu");
|
||||
};
|
||||
|
||||
|
||||
|
@ -137,35 +137,39 @@ private:
|
||||
/**
|
||||
* @brief show debug messages
|
||||
*/
|
||||
bool debug;
|
||||
bool debug = false;
|
||||
/**
|
||||
* @brief use RootProcess instead of QProcess. Default is true
|
||||
*/
|
||||
bool useSuid = true;
|
||||
/**
|
||||
* @brief path to ctrl_directory. Defaults is "/run/wpa_supplicant_netctl-gui"
|
||||
*/
|
||||
QString ctrlDir;
|
||||
QString ctrlDir = QString("/run/wpa_supplicant_netctl-gui");
|
||||
/**
|
||||
* @brief group which is owner of CTRL_DIR. Default is "users"
|
||||
*/
|
||||
QString ctrlGroup;
|
||||
QString ctrlGroup = QString("users");
|
||||
/**
|
||||
* @brief wpa_supplicant PID file. Default is "/run/wpa_supplicant_netctl-gui.pid"
|
||||
*/
|
||||
QString pidFile;
|
||||
QString pidFile = QString("/run/wpa_supplicant_netctl-gui.pid");
|
||||
/**
|
||||
* @brief path to sudo command. Default is "/usr/bin/kdesu"
|
||||
*/
|
||||
QString sudoCommand;
|
||||
QString sudoCommand = QString("/usr/bin/kdesu");
|
||||
/**
|
||||
* @brief path to wpa_cli command. Default is "/usr/bin/wpa_cli"
|
||||
*/
|
||||
QString wpaCliPath;
|
||||
QString wpaCliPath = QString("/usr/bin/wpa_cli");
|
||||
/**
|
||||
* @brief wpa_supplicant drivers comma separated. Default is "nl80211,wext"
|
||||
*/
|
||||
QString wpaDrivers;
|
||||
QString wpaDrivers = QString("nl80211,wext");
|
||||
/**
|
||||
* @brief path to wpa_supplicant command. Default is "/usr/bin/wpa_supplicant"
|
||||
*/
|
||||
QString wpaSupPath;
|
||||
QString wpaSupPath = QString("/usr/bin/wpa_supplicant");
|
||||
// functions
|
||||
/**
|
||||
* @brief method which calls wpa_cli and returns its output
|
||||
|
@ -46,28 +46,22 @@ Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
|
||||
ifaceDirectory = new QDir(QString("/sys/class/net/"));
|
||||
if (settings.contains(QString("PREFERED_IFACE")))
|
||||
mainInterface = settings[QString("PREFERED_IFACE")];
|
||||
else
|
||||
mainInterface = QString("");
|
||||
if (settings.contains(QString("NETCTL_PATH")))
|
||||
netctlCommand = settings[QString("NETCTL_PATH")];
|
||||
else
|
||||
netctlCommand = QString("/usr/bin/netctl");
|
||||
if (settings.contains(QString("NETCTLAUTO_PATH")))
|
||||
netctlAutoCommand = settings[QString("NETCTLAUTO_PATH")];
|
||||
else
|
||||
netctlAutoCommand = QString("/usr/bin/netctl-auto");
|
||||
if (settings.contains(QString("NETCTLAUTO_SERVICE")))
|
||||
netctlAutoService = settings[QString("NETCTLAUTO_SERVICE")];
|
||||
else
|
||||
netctlAutoService = QString("netctl-auto");
|
||||
if (settings.contains(QString("SUDO_PATH")))
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
else
|
||||
sudoCommand = QString("/usr/bin/kdesu");
|
||||
if (settings.contains(QString("SYSTEMCTL_PATH")))
|
||||
systemctlCommand = settings[QString("SYSTEMCTL_PATH")];
|
||||
else
|
||||
systemctlCommand = QString("/usr/bin/systemctl");
|
||||
if (settings.contains(QString("FORCE_SUDO")))
|
||||
if (settings[QString("FORCE_SUDO")] == QString("true"))
|
||||
useSuid = false;
|
||||
|
||||
if (useSuid)
|
||||
sudoCommand = QString("");
|
||||
}
|
||||
|
||||
|
||||
@ -103,7 +97,7 @@ bool Netctl::cmdCall(const bool sudo, const QString command, const QString comma
|
||||
cmd += command + QString(" ") + commandLine;
|
||||
if (argument != 0) cmd += QString(" ") + argument;
|
||||
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
TaskResult process = runTask(cmd, (useSuid && sudo));
|
||||
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
if (process.exitCode == 0)
|
||||
@ -132,7 +126,7 @@ QString Netctl::getCmdOutput(const bool sudo, const QString command, const QStri
|
||||
cmd += command + QString(" ") + commandLine;
|
||||
if (argument != 0) cmd += QString(" ") + argument;
|
||||
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
TaskResult process = runTask(cmd, (useSuid && sudo));
|
||||
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
return process.output;
|
||||
|
@ -47,8 +47,12 @@ NetctlProfile::NetctlProfile(const bool debugCmd, const QMap<QString, QString> s
|
||||
profileDirectory = new QDir(QString("/etc/netctl/"));
|
||||
if (settings.contains(QString("SUDO_PATH")))
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
else
|
||||
sudoCommand = QString("/usr/bin/kdesu");
|
||||
if (settings.contains(QString("FORCE_SUDO")))
|
||||
if (settings[QString("FORCE_SUDO")] == QString("true"))
|
||||
useSuid = false;
|
||||
|
||||
if (useSuid)
|
||||
sudoCommand = QString("");
|
||||
}
|
||||
|
||||
|
||||
@ -78,7 +82,7 @@ bool NetctlProfile::copyProfile(const QString oldPath)
|
||||
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
|
||||
QString cmd = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
|
||||
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
TaskResult process = runTask(cmd, useSuid);
|
||||
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
if (process.exitCode == 0)
|
||||
@ -213,7 +217,7 @@ bool NetctlProfile::removeProfile(const QString profile)
|
||||
QString profilePath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
|
||||
QString cmd = sudoCommand + QString(" /usr/bin/rm ") + profilePath;
|
||||
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
TaskResult process = runTask(cmd, useSuid);
|
||||
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
if (process.exitCode == 0)
|
||||
|
@ -43,32 +43,24 @@ WpaSup::WpaSup(const bool debugCmd, const QMap<QString, QString> settings)
|
||||
|
||||
if (settings.contains(QString("CTRL_DIR")))
|
||||
ctrlDir = settings[QString("CTRL_DIR")];
|
||||
else
|
||||
ctrlDir = QString("/run/wpa_supplicant_netctl-gui");
|
||||
if (settings.contains(QString("CTRL_GROUP")))
|
||||
ctrlGroup = settings[QString("CTRL_GROUP")];
|
||||
else
|
||||
ctrlGroup = QString("users");
|
||||
if (settings.contains(QString("PID_FILE")))
|
||||
pidFile = settings[QString("PID_FILE")];
|
||||
else
|
||||
pidFile = QString("/run/wpa_supplicant_netctl-gui.pid");
|
||||
if (settings.contains(QString("SUDO_PATH")))
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
else
|
||||
sudoCommand = QString("/usr/bin/kdesu");
|
||||
if (settings.contains(QString("WPACLI_PATH")))
|
||||
wpaCliPath = settings[QString("WPACLI_PATH")];
|
||||
else
|
||||
wpaCliPath = QString("/usr/bin/wpa_cli");
|
||||
if (settings.contains(QString("WPA_DRIVERS")))
|
||||
wpaDrivers = settings[QString("WPA_DRIVERS")];
|
||||
else
|
||||
wpaDrivers = QString("nl80211,wext");
|
||||
if (settings.contains(QString("WPASUP_PATH")))
|
||||
wpaSupPath = settings[QString("WPASUP_PATH")];
|
||||
else
|
||||
wpaSupPath = QString("/usr/bin/wpa_supplicant");
|
||||
if (settings.contains(QString("FORCE_SUDO")))
|
||||
if (settings[QString("FORCE_SUDO")] == QString("true"))
|
||||
useSuid = false;
|
||||
|
||||
if (useSuid)
|
||||
sudoCommand = QString("");
|
||||
}
|
||||
|
||||
|
||||
@ -273,7 +265,7 @@ bool WpaSup::startWpaSupplicant()
|
||||
QString(" -i ") + interface + QString(" -D ") + wpaDrivers +
|
||||
QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\"");
|
||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
TaskResult process = runTask(cmd, useSuid);
|
||||
waitForProcess(1);
|
||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user