KDOS keeps six root daemons of its own. Each answers a few fixed questions, on a Unix socket in
/run, on the system bus, or both: open a named service in the firewall, say which application is
spending the battery, kill a runaway program before the desktop freezes, mount application packs,
set the machine’s name, clock and keyboard, and install a system update into the other root slot.
Everything else a desktop asks of root, such as suspending, logging in or mounting a USB stick,
belongs to programs KDOS ports from upstream: elogind, polkit, udisks2 and the rest. This chapter
describes KDOS’s six; kdos-mdnsd, which answers .local names and binds its socket as root but
then runs as nobody; the per-box Wayland socket kdos-boxsock, which sits close to privilege
without being a root daemon; the other services ksvc runs beside them, and the two
login-record services, utmpd and wtmpd.
It is written for two readers:
Why the authorisation is shaped this way, and what it defends against, is argued in The security model. How init starts services is in Boot and init. Every socket path, bus name and verb on the system is listed in Filesystem and IPC.
Each root daemon is one binary in /usr/sbin, started at boot by a script in /etc/init.d and
kept running by ksvc, the service supervisor in kdos-tools. None of them ships a D-Bus
activation file: a bus name is taken by the supervised daemon or by nobody.
| Daemon | Socket | System bus | Command-line client | Other clients | Init script | Skipped at boot when |
|---|---|---|---|---|---|---|
kdos-settingsd |
— | org.freedesktop.hostname1, org.freedesktop.timedate1, org.freedesktop.locale1 |
kdos timezone, kdos hostname, kdos locale, kdos keymap |
System Settings’ Date & Time page, plasma-setup, the login screen’s KWin (kwin_wayland --locale1), startplasma, System Monitor’s OS sensors |
43_settingsd.sh |
The binary is missing |
kdos-sysupdated |
— | org.freedesktop.sysupdate1, io.kdos.Slots1 |
kdos update, kdos-bootctl (which it runs) |
Discover, the System Versions page, kdos-notice |
46_sysupdated.sh |
The binary is missing |
kdos-powerd |
/run/kdos-powerd.sock |
io.kdos.Power1 |
kdos-power |
The Firewall settings page, kdos-fwask and kded-kdos (over the bus), kdos theme, kdos phosphor, kdos doctor |
55_powerd.sh |
The binary is missing |
kdos-energyd |
/run/kdos-energyd.sock |
— | kdos-energy |
System Monitor’s KDOS sensors (ksystemstats-kdos), kdos doctor |
56_energyd.sh |
The binary is missing, or no /sys/class/powercap/*/energy_uj is readable |
kdos-oomd |
/run/kdos-oomd.sock |
— | — | kdos doctor, kdos-notice |
57_oomd.sh |
The binary is missing, or /proc/pressure/memory is not writable (the kernel has PSI off) |
kdos-packd |
/run/kdos-packd.sock |
— | — | kdos-appbox (and kdos app, which runs it), Discover’s KDOS backend, kdos doctor |
59_packd.sh |
The binary is missing, or erofs is absent from /proc/filesystems even after modprobe erofs |
kdos-mdnsd |
UDP 127.0.0.1:5380, as nobody |
— | — | NetworkManager’s dnsmasq, for every .local lookup |
45_mdns.sh |
The binary or avahi-daemon is missing, or avahi is disabled |
kdos-powerd and kdos-energyd are each one binary with two names. Run under the daemon’s name
it serves the socket; run under the client’s name (kdos-power, kdos-energy) it sends one
request and prints the answer.
The service command (a second name for ksvc) takes the verb first and then the service
name, which is the init script’s name without its two-digit prefix and .sh suffix:
service status powerd
service restart settingsd
service stop packd
service start energyd
service list # every service, whether it starts at boot, and its state
service disable oomd # do not start it at boot
rcS and rcK are the boot and shutdown scripts in /etc/init.d that run every numbered service
script in order (see Boot and init). disable creates
/etc/service.disabled/<name>, which both skip; enable removes it. A name that matches no
script exactly is matched as a substring, so service status pack also reaches 59_packd.sh.
The daemon’s full name (kdos-powerd) matches nothing: it contains the service name rather than
the other way round.
The substring match finds the script for status, start, stop and restart only. enable and
disable check that some script matches, then write or remove the marker under the name exactly
as typed, while rcS and rcK look for the marker under the script’s own service name. They
therefore need the exact service name: service disable pack reports success, creates
/etc/service.disabled/pack, and disables nothing.
Two kinds of gate stand in front of these daemons. A socket asks the kernel who the caller is and
admits root and the wheel group, the administrators; a bus method asks polkit about the caller
and follows the action’s defaults and whatever /etc/polkit-1/rules.d says. The person at the
machine is the active local session, as elogind reports it.
| Daemon | root | wheel |
The active local session | Anyone else |
|---|---|---|---|---|
kdos-settingsd |
Every method, without asking polkit | polkit’s answer | Time zone and network time without a password (the Date & Time page asks for one anyway, see Checking, then asking, then writing); the clock, locale, keyboard and names after an administrator’s password | Refused |
kdos-sysupdated |
Every method, without asking polkit | polkit’s answer | Checking and Bless without a password; installing, trying a slot and changing the channel after an administrator’s password |
Refused |
kdos-powerd, socket |
Every verb | Every verb | ping, firewall list, firewall knocks, and accent and splash when polkit grants them without a prompt |
ping, firewall list and firewall knocks |
kdos-powerd, bus |
Every method | polkit’s answer | The accent and the splash without a password; the firewall after an administrator’s password | The reads only |
kdos-energyd |
Every verb | Every verb | Refused | Refused |
kdos-oomd |
Every verb | Every verb | Every verb | Refused |
kdos-packd |
Every verb | Every verb | Refused | Refused |
The non-administrator column of a socket is never a group: kdos-oomd asks elogind whether the
caller has the active session on a seat, and kdos-powerd asks polkit. A login elogind does not
count as active, such as an ssh session, gets the administrators’ answer or nothing. Each daemon’s
--explain <user> says which row a user falls in.
Every root daemon here is built the same way. Knowing the pattern once tells you how to run, diagnose and review all six.
A daemon runs in the foreground and never forks into the background. The init script calls
supervise <name> <binary> from /etc/init.d/service_helper; the supervisor leads its own process
group, writes /run/kdos-svc.<full name>.pid, and restarts the daemon five seconds after it exits.
service stop <name> sends SIGTERM to the whole group, waits for it to empty, checking every 50
ms, and sends SIGKILL to whatever is left when the stop grace runs out. The grace is five seconds
unless the init script passed supervise --stop-grace <seconds>; none of these six daemons does.
supervise on a name whose supervisor is alive starts nothing and says [SKIP], so a second
service start cannot leave a daemon nothing stops. A SIGTERM sent to the supervisor alone is
passed on to its group, so the daemon goes with it. A daemon whose supervisor was killed outright is
still found through the state file: service status reports it as [FAIL] rather than [DOWN],
service start refuses to start a second beside it, and service stop ends it.
The daemon’s output goes to syslog and to a small file in /run. The supervisor points the
daemon’s standard output and error, and its own Starting and Exited lines, at a forwarder
process. Each line becomes a daemon-facility syslog message tagged with the daemon’s full name
(supervise --facility <name> picks another facility; none of these six daemons uses it), and
is also appended to /run/kdos-svc.<full name>.log: for example /run/kdos-svc.kdos-powerd.log,
tagged kdos-powerd. Files and tags use the full name; only the service command takes the short
one. The file holds at most 64 KiB; when it would grow past that it is renamed to
/run/kdos-svc.<full name>.log.old and a fresh one starts. The file is what you read before
syslogd is up or while it restarts.
The daemon never keeps the descriptors it inherited. Under rcS those point at the boot step’s
capture file on the /run tmpfs, so a daemon that crash-looped would fill memory until the next
reboot, and a daemon that logs only to standard error would never reach /var/log/messages. The
forwarder ignores the SIGTERM that service stop sends the group and exits only when the daemon’s
end of the pipe closes, so what a daemon prints while shutting down is kept and it never writes
into a pipe with no reader.
The init script checks the machine first and skips with a reason. A daemon that cannot do its job
on this machine (no energy counter, no PSI, no EROFS) is skipped and prints
[SKIP] <name>: <reason> at boot, because a daemon that refuses to start under a respawn loop is
restarted every five seconds for as long as the machine is up. A refusal the script cannot see
(kdos-energyd finding no usable energy domain after the script’s glob matched) is restarted
every five seconds, and service status reports it as [FAIL] with its exit status rather than
[ OK ] (see ksvc and service).
The two bus-only daemons use two more supervise options:
--restart-with dbus restarts the daemon whenever the system bus’s own service is restarted or
stopped, and holds each start while the bus is between two runs. A daemon left holding names on
a bus that has gone answers nobody.--final-exit 3 stops the respawn when the daemon exits 3, which kdos-settingsd and
kdos-sysupdated do when another process already owns one of their names. Restarting cannot
change that.An init script whose daemon owns a bus name calls wait_bus_name <name> after supervise, which
holds the boot for up to ten seconds until the name has an owner, so the scripts after it find the
name taken. kdos-powerd’s script waits for io.kdos.Power1 only when a system bus is running:
its socket answers whether or not the bus is up, and it retries the bus itself.
The four daemons with a socket each own one in /run, named after the daemon, and remove a stale
one before binding so that a socket file left by a crash cannot hold the name.
The listening socket and every accepted connection are close-on-exec (SOCK_CLOEXEC on the
socket() and on accept4()), so no program a daemon runs inherits a client’s connection. A
program that kept one open would hold it past the reply: kdos-powerd’s firewall ssh on starts
sshd under its supervisor, and a client whose connection a running program still holds never
reads the end of its answer.
The socket is mode 0666, and anyone may connect; the real check is the caller’s identity. The
daemon asks the kernel for the connecting process’s credentials (SO_PEERCRED, which the caller
cannot forge) and answers err not permitted to anyone it does not admit. The file mode is left
open on purpose: a mode that looked like the authorisation is a mode somebody eventually loosens.
There is one implementation of the group check, kb_uid_allowed() in libkbase. It admits uid 0
outright; otherwise it looks the uid up in the password database and reads /etc/group, and admits
the account when the group’s id is its primary group or its name is in the group’s member list.
Membership is therefore read at the moment of the request, not from the caller’s process
credentials, and a group change applies to the next request without a new login. No daemon keeps
its own copy of the rule: a copy per daemon is a rule that gets tightened on one socket and stays
loose on the others. A daemon that admits more than root and wheel states the difference beside
its own call, as kdos-oomd and kdos-powerd do.
The client never names a path. Every verb takes an identifier from a list the daemon itself published: a firewall service name, an accent, a pack id.
The client connects, writes one short line, reads the answer and the connection closes. There is no session state.
Each daemon serves one request at a time. kdos-powerd, kdos-energyd and kdos-oomd give a
connection two seconds to send its request, because the same loop drives kdos-powerd’s bus face,
kdos-energyd’s sampler and kdos-oomd’s pressure trigger, and a client that connected and said
nothing would otherwise stop them. kdos-packd sets no such limit, so a connection that never
speaks delays every later request until it closes.
The two bus daemons never block on polkit. An interactive check lasts as long as somebody takes to type a password, so the question goes out asynchronously and the method call is answered when polkit is; the bus keeps answering other callers meanwhile.
kdos-energyd, kdos-oomd and kdos-packd each have a fixture mode: the daemon can be pointed
at a recorded copy of the system state and made to print what it would do without doing it. This
is how the selection logic, which decides what gets measured, mounted or killed, is tested without
a machine to lose. kdos-powerd has none; its --explain, --firewall, --accent, --splash and
--file-sharing flags run the same rules against a scratch /etc instead (see
Diagnosis and testing). kdos-settingsd reads a scratch tree from
environment variables, and kdos-sysupdated serves a test bus over a fixture root; each is
described in its own section.
Each socket daemon reads another socket path from an environment variable (KDOS_POWERD_SOCKET,
KDOS_ENERGYD_SOCKET, KDOS_OOMD_SOCKET, KDOS_PACKD_SOCKET) so the test suite can run it
unprivileged. Moving the socket grants nothing: the check is the caller’s identity, never the
path. kdos-powerd, kdos-oomd and kdos-packd refuse to start on their real socket unless they
are root, because an unprivileged daemon would answer ok to work it cannot do. kdos-energyd has
no such check; it refuses to start when it cannot read the energy counter, which without root it
cannot.
A socket address holds at most 107 bytes of path. kdos-packd refuses to start on a longer path,
because truncating would bind a socket at a path nobody asked for, and the next start would fail
with “address already in use” for a file that appears not to exist. kdos-powerd, kdos-energyd
and kdos-oomd cut an over-long path to fit and bind at the shortened one.
The few root-owned settings a desktop that is not root still changes: which named services the
firewall lets in, the accent that everything drawn before a login wears (the boot menu, the
splash, the text console and the login screen), and the splash’s motion. It offers the same verbs
twice: a socket for the kdos command, and io.kdos.Power1 on the system bus for System Settings.
The bus face alone also starts Samba once an account can share folders; see
Starting Samba for a shared folder.
Suspend, power-off and reboot are not this daemon’s. They belong to elogind, which Plasma’s Leave
menu, PowerDevil and the lid switch all reach through org.freedesktop.login1; see
What happens around a suspend.
| Verb | Who, over the socket | Does |
|---|---|---|
ping |
Anyone | Answers ok |
firewall list |
Anyone | One row per named service: name, on or off, and what the service is for (the For column below, in the daemon’s words), tab-separated, then ok |
firewall knocks |
Anyone | One row per named service: name and the number of packets turned away while it was closed, or -1 where nothing was counted, then ok |
firewall <service> on\|off |
root, wheel, or polkit’s io.kdos.firewall.set without a prompt |
Open or close one named service |
accent <scheme> |
root, wheel, or polkit’s io.kdos.accent.set without a prompt |
Recolour the boot menu, the splash, the text console and the login screen |
splash phosphor\|modern |
The same as accent |
Choose the boot splash’s motion |
The three reads answer anybody: a liveness check, a file every user can read, and counts of packets that were dropped. Every refusal is written to the daemon’s log with the caller’s uid and the action polkit did not grant, so a setting that did not change can be attributed.
kdos-power suspend|poweroff|reboot
kdos-power ping
kdos-power firewall list|knocks|<service> on|off
kdos-power accent <scheme>
kdos-power splash phosphor|modern
suspend, poweroff and reboot never reach the daemon. The client replaces itself with
loginctl suspend, loginctl poweroff or loginctl reboot, run as the caller, so elogind sees
the caller, polkit answers about the caller’s session, and the screen locker’s sleep inhibitor
gets its lock in before the machine goes down: the same path the Leave menu takes. When loginctl
cannot be run the client says that elogind owns these and exits 1.
Every other verb is one request line of at most 63 bytes, newline included; the daemon reads nothing past that.
| Exit status | Means |
|---|---|
| 0 | The daemon answered ok |
| 1 | The daemon answered err …, closed without answering, or is not running (kdos-power: no kdos-powerd — `service start powerd`) |
| 2 | Bad usage, or an argument too long for the request line |
When the daemon is not running, start it with the command the client prints, service start
powerd (see Starting and stopping one by hand).
firewall prints the daemon’s whole reply on standard output, the err line included, so a caller
capturing the table reads all of it. For accent and splash an error is printed to standard error
as kdos-power: <reply>, and a success that left something unchanged prints the daemon’s note the
same way, such as kdos-power: (boot menu unchanged).
The bus face, at /io/kdos/Power1 on interface io.kdos.Power1, is what the Firewall settings
page and kdos-fwask call. Root owns the name; anybody may call it, and polkit decides who may
change anything.
| Member | Kind | Does |
|---|---|---|
ListFirewallServices() → a(sbs) |
Method | Each named service: name, whether it is open, what it is for |
ListFirewallKnocks() → a(st) |
Method | Each closed service and the packets turned away |
SetFirewallService(s name, b open) |
Method | polkit io.kdos.firewall.set |
SetAccent(s scheme) |
Method | polkit io.kdos.accent.set |
SetSplash(s motion) |
Method | polkit io.kdos.accent.set |
StartFileSharing() |
Method | polkit io.kdos.filesharing.start; runs /etc/init.d/83_samba.sh start |
Accent (s) |
Property, emits change | The scheme /etc/kdos/accent names |
Accents (as) |
Property, constant | Every scheme this build knows |
FirewallServicesChanged() |
Signal | After any firewall change, from either face |
| Action | Active local session | Inactive | Any other |
|---|---|---|---|
io.kdos.firewall.set |
auth_admin_keep |
no |
no |
io.kdos.accent.set |
yes |
no |
no |
io.kdos.filesharing.start |
yes |
no |
no |
The subject polkit is asked about is the caller’s bus name, which polkitd resolves to a process
and a session itself, so nothing the caller says about who it is takes part. A caller that did not
allow a prompt is not prompted: a challenge it could have answered comes back as the standard
InteractiveAuthorizationRequired error rather than AccessDenied. A bad name answers
io.kdos.Power1.Error.NoSuchService, NoSuchAccent or NoSuchMotion.
The socket comes up before the bus and does not wait for it. A system bus that cannot be reached is
retried every five seconds from the daemon’s loop while the socket answers, so the kdos command
reaches the firewall on a machine whose bus is down.
smbd does not run until some account can share. At boot, Samba’s service script
/etc/init.d/83_samba.sh makes /var/lib/samba/usershares (root’s, group sambashare, mode
1770) and starts smbd only when the sambashare group has a member in /etc/group, that
directory holds a usershare, or /etc/samba/smb.conf defines a share below [global]; otherwise
it prints [SKIP] samba: no account shares folders. smbd has to be running before the first
share can be made: a folder shared from Dolphin’s Share tab is a file net usershare add writes
into the directory as the user, and net first turns every name in the share’s ACL, Dolphin’s
Everyone among them, into a SID by asking the local smbd. With smbd down it fails with
“cannot convert name … to a SID” and writes nothing.
The Share tab adds its user to sambashare, which counts from that user’s next login, and that
login can come before the next boot. So the session’s kded-kdos module calls
StartFileSharing() once when it loads in a session whose credentials can write into the
usershare directory, which only a member’s can. The method takes no argument, so a caller names
nothing: after polkit’s io.kdos.filesharing.start, which the person at the machine is granted,
the daemon runs /etc/init.d/83_samba.sh start as an argument vector, and the script decides again.
That is all the next boot would do, which is why the action needs no password. The call is refused
with io.kdos.Power1.Error.Failed while /etc/service.disabled/samba exists, the boot’s own marker
for a service an administrator turned off, or when Samba is not installed. A service already
supervised is not started twice, so the call at every later login costs one script run. Nothing
stops smbd again: leaving the group or removing the last share leaves it serving nothing until
the next boot, which then does not start it.
Samba’s lock directory is /var/lib/samba/lock, which the package carries, root’s and mode 0755.
smbd refuses to start when the msg.lock directory inside it belongs to anybody but root, and
any Samba client run first, net usershare among them, makes the lock directory as the user when
it can; in a directory only root can write to, a client makes nothing and still works.
elogind runs a suspend; this daemon takes no part in it. What runs, in order:
kdos-power suspend, the Leave menu, PowerDevil, or the lid, which
/etc/elogind/logind.conf.d/50-kdos.conf sets to suspend unless the machine is docked) calls
login1’s Suspend, and polkit answers for the caller’s session.PrepareForSleep(true) and waits up to five seconds (InhibitDelayMaxSec=5) for
the delay inhibitors to let go. kscreenlocker locks the session there, and NetworkManager, built
with -Dsuspend_resume=elogind, takes its devices down./usr/lib/elogind/system-sleep run, TLP’s 49-tlp-sleep among them, which saves
the radio states and applies TLP’s suspend settings./etc/elogind/sleep.conf.d/50-kdos.conf turns hibernation and the
hybrid modes off, because swap on KDOS is zram, which holds nothing across a power-off.post, and PrepareForSleep(false) brings NetworkManager
back.The power key powers off (HandlePowerKey=poweroff), which is init’s ordinary shutdown through
rcK (see Boot and init).
accent <scheme> takes one of the eight scheme names compiled into libkcolor: phosphor,
amber, ice, bone, norton, borland, perfect or paper. The name is matched by
kcol_find(); anything else is refused with err not an accent. There is no path to aim and
nothing to traverse, which is why this verb is safe to reach from a session.
It writes only root-owned files and the login screen’s own:
/etc/kdos/accent, which rcS reads to recolour the boot splash that is already running, and
which the bus face’s Accent property reports;limine.conf on the EFI system partition, the ESP) and the text-console palette
(/etc/vtrgb), by running kdos-bootctl theme <scheme>, which owns both files. kdos-bootctl is
found through the daemon’s inherited PATH; every other program the daemon runs is named by
absolute path;sddm account and takes its look from that
account’s ~/.config/kdeglobals, plasmarc and kcminputrc and the picture
~/kdos-background.png. One set per accent is built into /usr/share/kdos/greeter/<accent>/, a
light accent’s carrying its dark partner because the greeter never follows day and night, and
the daemon copies the accent’s set into the sddm home. The copy runs in a child with the
sddm account’s uid and gid and no other group, so a link the account left in place of a file
is never followed as root. A set missing a file leaves the greeter as it was, and each file is
replaced by a rename.It recolours nothing inside a session. That is kdos theme’s job, which runs as the user and
touches only the user’s own files; kdos theme calls this verb for the parts that need root.
A machine with no writable ESP, or no greeter, is not a failure. The live medium is read-only, and
a machine may have no /boot/efi at all. When a part cannot be written the verb still succeeds and
names what stayed as it was: ok <scheme> (boot menu unchanged), (login screen unchanged) or
(boot menu and login screen unchanged). Refusing would make kdos theme look broken on the ISO,
where everything else recolours correctly.
splash phosphor|modern sets the boot splash’s motion: a CRT power-on with Phosphor mode, a flat
mark without it. The splash runs in the initramfs before any root filesystem is mounted, so the
kernel command line is the one thing it can read; the verb runs kdos-bootctl splash <motion>,
which writes kdos.splash=<motion> on every KDOS entry in limine.conf. Any other word is refused
with err not a splash motion (phosphor or modern). On a machine whose boot menu cannot be written
the answer is ok <motion> (boot menu unchanged), for the accent’s reason. kdos phosphor on and
off send it.
firewall names services, never ports, and the table of what each name means belongs to the
daemon. A client that could name a port could open any port; a client that can only name ssh
opens exactly what the daemon’s table says ssh is. The Firewall settings page asks for the list
rather than carrying its own copy.
The For column is the sentence the Firewall page shows under each name and firewall list
prints; the Served by column names the service script or program behind it, which the page does
not show.
| Service | Opens | For | Served by |
|---|---|---|---|
ssh |
TCP 22 | Logging in to this computer over SSH | 70_sshd.sh. Turning it on also removes /etc/service.disabled/sshd and starts sshd; turning it off puts the marker back and stops sshd |
http |
TCP 80 | A web server on this computer | Any |
https |
TCP 443 | A web server on this computer, over HTTPS | Any |
ipp |
TCP 631 | Sharing a printer with other computers | CUPS |
smb |
TCP 445 | Sharing files with Windows and other computers (SMB) | 83_samba.sh |
kiwix |
TCP 8080 | Offline content served by Kiwix | kiwix-serve, on its default port |
mqtt |
TCP 1883, 8883 | An MQTT broker for devices on the network (Mosquitto) | 73_mosquitto.sh |
xmpp |
TCP 5222 | A chat server for XMPP clients (Prosody) | 74_prosody.sh |
nfs |
TCP 2049 | Sharing files with other computers over NFS | 72_nfsd.sh (NFSv4) |
babel |
UDP 6696 | Mesh routing with Babel | 31_babeld.sh |
nut |
TCP 3493 | Telling other computers how the UPS is doing (NUT) | 56_nut.sh |
snmp |
UDP 161 | Answering SNMP queries about this computer | 71_snmpd.sh |
mumble |
TCP 64738, UDP 64738 | A Mumble voice chat server | 75_mumble-server.sh |
caldav |
TCP 5232 | Shared calendars and contacts (Radicale) | 77_radicale.sh |
mail |
TCP 25, 143, 465, 587, 993 | A mail server for the network (Maddy) | 78_maddy.sh |
irc |
TCP 6667, 6697 | An IRC chat server | 79_ngircd.sh |
dlna |
TCP 8200, UDP 1900 | Sharing media with TVs and players (DLNA) | 84_minidlna.sh |
tryton |
TCP 8000 | GNU Health for Tryton clients | 85_gnuhealth.sh |
caddy |
TCP 8443 | The Caddy web server’s HTTPS site | Caddy, the listener of the shipped /etc/caddy/Caddyfile |
mosh |
UDP 60000–61000 | Mosh sessions to this computer (needs SSH too) | mosh-server, after an SSH login, so ssh must be on as well |
syncthing |
TCP 22000, UDP 22000, UDP 21027 | Syncing folders with Syncthing | Syncthing: sync, and local discovery |
kdeconnect |
TCP 1714–1764, UDP 1714–1764 | KDE Connect with a phone on the network | kdeconnectd in a session |
vnc |
TCP 5900 | Sharing this desktop over VNC (Krfb) | krfb, on its default port, while sharing is on in a session |
rdp |
TCP 3389 | Sharing this desktop over RDP (KRdp) | krdp, on its default port, while sharing is on in a session |
xonotic |
UDP 26000 | Hosting a Xonotic game for the network | A Xonotic server |
A port moved in krfb’s or krdp’s own settings stays shut until a hand-written rule beside the daemon’s file opens it.
A closed service is counted. In the daemon’s file an open service is its rule; a closed one is
the same match, for a packet from another machine (fib saddr type != local), counting into a
named counter, kdos_knock_<service>, after which the packets meet the chain’s policy and are
dropped. A packet this machine sent itself is not counted: its own broadcasts — KDE Connect’s
identity packet, Syncthing’s discovery, SSDP — loop back in on the network interface, and counted
they would be a knock with nobody knocking. firewall knocks and ListFirewallKnocks read those counters
with nft list counters, which is how the Firewall page and kdos-fwask can say that a phone or an
RDP client was turned away and offer to let it in by name. A reload rebuilds the table, so every
change starts every counter from zero; a counter the kernel does not hold reads -1, which is not
the same as nothing having knocked.
How a change is applied:
/etc/nftables.d/50-kdos-services.nft.input chain of
the inet filter table. It never merges, because merging means parsing nftables syntax, and a
parser that got it wrong would leave a port open that the settings page showed as closed.
Anything you write by hand belongs in another file under /etc/nftables.d, which the daemon
never reads or touches. The new file is renamed into place before anything checks it, because
the check reads it through /etc/nftables.conf’s include. The daemon reads the current file
first so that it can put it back; a file that exists but cannot be read refuses the toggle with
err cannot read the current rules.nft --check -f /etc/nftables.conf. If the ruleset would not load, the previous
50-kdos-services.nft is put back, or removed if there was none, and the answer is
err the ruleset would not load; nothing changed. The kernel keeps the previous rules, and
firewall list and the next boot see the previous state too.nft -f /etc/nftables.conf. That file deletes and rebuilds only its own inet filter
table, so the NAT that netavark (the container network backend) sets up for rootful containers
and NetworkManager’s for a hotspot survive a toggle. If the load itself fails, the previous file
is put back the same way and the answer is err the ruleset did not apply.A successful toggle answers ok <service> on|off and emits FirewallServicesChanged. An unknown
name answers err no service called that; a state other than on or off answers
err a service is on or off.
kdos-powerd --explain <user>
kdos-powerd --firewall list|knocks
kdos-powerd --firewall <service> <on|off>
kdos-powerd --accent <scheme>
kdos-powerd --splash phosphor|modern
kdos-powerd --file-sharing
--explain answers “would this user be allowed, and why”. It is the first thing to run when a
settings change is refused, because a refusal otherwise shows up only in the daemon’s log. It asks
libkbase the same question the socket asks, needs no privilege, and prints one line, for example:
alice: uid 1001, primary gid 1001, not in wheel — permitted ping, the firewall list and its knocks; `firewall` only where polkit grants io.kdos.firewall.set and `accent` and `splash` only where it grants io.kdos.accent.set, each without a prompt (the shipped policy: the accent and the splash from an active session at the machine), otherwise refused
polkit’s half is named and not asked: polkit answers about a process, and there is no process to ask it about. It exits 0 when the group rule admits the three changes and 1 otherwise.
The other flags run a verb’s own rules without the socket, which is the only way to test them: the
socket’s check needs two different users to exercise. They grant nothing, because the binary is
writing to an /etc the person running it could already write to. KDOS_POWERD_ETC replaces
/etc, and a daemon pointed at another /etc leaves the kernel’s ruleset, sshd, Samba, the boot menu
and the login screen alone: KDOS_POWERD_NFT, KDOS_POWERD_BOOTCTL and KDOS_POWERD_SAMBA name
stand-ins for nft, kdos-bootctl and Samba’s service script (unset, nothing is run), and KDOS_POWERD_GREETER and
KDOS_POWERD_SDDM_HOME name the greeter sets and a home to copy them into. KDOS_POWERD_SOCKET
moves the socket.
Per-application energy attribution: which application is using the processor’s power.
Measuring the processor’s energy is routine: the kernel exposes the counter under
/sys/class/powercap. Attribution is the hard part on an ordinary Linux desktop: an application is
dozens of processes in scattered groups, and nothing owns enough of the system to name them. On
KDOS every boxed application (one running in its own box, a rootless
container) runs under a known name, listed in /usr/share/kdos/alien-apps, so the attribution
starts from an identity rather than a guess.
| Verb | Answers |
|---|---|
ping |
ok |
report |
The text report |
report-json |
The same report as one JSON object |
kdos-energy [--json|ping]
kdos-energy prints the report (or JSON with --json) and exits 0. It exits 1 when the daemon is
not running or answered err, and 2 on bad usage. An err answer goes to standard error. System
Monitor’s KDOS sensors (ksystemstats-kdos) read report-json; each row there carries the display
name, and beside it app and box (null for a process in no box), so a reader that groups by
box never parses the display string. When the daemon is not running the client suggests
service start energyd (see Starting and stopping one by hand).
This is the report the test fixture in testing/fixtures/energy produces (thirty seconds of
recorded samples) when replayed with the fixture’s own application table, as the test suite runs
it:
KDOS_ALIEN_APPS=testing/fixtures/energy/alien-apps \
kdos-energyd --fixture testing/fixtures/energy
Without that table the host’s /usr/share/kdos/alien-apps names the processes instead, and the
rows differ. Its rows, with the 20-cell bar each prints between the share and the gpu column
left out here:
KDOS energy — 30 s of samples, RAPL package-0
firefox-esr (appbox kdos-apps) 75.5% gpu 75.0%
kwin_wayland 15.4% gpu 25.0%
gimp (appbox kdos-apps) 0.4% gpu 0.0%
short-lived and exited processes 8.7%
and the notes it prints under them, one line each:
shares are of ATTRIBUTABLE energy — 57% of the package total; the rest is the idle flooridle floor 15.00 W, the lowest average power seen in 3 samples (still falling — early shares
read low)an uncore domain is present, so the integrated GPU's energy is already countedthe gpu column is engine TIME from drm fdinfo, never energyrelative only. RAPL cannot see the panel, the radio or the disk, so there are no watt-hours
here.Answers go to root and wheel only: on a multi-user machine this list is what everyone else is
running.
Figures are shares, never watt-hours. The counter (Intel RAPL, read from
/sys/class/powercap) measures the processor package. It cannot see the screen, which is the
largest single draw on a laptop, nor the radio, the storage or a discrete graphics card. “This
application was 41% of attributable CPU energy today” is a measurement; “this application used 12%
of your battery” would be a guess presented as a unit.
The daemon samples every ten seconds. The interval is fixed and not configurable, for the reason given below, and it is short enough to stay far inside the counter’s wrap period. Seven rules each change the answer:
psys domain goes the other way: it contains the packages, so where it exists it
replaces them.max_energy_range_uj and corrects a single wrap per window.CLOCK_BOOTTIME and
CLOCK_MONOTONIC moved across each window; a difference over one second means a suspend inside
it. The counter after a resume runs from wherever the firmware left it, so the delta across one is
a wrap that never happened or a reset read as one. Such windows are counted and left out, and the
report says how many (suspended_windows in the JSON).uncore domain exists); on a discrete card it is outside the counter entirely, and
the report says that instead. A driver that publishes no per-client statistics gets no column
rather than a column of zeroes.A process’s box is found by walking its parents to the container supervisor that started it, not from its cgroup: a box started where rootless podman could write no cgroup of its own sits in its parent’s, and an elogind session’s delegated subtree is named for the session, not the box.
Why a daemon rather than a one-shot command. The counter runs freely, so a one-shot command could only report what happened while it was watching. The counter is also readable only by root since Linux 5.10, because the PLATYPUS side-channel attack showed that fine-grained unprivileged reads can recover cryptographic keys. What leaves this daemon is a per-application percentage over minutes; the raw counter and the sampling interval are never republished, and no client can ask for a shorter interval. There is no write path into the power interface at all.
The init script skips the daemon when no /sys/class/powercap/*/energy_uj is readable, which covers
most virtual machines and every non-x86 processor. The daemon itself also refuses to start there,
naming the powercap path in its log, because a daemon sampling an unreadable counter would report a
machine that uses no energy, which reads as “nothing is draining the battery”. kdos doctor tells
the two cases apart: a machine with no energy domain at all, and a daemon that is not running.
kdos-energyd --fixture <dir> [--json] replays recorded snapshots (<dir>/0, <dir>/1, … each
holding a proc tree, a powercap tree, an optional dt in seconds and an optional slept, the
seconds the machine was suspended inside that step’s window) through the same sampler and report,
and prints the result. KDOS_ENERGY_PROC and KDOS_ENERGY_POWERCAP point the reader at other
/proc and powercap trees, and KDOS_ALIEN_APPS at another application-name table.
Kills the process that is starving the machine of memory, before the desktop freezes.
The kernel has its own out-of-memory killer, but it fires when an allocation fails. On a machine
with swap that is often minutes after the desktop stopped responding, the whole session spent
thrashing while the kernel still had pages to hand out. The kernel’s pressure interface (PSI, in
/proc/pressure/memory) reports instead that the machine is stalling on memory, which is what a
frozen desktop feels like. Boxed applications make this likely: a browser and a 3D slicer on one
modest machine.
It waits on the kernel; it does not poll. It writes the trigger full 150000 1000000 into the
pressure file (150 ms of full stall within a one-second window, meaning every runnable thread was
stuck on memory for 15% of the last second) and sleeps until the kernel signals it. A sampling
loop would itself compete for processor time with the stall it is trying to notice.
A stall kills only when memory is short. When the trigger fires the daemon reads
/proc/meminfo and kills nothing unless MemAvailable is at most 10% of MemTotal, or at most
25% when swap is exhausted (SwapFree at most 2% of a non-zero SwapTotal). A machine with no
swap keeps the 10% line alone, and a /proc/meminfo that cannot be read leaves the stall as the
only test.
The stall alone is not enough because a single busy process stalls every task that wants to run
while it waits on reclaim itself. A copy streaming gigabytes through the page cache, such as the
installer’s rsync, fires the trigger with most of memory available and nothing else asking for
any; killing it would free nothing anyone was short of. A process pushing the working set out is
the case that also takes MemAvailable down.
The line rises to 25% once swap is full because the 10% line is then never reached. No anonymous
page can leave memory, reclaim drops the live system’s own program files and reads them straight
back from the squashfs, and MemAvailable, which counts those files as reclaimable, stays near a
fifth of MemTotal while every task stalls. The line is raised rather than dropped: pages swapped
out once stay in zram after memory frees up, so a copy on a machine whose swap filled earlier,
with most of memory available, is still the busy-process case.
A process can be protected by its oom_score_adj. A process whose
/proc/<pid>/oom_score_adj is -500 or lower is never a victim; -1000 is the kernel’s “never
kill” and -500 is the threshold other user-space killers honour. Only root can lower the value,
and a child inherits it, so a root program shields everything it will start by lowering its own
first (choom -n -1000 -p $$ in a shell). This is the contract a program uses to keep work it
must finish out of reach; no program outside the desktop is protected by name.
The desktop is never a victim. Protected are process 1, kernel threads, the daemon itself, every
process whose name starts with pipewire, and these by process name: kwin_wayland,
kwin_wayland_wr, plasmashell, ksmserver, kded6, plasma_session, kglobalacceld,
kscreenlocker_g, Xwayland, xdg-desktop-por, polkit-kde-auth, ksecretd, sddm,
sddm-helper, sddm-greeter-qt, elogind, turnstiled, dbus-daemon, ksvc, kdos-powerd,
kdos-energyd, kdos-oomd, kdos-settingsd, accounts-daemon and wireplumber. Killing the
compositor to save the desktop is not a trade, and killing the audio session manager leaves a
machine whose sound stopped for no visible reason.
Every name in that list is a process name as the kernel keeps it, which is at most 15 bytes. The
kernel cuts the executable’s name there, so kwin_wayland_wrapper is kwin_wayland_wr,
kscreenlocker_greet is kscreenlocker_g, sddm-greeter-qt6 is sddm-greeter-qt and
polkit-kde-authentication-agent-1 is polkit-kde-auth. A name spelled in full would match
nothing, and the process it was meant to spare would be the first one chosen.
xdg-desktop-por is every portal at once, the front end and the KDE back end. The greeter’s
names run only before a login and the lock screen’s only while the screen is locked; protecting a
name that is not running costs nothing.
A box over its declared memory budget goes first. A box profile’s memory key is passed to
the container, and the kernel enforces it only when the box’s cgroup sits in an elogind session’s
delegated subtree; a box started anywhere else has the limit accepted and ignored. This rule is
what makes the key mean something there too (see
Memory and grants). The daemon adds up the resident
memory of each box’s processes, and when a box is over its budget the largest process in that box
is the victim. Budgets come from each user’s own box profiles,
/home/<user>/.config/kdos/boxes/<box>.conf; KDOS_BOX_PROFILES, when set, replaces that search
with one directory (the test suite uses it).
Otherwise boxed processes are preferred, but not absolutely. A boxed application is the likely culprit, is supervised, and relaunches in seconds, while a host process is more often session state. The largest boxed process is chosen when it holds at least half the resident memory of the largest eligible process overall; otherwise the largest process overall goes. An absolute preference would kill a small boxed helper while a host process many times its size kept the machine stalled.
The victim is named by its box. Identity comes from the same container-supervisor walk in
libkproc that kdos-energyd uses.
The memory comes back immediately. The daemon takes a handle on the process first (a pidfd,
so the next step cannot land on a recycled process id), sends SIGKILL, then calls
process_mrelease to free the victim’s memory at once rather than whenever it is reaped. On a
kernel without that call the release is skipped and the kill stands.
At most one scan every ten seconds. The cool-down starts when a firing finds memory short and
scans /proc, not when a kill succeeds, so a scan that finds nothing killable does not rescan
every entry in /proc once a second on a machine that is already stalling. A firing that finds
memory not yet short reads only /proc/meminfo and starts no cool-down, so the next firing of the
same incident, once memory is short, can still kill before the kernel’s own killer does.
The daemon shields itself from the emergency it watches: at start-up it sets its own
oom_score_adj to -1000 and locks its memory with mlockall. Each kill is logged with the victim,
the ten-second pressure averages and the memory available when it chose, in the form
kdos-oomd: killed <name> [(appbox <box>)] (pid <pid>, <size> MB) — memory pressure avg10 full=<f> some=<s>, <avail> of <total> MB available.
A trigger that finds memory not short logs nothing.
Nothing in the protocol names a process, so there is nothing to aim. The socket takes no argument
and answers root, wheel and a user with the active session on a seat:
| Verb | Answers |
|---|---|
ping |
ok |
status |
ok trigger 'full 150000 1000000', kills <n> and, after the first kill, , last: <name> [(appbox <box>)] (pid <pid>, <size> MB) |
protected |
ok and the protected names, space-separated, the prefix rule last as pipewire* |
The active-session answer comes from elogind’s sd_uid_get_state(), read through libelogind,
which the daemon opens at first use rather than links. The daemon exists for the minute memory runs
out, and a session library that is missing or broken must cost the read tier and never the killer.
Root and wheel never reach that question.
kdos doctor reports whether the socket is present and lists the protected names that are not
running, naming those that run only at certain times. kdos-notice reads status to say how many
processes have been killed since boot.
kdos-oomd --fixture <dir> reads a recorded /proc tree, prints the process it would kill as
would kill <name> … (pid <pid>, <size> kB) with the recorded pressure, and signals nobody. It
exits 0 when there is a candidate and 1 (printing no candidate) when there is none. A tree whose
meminfo does not show memory short, by the rule in How it decides, prints
no kill: <avail> of <total> kB available and exits 1, the answer the daemon gives a trigger
there; a tree without a meminfo is judged on the stall alone.
kdos-oomd --protected prints the protected names one a line, the prefix rule last, which is what
the check that holds each name to 15 bytes reads. kdos-oomd --explain <user> prints whether that
user may read the socket and why, and exits 0 when permitted.
testing/oomd-fire.sh exercises the real path in a booted virtual machine: it allocates and
touches memory until the trigger fires, then asks the socket what happened rather than watching
the allocating process die (the kernel’s own killer would also have got it, later). A passing run
shows status going from kills 0 to kills 1, last: <name> (pid <pid>, <size> MB) while the
script that started the allocation keeps running. A second round then holds a process under a
cgroup’s memory.high so the trigger fires while MemAvailable is still high, and exhausts memory
with another inside the ten-second cool-down: it passes when the daemon still kills and the kernel’s
Out of memory count in dmesg does not rise. That run has one large process to choose; which
process the daemon picks on a busy desktop is what --fixture tests.
The only program on the system that mounts an application pack. A pack is a signed, read-only EROFS image holding an application, a runtime it depends on, or data; how packs are built, verified and combined into a box is in Packs and boxes.
| Verb | Does |
|---|---|
list |
Every pack the machine can see: id, version, kind, state (mounted, installed or available), size in bytes, and origin (store or medium), tab-separated, then ok |
info <id> |
One pack’s metadata, then its state, origin and, when mounted, mountpoint |
mount <id>, unmount <id> |
Mount or release a pack. A pack still used by a box is not unmounted |
compose <box> <id>… |
Build a box’s overlay stack from 1 to 32 packs. Ids past the 32nd are ignored rather than refused |
decompose <box> |
Tear it down |
install <file> [<index>] |
Copy a pack out of the staging directory, verify the copy and move it into the store. <index> is a second staged file name, a signed index with its signature staged as <index>.sig; the daemon reads no index a request does not name |
remove <id> |
Take a pack out of the store |
rollback <id> |
Return to a retained earlier version |
graft <id>, ungraft <id> |
Place a data pack’s contents where its consumer looks for them, or remove them (a graft) |
ping |
ok |
status |
Tab-separated lines: store, medium and staging directories, retain count, mount route (file-backed, loop device, or not yet used), packs (installed, available and mounted counts), boxes (how many are composed), and a box line for each composed box (name, merged root, ephemeral or persistent), then ok |
Every verb answers root and wheel only. Launching a boxed application sends info for the pack’s
environment and compose for its box; kdos-box start sends compose and kdos-box remove sends
decompose. kdos-appbox genlaunchers --packs sends list and then mount for each installed
pack. kdos app import, kdos-appbox import and kdos-box import copy a pack into the staging
directory and send install, and an import of a data pack sends graft. Discover’s KDOS backend
sends list and info to show the packs, and graft, ungraft and remove when a person
installs or removes one. kdos-appbox status and kdos doctor ask for status, and kdos doctor
reports the mount route. kdos app install and kdos app remove build and delete container images
and ask this daemon nothing. No program on the system sends unmount or rollback; those verbs
are reached only by a client that speaks the socket directly.
An id is at most 63 characters from [A-Za-z0-9._-] and does not begin with . or -; anything
else is refused before it is looked up.
Paths:
| Path | What |
|---|---|
/var/lib/kdos/packs |
The store; the current version of a pack is <id>.kpack |
/var/lib/kdos/packs/staging |
Where an unprivileged download lands; mode 01777, set when the daemon starts |
/var/lib/kdos/packs/mnt |
Mountpoints |
/mnt/iso/packs |
Packs on the boot medium |
/var/lib/kdos/packs/pack-manifest |
Every graft made, so an ungraft removes exactly what was added; in the shared store, so at start the daemon makes every host graft it names that this root lacks |
/var/lib/kdos/packs/pack-manifest.ungrafted |
The paths an ungraft dropped, so the other slot unlinks its own copy of each at its next start |
/etc/kdos/keys/packs |
The keys packs are verified against, separate from /etc/kdos/keys, which is kpkg’s package-repository ring |
/etc/kdos/packd.conf |
Configuration |
The daemon reads these environment variables in normal operation, not only in fixture mode. The init script sets none of them:
| Variable | Effect |
|---|---|
KDOS_PACK_STORE, KDOS_PACK_MEDIUM, KDOS_PACK_MANIFEST |
Replace the store, the boot-medium pack directory and the graft record |
KDOS_PACK_HOME, KDOS_PACK_SHARE |
Replace the caller’s home directory and /usr/share as graft and box-upper destinations |
KDOS_PACK_RETAIN |
Overrides retain in packd.conf (below); a negative value counts as 0, as it does in the file |
KDOS_REQUIRE_SIG |
Refuse every unsigned pack at install (<id> is unsigned and KDOS_REQUIRE_SIG is set), for a machine that installs only what it can attribute |
All of them are also listed in Filesystem and IPC.
The client never names a path, with one exception: install takes a file name inside the
staging directory. A name containing /, the name .., an empty name, or a name with a character
outside [A-Za-z0-9._-] is refused. status publishes the staging directory and the retention
count, so a program writing a download into the store does not have to work either out for itself;
a second definition of where an unprivileged write is allowed is the kind of thing that drifts.
Verification happens in the daemon, where the mount happens, because a client that verified and
then asked a daemon to mount would have verified nothing. The daemon first copies the staged pack,
and the staged index the request names and its <index>.sig when there is one, into private root-owned
files in the store (.install.part, .install-index.part, mode 0644), and everything after reads
the copies. The staged file belongs to whoever put it in a directory every user may write, so a
check on it would say nothing about the bytes a later read found. A staged symlink or anything
other than a regular file is refused with err cannot read <name> from the staging directory.
An install therefore needs free space in the store for a second copy of the pack while it runs.
PACKAGES index whose signature is good and which lists this
pack, the pack’s SHA-256 must match the index entry; a mismatch is refused
(<id> does not match the signed index)./etc/kdos/keys/packs. A good
signature is accepted; a bad one, a hash mismatch, or a signature by a key the ring does not
hold is refused.KDOS_REQUIRE_SIG
is set.A pack that passes has its copy renamed to <id>.kpack, and only then is the staged file deleted;
a refused install deletes the copies and leaves the staged file where it was.
A pack in the store was verified when it was written and only root can write the store, so it is
not re-hashed at each mount. A pack on the boot medium was never installed, so it is verified at its
first mount; there a bad signature, a hash mismatch or a missing key is refused, and an unsigned
pack mounts. Every pack is mounted read-only with nosuid and nodev, and a data pack with
noexec as well.
The list is rescanned on every request, so a medium pulled out between two requests is not still
offered. At start-up the daemon adopts whatever packs and boxes are already mounted, so a restart
while boxes are running does not lose track of them, and then makes every host graft the store’s
pack-manifest names for a data pack in the store and this root lacks, so a data pack grafted from
the other A/B slot is in place in this one; see
Grafts and data packs.
An install replaces the old version safely. If the old version is mounted but not in use, it is
unmounted before the file is swapped, so the next compose reads the new file. If it is composed
into a running box, the install is refused (<id> is composed into <n> box(es) — stop them, then
install), the same rule remove and rollback apply. Without this, a box composed after an update
would put the new application’s layer over the old runtime’s still-mounted files, and the
application would fail on a library only the new runtime carries. The version being replaced is
kept as <id>-<version>.kpack beside the new <id>.kpack.
/etc/kdos/packd.conf sets how many superseded versions of each pack the store keeps:
retain = 1
| Value | Effect |
|---|---|
1 (shipped) |
The most recent update can be undone |
0 |
Nothing is kept; rollback answers err no earlier <id> is kept |
Up to 8 |
That many, newest first by version; higher values are treated as 8 |
The daemon reads retain from the file once, when it first needs it, and keeps that value for the
rest of its life; restart it (service restart packd) after changing the file.
KDOS_PACK_RETAIN, when set, is read on every use.
The sweep that deletes older versions runs after an install and at no other time, so nothing deletes
a rollback while somebody is deciding whether to use it. rollback keeps the current file as
<id>-<version>.kpack, renames the newest retained version (by version comparison, as the sweep
keeps them, so 1.10 is newer than 1.9) into its place, and answers
ok <id> <current> -> <restored>. The version rolled away from stays in the store under its own
version. A retained copy of the installed version itself, left by installing the same version
again, is never the one restored; with nothing else retained the answer is
err no earlier <id> is kept.
The store’s row for an id is <id>.kpack and no other file. A retained <id>-<version>.kpack is
material for rollback and is never listed, mounted or composed. The sweep and rollback count a
file as a retained version of an id only when its own metadata names that id, because an id may
contain -: foo-bar.kpack is the installed pack foo-bar, not a version bar of foo.
kdos-packd --fixture <store> [medium] lists the packs in a scratch store with their signature
state, composes each application pack, grafts each data pack (printing each graft’s destination),
and prints the result, mounting nothing. KDOS_PACKD_VERBOSE shows its log lines; KDOS_KEYS
points it at another key directory. The daemon reads KDOS_KEYS only in fixture mode; the
kdos-pack tool reads it in normal use, to choose the ring its verify and info check against
(default /etc/kdos/keys/packs). kdos-packd --fixture-graft <store> <id> is the graft verb and
kdos-packd --fixture-start <store> the start-up re-graft over a scratch store, each mounting
nothing but writing the links and the record for real, under KDOS_PACK_SHARE (instead of
/usr/share) and KDOS_PACK_HOME (instead of the caller’s home); two share directories over one
store stand for the two slots of an A/B machine.
The two mount routes, reference counting and adoption of existing mounts at start-up are described in Packs and boxes.
The machine’s name, clock, time zone, locale and keyboards, on the system bus. KDE does not write
these settings to files itself. It calls three interfaces that systemd defined,
org.freedesktop.hostname1, org.freedesktop.timedate1 and org.freedesktop.locale1. KDOS has
no systemd, so this daemon answers for them, with every method and property of the three interfaces
except hostname1’s Describe, which nothing on the system calls. It is C on basu and libkbase
and links no glib and no Qt.
Its callers are:
kwin_wayland --locale1, takes its keyboard layout
from locale1 and follows it when it changes.XKB_DEFAULT_*). KWin
uses that only when the account’s kxkbrc cascade names no layout.The system-wide /etc/xdg/kxkbrc is written by the installer and rewritten by this daemon on every
locale1 layout change. A layout changed through locale1, plasma-setup’s on an OEM first boot
included, therefore reaches the login screen, the session and the lock screen of every account
that has no ~/.config/kxkbrc of its own. An account whose own kxkbrc names a layout keeps it.
What a person sees of the daemon, page by page, is in
KDOS’s settings pages.
Each setting is kept in the file the rest of the machine already reads, and nothing is cached: every getter reads its file, so a value the installer or a person with an editor wrote is what the next caller sees.
| Setting | File |
|---|---|
| Static hostname | /etc/hostname, which 05_hostname.sh gives the kernel at boot; the 127.0.1.1 line of /etc/hosts follows the name, because musl resolves the machine’s own name from that file and nothing else before the DNS |
| Pretty name, icon, chassis, deployment, location | /etc/machine-info |
| Time zone | /etc/localtime, a symlink into /usr/share/zoneinfo, and /etc/profile.d/20-timezone.sh, which exports TZ=':/etc/localtime' |
| Wi-Fi country | /etc/modprobe.d/kdos-regdom.conf, from the zone |
| Network time | Whether /etc/service.disabled/chrony exists |
| Locale | /etc/locale.conf, bare NAME=value lines, which SDDM puts into every session; SetLocale refuses with InvalidArgs a value that is not C, C.UTF-8, POSIX or ll[_CC][.UTF-8\|.utf8][@modifier] whose language has a file in /usr/share/i18n/locales/musl or a directory in /usr/share/locale, and a LANGUAGE element of any other shape (no codeset) or language, so a typo never reaches every session. The territory is not checked, because plasma-setup’s language page sends LANG=<ll_CC>.UTF-8 for every language Plasma is translated into and most have no musl-locales file. A value already in the file is read as written |
| Console keymap | /etc/keymap, which kdos-getty loads on every console, and its copy /boot/efi/EFI/kdos/keymap (below) |
| Graphical keyboard | /etc/kdos/xkb.conf (XKBMODEL, XKBLAYOUT, XKBVARIANT, XKBOPTIONS), never under /etc/X11; and the same layout in /etc/xdg/kxkbrc ([Layout] LayoutList, VariantList, Model and Options with ResetOldOptions=true when set, Use=true), written whole on every layout change and removed for an empty layout, because KWin and the lock screen read the kxkbrc cascade before the environment xkb.conf reaches them through |
Both halves of a time zone are written or the call fails. musl reads TZ where it is set, and
every login sets it once the installer or the daemon has chosen a zone, so writing only the link
would leave every new login reporting the old zone. The colon form points musl at the link itself,
the one value that cannot drift from it, and it is the form Qt reads as “follow /etc/localtime”.
It is also what moves the programs already running: KDOS’s musl re-reads the file a path-form TZ
names on the next tzset() once it has been replaced (see
musl’s port note), and Qt calls tzset()
before every local time, so the panel clock and every Qt or KDE program take the new zone at their
next update. The link is replaced by rename(), so a program never finds it missing. A C program
that never calls tzset() keeps the zone it started with.
The Wi-Fi country follows the zone. The kernel’s wireless layer starts in the “world”
regulatory domain, which keeps every 5 GHz DFS channel (one shared with radar) closed and caps
transmit power until something names a country, and some drivers never take one from an access
point. The daemon looks the zone up in zone.tab, which maps each zone to exactly one country
code, writes options cfg80211 ieee80211_regdom=<CC> to /etc/modprobe.d/kdos-regdom.conf for the
next boot, and runs iw reg set <CC> for this one. A zone with no country, such as UTC, removes
the file and runs iw reg set 00, so the running radio returns to the world domain at once rather
than keeping the previous country’s channels and power until the next boot. Neither step failing fails the zone: a machine with no radio still has a time zone. The
installer writes the same file from the zone chosen during installation.
An empty layout follows the console. The installer writes the console keymap alone and the
shipped xkb.conf leaves XKBLAYOUT empty, so locale1’s X11Layout is then the layout nearest
/etc/keymap, and the login screen has the installed keyboard from the first boot. A derived
layout is given only when xkeyboard-config carries it: KWin falls back to US for a layout it
cannot compile and says so only in its log.
The console keymap has one copy, on the ESP. The disk passphrase is typed before any root is
open, so the initramfs cannot read /etc/keymap; it loads the map named in
/boot/efi/EFI/kdos/keymap instead (see
Unlocking an encrypted root).
SetVConsoleKeyboard, and SetX11Keyboard with convert, write /etc/keymap and then the ESP’s
file, and an empty keymap removes both; at start the daemon rewrites the ESP’s file from
/etc/keymap wherever the two differ or the file is missing. Only where /boot/efi/EFI/kdos
exists, so the live medium is left alone. The ESP file is written as kdos-bootctl writes the boot
state, a temporary file, its fsync, the rename, then the file’s fsync and a syncfs; failing
to write it leaves the call succeeded, since /etc/keymap is the setting, and is logged. The
daemon never reads the copy.
The console map nearest a layout is the 8-bit one. convert and the installer pick the
console map for an XKB layout from a table, then <layout>-latin1, and only then a map named
<layout>: kbd’s bare de, dk, no, fr, sg and fr_CH are the 7-bit ISO-646 maps, on which
the keys for ü ö ä ß type @ [ ] \, and its pt is the OLPC laptop’s. German gives de-latin1,
Swiss German sg-latin1, Swiss French fr_CH-latin1.
The hardware clock is UTC. The kernel reads it as UTC at boot and writes it back every eleven
minutes while chrony has the clock synchronised, so LocalRTC is false and SetLocalRTC(true) is
refused. A clock set by hand is not synchronised, so SetTime writes the hardware clock itself.
Network time is chrony. CanNTP is true when chrony’s init script and chronyd are both
installed. SetNTP(true) removes the marker and runs service start chrony; SetNTP(false) puts
it back and runs service stop chrony. On a machine without chrony, SetNTP(true) answers
NoNTPSupport and SetNTP(false) succeeds, as systemd-timedated’s does: the Date & Time page sends
SetNTP(false) on every Apply when CanNTP is false, and refusing it would fail the whole Apply.
A method validates its arguments before polkit is asked, so a bad value is refused without a
password prompt, and polkit answers before a single byte is written. Every value is checked
against a character set and, where the machine carries the list, against the list: a zone must be
a regular file in the zone tree that starts with the TZif magic, a console keymap must be one of
kbd’s keymaps and an XKB layout one of xkeyboard-config’s rules/evdev.lst. A name that passes
the character rule and names nothing is refused, because a keymap nobody can load and a layout no
compositor can compile both fail silently later, at the login screen, where nobody can type the way
out.
Root is answered without asking polkit. Everyone else gets polkit’s answer under systemd’s own action ids, because plasma-setup’s rule and the Date & Time page name them:
| Action | Active local session |
|---|---|
org.freedesktop.timedate1.set-time |
auth_admin_keep |
org.freedesktop.timedate1.set-timezone |
yes |
org.freedesktop.timedate1.set-ntp |
yes |
org.freedesktop.timedate1.set-local-rtc |
auth_admin_keep |
org.freedesktop.locale1.set-locale |
auth_admin_keep |
org.freedesktop.locale1.set-keyboard |
auth_admin_keep |
org.freedesktop.hostname1.set-hostname, set-static-hostname, set-machine-info |
auth_admin_keep |
org.freedesktop.hostname1.get-product-uuid, get-hardware-serial |
auth_admin_keep |
set-time implies set-timezone and set-ntp. The Date & Time page authorises set-time before
it saves anything, whatever changed, so every Apply there asks for an administrator’s password,
which then covers its three calls. The zone and network time pass with no password only from a
caller that asks for them alone, such as kdos timezone or plasma-setup. The last two rows guard
the values that identify the machine, which the kernel lets only root read.
An interactive question may stay open for five minutes, after which the call is refused; no answer from polkit is a refusal.
The programs it runs, service, loadkeys and iw, are argument vectors found through PATH and
skipped when missing, because every argument they are given came over a bus.
43_settingsd.sh starts the daemon under ksvc after polkitd and before the display manager,
with --restart-with dbus and --final-exit 3, and waits for all three names. It exits 3 when
another process owns one of them. A kernel left with no hostname, which is what
SetStaticHostname("") and a missing /etc/hostname produce, is given the default name
(DEFAULT_HOSTNAME= in os-release, else kdos) when the daemon starts.
KDOS_SETTINGSD_ETC, KDOS_SETTINGSD_SHARE and KDOS_SETTINGSD_SYS replace /etc, /usr/share
and /sys, and the first also keeps the daemon off the machine it runs on: with it set the
kernel’s hostname, the clock and the hardware clock are left alone, and the ESP’s keymap copy is
written only when KDOS_SETTINGSD_ESP names a scratch ESP directory. testing/selftest.sh drives
every method that way, over a private bus, against a polkit stand-in in
testing/fixtures/settingsd/.
The bus face of a KDOS system update. Discover’s stock SystemdSysupdate backend is how Plasma shows
an operating-system update, and this daemon serves org.freedesktop.sysupdate1 the way Discover
6.8.2 calls it, so Discover drives a KDOS update with no patch. It does no update work itself:
every check, download, install and boot decision is a run of kdos update or kdos-bootctl,
executed with an argument vector, both found through the daemon’s PATH, and the daemon waits for them without blocking the bus. It also
serves io.kdos.Slots1 for the System Versions page and the update notifier, and it is the root
half of the boot confirmation that keeps a new slot. What an update is, where it comes from and how
the slots are chosen are in Updating a machine
and A/B slot selection; how Discover
drives it is in Discover.
| Call | Answers |
|---|---|
Peer.Ping |
Whether the backend is there at all |
Manager.ListTargets |
One target, host, at /org/freedesktop/sysupdate1/target/host |
Manager.ListJobs, ListAppStream |
The running job; the AppStream URL |
Target.GetAppStream |
file:///run/kdos/sysupdate/io.kdos.system.metainfo.xml |
Target.GetVersion |
The running version |
Target.CheckNew |
The version on offer, or empty for nothing. Discover calls it when it opens and on Refresh; it fetches the signed indexes at most once per --refresh-after and downloads no package |
Target.List, Describe |
The installed and offered versions |
Target.Acquire("", 0) |
All the long work: kdos update apply --acquire --mount --progress 3. Its reply is a job path, whose Progress Discover watches |
Target.Install("", 0) |
The short arm: kdos update apply --arm --mount --progress 3 |
Target.Vacuum |
0: the slots are the history, and nothing is vacuumed |
Job.Cancel |
Stops the running child |
Manager.JobRemoved |
Sent once, when a job this daemon replied with ends |
Acquire answers only after kdos update has said verified or refused. Discover shows a
failed call’s message in the details of its “Update Issue” sheet, leaving nothing pending (the
discover port’s sysupdate-errors.patch offers a restart only after Install succeeds), but
shows a failed job as nothing more than “failed”. So everything that can refuse an update is
learned before the reply: a release index, binhost index or image manifest that no trusted key
signed, a file the release index does not name, a package the binhost does not cover, a slot that
cannot be mounted. Only an update that can go ahead becomes a job. JobRemoved is sent only for a job this daemon replied with, because Discover
ends whatever transaction it is waiting on at the first one it sees.
Acquire and Install take "", the offered version, which is what Discover sends, or that
version by name; any other version answers that it is not available. Only one job runs at a time,
and a call during the hourly check is refused until the check finishes, because the fetch holds the
update lock the apply would take. Every one of these is checked again once polkit has answered, since an
administrator’s prompt can stay open for minutes: a call whose version is not the one offered or
acquired at that moment is refused, and nothing other than the version that was authorised is installed.
A trial boot is offered nothing. While this boot is the trial of the other slot, the slot an
update would fill is the confirmed way back, so CheckNew answers empty and Acquire is refused
until the trial is confirmed or rolled back. A machine with no second root slot is offered no
system update. Its CheckNew runs kdos update fetch --binhost-only as root, at most once per
--refresh-after, which fetches the signed binhost index of the release the tree in place is into
/var/lib/kdos/binhost, and answers empty when that ends, so Discover reports the system up to
date and a session with no terminal still gets the prebuilt programs and the group sizes Make It
Yours shows. The time of the last such fetch is the binhost line of
/var/lib/kdos/update.state; a line whose code is no-network or fetch-failed counts as no
fetch, so the next CheckNew after connecting tries again at once. Such a machine never runs
kdos update check --fetch. Its Acquire and Install are refused before any busy check, even
while that fetch runs, so the reply never says to try again: on a single-root install it names
kdos update apply, which updates it in place at a shell, and on the live medium it says that
nothing installed there survives a restart and that KDOS is to be installed. The AppStream file
names the live medium as the live session.
The update document belongs to the root that wrote it. On a machine with slots, CheckNew
reads /var/lib/kdos/update.json. At most once an hour (--refresh-after) it also runs
kdos update check --fetch, which fetches the signed tree and release index and, through that
index, the binhost index and the slot image manifest, so what it offers is only what the index
named. The hour is judged by the fetch line of /var/lib/kdos/update.state. A no-network code
there counts as no fetch, so the next CheckNew after connecting tries again at once; a
fetch-failed keeps its time.
The document is kept in each slot, so the first boot of a slot, or the boot a rollback returns to,
finds one written before that root was what it is now. A document whose installed is not the
running version offers nothing, and the daemon rewrites it at start with kdos update check --out,
which downloads nothing. The daemon watches /var/lib/kdos and regenerates the AppStream file
whenever the document changes, so a check typed at a shell reaches Discover too.
The AppStream file lives on /run. /run/kdos/sysupdate/io.kdos.system.metainfo.xml is what
Discover shows for the update. It carries:
ports/RELEASE is written in into
AppStream’s description markup: a # heading becomes a paragraph of its text, a run of -
items one list, and backticks are dropped, since Discover shows a paragraph’s text as it is.lane), the signer’s fingerprint, the packages it changes and the size still to
fetch.discover
port’s sysupdate-size.patch reads for the Updates list.<project_license>MIT</project_license> beside its CC0-1.0 metadata licence, which More
Info’s Licenses field shows through the discover port’s sysupdate-licenses.patch.The size reads “to copy” when the offered lane’s origin is a directory or a file:// URL, and “to
download” otherwise. The origin is the document’s image field for the image lane and its
binhost field for the packages, which is where kdos update fetches the bytes from:
update.conf’s image = and binhost = lines, $KDOS_UPDATE_IMAGE and $KDOS_UPDATE_BINHOST,
else the release’s https defaults. The tree’s channel does not decide it. The copy in
/usr/share/kdos/update/ is the fallback that names the system and offers nothing.
The System Versions page and kdos-notice read the slots through io.kdos.Slots1. Its contract
is the page’s own io.kdos.Slots1.xml:
| Kind | Members |
|---|---|
| Properties | Configured, Live (the live medium, from kdos-bootctl status --json), RunningSlot, ActiveSlot, TrySlot, TryAttempts, TryBootNext, Channel, InstallRoute, BuildDeps, State |
| Methods | ListSlots, Try, CancelTry, SetChannel, SetInstallRoute, Bless |
| Signal | SlotsChanged |
Each ListSlots entry’s state is the first of trial, visiting, incomplete, failed,
abandoned, confirmed, installed and empty that holds. visiting and abandoned are
kdos-bootctl status --json’s own words for the slot: visiting is one boot of a root picked at
the boot menu, and abandoned a trial set aside there, which is not a failure. The entry carries
the booleans failed, abandoned and incomplete beside its state.
InstallRoute and BuildDeps are the install = and build-deps = lines of
/etc/kdos/update.conf, the route kdos update install
takes when no flag names one and the route of what a source install lacks: each prebuilt or
source, and prebuilt when the line is absent or holds anything else, which is what kdos
update does with it. SetInstallRoute(ss install, deps) writes both lines, every other line of
the file kept as it was, and answers InvalidArgs for any word but those two; PropertiesChanged
announces both properties.
SetChannel(s) writes the tree = line of update.conf, or removes it for "". It takes an
absolute directory, an https:// URL or a file:/// URL. Anything else, http:// among them, is
answered with InvalidArgs “not an update channel: kdos update fetches with curl’s --proto =https,file. The channel names where the tree comes from; the binhost and the image keep
their own lines.
A slot is confirmed only when two marks exist, tested together, both root’s regular files in
/run/kdos/bless/:
| Mark | Written when |
|---|---|
userspace |
The end of rcS: every service started |
graphical |
A Plasma session answered for a minute (Bless, which kdos-notice --bless calls), or the login greeter stayed up for a minute on a machine SDDM does not log in automatically |
Then the daemon runs kdos-bootctl mark-good, once per boot, and writes /run/kdos/bless/confirmed
after it succeeds. Either mark alone confirms nothing: a system whose services all start but whose
desktop crashes is the failure a trial exists to catch.
The greeter counts only on a machine with no automatic login, and only before any user session has existed this boot, because a greeter that came back after the session crashed must not confirm the slot that crashed it. On such a machine the greeter is the graphical check, so a desktop that fails only after a login is not caught. Waiting for a session instead would roll a good release back whenever its one trial boot is left at the login screen. The way back from such a desktop is Start This Version Next Time on the other slot, in System Versions.
The greeter is recognised as an sddm-greeter and a kwin_wayland both running as SDDM’s
account, sddm, by the uid /etc/passwd gives it. The names alone are not enough, since any
account can start two processes called that. A machine whose inittab starts no display manager
has no graphical half to wait for, and the first mark is enough there.
Root is answered without asking polkit, and the bus policy lets only root own the two names.
| Action | Methods | Active local session | Inactive and any other |
|---|---|---|---|
org.freedesktop.sysupdate1.check |
CheckNew |
yes |
auth_admin |
org.freedesktop.sysupdate1.update |
Acquire, Install, Cancel |
auth_admin_keep |
auth_admin |
org.freedesktop.sysupdate1.update-to-version |
Acquire and Install naming a version |
auth_admin |
auth_admin |
io.kdos.slots.try |
Try, CancelTry |
auth_admin_keep |
auth_admin |
io.kdos.slots.channel |
SetChannel |
auth_admin_keep |
auth_admin |
io.kdos.slots.install-route |
SetInstallRoute |
auth_admin_keep |
auth_admin |
io.kdos.slots.bless |
Bless, never interactive |
yes |
no |
A CheckNew polkit does not allow, denied or answered with a challenge nobody takes up, is not an
error: it is answered from the update document with no fetch, after any check already running
has rewritten it, as an allowed caller is. The offer is the document’s, which
every account reads, so the action guards only the network fetch; an error would be an “Update
Issue” sheet in Discover for a caller outside the active session, such as a program started from
the live medium’s console, that a quiet answer loses nothing by. Every other method’s refusal is
the call’s error.
kdos-sysupdated [--session] [--root DIR] [--proc DIR]
[--bless-after SECONDS] [--tick SECONDS] [--refresh-after SECONDS]
| Option | Default | Effect |
|---|---|---|
--session |
off | Serve the session bus, which is where Discover looks with DISCOVER_TEST_SYSUPDATE=1 |
--root DIR |
/ |
Read and write every file under a fixture root |
--proc DIR |
/proc |
Read processes from another tree |
--bless-after |
60 | Seconds the greeter must stay up to earn the graphical mark |
--tick |
5 | Seconds between checks of the boot state |
--refresh-after |
3600 | Seconds between fetches by CheckNew (the tree and indexes, or the binhost index alone on a machine with no second slot); 0 never fetches |
--session --root together is how the whole flow runs without root. Without --session the
daemon refuses to start unless it is root. It exits 1 when its bus goes away, for the supervisor to
restart it with the bus, 2 on bad usage, and 3 when another process owns one of its names.
SIGHUP rereads every file it serves from. The children’s standard error is the daemon’s, so a
failed update is read line by line in syslog under kdos-sysupdated.
46_sysupdated.sh starts it under ksvc with --restart-with dbus and --final-exit 3 and waits
for org.freedesktop.sysupdate1. The interface is tested against Discover’s own XML:
tests/org.freedesktop.sysupdate1.xml beside the source is discover-6.8.2’s, byte for byte, and
testing/selftest.sh diffs the daemon’s introspection against it and against the Slots1 contract.
kdos-mdnsd answers DNS questions about .local host names from Avahi, so that ping, ssh,
a browser, getent hosts and CUPS resolve <host>.local on musl, which has no NSS for an
nss-mdns module to hook into getaddrinfo(). Every host lookup goes to /etc/resolv.conf’s
127.0.0.1, NetworkManager’s dnsmasq, and
/etc/NetworkManager/dnsmasq.d/kdos-mdns.conf (server=/local/127.0.0.1#5380) forwards the
local domain to this daemon on UDP 127.0.0.1:5380. For each question it opens Avahi’s
simple-protocol socket, /run/avahi-daemon/socket, and sends RESOLVE-HOSTNAME-IPV4 <name> or
RESOLVE-HOSTNAME-IPV6 <name>.
| Question | Answer |
|---|---|
A or AAAA for a name ending in .local, Avahi answers + <if> <proto> <name> <address> |
One record with that address, TTL 10 seconds |
The same, Avahi answers -, says nothing for three seconds, or gives an IPv6 link-local address |
NOERROR, no answer, and an SOA for local whose minimum is 10 seconds, which dnsmasq caches |
Any other type under .local |
The same empty answer |
A name outside .local, the bare local, or a name holding a byte other than a letter, digit, -, _ or UTF-8 |
REFUSED |
| A truncated question, a compression pointer that does not point back before the last one followed, more than one question | FORMERR |
| Avahi’s socket cannot be reached, Avahi ends the connection before a reply line, or 48 clients’ questions are already open (under Avahi’s own limit of 50 simple-protocol clients, past which it closes the connection) | SERVFAIL, which dnsmasq does not cache |
| A packet shorter than a header, or a response | Nothing |
A miss is never NXDOMAIN: musl’s getaddrinfo() asks A and AAAA together and fails the
whole lookup on an NXDOMAIN to either, so an IPv4-only host would resolve to nothing. Once one
family has answered, the other family’s question for the same name gets half a second more rather
than the rest of its three, because Avahi already holds every address record the responder sent.
A question for one family also asks Avahi for the other, with no client waiting on it, and the
last 48 answers and misses are kept for ten seconds: a later question for a name and family in
that table is answered at once, and one whose family is still being asked joins that question.
musl’s getent hosts asks AAAA and only after its miss A, so a name nothing answers fails
in one three-second wait, not two. The other family’s question takes one of the 48 slots, is not
asked when none is free, and is closed to free its slot for a client’s question that finds none,
so it never costs a client a SERVFAIL. An IPv6 link-local address is left out because a DNS
record cannot carry the interface it belongs to. Each question has its own non-blocking connection to Avahi, and poll() waits on all
of them, so a name that never answers delays no other.
It is the one daemon here that does not keep root: 45_mdns.sh starts it, it binds the port and
then becomes nobody (no supplementary groups, no_new_privs) before it reads a packet, and it
refuses to run if it can still become root. It links libkbase alone and has no socket in /run,
no bus name and no client. 45_mdns.sh sorts after 45_avahi.sh, starts it under ksvc with
--restart-with avahi-daemon, and skips it when avahi-daemon is not installed or
/etc/service.disabled/avahi exists. A machine whose network is run by 30_network’s dhcpcd has
no dnsmasq to forward to it; see
Known gaps.
kdos-mdnsd [--port N] [--socket PATH] [--user NAME]
kdos-mdnsd --answer QUERY-FILE AVAHI-REPLY
--port 0 takes a port the kernel picks and prints it on the first line; --socket asks another
Avahi socket; --user names the account to become, and only root becomes one. --answer runs one
DNS packet from a file through the parser and the answer builder against a recorded Avahi reply
line (empty for none) and writes the response packet to standard output, exiting 3 for a packet
that gets no answer. testing/selftest.sh drives both through testing/fixtures/mdnsd/drive.py:
good A and AAAA questions, misses, refusals, truncated packets and compression loops through
--answer, and the daemon against a fake Avahi with one name that never answers beside one that
does.
kdos-boxsock is not a root daemon and has no socket in /run. It is installed in /usr/bin, runs
as the desktop user, one process per box launcher, and gives that launcher a Wayland socket of its
own that KWin tags, so the compositor always knows which box a window came from. kdos-appbox runs
it on every launch; the box’s side of it is in kdos-appbox.
kdos-boxsock [-s confined|tagged] <box> [<launcher-id>]
What it does:
[A-Za-z0-9._-], the first a letter or a digit,
so an option is never taken for a name. The launcher id is the box itself, the box plus one more
component (one launcher of a box with several, <box>.<stem>), or the box less its last
component (a throwaway box, <launcher-id>.tw<n>, whose windows are its application’s); it
defaults to the box. -s is confined unless given. -h or --help alone prints the usage and
exits 0; bad usage exits 2.$XDG_RUNTIME_DIR/kdos/box/<box>, exists and is
this user’s alone. kdos-appbox makes it; a box sees it as its whole /run/user/<uid>, so a
socket bound anywhere else is one the box cannot reach.$XDG_RUNTIME_DIR/kdos/box/.<box>.wl[.<stem>]@<display>.lock, beside the private
directory and not inside it, so nothing in the box can take it. The holder writes its pid and its
engine into the lock. A second run for the same socket prints the holder’s path when the holder
serves the same state, or stops the holder and takes over when it serves the other one.wl[.<stem>]@<display> in the private directory, mode 0700, so only this user can
connect.io.kdos.appbox+private for a confined box or io.kdos.appbox+tagged for one with a way past
the tag, the launcher id as the application id, and the box as the instance id.ready <path> on standard output, or error <reason> when it cannot tag, closes
standard output so its caller reads to end of file, and stays alive holding the descriptor that
keeps the tag valid. When the compositor exits, it removes the socket and exits too.Every client that connects on that socket is tagged by KWin itself; the client never sees the tag, so it cannot forge, choose or drop it. What the tag carries is read in three places:
genlaunchers wrote, so
the window shows that launcher’s icon, lights its pinned task and matches its box’s window rule.grant key from
~/.config/kdos/boxes/<box>.conf, and the window decoration’s badge names it.kdos-appbox decides which boundary held for the box
and the decoration shows it. An engine is fixed when a context is committed, so a holder serving
one state is replaced by a run asking for the other, and the replacement is what the next client
connects through.<display> is taken from $WAYLAND_DISPLAY: its last path component, reduced to
[A-Za-z0-9._-] and cut to twelve characters, or session when nothing is left. It is in the path
because the listener belongs to the compositor this process connected to; a path keyed on the box
alone would send a later launch through a compositor that may already be gone. kdos-appbox
derives the same path from the same variables, so the two agree with nothing passed between them.
If the compositor does not offer the security-context protocol, kdos-boxsock answers
error the compositor has no security-context-v1 rather than bind an untagged socket, and
kdos-appbox refuses to start the box with that line as the reason. An untagged socket would be
indistinguishable from the compositor’s own.
It is a separate program for two reasons:
kdos-appbox links only libkbase, libktui, libkcolor and libkxdg, none of which speaks
Wayland. Speaking Wayland would add a client library and generated protocol code to a program
whose short dependency list is a deliberate property.The port is src/system/kdos-boxsock, built in the 42_graphics phase with libwayland-client.
These root services come from upstream ports, and KDOS starts each from /etc/init.d under
supervise like its own daemons. None of them is started by D-Bus activation: each port ships no
activation file, so a caller that came before the name was owned is refused rather than handed a
second, unsupervised copy that would then hold the name the supervised one needs.
| Init script | Service | What it is for |
|---|---|---|
40_elogind.sh |
elogind |
org.freedesktop.login1: every login registers here, KWin takes the seat through it, polkit asks it who is at the machine, and Plasma’s Shut Down, Restart and Suspend are its calls. Configured by /etc/elogind/logind.conf.d/50-kdos.conf and sleep.conf.d/50-kdos.conf. Run with SYSTEMD_REBOOT_TO_BOOT_LOADER_ENTRY=1, so login1’s RebootToBootLoaderEntry is the file kdos-bootctl try writes, /run/systemd/reboot-to-boot-loader-entry, and the logout screen can name the slot a restart boots |
41_polkitd.sh |
polkitd |
The authorisation every bus daemon here asks. What KDOS adds to the defaults is /etc/polkit-1/rules.d/50-kdos.rules |
44_accounts.sh |
accounts-daemon |
org.freedesktop.Accounts: the Users page, plasma-setup’s first account, and the avatar the login screen shows |
48_iio-sensor-proxy.sh |
iio-sensor-proxy |
net.hadess.SensorProxy, for screen rotation and ambient-light brightness. Started only where udev tagged a sensor it can drive |
55_tlp.sh |
tlp |
Not supervised: it applies TLP’s settings at boot and exits |
56_tlppd.sh |
tlp-pd |
Power profiles for PowerDevil and the battery applet, as org.freedesktop.UPower.PowerProfiles and net.hadess.PowerProfiles; each switch runs tlp power-saver\|balanced\|performance |
65_turnstiled.sh |
turnstiled |
Every login’s runtime directory and every user’s services under ksvc; the greeter cannot start without it |
85_crond.sh |
crond |
Users’ crontabs, from cronie. The system’s own scheduled jobs are snooze’s timers, and cronie reads no /etc/crontab |
elogind, accounts-daemon, iio-sensor-proxy and tlp-pd are restarted with the system bus
(--restart-with dbus). How each fits into the boot and the session is in
Boot and init and The session.
Two services that are not KDOS’s own and not root keep the login records musl cannot: utmpd
holds who is logged in now and wtmpd appends the history to /var/log/wtmp. Both come from the
utmps port, each run as utmps-utmpd or utmps-wtmpd behind s6-ipcserver (from s6) as the
utmp account, and 06_utmps.sh starts both under ksvc with the supervised names utmpd and
wtmpd. The service name for service and /etc/service.disabled is utmps, and disabling it
leaves who, w, users and last with nothing to report. What each socket and file holds, who
may write to them and why every reader is built against utmps is in
Login records.
A new daemon should meet all of these. Where an existing one does not, the exception is stated in
its section. The standing exception is rule 8: kdos-powerd finds kdos-bootctl through PATH,
kdos-settingsd finds service, loadkeys and iw, and kdos-sysupdated finds kdos and
kdos-bootctl.
/etc/init.d script through supervise, with no
D-Bus activation file./run, mode 0666, or its names on the system bus with a bus
policy that lets only root own them, and refuses to serve its real socket or the system bus
unless it is root (or, like kdos-energyd, cannot start at all without root’s access).wheel, by calling
kb_uid_allowed(), never a copy of that test, and answers err not permitted otherwise; what it
admits beyond that comes from elogind or polkit, never from a group. A bus method asks polkit
about the caller’s bus name, asynchronously, under an action id with its own .policy file.--fixture mode that decides and prints without acting, or, like kdos-powerd,
kdos-settingsd and kdos-sysupdated, a way to run its rules against a scratch tree.libkbase, libkcolor, libkproc and basu, and for kdos-packd libksig,
libkpkg and libkpack, which verify and read packs.Where the pieces go is fixed as well. The source and its recipe (kpkgbuild and build.sh) are
src/daemons/<name>/, the area that holds the six root daemons above and kdos-mdnsd
(kdos-boxsock is a session program, under src/system/); the port is named under the
src-daemons heading of script/phases/50_desktop/packages.txt, the only phase whose PORT_REPO
includes src/daemons; and its init script is fs/etc/init.d/<NN>_<service>.sh, whose number
places it after everything it needs, since rcS starts the scripts in numeric order. The six here
are 43, 46, 55, 56, 57 and 59: the bus daemons after polkitd (41), the others after the network;
kdos-mdnsd is 45, after Avahi.
rcS starts them and rcK stops themkdos-sysupdated driveskdos-sysupdated servesio.kdos.Power1, and the
pages kdos-settingsd answerskdos-boxsockPart IV — Programs, chapter 26. Previous: 25. kdos-appbox · Contents · Next: 27. kinstall