Skip to content

Commit

Permalink
feat: profiles and integration tests improvments.
Browse files Browse the repository at this point in the history
  • Loading branch information
roddhjav committed Nov 13, 2024
1 parent b4bcb2f commit 3538d67
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 19 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
build:
runs-on: ${{ matrix.os }}
needs: check
strategy:
matrix:
os:
Expand Down Expand Up @@ -93,14 +94,21 @@ jobs:
sudo apt-get install -y \
apparmor-profiles apparmor-utils \
bats bats-support
bash tests/requirements.sh
- name: Install apparmor.d
run: |
sudo install -Dm0644 tests/github.local /etc/apparmor.d/tunables/global.d/github.local
sudo dpkg --install .pkg/apparmor.d_*_amd64.deb || true
sudo systemctl restart apparmor.service
- name: Github Action specific requirements
run: |
bash tests/requirements.sh
sudo systemctl restart ModemManager NetworkManager
sudo systemctl restart polkit snapd
sudo systemctl restart systemd-hostnamed systemd-logind
sudo systemctl restart packagekit udisks2
- name: Run the bats integration tests
run: |
make bats
Expand Down
9 changes: 5 additions & 4 deletions apparmor.d/abstractions/app/sudo
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@

network netlink raw, # PAM

dbus send bus=system path=/org/freedesktop/login1
interface=org.freedesktop.logi1.Manager
member=CreateSession
peer=(name=org.freedesktop.login1, label=systemd-logind),
unix bind type=stream addr=@@{hex15}/bus/sudo/system,
unix bind type=stream addr=@@{hex16}/bus/sudo/system,

#aa:dbus talk bus=system name=org.freedesktop.home1 label=systemd-homed
#aa:dbus talk bus=system name=org.freedesktop.login1 label=systemd-logind

dbus (send receive) bus=session path=/org/freedesktop/systemd1
interface=org.freedesktop.systemd.Manager
Expand Down
2 changes: 2 additions & 0 deletions apparmor.d/abstractions/attached/base
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

abi <abi/4.0>,

@{att}/@{run}/systemd/journal/dev-log w,
@{att}/@{run}/systemd/journal/socket w,

deny /apparmor/.null rw,
deny @{att}/apparmor/.null rw,

