commit before starting work on helper

This commit is contained in:
arcan1s 2014-08-08 17:01:33 +04:00
parent c15e387472
commit 1ae30b0821
11 changed files with 28 additions and 26 deletions

View File

@ -22,7 +22,7 @@
TaskResult runTask(const QString cmd) TaskResult runTask(const QString cmd)
{ {
return Task::await<TaskResult>( [ & ]() { return Task::await<TaskResult>( [ & ]() {
QProcess command; SandboxProcess command;
command.start(cmd); command.start(cmd);
command.waitForFinished(-1); command.waitForFinished(-1);
TaskResult r; TaskResult r;

View File

@ -20,10 +20,21 @@
#define TASKADDS_H #define TASKADDS_H
#include <QProcess> #include <QProcess>
#include <unistd.h>
#include "task.h" #include "task.h"
class SandboxProcess : public QProcess
{
protected:
void setupChildProcess()
{
::setuid(0);
};
};
struct TaskResult struct TaskResult
{ {
int exitCode; int exitCode;

View File

@ -18,7 +18,7 @@
# variables # variables
_netctl_gui_arglist=( _netctl_gui_arglist=(
'--daemonized' '--daemon'
'--maximized' '--maximized'
'--minimized' '--minimized'
'--about' '--about'

View File

@ -60,4 +60,5 @@ endif()
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS}) add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS}) target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
# install properties # install properties
install (TARGETS ${SUBPROJECT} DESTINATION bin) install (TARGETS ${SUBPROJECT} DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID)

View File

@ -19,6 +19,7 @@
#include <QApplication> #include <QApplication>
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusMessage> #include <QDBusMessage>
#include <QDebug>
#include <QDir> #include <QDir>
#include <QTranslator> #include <QTranslator>
#include <iostream> #include <iostream>
@ -54,6 +55,10 @@ int main(int argc, char *argv[])
daemon(0, 0); daemon(0, 0);
break; break;
} }
#if QT_VERSION >= 0x050000
QApplication::setSetuidAllowed(true);
qDebug() << QApplication::isSetuidAllowed();
#endif
QApplication a(argc, argv); QApplication a(argc, argv);
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
// check if exists // check if exists

View File

@ -52,6 +52,9 @@
#include "vlanwidget.h" #include "vlanwidget.h"
#include "wirelesswidget.h" #include "wirelesswidget.h"
#include <polkit-qt5-1/polkitqt1-authority.h>
#include <polkit-qt5-1/polkitqt1-subject.h>
MainWindow::MainWindow(QWidget *parent, MainWindow::MainWindow(QWidget *parent,
const QMap<QString, QVariant> args, const QMap<QString, QVariant> args,
@ -78,7 +81,6 @@ MainWindow::MainWindow(QWidget *parent,
isDaemon = true; isDaemon = true;
else else
isDaemon = false; isDaemon = false;
createDBusSession();
updateConfiguration(args); updateConfiguration(args);
// main actions // main actions
@ -117,7 +119,6 @@ MainWindow::~MainWindow()
{ {
if (debug) qDebug() << "[MainWindow]" << "[~MainWindow]"; if (debug) qDebug() << "[MainWindow]" << "[~MainWindow]";
QDBusConnection::sessionBus().unregisterService(QString(DBUS_SERVICE));
deleteObjects(); deleteObjects();
} }
@ -294,6 +295,7 @@ void MainWindow::createObjects()
if (debug) qDebug() << "[MainWindow]" << "[createObjects]"; if (debug) qDebug() << "[MainWindow]" << "[createObjects]";
// backend // backend
createDBusSession();
netctlCommand = new Netctl(debug, configuration); netctlCommand = new Netctl(debug, configuration);
netctlProfile = new NetctlProfile(debug, configuration); netctlProfile = new NetctlProfile(debug, configuration);
wpaCommand = new WpaSup(debug, configuration); wpaCommand = new WpaSup(debug, configuration);
@ -340,6 +342,7 @@ void MainWindow::deleteObjects()
{ {
if (debug) qDebug() << "[MainWindow]" << "[deleteObjects]"; if (debug) qDebug() << "[MainWindow]" << "[deleteObjects]";
QDBusConnection::sessionBus().unregisterService(QString(DBUS_SERVICE));
if (netctlCommand != nullptr) delete netctlCommand; if (netctlCommand != nullptr) delete netctlCommand;
if (netctlProfile != nullptr) delete netctlProfile; if (netctlProfile != nullptr) delete netctlProfile;
if (wpaCommand != nullptr) delete wpaCommand; if (wpaCommand != nullptr) delete wpaCommand;

View File

@ -19,7 +19,9 @@
#define MESSAGES_H #define MESSAGES_H
#include <QChar> #include <QChar>
#include <QMap>
#include <QString> #include <QString>
#include <QVariant>
QString errorMessage(); QString errorMessage();

View File

@ -19,7 +19,7 @@
# variables # variables
_netctl_gui_arglist=( _netctl_gui_arglist=(
{'--daemonized','--daemonized'}'[start daemonized]' {'--daemon','--daemon'}'[start as daemon]'
{'--maximized','--maximized'}'[start maximized]' {'--maximized','--maximized'}'[start maximized]'
{'--minimized','--minimized'}'[start minimized to tray]' {'--minimized','--minimized'}'[start minimized to tray]'
{'--about','--about'}'[show about window]' {'--about','--about'}'[show about window]'

View File

@ -97,10 +97,6 @@ bool Netctl::cmdCall(const bool sudo, const QString command, const QString comma
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Could not find command"; if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Could not find command";
return false; return false;
} }
if ((sudo) && (sudoCommand == 0)) {
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Could not find sudo";
return false;
}
QString cmd = QString(""); QString cmd = QString("");
if (sudo) cmd = sudoCommand + QString(" "); if (sudo) cmd = sudoCommand + QString(" ");
@ -130,10 +126,6 @@ QString Netctl::getCmdOutput(const bool sudo, const QString command, const QStri
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Could not find command"; if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Could not find command";
return QString(); return QString();
} }
if ((sudo) && (sudoCommand == 0)) {
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Could not find sudo";
return QString();
}
QString cmd = QString(""); QString cmd = QString("");
if (sudo) cmd = sudoCommand + QString(" "); if (sudo) cmd = sudoCommand + QString(" ");

View File

@ -74,10 +74,6 @@ bool NetctlProfile::copyProfile(const QString oldPath)
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Could not find directory"; if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Could not find directory";
return false; return false;
} }
if (sudoCommand == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Could not find sudo";
return false;
}
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName(); QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
QString cmd = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath; QString cmd = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
@ -213,10 +209,6 @@ bool NetctlProfile::removeProfile(const QString profile)
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Could not find directory"; if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Could not find directory";
return false; return false;
} }
if (sudoCommand == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Could not find sudo";
return false;
}
QString profilePath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName(); QString profilePath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
QString cmd = sudoCommand + QString(" /usr/bin/rm ") + profilePath; QString cmd = sudoCommand + QString(" /usr/bin/rm ") + profilePath;

View File

@ -249,10 +249,6 @@ bool WpaSup::startWpaSupplicant()
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find PID file"; if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find PID file";
return false; return false;
} }
if (sudoCommand == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find sudo";
return false;
}
if (wpaDrivers == 0) { if (wpaDrivers == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find drivers"; if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find drivers";
return false; return false;