mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-06 10:35:46 +00:00
add --system flag to the helper
add security notes
This commit is contained in:
@ -21,6 +21,7 @@ file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN})
|
||||
configure_file (${SUBPROJECT_MAN_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN})
|
||||
|
||||
install (FILES org.netctlgui.helper.conf DESTINATION ${DBUS_SYSTEMCONF_PATH})
|
||||
install (FILES netctlgui-helper.conf DESTINATION /etc)
|
||||
install (FILES netctlgui-helper.service DESTINATION ${SYSTEMD_SERVICE_PATH})
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/)
|
||||
install (FILES bash-completions DESTINATION share/bash-completion/completions/ RENAME ${SUBPROJECT})
|
||||
|
@ -25,6 +25,7 @@ _netctlgui_helper_arglist=(
|
||||
'--nodaemon'
|
||||
'--replace'
|
||||
'--restore'
|
||||
'--system'
|
||||
'-v'
|
||||
'--version'
|
||||
'-i'
|
||||
|
@ -22,6 +22,8 @@ do not run as daemon
|
||||
force replace the existing session
|
||||
.IP "--restore"
|
||||
force restore the existing session
|
||||
.IP "--system"
|
||||
do not read user configuration
|
||||
.IP "-v, --version"
|
||||
show version and exit
|
||||
.IP "-i, --info"
|
||||
|
24
sources/helper/netctlgui-helper.conf
Normal file
24
sources/helper/netctlgui-helper.conf
Normal file
@ -0,0 +1,24 @@
|
||||
CLOSETOTRAY=true
|
||||
CLOSE_HELPER=false
|
||||
CTRL_DIR=/run/wpa_supplicant_netctl-gui
|
||||
CTRL_GROUP=users
|
||||
FORCE_SUDO=false
|
||||
HELPER_PATH=/usr/bin/netctlgui-helper
|
||||
HELPER_SERVICE=netctlgui-helper.service
|
||||
IFACE_DIR=/sys/class/net/
|
||||
LANGUAGE=en
|
||||
NETCTLAUTO_PATH=/usr/bin/netctl-auto
|
||||
NETCTLAUTO_SERVICE=netctl-auto
|
||||
NETCTL_PATH=/usr/bin/netctl
|
||||
PID_FILE=/run/wpa_supplicant_netctl-gui.pid
|
||||
PREFERED_IFACE=
|
||||
PROFILE_DIR=/etc/netctl/
|
||||
RFKILL_DIR=/sys/class/rfkill/
|
||||
STARTTOTRAY=false
|
||||
SUDO_PATH=/usr/bin/sudo
|
||||
SYSTEMCTL_PATH=/usr/bin/systemctl
|
||||
SYSTRAY=true
|
||||
USE_HELPER=true
|
||||
WPACLI_PATH=/usr/bin/wpa_cli
|
||||
WPASUP_PATH=/usr/bin/wpa_supplicant
|
||||
WPA_DRIVERS=nl80211,wext
|
@ -3,7 +3,7 @@ Description=netctlgui-helper daemon
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=/usr/bin/netctlgui-helper
|
||||
ExecStart=/usr/bin/netctlgui-helper --system
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -67,6 +67,9 @@ int main(int argc, char *argv[])
|
||||
} else if (QString(argv[i]) == QString("--restore")) {
|
||||
// restore
|
||||
args[QString("state")] = (int) 2;
|
||||
} else if (QString(argv[i]) == QString("--system")) {
|
||||
// system
|
||||
args[QString("system")] = true;
|
||||
} else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
|
||||
// help message
|
||||
args[QString("help")] = true;
|
||||
|
@ -38,6 +38,7 @@ QMap<QString, QVariant> getArgs()
|
||||
args[QString("debug")] = false;
|
||||
args[QString("nodaemon")] = false;
|
||||
args[QString("state")] = (int) 0;
|
||||
args[QString("system")] = false;
|
||||
args[QString("help")] = false;
|
||||
args[QString("info")] = false;
|
||||
args[QString("version")] = false;
|
||||
@ -64,6 +65,8 @@ QString helpMessage()
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "force replace the existing session"));
|
||||
helpMessage += QString(" --restore - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "force restore the existing session"));
|
||||
helpMessage += QString(" --system - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "do not read user configuration, system-wide only"));
|
||||
helpMessage += QString(" %1\n").arg(QCoreApplication::translate("NetctlHelper", "Show messages:"));
|
||||
helpMessage += QString(" -v, --version - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "show version and exit"));
|
||||
|
@ -33,7 +33,8 @@
|
||||
NetctlHelper::NetctlHelper(QObject *parent, QMap<QString, QVariant> args)
|
||||
: QObject(parent),
|
||||
configPath(args[QString("config")].toString()),
|
||||
debug(args[QString("debug")].toBool())
|
||||
debug(args[QString("debug")].toBool()),
|
||||
system(args[QString("system")].toBool())
|
||||
{
|
||||
updateConfiguration();
|
||||
if (!args[QString("nodaemon")].toBool())
|
||||
@ -136,12 +137,16 @@ QMap<QString, QString> NetctlHelper::getDefault()
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> NetctlHelper::getSettings()
|
||||
QMap<QString, QString> NetctlHelper::getSettings(const QString file, const QMap<QString, QString> existing)
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[getSettings]";
|
||||
|
||||
QMap<QString, QString> settings = getDefault();
|
||||
QFile configFile(configPath);
|
||||
QMap<QString, QString> settings;
|
||||
if (existing.isEmpty())
|
||||
settings = getDefault();
|
||||
else
|
||||
settings = existing;
|
||||
QFile configFile(file);
|
||||
QString fileStr;
|
||||
if (!configFile.open(QIODevice::ReadOnly))
|
||||
return settings;
|
||||
@ -168,7 +173,9 @@ void NetctlHelper::updateConfiguration()
|
||||
if (debug) qDebug() << "[NetctlHelper]" << "[updateConfiguration]";
|
||||
|
||||
deleteInterface();
|
||||
configuration = getSettings();
|
||||
configuration = getSettings(QString("/etc/netctlgui-helper.conf"));
|
||||
if (!system)
|
||||
configuration = getSettings(configPath, configuration);
|
||||
createInterface();
|
||||
}
|
||||
|
||||
|
@ -41,10 +41,12 @@ private:
|
||||
QString configPath;
|
||||
QMap<QString, QString> configuration;
|
||||
bool debug;
|
||||
bool system;
|
||||
void createInterface();
|
||||
void deleteInterface();
|
||||
QMap<QString, QString> getDefault();
|
||||
QMap<QString, QString> getSettings();
|
||||
QMap<QString, QString> getSettings(const QString file,
|
||||
const QMap<QString, QString> existing = QMap<QString, QString>());
|
||||
};
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@ _netctlgui_helper_arglist=(
|
||||
{'--nodaemon','--nodaemon'}'[do not start as daemon]'
|
||||
{'--replace','--replace'}'[force replace the existing session]'
|
||||
{'--restore','--restore'}'[force restore the existing session]'
|
||||
{'--system','--system'}'[do not read user configuration]'
|
||||
{'(--version)-v','(-v)--version'}'[show version and exit]'
|
||||
{'(--info)-i','(-i)--info'}'[show build information and exit]'
|
||||
{'(--help)-h','(-h)--help'}'[show help and exit]'
|
||||
|
Reference in New Issue
Block a user