Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/skills/desktop-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions tests/test_avahi_selinux.py
Original file line number Diff line number Diff line change
@@ -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()
Loading