358.10. kcm-kdos-firewall-1.0.0
System Settings Firewall page — named services through kdos-powerd, and the prompt that offers to let a blocked program in
| Version | 1.0.0, release 1 |
| Source tree | src/desktop/kcm-kdos-firewall/ |
| Phase | 50_desktop (Desktop), 65 of 92 in build order |
| Licence | MIT |
| Homepage | https://github.com/kunaldawn/kdos |
| Build time | 0.1 SBU |
| Installed size | 396.5 KiB in 4 files |
| Recipe | src/desktop/kcm-kdos-firewall/kpkgbuild |
About
kcm-kdos-firewall is the Firewall page of System Settings, under Networking, and the notification that offers to let a blocked program in. Both speak to kdos-powerd over its system-bus face, io.kdos.Power1, and neither knows a port: the page lists the daemon’s named services (ListFirewallServices), holds the switches until Apply, and sends one SetFirewallService(name, open) per changed row, in order, stopping at the first refusal. The interface it relies on is io.kdos.Power1.xml beside the sources. Upstream’s plasma-firewall is not ported: its backends are firewalld and ufw, and it edits rules by port and protocol, which the KDOS firewall refuses by design.
The port is KDOS’s own code with no upstream source. It builds three things with one CMake project against KF6 KCMUtils: the KCM plugin kcm_kdos_firewall, whose page is QML in ui/; the C program /usr/libexec/kdos/kdos-fwask, compiled with libkbase from src/libs and linked to basu only; and that program’s autostart entry.
kdos-fwask asks kdos-powerd every ten seconds how many packets each closed service’s counter has turned away (ListFirewallKnocks). It posts one notification offering Allow and Not on This Network when all three hold:
- a count rose for KDE Connect, krdp, krfb or kiwix-serve;
- the program behind it is running as the session’s user;
- that user has not been asked about it on the current NetworkManager connection.
The answers are kept in $XDG_STATE_HOME/kdos/fwask, one line per network and service.
Both the page and kdos-fwask follow the daemon’s FirewallServicesChanged signal: the page reloads its list when it holds no unapplied change, and kdos-fwask asks for the list again and withdraws a prompt whose service was opened elsewhere while it was up, remembering that as its answer.
Why it is in KDOS
The comment above the 5 ports from kcm-kdos-system to kcm-kdos-health in script/phases/50_desktop/packages.txt:
System Settings pages: the A/B slots, boxes, the firewall's named services, the KDOS look and Phosphor mode, and the Health page.
Sources
None: the port builds from its own directory, /kdos/src/desktop/kcm-kdos-firewall.
Dependencies
Depends on: cmake, ninja, pkgconf, extra-cmake-modules, qt6-qtbase, qt6-qtdeclarative, kcoreaddons, ki18n, kcmutils, kirigami, basu, kdos-powerd.
Required by (1): kde-plasma.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/50_desktop/phase.env && kpkg install kcm-kdos-firewall'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/desktop/kcm-kdos-firewall.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/kcm-kdos-firewall
SRC=$SRC_ROOT/kcm-kdos-firewall-1.0.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
cmake -S "$PORT_SRC" -B build -G Ninja \
-D CMAKE_INSTALL_PREFIX=/usr \
-D KDE_INSTALL_LIBDIR=lib \
-D KDE_INSTALL_LIBEXECDIR=libexec \
-D KDE_INSTALL_AUTOSTARTDIR=/usr/share/kdos/xdg/autostart \
-D CMAKE_BUILD_TYPE=Release \
-D KDE_INSTALL_USE_QT_SYS_PATHS=ON \
-D BUILD_TESTING=OFF \
-Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build
The switches, and why each is set:
-D KDE_INSTALL_LIBEXECDIR=libexec— Putkdos-fwaskin/usr/libexec/kdos, beside the other helpers KDOS’s own ports install there. ECM’s default for this tree’s layout islib/libexec, and the autostart entry names the path the build used.-D KDE_INSTALL_AUTOSTARTDIR=/usr/share/kdos/xdg/autostart— Install the autostart entry among the distribution’s defaults instead of/etc/xdg/autostart./etc/xdgis the administrator’s, and the session finds the entry throughXDG_CONFIG_DIRS, which lists/usr/share/kdos/xdgafter/etc/xdg; an administrator disables it by shadowing the file in/etc/xdg/autostartwithHidden=true.-D BUILD_TESTING=OFF— Build no tests into the package.testing/plasmatest.shconfigures the same sources with tests on and runs them under a private session bus: the page’s logic andkdos-fwaskend to end against fakes ofio.kdos.Power1, polkit, NetworkManager and the notification server, andfwcoretest, whichtesting/selftest.shalso builds on a bare host.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/kcm-kdos-firewall, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf kcm-kdos-firewall-1.0.0-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/kcm-kdos-firewall, and runs the triggers its paths call for.
Other files in the port directory, read by build.sh: CMakeLists.txt, firewallcontroller.cpp, firewallcontroller.h, firewallkcm.cpp, firewalltypes.cpp, firewalltypes.h, fwask/, io.kdos.Power1.xml, kcm_kdos_firewall.json, polkitcheck.cpp, polkitcheck.h, power1client.cpp, power1client.h, servicemodel.cpp, servicemodel.h, tests/, ui/.
Notes
The page goes read-only when polkit, asked without interaction, says no to io.kdos.firewall.set for the page’s own bus connection, which is the question the daemon’s check asks of the same caller. The answer “yes after a password” leaves the switches live, and the daemon’s own check raises the prompt when the change is applied. The KCM sets no authActionName: System Settings would then pre-authorise through KAuth on the same click, and polkit’s agent shows one dialog at a time.
kdos-fwask asks only about services a session program serves. A rising count on http with no web server running is a scan, and asking about it teaches people to click Allow. Allow opens the service on every network, because the firewall is one table for the machine; opening it on one network only would mean closing it again at every change of network, each with a new password prompt. What is remembered per network is the question, so a person who declined at a café is asked again at home.
The counters it reads are kdos-powerd’s: one named counter for each closed row, read as root with nft. A daemon without ListFirewallKnocks answers UnknownMethod; the page then shows no counts and kdos-fwask looks again every five minutes; so does a daemon that could not read the counters, which answers io.kdos.Power1.Error.Failed.
The prompt’s Notify is sent without blocking and waits three minutes for its id, longer than the session bus’s 120-second limit on starting a service. At login the notification server is still being started when the first knock is seen; a call given up before the bus gives up is still delivered when Plasma comes, and a second one posted meanwhile would be a notification whose buttons nobody hears. The service’s slot is held from the call to its reply, so a count still rising posts nothing more; an error reply frees it and the next look asks again.
The notifications carry no desktop-entry hint. Plasma asks KWin for a launch token for that entry on every action, so Not on This Network would show the Firewall page starting in the task manager while nothing opens. They are named Firewall and wear the security-high icon instead, and are not configured under Settings › Notifications as an application of their own.
A signal names its sender’s unique bus name only, and any connection on the system bus may emit one with the daemon’s path and interface. The page’s QtDBus connection follows the owner of io.kdos.Power1, and kdos-fwask asks the bus who owns the name before it acts on the signal, so a forged one can neither reset the page nor silence a prompt.