Root and sudo
What runs as root, when seawall asks for sudo and what it never does.
What uses root
seawall runs as you. It uses root through sudo for named actions and in the root units init installs. Each action is a dry run first, except cloud capture, cloud drift and images check, which start a unit at once.
initwrites the log caps, adds you to the docker group, sets up ufw, unattended upgrades, the CrowdSec bouncer and the audit rules, and installs the root units below.host audit-reloadloads the audit rules from their files as init does.cloud driftreads the loaded audit rules and the compiled rules file (auditctl -l,/etc/audit/audit.rules) through sudo, to name each rule a drift is about. The config drift row reads only the counts seawall-facts-audit.service writes: rules loaded, rules in the files, and whether seawall's containerd socket watch is loaded, never a rule.host upgradeupgrades Docker and the CrowdSec bouncer.host fixapplies the Security tab's fixes, such as an account's expiry, sshd's drop-in, AppArmor, kernel settings and Docker's files.- A deploy of a stopped stack writes its compose into Portainer's data volume.
- The trial copy that
stack hardenandstack limitsrun is cut off from the network with iptables, and a root timer removes it if the run dies. - A run-as stack gets an account of its own, with no subuid or subgid range;
--drop-rangestakes back one an earlier run-as gave. - Restores,
stack moveand the rootless move copy files with their owners. stray rmreads another user's files as that user through sudo for its copy, and reclaiming disk space trims the journal.- The data backup hands its password file to the backup's user.
systemctl startruns the update check, the facts (at the end of any change; root's read first after ahost fix) and the config capture now.cloud syncruns the config capture with--dry-run(python3 -I), to list each file a sync would take, and leaves that list root's (0600,/run/privatecloud/expect) for the capture unit to hold the sync to.- The command centre runs
sudo -vin a sheet before an action that needs root. - Only
sudo -n true, to say whether sudo would ask. Nothing runs as root.
sudo asks for your password in the terminal or in a sheet in the command centre. seawall never sees it and writes no sudoers rules. Nothing scheduled needs a password. A new stack's volumes are handed to their user by a one-off run of the app's image with only CHOWN and no network.
seawall-facts-root runs as root every minute, sandboxed. It reads the firewall, the accounts (passwd, shadow and sshd -T for each), seawall's journal lines, the audit log, AppArmor and dpkg's file check. It writes /run/seawall-firewall, its audit heartbeat in /var/lib/seawall, the login-session record /var/lib/seawall/sessions and node-exporter's folder. Four ExecStartPre lines run first. Three start with + and run as full root, outside the unit's NoNewPrivileges, ProtectSystem and capability bounds. One makes /run/ufw.lock, one makes sshd's empty /run/sshd and one creates /var/lib/seawall/sessions. The fourth writes the audit heartbeat inside those bounds. Every minute it removes a dead trial's -A INPUT -i swt<n> -j DROP rule from iptables, and no other. seawall's other timers run as you, then copy their metrics file in as root.
seawall-facts-sudo starts with it. It holds CAP_SETUID, CAP_SETGID and CAP_AUDIT_WRITE and runs sudo -n -l -U for each account, hourly or when sudoers, passwd or group change, to list what sudo gives each one. It writes that to /run/seawall-firewall/sudo.txt.
seawall-facts-audit starts with it and holds CAP_AUDIT_CONTROL alone. It writes only counts of the audit rules, loaded and in the files, and whether seawall's socket watch is loaded.
seawall-facts-smart starts with it and holds CAP_SYS_ADMIN and CAP_SYS_RAWIO alone. At most every 10 minutes it runs smartctl --json -A -H -i once for each NVMe and SATA drive and writes each answer to /run/seawall-firewall, its serial number blanked. seawall reads each drive's health, wear, data written, spare and media errors from there.
seawall-audit-runtime runs auditctl as root once containerd is up and after each load of the audit rules, to watch containerd's socket. It holds CAP_AUDIT_CONTROL alone, with the filesystem read-only.
seawall-backup-egress is installed by the data backup's setup. It runs as root, without a sandbox, at each start of Docker. Its /bin/sh lines insert a rule into DOCKER-USER with iptables and ip6tables that drops what restic's network sends anywhere but the default route's interface. The interface name is checked (letters, digits, ., _ and -, 15 at most) before it is written into the unit.
/etc/update-motd.d/60-seawall runs as root at every login, from pam_motd. It drops to your account with runuser before it starts seawall, and is killed after 7 seconds.
seawall-docker-rebind runs as you, as part of docker.service. After each start of the engine it restarts the containers that bind-mount Docker's socket and started before the socket file now there (seawall container rebind), each said first in the journal. It never restarts Docker.
With unattended upgrades on ([host.auto_upgrades]), apt's hooks run /usr/local/libexec/seawall-upgrade-rollback as root. Before each install it records the version each Docker or bouncer package replaces in /var/lib/seawall/upgrades. After a Docker upgrade its unit waits for apt to finish, then 3 minutes for the engine. Still down, with apt idle, it installs the recorded versions through apt, within a patch step and once per version, holds them and raises DockerDownAfterUpgrade.