fix security hole in helper

This commit is contained in:
arcan1s
2014-08-09 22:33:13 +04:00
parent 2ff76e9c8e
commit 41f58c1448
9 changed files with 79 additions and 25 deletions

View File

@ -47,14 +47,18 @@ _netctl_gui_arglist=(
) )
_netctl_gui_settings=( _netctl_gui_settings=(
'CLOSE_HELPER'
'CLOSETOTRAY' 'CLOSETOTRAY'
'CTRL_DIR' 'CTRL_DIR'
'CTRL_GROUP' 'CTRL_GROUP'
'FORCE_SUDO'
'HELPER_PATH'
'HELPER_SERVICE'
'IFACE_DIR' 'IFACE_DIR'
'LANGUAGE' 'LANGUAGE'
'NETCTL_PATH'
'NETCTLAUTO_PATH' 'NETCTLAUTO_PATH'
'NETCTLAUTO_SERVICE' 'NETCTLAUTO_SERVICE'
'NETCTL_PATH'
'PID_FILE' 'PID_FILE'
'PREFERED_IFACE' 'PREFERED_IFACE'
'PROFILE_DIR' 'PROFILE_DIR'
@ -63,6 +67,7 @@ _netctl_gui_settings=(
'SUDO_PATH' 'SUDO_PATH'
'SYSTEMCTL_PATH' 'SYSTEMCTL_PATH'
'SYSTRAY' 'SYSTRAY'
'USE_HELPER'
'WPACLI_PATH' 'WPACLI_PATH'
'WPASUP_PATH' 'WPASUP_PATH'
'WPA_DRIVERS' 'WPA_DRIVERS'

View File

@ -437,6 +437,10 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
createObjects(); createObjects();
if (useHelper) useHelper = isHelperActive(); if (useHelper) useHelper = isHelperActive();
if (useHelper)
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Update"),
QList<QVariant>(), true, debug);
setTab(args[QString("tab")].toInt() - 1); setTab(args[QString("tab")].toInt() - 1);
createActions(); createActions();
setIconsToTabs(); setIconsToTabs();

View File

@ -322,6 +322,7 @@ QMap<QString, QString> SettingsWindow::readSettings()
else else
settings[QString("FORCE_SUDO")] = QString("false"); settings[QString("FORCE_SUDO")] = QString("false");
settings[QString("HELPER_PATH")] = ui->lineEdit_helperPath->text(); settings[QString("HELPER_PATH")] = ui->lineEdit_helperPath->text();
settings[QString("HELPER_SERVICE")] = ui->lineEdit_helperService->text();
settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text(); settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText(); settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text(); settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
@ -375,6 +376,7 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
else else
ui->checkBox_forceSudo->setCheckState(Qt::Unchecked); ui->checkBox_forceSudo->setCheckState(Qt::Unchecked);
ui->lineEdit_helperPath->setText(settings[QString("HELPER_PATH")]); ui->lineEdit_helperPath->setText(settings[QString("HELPER_PATH")]);
ui->lineEdit_helperPath->setText(settings[QString("HELPER_SERVICE")]);
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]); ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
ui->comboBox_language->setCurrentIndex(0); ui->comboBox_language->setCurrentIndex(0);
for (int i=0; i<ui->comboBox_language->count(); i++) for (int i=0; i<ui->comboBox_language->count(); i++)
@ -421,6 +423,7 @@ QMap<QString, QString> SettingsWindow::getDefault()
settings[QString("CTRL_GROUP")] = QString("users"); settings[QString("CTRL_GROUP")] = QString("users");
settings[QString("FORCE_SUDO")] = QString("false"); settings[QString("FORCE_SUDO")] = QString("false");
settings[QString("HELPER_PATH")] = QString("/usr/bin/netctlgui-helper"); settings[QString("HELPER_PATH")] = QString("/usr/bin/netctlgui-helper");
settings[QString("HELPER_SERVICE")] = QString("netctlgui-helper.service");
settings[QString("IFACE_DIR")] = QString("/sys/class/net/"); settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
settings[QString("LANGUAGE")] = QString("en"); settings[QString("LANGUAGE")] = QString("en");
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl"); settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>658</width> <width>656</width>
<height>319</height> <height>317</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -119,7 +119,7 @@
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="page_general"> <widget class="QWidget" name="page_general">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -136,8 +136,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>442</width> <width>440</width>
<height>258</height> <height>256</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
@ -211,8 +211,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>442</width> <width>440</width>
<height>258</height> <height>256</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_13"> <layout class="QVBoxLayout" name="verticalLayout_13">
@ -220,6 +220,12 @@
<layout class="QHBoxLayout" name="layout_status"> <layout class="QHBoxLayout" name="layout_status">
<item> <item>
<widget class="QLabel" name="label_statusText"> <widget class="QLabel" name="label_statusText">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Helper status</string> <string>Helper status</string>
</property> </property>
@ -251,7 +257,9 @@
<string>Start</string> <string>Start</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="system-run"/> <iconset theme="system-run">
<normaloff/>
</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@ -282,6 +290,12 @@
<layout class="QHBoxLayout" name="layout_helperPath"> <layout class="QHBoxLayout" name="layout_helperPath">
<item> <item>
<widget class="QLabel" name="label_helperPath"> <widget class="QLabel" name="label_helperPath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Helper command</string> <string>Helper command</string>
</property> </property>
@ -299,6 +313,30 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="layout_helperService">
<item>
<widget class="QLabel" name="label_helperService">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Helper service</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_helperService">
<property name="toolTip">
<string>Name of netctlgui-helper service</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<spacer name="spacer_helper"> <spacer name="spacer_helper">
<property name="orientation"> <property name="orientation">
@ -333,8 +371,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>436</width> <width>440</width>
<height>165</height> <height>256</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">

