Skip to content

Commit 2002fb3

Browse files
committed
Test installed CUPS state directly
1 parent 96d5682 commit 2002fb3

3 files changed

Lines changed: 53 additions & 400 deletions

File tree

‎test/acceptance.d/cups-test.sh‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
6+
7+
for package in cups cups-filters system-config-printer cups-pk-helper; do
8+
pacman -Q "$package" >/dev/null 2>&1 || fail "printing packages are installed" "$package is missing"
9+
done
10+
pass "printing packages are installed"
11+
12+
! pacman -Q cups-pdf >/dev/null 2>&1 || fail "the root CUPS-PDF backend is absent"
13+
pass "the root CUPS-PDF backend is absent"
14+
15+
! pacman -Q cups-browsed >/dev/null 2>&1 || fail "automatic printer discovery is absent"
16+
! systemctl is-enabled --quiet cups-browsed.service 2>/dev/null ||
17+
fail "automatic printer discovery is not enabled"
18+
! systemctl is-active --quiet cups-browsed.service 2>/dev/null ||
19+
fail "automatic printer discovery is not running"
20+
! pgrep -x cups-browsed >/dev/null 2>&1 || fail "no cups-browsed process exists"
21+
pass "automatic printer discovery is not installed or running"
22+
23+
for path in \
24+
/etc/cups/cups-browsed.conf \
25+
/etc/cups/cups-browsed.conf.pacsave \
26+
/etc/cups/cups-browsed.conf.pacnew \
27+
/usr/bin/cups-browsed \
28+
/usr/lib/cups/backend/implicitclass \
29+
/usr/lib/systemd/system/cups-browsed.service \
30+
/etc/systemd/system/multi-user.target.wants/cups-browsed.service; do
31+
[[ ! -e $path && ! -L $path ]] ||
32+
fail "automatic printer discovery leaves no package files" "$path still exists"
33+
done
34+
pass "automatic printer discovery leaves no package files"
35+
36+
systemctl is-enabled --quiet cups.service || fail "CUPS is enabled"
37+
systemctl is-active --quiet cups.service || fail "CUPS is running"
38+
timeout 10 lpstat -r >/dev/null 2>&1 || fail "the CUPS scheduler answers"
39+
pass "CUPS is enabled, running, and answering"
40+
41+
policy_metadata=$(stat -c '%U:%G %a' /etc/cups/cups-files.conf)
42+
[[ $policy_metadata == "root:cups 640" ]] ||
43+
fail "the CUPS authorization policy is protected" "$policy_metadata"
44+
pass "the CUPS authorization policy is protected"
45+
46+
if lpinfo_output=$(LC_ALL=C timeout 10 lpinfo -v </dev/null 2>&1); then
47+
fail "the desktop user cannot administer CUPS without authentication"
48+
elif [[ $lpinfo_output != *"Forbidden"* ]]; then
49+
fail "CUPS explicitly denies unauthenticated desktop administration" "$lpinfo_output"
50+
fi
51+
pass "CUPS denies unauthenticated desktop administration"

‎test/acceptance.d/system-test.sh‎

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ verify_services() {
4747
local unit
4848

4949
for unit in \
50-
avahi-daemon.service cups.service docker.socket \
50+
avahi-daemon.service docker.socket \
5151
NetworkManager.service power-profiles-daemon.service sddm.service \
5252
systemd-resolved.service ufw.service; do
5353
systemctl is-enabled --quiet "$unit" || fail "core system services are enabled" "$unit is not enabled"
@@ -64,46 +64,6 @@ verify_services() {
6464
pass "user audio services are running"
6565
}
6666

67-
verify_printing_security() {
68-
local lpinfo_output path
69-
70-
! pacman -Q cups-pdf >/dev/null 2>&1 || fail "CUPS-PDF is absent"
71-
pass "the root CUPS-PDF backend is not installed"
72-
73-
# Automatic discovery is temporarily out of the default install: a daemon that
74-
# turns anything advertising itself on the network into a print queue is more
75-
# exposure than the convenience is worth while it is reworked. CUPS itself
76-
# stays, so what a stock machine proves here is that printing runs and that
77-
# the desktop user still cannot administer it without authenticating.
78-
! pacman -Q cups-browsed >/dev/null 2>&1 || fail "automatic printer discovery is not installed"
79-
! systemctl is-enabled --quiet cups-browsed.service 2>/dev/null ||
80-
fail "no discovery service is enabled"
81-
! systemctl is-active --quiet cups-browsed.service 2>/dev/null ||
82-
fail "no discovery service is running"
83-
84-
for path in \
85-
/etc/cups/cups-browsed.conf \
86-
/etc/cups/cups-browsed.conf.pacsave \
87-
/usr/bin/cups-browsed \
88-
/usr/lib/cups/backend/implicitclass \
89-
/usr/lib/systemd/system/cups-browsed.service \
90-
/etc/systemd/system/multi-user.target.wants/cups-browsed.service; do
91-
[[ ! -e $path && ! -L $path ]] ||
92-
fail "automatic printer discovery leaves no installed package files" "$path still exists"
93-
done
94-
pass "automatic printer discovery is absent from a stock install"
95-
96-
systemctl is-active --quiet cups.service || fail "CUPS is running"
97-
98-
if lpinfo_output=$(LC_ALL=C timeout 10 lpinfo -v </dev/null 2>&1); then
99-
fail "the desktop user cannot administer CUPS without authentication"
100-
elif [[ $lpinfo_output != *"Forbidden"* ]]; then
101-
fail "CUPS explicitly denies unauthenticated desktop administration" "$lpinfo_output"
102-
fi
103-
104-
pass "CUPS runs with passwordless desktop administration still denied"
105-
}
106-
10767
verify_runtime_tools() {
10868
# Docker access is intentionally NOT granted to the desktop user: the docker
10969
# group is root-equivalent, so a rogue process running as the user could
@@ -147,7 +107,7 @@ verify_user_setup() {
147107
pass "Omarchy user state and shell configuration exist"
148108
}
149109

150-
for check in verify_core_packages verify_defaults verify_services verify_printing_security verify_runtime_tools verify_user_setup; do
110+
for check in verify_core_packages verify_defaults verify_services verify_runtime_tools verify_user_setup; do
151111
if ! ("$check"); then
152112
status=1
153113
fi

0 commit comments

Comments
 (0)