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=(
'CLOSE_HELPER'
'CLOSETOTRAY'
'CTRL_DIR'
'CTRL_GROUP'
'FORCE_SUDO'
'HELPER_PATH'
'HELPER_SERVICE'
'IFACE_DIR'
'LANGUAGE'
'NETCTL_PATH'
'NETCTLAUTO_PATH'
'NETCTLAUTO_SERVICE'
'NETCTL_PATH'
'PID_FILE'
'PREFERED_IFACE'
'PROFILE_DIR'
@ -63,6 +67,7 @@ _netctl_gui_settings=(
'SUDO_PATH'
'SYSTEMCTL_PATH'
'SYSTRAY'
'USE_HELPER'
'WPACLI_PATH'
'WPASUP_PATH'
'WPA_DRIVERS'

View File

@ -437,6 +437,10 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
createObjects();
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);
createActions();
setIconsToTabs();

View File

@ -322,6 +322,7 @@ QMap<QString, QString> SettingsWindow::readSettings()
else
settings[QString("FORCE_SUDO")] = QString("false");
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("LANGUAGE")] = ui->comboBox_language->currentText();
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
@ -375,6 +376,7 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
else
ui->checkBox_forceSudo->setCheckState(Qt::Unchecked);
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->comboBox_language->setCurrentIndex(0);
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("FORCE_SUDO")] = QString("false");
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("LANGUAGE")] = QString("en");
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");

View File

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

View File

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

View File

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

View File

@ -32,10 +32,10 @@
NetctlHelper::NetctlHelper(QObject *parent, QMap<QString, QVariant> args)
: QObject(parent),
initConfigPath(args[QString("config")].toString()),
configPath(args[QString("config")].toString()),
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("FORCE_SUDO")] = QString("false");
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("LANGUAGE")] = QString("en");
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]";
@ -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]";
deleteInterface();
if (configPath.isEmpty())
configPath = initConfigPath;
configuration = getSettings(configPath);
configuration = getSettings();
createInterface();
}

View File

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