View File

@ -39,14 +39,18 @@ _netctl_gui_arglist=(
) )
_netctl_gui_settings=( _netctl_gui_settings=(
'CLOSE_HELPER'
'CLOSETOTRAY' 'CLOSETOTRAY'
'CTRL_DIR' 'CTRL_DIR'
'CTRL_GROUP' 'CTRL_GROUP'
'FORCE_SUDO'
'HELPER_PATH'
'HELPER_SERVICE'
'IFACE_DIR' 'IFACE_DIR'
'LANGUAGE' 'LANGUAGE'
'NETCTL_PATH'
'NETCTLAUTO_PATH' 'NETCTLAUTO_PATH'
'NETCTLAUTO_SERVICE' 'NETCTLAUTO_SERVICE'
'NETCTL_PATH'
'PID_FILE' 'PID_FILE'
'PREFERED_IFACE' 'PREFERED_IFACE'
'PROFILE_DIR' 'PROFILE_DIR'
@ -55,6 +59,7 @@ _netctl_gui_settings=(
'SUDO_PATH' 'SUDO_PATH'
'SYSTEMCTL_PATH' 'SYSTEMCTL_PATH'
'SYSTRAY' 'SYSTRAY'
'USE_HELPER'
'WPACLI_PATH' 'WPACLI_PATH'
'WPASUP_PATH' 'WPASUP_PATH'
'WPA_DRIVERS' 'WPA_DRIVERS'

View File

@ -59,9 +59,9 @@ QStringList ControlAdaptor::Settings()
} }
bool ControlAdaptor::Update(const QString configPath) bool ControlAdaptor::Update()
{ {
helper->updateConfiguration(configPath); helper->updateConfiguration();
return true; return true;
} }

View File

@ -40,7 +40,7 @@ public slots:
bool Active(); bool Active();
bool Close(); bool Close();
QStringList Settings(); QStringList Settings();
bool Update(const QString configPath = QString("")); bool Update();
// netctlCommand // netctlCommand
bool autoDisableAll(); bool autoDisableAll();
bool autoEnable(const QString profile); bool autoEnable(const QString profile);

View File

@ -32,10 +32,10 @@
NetctlHelper::NetctlHelper(QObject *parent, QMap<QString, QVariant> args) NetctlHelper::NetctlHelper(QObject *parent, QMap<QString, QVariant> args)
: QObject(parent), : QObject(parent),
initConfigPath(args[QString("config")].toString()), configPath(args[QString("config")].toString()),
debug(args[QString("debug")].toBool()) debug(args[QString("debug")].toBool())
{ {
updateConfiguration(initConfigPath); updateConfiguration();
} }
@ -108,6 +108,7 @@ QMap<QString, QString> NetctlHelper::getDefault()
settings[QString("CTRL_GROUP")] = QString("users"); settings[QString("CTRL_GROUP")] = QString("users");
settings[QString("FORCE_SUDO")] = QString("false"); settings[QString("FORCE_SUDO")] = QString("false");
settings[QString("HELPER_PATH")] = QString("/usr/bin/netctlgui-helper"); settings[QString("HELPER_PATH")] = QString("/usr/bin/netctlgui-helper");
settings[QString("HELPER_SERVICE")] = QString("netctlgui-helper.service");
settings[QString("IFACE_DIR")] = QString("/sys/class/net/"); settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
settings[QString("LANGUAGE")] = QString("en"); settings[QString("LANGUAGE")] = QString("en");
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl"); settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
@ -133,7 +134,7 @@ QMap<QString, QString> NetctlHelper::getDefault()
} }
QMap<QString, QString> NetctlHelper::getSettings(const QString configPath) QMap<QString, QString> NetctlHelper::getSettings()
{ {
if (debug) qDebug() << "[NetctlHelper]" << "[getSettings]"; if (debug) qDebug() << "[NetctlHelper]" << "[getSettings]";
@ -160,15 +161,13 @@ QMap<QString, QString> NetctlHelper::getSettings(const QString configPath)
} }
void NetctlHelper::updateConfiguration(QString configPath) void NetctlHelper::updateConfiguration()
{ {
if (debug) qDebug() << "[NetctlHelper]" << "[updateConfiguration]"; if (debug) qDebug() << "[NetctlHelper]" << "[updateConfiguration]";
deleteInterface(); deleteInterface();
if (configPath.isEmpty()) configuration = getSettings();
configPath = initConfigPath;
configuration = getSettings(configPath);
createInterface(); createInterface();
} }

View File

@ -34,17 +34,17 @@ public:
QStringList printSettings(); QStringList printSettings();
public slots: public slots:
void updateConfiguration(QString configPath = QString("")); void updateConfiguration();
void quitHelper(); void quitHelper();
private: private:
QString initConfigPath; QString configPath;
QMap<QString, QString> configuration; QMap<QString, QString> configuration;
bool debug; bool debug;
void createInterface(); void createInterface();
void deleteInterface(); void deleteInterface();
QMap<QString, QString> getDefault(); QMap<QString, QString> getDefault();
QMap<QString, QString> getSettings(const QString configPath); QMap<QString, QString> getSettings();
}; };