diff --git a/.gitmodules b/.gitmodules index 48cbb3b..93bd87e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,12 @@ -[submodule "sources/3rdparty/task"] - path = sources/3rdparty/task - url = https://github.com/arcan1s/qtadds-task.git [submodule "sources/3rdparty/tasks"] path = sources/3rdparty/tasks url = https://github.com/mhogomchungu/tasks.git -[submodule "sources/3rdparty/language"] - path = sources/3rdparty/language - url = https://github.com/arcan1s/qtadds-language.git [submodule "sources/3rdparty/pdebug"] path = sources/3rdparty/pdebug url = https://github.com/arcan1s/qtadds-pdebug.git +[submodule "sources/3rdparty/language"] + path = sources/3rdparty/language + url = https://github.com/arcan1s/qtadds-language.git +[submodule "sources/3rdparty/task"] + path = sources/3rdparty/task + url = https://github.com/arcan1s/qtadds-taskadds-qprocess.git diff --git a/sources/gui/src/settingswindow.ui b/sources/gui/src/settingswindow.ui index 51ac9cf..2f19661 100644 --- a/sources/gui/src/settingswindow.ui +++ b/sources/gui/src/settingswindow.ui @@ -6,8 +6,8 @@ 0 0 - 680 - 397 + 678 + 395 @@ -73,7 +73,7 @@ - :/icon.png:/icon.png + :/icon-helper.png:/icon-helper.png @@ -136,8 +136,8 @@ 0 0 - 464 - 336 + 462 + 330 @@ -218,8 +218,8 @@ 0 0 - 397 - 256 + 462 + 330 @@ -389,7 +389,7 @@ 0 0 436 - 165 + 173 @@ -576,7 +576,7 @@ 0 0 436 - 43 + 45 @@ -646,7 +646,7 @@ 0 0 277 - 190 + 194 @@ -843,7 +843,7 @@ 0 0 436 - 103 + 107 diff --git a/sources/helper/bash-completions b/sources/helper/bash-completions index 19b06d8..2b12a9d 100644 --- a/sources/helper/bash-completions +++ b/sources/helper/bash-completions @@ -25,6 +25,7 @@ _netctlgui_helper_arglist=( '--nodaemon' '--replace' '--restore' + '--session' '--system' '-v' '--version' diff --git a/sources/helper/netctlgui-helper.1 b/sources/helper/netctlgui-helper.1 index 8052ec8..653dabe 100644 --- a/sources/helper/netctlgui-helper.1 +++ b/sources/helper/netctlgui-helper.1 @@ -23,6 +23,8 @@ do not run as daemon force replace the existing session .IP "--restore" force restore the existing session +.IP "--session" +force create user DBus session .IP "--system" do not read user configuration .IP "-v, --version" diff --git a/sources/helper/netctlgui-helper.service b/sources/helper/netctlgui-helper.service index 454b01b..daa4c0b 100644 --- a/sources/helper/netctlgui-helper.service +++ b/sources/helper/netctlgui-helper.service @@ -1,9 +1,12 @@ [Unit] Description=netctlgui-helper daemon +Documentation=man:netctlgui-helper(1) man:netctl-gui.conf(5) [Service] -Type=forking -ExecStart=/usr/bin/netctlgui-helper --system +Type=dbus +BusName=org.netctlgui.helper +ExecStart=/usr/bin/netctlgui-helper --nodaemon --system +Capabilities=CAP_SETUID [Install] WantedBy=multi-user.target diff --git a/sources/helper/src/CMakeLists.txt b/sources/helper/src/CMakeLists.txt index c5ca85c..41180e6 100644 --- a/sources/helper/src/CMakeLists.txt +++ b/sources/helper/src/CMakeLists.txt @@ -47,14 +47,14 @@ else () set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM}) add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS}) endforeach () - add_custom_target (translations-header COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS}) - add_custom_command (TARGET translations-header COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS}) + add_custom_target (translations-helper COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS}) + add_custom_command (TARGET translations-helper COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS}) endif() add_executable (${SUBPROJECT} ${SOURCES} ${HEADERS} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS}) target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS}) # install properties install (TARGETS ${SUBPROJECT} DESTINATION bin) -if (USE_CAPABILITIES) - install (CODE "exec_program (setcap ARGS \"cap_setuid=ep\" \"$ENV{DESTDIR}/bin/${SUBPROJECT}\")") -endif () +# if (USE_CAPABILITIES) +# install (CODE "exec_program (setcap ARGS \"cap_setuid=ep\" \"$ENV{DESTDIR}/bin/${SUBPROJECT}\")") +# endif () diff --git a/sources/helper/src/main.cpp b/sources/helper/src/main.cpp index ff7c9f2..861b518 100644 --- a/sources/helper/src/main.cpp +++ b/sources/helper/src/main.cpp @@ -68,6 +68,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("--session")) { + // session + args[QString("session")] = true; } else if (QString(argv[i]) == QString("--system")) { // system args[QString("system")] = true; @@ -96,6 +99,7 @@ int main(int argc, char *argv[]) .arg(QString::number(geteuid())).toUtf8().data() << endl; cout << QCoreApplication::translate("NetctlHelper", "See security notes for more details.") .toUtf8().data() << endl; + args[QString("session")] = true; } #if QT_VERSION >= 0x050000 diff --git a/sources/helper/src/messages.cpp b/sources/helper/src/messages.cpp index 8b0b9dc..e56aaf8 100644 --- a/sources/helper/src/messages.cpp +++ b/sources/helper/src/messages.cpp @@ -37,6 +37,7 @@ QMap getArgs() args[QString("config")] = QString(QDir::homePath() + QString("/.config/netctl-gui.conf")); args[QString("debug")] = false; args[QString("nodaemon")] = false; + args[QString("session")] = false; args[QString("state")] = (int) 0; args[QString("system")] = false; args[QString("help")] = false; @@ -65,6 +66,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(" --session - %1\n") + .arg(QCoreApplication::translate("NetctlHelper", "force create user DBus 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:")); diff --git a/sources/helper/src/netctlhelper.cpp b/sources/helper/src/netctlhelper.cpp index eecd3c6..e905815 100644 --- a/sources/helper/src/netctlhelper.cpp +++ b/sources/helper/src/netctlhelper.cpp @@ -35,6 +35,7 @@ NetctlHelper::NetctlHelper(QObject *parent, QMap args) : QObject(parent), configPath(args[QString("config")].toString()), debug(args[QString("debug")].toBool()), + session(args[QString("session")].toBool()), system(args[QString("system")].toBool()) { updateConfiguration(); @@ -88,6 +89,28 @@ void NetctlHelper::createInterface() if (debug) qDebug() << PDEBUG << ":" << bus.lastError().message(); return quitHelper(); } + // session bus + if (!session) return; + QDBusConnection sessionBus = QDBusConnection::sessionBus(); + if (!sessionBus.registerService(DBUS_HELPER_SERVICE)) { + if (debug) qDebug() << PDEBUG << ":" << "Could not register session service"; + if (debug) qDebug() << PDEBUG << ":" << sessionBus.lastError().message(); + return quitHelper(); + } + if (!sessionBus.registerObject(DBUS_LIB_PATH, + new NetctlAdaptor(this, debug, configuration), + QDBusConnection::ExportAllContents)) { + if (debug) qDebug() << PDEBUG << ":" << "Could not register session library object"; + if (debug) qDebug() << PDEBUG << ":" << sessionBus.lastError().message(); + return quitHelper(); + } + if (!sessionBus.registerObject(DBUS_CTRL_PATH, + new ControlAdaptor(this, debug, configuration), + QDBusConnection::ExportAllContents)) { + if (debug) qDebug() << PDEBUG << ":" << "Could not register session control object"; + if (debug) qDebug() << PDEBUG << ":" << sessionBus.lastError().message(); + return quitHelper(); + } } @@ -98,6 +121,11 @@ void NetctlHelper::deleteInterface() QDBusConnection::systemBus().unregisterObject(DBUS_LIB_PATH); QDBusConnection::systemBus().unregisterObject(DBUS_CTRL_PATH); QDBusConnection::systemBus().unregisterService(DBUS_HELPER_SERVICE); + // session bus + if (!session) return; + QDBusConnection::sessionBus().unregisterObject(DBUS_LIB_PATH); + QDBusConnection::sessionBus().unregisterObject(DBUS_CTRL_PATH); + QDBusConnection::sessionBus().unregisterService(DBUS_HELPER_SERVICE); } diff --git a/sources/helper/src/netctlhelper.h b/sources/helper/src/netctlhelper.h index 17af67c..e9dc0ba 100644 --- a/sources/helper/src/netctlhelper.h +++ b/sources/helper/src/netctlhelper.h @@ -41,6 +41,7 @@ private: QString configPath; QMap configuration; bool debug; + bool session; bool system; void createInterface(); void deleteInterface(); diff --git a/sources/helper/zsh-completions b/sources/helper/zsh-completions index f97df91..427ec87 100644 --- a/sources/helper/zsh-completions +++ b/sources/helper/zsh-completions @@ -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]' + {'--session','--session'}'[force create user DBus 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]' diff --git a/sources/resources/icon-helper.png b/sources/resources/icon-helper.png new file mode 100644 index 0000000..3fbfb61 Binary files /dev/null and b/sources/resources/icon-helper.png differ diff --git a/sources/resources/resources.qrc b/sources/resources/resources.qrc index 3b01b52..567331d 100644 --- a/sources/resources/resources.qrc +++ b/sources/resources/resources.qrc @@ -5,6 +5,7 @@ translations/ru.qm icon.png + icon-helper.png wifi.png network-idle-64x64.png network-offline-64x64.png