357.7. kdos-settingsd-0.1.0
hostname1, timedate1 and locale1 on the system bus, over the files KDOS keeps
| Version | 0.1.0, release 1 |
| Source tree | src/daemons/kdos-settingsd/ |
| Phase | 50_desktop (Desktop), 81 of 92 in build order |
| Licence | MIT |
| Homepage | https://github.com/kunaldawn/kdos |
| Build time | 0.1 SBU |
| Installed size | 135.7 KiB in 5 files |
| Recipe | src/daemons/kdos-settingsd/kpkgbuild |
About
kdos-settingsd is the root daemon that serves org.freedesktop.hostname1, org.freedesktop.timedate1 and org.freedesktop.locale1 on the system bus: the three interfaces systemd defined for a machine’s name, clock, time zone, locale and keyboards, which KDE calls instead of writing files. The Date & Time page of System Settings saves through timedate1 and nothing else; plasma-setup uses all three; the SDDM greeter runs kwin_wayland --locale1, which takes the login screen’s keyboard layout from locale1 and follows it when it changes; startplasma copies that layout into each session; the system monitor’s OS sensors read hostname1. KDOS has no systemd, so this daemon answers for them, with every method and property systemd’s three interfaces have except hostname1’s Describe, which nothing on the system calls.
Each setting is kept in the file the rest of the machine already reads:
| Setting | Kept in |
|---|---|
| static hostname | /etc/hostname, set at boot by 05_hostname.sh, with the 127.0.1.1 line of /etc/hosts naming whatever the kernel carries, 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 | the /etc/localtime link, with export TZ=':/etc/localtime' in /etc/profile.d/20-timezone.sh |
| Wi-Fi country, which follows the zone | /etc/modprobe.d/kdos-regdom.conf |
| network time on or off | the /etc/service.disabled/chrony marker |
| locale | /etc/locale.conf, which SDDM puts into every session |
| console keymap | /etc/keymap, loaded by kdos-getty, with a copy in /boot/efi/EFI/kdos/keymap for the initramfs’s passphrase prompt |
| graphical keyboard layout | /etc/kdos/xkb.conf, never under /etc/X11, with the same layout in /etc/xdg/kxkbrc |
Every method checks its arguments, then asks polkit under systemd’s own action ids, then writes; the pattern the root daemons share is in The shape they share.
The port is KDOS’s own C with no upstream source. build.sh compiles the daemon with the sources of libkbase and links basu and nothing else: no glib and no Qt, because everything a root daemon links is code running as root.
Why it is in KDOS
The comment above it in script/phases/50_desktop/packages.txt:
hostname1, timedate1 and locale1 on the system bus, written to the files KDOS keeps, for System Settings, the greeter and plasma-setup.
Sources
None: the port builds from its own directory, /kdos/src/daemons/kdos-settingsd.
Dependencies
Depends on: basu, dbus, polkit.
Required by (1): kde-plasma.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/50_desktop/phase.env && kpkg install kdos-settingsd'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/daemons/kdos-settingsd.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/kdos-settingsd
SRC=$SRC_ROOT/kdos-settingsd-0.1.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
LIBS="$PORT_SRC/../../libs"
gcc $CFLAGS -O2 -std=gnu11 -D_GNU_SOURCE -Wall -Wextra \
$(pkg-config --cflags basu) -I"$LIBS/libkbase" \
-o kdos-settingsd "$PORT_SRC"/*.c "$LIBS"/libkbase/*.c \
$(pkg-config --libs basu) $LDFLAGS
install -Dm755 kdos-settingsd "$PKG/usr/sbin/kdos-settingsd"
install -Dm644 "$PORT_SRC/kdos-settingsd.conf" \
"$PKG/usr/share/dbus-1/system.d/kdos-settingsd.conf"
for _i in hostname1 timedate1 locale1; do
install -Dm644 "$PORT_SRC/org.freedesktop.$_i.policy" \
"$PKG/usr/share/polkit-1/actions/org.freedesktop.$_i.policy"
done
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/kdos-settingsd, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf kdos-settingsd-0.1.0-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/kdos-settingsd, and runs the triggers its paths call for.
Other files in the port directory, read by build.sh: bus.h, hostname.c, kdos-settingsd.conf, locale.c, main.c, org.freedesktop.hostname1.policy, org.freedesktop.locale1.policy, org.freedesktop.timedate1.policy, settingsd.h, store.c, timedate.c.
Contents
Installed programs: kdos-settingsd.
Notes
- Three kinds of file beside the binary, and no activation file. The D-Bus policy
/usr/share/dbus-1/system.d/kdos-settingsd.conflets root alone own the three names and lets anyone call them; dbus reads it, which is why dbus is independs. The polkit actions are three.policyfiles under/usr/share/polkit-1/actions/with systemd’s ids, because plasma-setup’s rule and the Date & Time page name them; without polkit every call from anyone but root is refused.set-timeimpliesset-timezoneandset-ntp, and those two are allowed to the active local session without a password. The Date & Time page authorisesset-timebefore it saves anything, so it asks for the password on every Apply, a zone-only one included, and that one prompt covers its three calls; hostname1’sget-product-uuidandget-hardware-serialguard the two values that identify the machine, which the kernel makes root’s alone. The daemon is started by/etc/init.d/43_settingsd.shunderksvc, after polkitd and before the display manager; a supervised daemon ships no activation file, or an early caller would make the bus start a second, unsupervised copy. - What it runs, and what it reads.
service start|stop chronyfrom kdos-tools turns network time on and off now,loadkeysfrom kbd loads a new console keymap, andiwfrom iw applies a new Wi-Fi country, or the world domain00for a zone with none, so the running radio never keeps the previous zone’s country; each is an argument vector found throughPATHand skipped when it is missing, so none is a dependency.CanNTPis true when chrony’s init script andchronydfrom chrony are both there. A zone is checked against the zone tree of tzdata, a console keymap against kbd’s keymaps and an XKB layout against xkeyboard-config’srules/evdev.lst, each where it is installed. The hardware properties are DMI’s files under/sys/class/dmi/id, with a vendor’s placeholder for “unset” read as no value; the chassis is machine-info’s, elsevmin a virtual machine, else DMI’s, ACPI’s or the device tree’s, in systemd-hostnamed’s order. - A kernel with no name gets the default.
05_hostname.shnames the kernel from/etc/hostnameand leaves it(none)when the file is gone, which is whatSetStaticHostname("")does to it; the daemon gives such a kernel the default name (DEFAULT_HOSTNAME=in os-release, elsekdos) when it starts, as systemd’s init would. - An empty layout follows the console. The installer writes the console keymap alone and the shipped
xkb.confleavesXKBLAYOUTempty, so locale1’sX11Layoutis then the layout nearest/etc/keymap, through a table of the console names whose first two letters are not their XKB layout, 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. - Every layout change rewrites
/etc/xdg/kxkbrc. KWin and the lock screen read the kxkbrc cascade before theXKB_DEFAULT_*environment startplasma builds fromxkb.conf, so a systemkxkbrcnaming a layout outranks locale1 in every session of an account with nokxkbrcof its own. The installer writes the file from its Keyboard page; on an OEM machine that is the preparer’s layout, and plasma-setup’s Keyboard page sets the owner’s throughSetX11Keyboard. SoSetX11Keyboard, andSetVConsoleKeyboardwhenconvertchanges the layout, write the file whole in the installer’s shape ([Layout],LayoutList,VariantList,ModelandOptionswithResetOldOptions=truewhen set,Use=true), and an empty layout removes it, as the installer does when no layout was named. Without it the session and the lock screen type the installer’s layout while the login screen types the owner’s, and a password with keys the two lay out differently cannot unlock the screen. - The console keymap is copied to the ESP. The initramfs types the disk passphrase before any root is open, so it loads the map named in
/boot/efi/EFI/kdos/keymap. Every keymap the daemon writes is written there too, an empty one removes it, and at start the copy is rewritten from/etc/keymapwhen it differs or is missing; only where/boot/efi/EFI/kdosexists. The write iskdos-bootctl’s: a temporary file, itsfsync, the rename, the file’sfsyncand asyncfs, without anfchmod, which vfat refuses. Without it a passphrase set on any layout but US cannot be typed at boot. - The console map nearest a layout is
<layout>-latin1before<layout>. kbd’s barede,dk,no,fr,sgandfr_CHare the 7-bit ISO-646 maps, with no ü ö ä ß, and its bareptis the OLPC laptop’s, soconvertnames the 8-bit maps in its table and takes the bare name last. - The RTC is UTC. The kernel reads the RTC as UTC at boot and writes it back every eleven minutes while chrony has the clock synchronised, so
LocalRTCis false andSetLocalRTC(true)is refused. A clock set by hand is not synchronised, soSetTimewrites the RTC itself. /etc/locale.confis bareNAME=valuelines. SDDM splits each line at=and passes the field after the first one on verbatim, so a quoted value would reach the session with its quotes and a comment holding an=would become a variable; the daemon writes neither, andSetLocalewrites onlyC,C.UTF-8,POSIXorll[_CC][.UTF-8|.utf8][@modifier]whose language has a file in<share>/i18n/locales/muslor a directory in<share>/locale, so a typo cannot reach every session. It does not demand a musl-locales file for the whole name: plasma-setup’s language page sendsLANG=<ll_CC>.UTF-8for every language Plasma has translations for, and a refusal there leaves the system language English with only a warning in its log.- The test tree.
KDOS_SETTINGSD_ETC,KDOS_SETTINGSD_SHAREandKDOS_SETTINGSD_SYSreplace/etc,/usr/shareand/sys, andKDOS_SETTINGSD_ESPreplaces/boot/efi. The first also keeps the daemon off the machine it runs on: with it set the kernel hostname, the clock and the RTC are left alone, and no ESP is written unlessKDOS_SETTINGSD_ESPnames one.testing/selftest.shdrives every method that way, over a private bus, against a polkit stand-in (testing/fixtures/settingsd/).