include if exists <abstractions/attached/base.d>
Expand Down
2 changes: 1 addition & 1 deletion apparmor.d/groups/bus/dbus-system
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ profile dbus-system flags=(attach_disconnected) {

ptrace (read) peer=@{p_systemd},

#aa:dbus own bus=system name=org.freedesktop.DBus
#aa:dbus own bus=system name=org.freedesktop.DBus path=/{,org/freedesktop/DBus}

@{exec_path} mrix,

Expand Down
5 changes: 3 additions & 2 deletions apparmor.d/groups/network/NetworkManager
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ profile NetworkManager @{exec_path} flags=(attach_disconnected) {
@{run}/udev/data/+rfkill:* r,
@{run}/udev/data/n@{int} r,

@{sys}/devices/**/uevent r,
@{sys}/devices/virtual/net/{,**} r,
@{sys}/devices/@{pci}/net/*/{,**} r,
@{sys}/devices/@{pci}/usb@{int}/**/net/{,**} r,
@{sys}/devices/**/@{uuid}/net/*/{,**} r,
@{sys}/devices/**/uevent r,
@{sys}/devices/virtual/net/{,**} r,

@{PROC}/@{pids}/stat r,
@{PROC}/1/environ r,
Expand Down
8 changes: 7 additions & 1 deletion apparmor.d/groups/network/netplan.script
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ profile netplan.script @{exec_path} flags=(attach_disconnected) {
include <abstractions/nameservice-strict>
include <abstractions/python>

network netlink raw,

@{exec_path} mr,

@{lib}/netplan/generate rix,
Expand All @@ -25,12 +27,16 @@ profile netplan.script @{exec_path} flags=(attach_disconnected) {
@{run}/NetworkManager/conf.d/10-globally-managed-devices.conf{,.@{rand6}} rw,
@{run}/NetworkManager/system-connections/ rw,
@{run}/NetworkManager/system-connections/netplan-*.nmconnection{,.@{rand6}} rw,
@{run}/systemd/network/ r,
@{run}/systemd/network/@{int}-netplan{,-*}.{network,link}{,.@{rand6}} rw,
@{run}/systemd/system/ r,
@{run}/systemd/system/netplan-* rw,
@{run}/systemd/system/systemd-networkd-wait-online.service.d/ r,
@{run}/systemd/system/systemd-networkd-wait-online.service.d/10-netplan.conf w,
@{run}/systemd/system/systemd-networkd.service.wants/ rw,
@{run}/systemd/system/systemd-networkd.service.wants/netplan-*.service rw,
@{run}/udev/rules.d/ r,
@{run}/udev/rules.d/90-netplan.rules{,.@{rand6}} rw,
@{run}/udev/rules.d/@{int}-netplan{,-*}.rules{,.@{rand6}} rw,

profile udevadm {
include <abstractions/base>
Expand Down
1 change: 1 addition & 0 deletions apparmor.d/groups/ssh/ssh-keygen
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ profile ssh-keygen @{exec_path} {
owner @{HOME}/@{XDG_SSH_DIR}/*_*{,.pub} rw,

/tmp/snapd@{int}/*_*{,.pub} w,
/tmp/snapd@{int}/*.key{,.pub} w,

/dev/tty@{int} rw,
/dev/ttyS@{int} rw,
Expand Down
1 change: 1 addition & 0 deletions apparmor.d/groups/systemd/hostnamectl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include <tunables/global>
profile hostnamectl @{exec_path} {
include <abstractions/base>
include <abstractions/bus-system>
include <abstractions/bus/org.freedesktop.systemd1>
include <abstractions/consoles>

capability net_admin,
Expand Down
3 changes: 3 additions & 0 deletions apparmor.d/groups/systemd/systemd-homed
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ profile systemd-homed @{exec_path} flags=(attach_disconnected) {
mount options=(rw, rslave) -> @{run}/,
mount /dev/dm-@{int} -> @{run}/systemd/user-home-mount/,

unix bind type=stream addr=@@{hex16}/bus/systemd-homed/system,

#aa:dbus own bus=system name=org.freedesktop.home1

@{exec_path} mr,
Expand All @@ -61,6 +63,7 @@ profile systemd-homed @{exec_path} flags=(attach_disconnected) {
@{run}/systemd/home/{,**} rw,
@{run}/systemd/userdb/io.systemd.home r,
@{run}/systemd/user-home-mount/{,**} rw,
@{run}/systemd/notify w,

@{sys}/bus/ r,
@{sys}/fs/ r,
Expand Down
2 changes: 2 additions & 0 deletions apparmor.d/profiles-m-r/needrestart-apt-pinvoke
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ profile needrestart-apt-pinvoke @{exec_path} {
include <abstractions/bus/org.freedesktop.login1>
include <abstractions/consoles>

capability dac_read_search,

@{exec_path} mr,

@{sh_path} rix,
Expand Down
2 changes: 0 additions & 2 deletions apparmor.d/profiles-s-z/sudo
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ profile sudo @{exec_path} flags=(attach_disconnected) {
signal (send) set=(winch) peer=pacman,
signal (send) set=(winch, hup, term) peer=rpm,

unix bind type=stream addr=@@{hex16}/bus/sudo/system/,

@{bin}/@{shells} rUx,
@{lib}/** PUx,
/opt/*/** PUx,
Expand Down
1 change: 1 addition & 0 deletions tests/bats/homectl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ load common

setup_file() {
aa_setup
skip
}

# bats test_tags=homectl
Expand Down
1 change: 0 additions & 1 deletion tests/bats/snap.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ load common

setup_file() {
aa_setup
skip
}

# bats test_tags=snap
Expand Down
6 changes: 0 additions & 6 deletions tests/bats/systemd-id128.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ setup_file() {
aa_check
}

# bats test_tags=systemd-id128
@test "systemd-id128: Print the identifier of the current service invocation (this is available in systemd services)" {
systemd-id128 invocation-id
aa_check
}

# bats test_tags=systemd-id128
@test "systemd-id128: Generate a new random identifier and print it as a UUID (five groups of digits separated by hyphens)" {
systemd-id128 new --uuid
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ arch)
;;
debian | ubuntu | whonix)
sudo apt-get install -y \
cpuid dfc systemd-userdbd
cpuid dfc systemd-userdbd systemd-homed tlp
;;
opensuse*)
;;
Expand Down

0 comments on commit 3538d67

Please sign in to comment.