Test installed CUPS state directly
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
||||
|
||||
for package in cups cups-filters system-config-printer cups-pk-helper; do
|
||||
pacman -Q "$package" >/dev/null 2>&1 || fail "printing packages are installed" "$package is missing"
|
||||
done
|
||||
pass "printing packages are installed"
|
||||
|
||||
! pacman -Q cups-pdf >/dev/null 2>&1 || fail "the root CUPS-PDF backend is absent"
|
||||
pass "the root CUPS-PDF backend is absent"
|
||||
|
||||
! pacman -Q cups-browsed >/dev/null 2>&1 || fail "automatic printer discovery is absent"
|
||||
! systemctl is-enabled --quiet cups-browsed.service 2>/dev/null ||
|
||||
fail "automatic printer discovery is not enabled"
|
||||
! systemctl is-active --quiet cups-browsed.service 2>/dev/null ||
|
||||
fail "automatic printer discovery is not running"
|
||||
! pgrep -x cups-browsed >/dev/null 2>&1 || fail "no cups-browsed process exists"
|
||||
pass "automatic printer discovery is not installed or running"
|
||||
|
||||
for path in \
|
||||
/etc/cups/cups-browsed.conf \
|
||||
/etc/cups/cups-browsed.conf.pacsave \
|
||||
/etc/cups/cups-browsed.conf.pacnew \
|
||||
/usr/bin/cups-browsed \
|
||||
/usr/lib/cups/backend/implicitclass \
|
||||
/usr/lib/systemd/system/cups-browsed.service \
|
||||
/etc/systemd/system/multi-user.target.wants/cups-browsed.service; do
|
||||
[[ ! -e $path && ! -L $path ]] ||
|
||||
fail "automatic printer discovery leaves no package files" "$path still exists"
|
||||
done
|
||||
pass "automatic printer discovery leaves no package files"
|
||||
|
||||
systemctl is-enabled --quiet cups.service || fail "CUPS is enabled"
|
||||
systemctl is-active --quiet cups.service || fail "CUPS is running"
|
||||
timeout 10 lpstat -r >/dev/null 2>&1 || fail "the CUPS scheduler answers"
|
||||
pass "CUPS is enabled, running, and answering"
|
||||
|
||||
policy_metadata=$(stat -c '%U:%G %a' /etc/cups/cups-files.conf)
|
||||
[[ $policy_metadata == "root:cups 640" ]] ||
|
||||
fail "the CUPS authorization policy is protected" "$policy_metadata"
|
||||
pass "the CUPS authorization policy is protected"
|
||||
|
||||
if lpinfo_output=$(LC_ALL=C timeout 10 lpinfo -v </dev/null 2>&1); then
|
||||
fail "the desktop user cannot administer CUPS without authentication"
|
||||
elif [[ $lpinfo_output != *"Forbidden"* ]]; then
|
||||
fail "CUPS explicitly denies unauthenticated desktop administration" "$lpinfo_output"
|
||||
fi
|
||||
pass "CUPS denies unauthenticated desktop administration"
|
||||
@@ -47,7 +47,7 @@ verify_services() {
|
||||
local unit
|
||||
|
||||
for unit in \
|
||||
avahi-daemon.service cups.service docker.socket \
|
||||
avahi-daemon.service docker.socket \
|
||||
NetworkManager.service power-profiles-daemon.service sddm.service \
|
||||
systemd-resolved.service ufw.service; do
|
||||
systemctl is-enabled --quiet "$unit" || fail "core system services are enabled" "$unit is not enabled"
|
||||
@@ -64,46 +64,6 @@ verify_services() {
|
||||
pass "user audio services are running"
|
||||
}
|
||||
|
||||
verify_printing_security() {
|
||||
local lpinfo_output path
|
||||
|
||||
! pacman -Q cups-pdf >/dev/null 2>&1 || fail "CUPS-PDF is absent"
|
||||
pass "the root CUPS-PDF backend is not installed"
|
||||
|
||||
# Automatic discovery is temporarily out of the default install: a daemon that
|
||||
# turns anything advertising itself on the network into a print queue is more
|
||||
# exposure than the convenience is worth while it is reworked. CUPS itself
|
||||
# stays, so what a stock machine proves here is that printing runs and that
|
||||
# the desktop user still cannot administer it without authenticating.
|
||||
! pacman -Q cups-browsed >/dev/null 2>&1 || fail "automatic printer discovery is not installed"
|
||||
! systemctl is-enabled --quiet cups-browsed.service 2>/dev/null ||
|
||||
fail "no discovery service is enabled"
|
||||
! systemctl is-active --quiet cups-browsed.service 2>/dev/null ||
|
||||
fail "no discovery service is running"
|
||||
|
||||
for path in \
|
||||
/etc/cups/cups-browsed.conf \
|
||||
/etc/cups/cups-browsed.conf.pacsave \
|
||||
/usr/bin/cups-browsed \
|
||||
/usr/lib/cups/backend/implicitclass \
|
||||
/usr/lib/systemd/system/cups-browsed.service \
|
||||
/etc/systemd/system/multi-user.target.wants/cups-browsed.service; do
|
||||
[[ ! -e $path && ! -L $path ]] ||
|
||||
fail "automatic printer discovery leaves no installed package files" "$path still exists"
|
||||
done
|
||||
pass "automatic printer discovery is absent from a stock install"
|
||||
|
||||
systemctl is-active --quiet cups.service || fail "CUPS is running"
|
||||
|
||||
if lpinfo_output=$(LC_ALL=C timeout 10 lpinfo -v </dev/null 2>&1); then
|
||||
fail "the desktop user cannot administer CUPS without authentication"
|
||||
elif [[ $lpinfo_output != *"Forbidden"* ]]; then
|
||||
fail "CUPS explicitly denies unauthenticated desktop administration" "$lpinfo_output"
|
||||
fi
|
||||
|
||||
pass "CUPS runs with passwordless desktop administration still denied"
|
||||
}
|
||||
|
||||
verify_runtime_tools() {
|
||||
# Docker access is intentionally NOT granted to the desktop user: the docker
|
||||
# group is root-equivalent, so a rogue process running as the user could
|
||||
@@ -147,7 +107,7 @@ verify_user_setup() {
|
||||
pass "Omarchy user state and shell configuration exist"
|
||||
}
|
||||
|
||||
for check in verify_core_packages verify_defaults verify_services verify_printing_security verify_runtime_tools verify_user_setup; do
|
||||
for check in verify_core_packages verify_defaults verify_services verify_runtime_tools verify_user_setup; do
|
||||
if ! ("$check"); then
|
||||
status=1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user