diff --git a/docs/skills/desktop-contract.md b/docs/skills/desktop-contract.md index 1642751f9..97bcc92c4 100644 --- a/docs/skills/desktop-contract.md +++ b/docs/skills/desktop-contract.md @@ -91,6 +91,18 @@ policy. Their payload matches the release and requires administrator authentication for all nine actions. The image contract requires both files; Utah does not layer a duplicate release install over Common's copy. +## NoNewPrivileges and SELinux domain transitions + +Hummingbird's hardened units can set `NoNewPrivileges=yes` where Fedora's do +not. Under NNP a domain transition needs an explicit `nnp_transition` +permission, and when the targeted policy lacks one the daemon silently runs in +`init_t` and fails on its first labelled write. avahi-daemon (0.9~rc4) is the +known case (#443): it exited 255 every start, so mDNS never worked. +`avahi-daemon.service.d/10-utah-selinux.conf` sets `NoNewPrivileges=no`; the +daemon still runs confined as `avahi_t`. Spot others on a booted VM with +`journalctl -b | grep nnp_transition` and `ps -eZ` (a daemon showing +`init_t` is the symptom). + ## Tolerating a non-zero exit in a unit file Tolerate an expected non-zero exit per command with the `ExecStart=-` prefix diff --git a/system_files/shared/usr/lib/systemd/system/avahi-daemon.service.d/10-utah-selinux.conf b/system_files/shared/usr/lib/systemd/system/avahi-daemon.service.d/10-utah-selinux.conf new file mode 100644 index 000000000..1810db6f3 --- /dev/null +++ b/system_files/shared/usr/lib/systemd/system/avahi-daemon.service.d/10-utah-selinux.conf @@ -0,0 +1,16 @@ +# Let avahi-daemon enter its SELinux domain (#443). +# +# Hummingbird's avahi (0.9~rc4) ships NoNewPrivileges=yes. Under NNP a domain +# transition needs an explicit nnp_transition permission, and the targeted +# policy (selinux-policy 45.20) grants none from init_t to avahi_t, so: +# +# avc: denied { nnp_transition } scontext=init_t tcontext=avahi_t +# avc: denied { create } comm="avahi-daemon" ... tcontext=avahi_var_run_t +# +# The daemon stays in init_t, cannot write its pid file, exits 255, and the +# socket gives up at the start limit: no mDNS, so `ssh host.local` fails with +# "Temporary failure in name resolution". Fedora's unit does not set NNP. +# avahi_t remains SELinux-confined; only the NNP flag is dropped. Remove this +# once the policy grants the transition (init_nnp_daemon_domain(avahi_t)). +[Service] +NoNewPrivileges=no diff --git a/tests/test_avahi_selinux.py b/tests/test_avahi_selinux.py new file mode 100644 index 000000000..432aab80d --- /dev/null +++ b/tests/test_avahi_selinux.py @@ -0,0 +1,28 @@ +"""avahi-daemon must be able to transition into avahi_t (#443). + +With Hummingbird's NoNewPrivileges=yes the targeted policy denies the +init_t -> avahi_t nnp_transition, the daemon exits 255 and mDNS never works. +Verified on a booted testing-20261001-41873b5: with the drop-in the daemon +runs as avahi_t with no AVC denials and *.local names resolve. +""" +import configparser +from pathlib import Path +import unittest + +DROPIN = Path(__file__).resolve().parents[1] / ( + "system_files/shared/usr/lib/systemd/system/avahi-daemon.service.d/" + "10-utah-selinux.conf") + + +class AvahiSelinuxTests(unittest.TestCase): + def test_drop_in_disables_no_new_privileges(self): + parser = configparser.ConfigParser(interpolation=None) + parser.read_string(DROPIN.read_text()) + self.assertEqual(parser["Service"]["NoNewPrivileges"], "no") + + def test_drop_in_names_its_removal_condition(self): + self.assertIn("nnp_transition", DROPIN.read_text()) + + +if __name__ == "__main__": + unittest.main()