224 lines
6.7 KiB
Text
224 lines
6.7 KiB
Text
# apparmor.d - Full set of apparmor profiles
|
|
# Copyright (C) 2023-2024 Alexandre Pujol <alexandre@pujol.io>
|
|
# Copyright (C) 2023 monsieuremre <https://github.com/monsieuremre>
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
# Profile for systemd (PID 1), it does not specify an attachment path because
|
|
# it is directly loaded by systemd.
|
|
|
|
# Only use this profile with a fully configured system. Otherwise it **WILL**
|
|
# break your computer. See https://apparmor.pujol.io/full-system-policy/.
|
|
|
|
# Distributions and other programs can add rules in the usr/systemd.d directory
|
|
|
|
abi <abi/3.0>,
|
|
|
|
include <tunables/global>
|
|
|
|
profile systemd flags=(attach_disconnected,mediate_deleted) {
|
|
include <abstractions/base>
|
|
include <abstractions/authentication>
|
|
include <abstractions/bus-system>
|
|
include <abstractions/nameservice-strict>
|
|
include <abstractions/wutmp>
|
|
|
|
capability audit_control,
|
|
capability audit_read,
|
|
capability audit_write,
|
|
capability bpf,
|
|
capability chown,
|
|
capability dac_override,
|
|
capability dac_read_search,
|
|
capability fowner,
|
|
capability fsetid,
|
|
capability kill,
|
|
capability mknod,
|
|
capability net_admin,
|
|
capability perfmon,
|
|
capability setfcap,
|
|
capability setgid,
|
|
capability setpcap,
|
|
capability setuid,
|
|
capability sys_admin,
|
|
capability sys_chroot,
|
|
capability sys_ptrace,
|
|
capability sys_resource,
|
|
capability sys_time,
|
|
capability sys_tty_config,
|
|
|
|
network inet dgram,
|
|
network inet stream,
|
|
network inet6 dgram,
|
|
network inet6 stream,
|
|
network netlink raw,
|
|
|
|
mount -> @{run}/systemd/incoming/,
|
|
mount -> @{run}/systemd/mount-rootfs/{,**},
|
|
mount -> @{run}/systemd/unit-root/{,**},
|
|
mount -> @{sys}/fs/fuse/connections/,
|
|
mount -> @{sys}/kernel/config/,
|
|
mount -> @{sys}/kernel/debug/,
|
|
mount -> @{sys}/kernel/tracing/,
|
|
mount -> /,
|
|
mount -> /dev/,
|
|
mount -> /dev/hugepages/,
|
|
mount -> /dev/mqueue/,
|
|
mount -> /efi/,
|
|
mount -> /tmp/,
|
|
mount @{run}/systemd/namespace-@{rand6}/ -> @{run}/systemd/mount-rootfs/proc/,
|
|
mount @{run}/systemd/namespace-@{rand6}/dev/ -> @{run}/systemd/mount-rootfs/dev/,
|
|
mount /dev/*/ -> @{run}/systemd/namespace-@{rand6}/dev/*/,
|
|
mount /dev/ptmx -> @{run}/systemd/namespace-@{rand6}/dev/ptmx,
|
|
mount /dev/tty -> @{run}/systemd/namespace-@{rand6}/dev/tty,
|
|
mount /tmp/systemd-private-*/tmp/ -> @{run}/systemd/mount-rootfs/tmp/,
|
|
mount fstype=proc proc -> @{run}/systemd/namespace-@{rand6}/,
|
|
mount fstype=sysfs sysfs -> @{run}/systemd/namespace-@{rand6}/,
|
|
mount fstype=tmpfs tmpfs -> @{run}/systemd/namespace-@{rand6}/dev/,
|
|
mount fstype=tmpfs tmpfs -> /dev/shm/,
|
|
mount fstype=ramfs ramfs -> /dev/shm/,
|
|
|
|
umount /,
|
|
umount /dev/shm/,
|
|
umount @{run}/systemd/mount-rootfs/{,**},
|
|
umount @{run}/systemd/namespace-@{rand6}/{,**},
|
|
umount @{run}/systemd/unit-root/{,**},
|
|
|
|
pivot_root oldroot=@{run}/systemd/mount-rootfs/ @{run}/systemd/mount-rootfs/,
|
|
pivot_root oldroot=@{run}/systemd/unit-root/ @{run}/systemd/unit-root/,
|
|
|
|
change_profile,
|
|
|
|
signal (receive) set=(term, hup, cont),
|
|
signal (send),
|
|
|
|
ptrace (read, readby),
|
|
|
|
unix (send) type=dgram,
|
|
|
|
# dbus: own bus=system name=org.freedesktop.systemd1
|
|
|
|
@{bin}/systemctl rix,
|
|
@{bin}/mount rix,
|
|
|
|
@{lib}/systemd/systemd-executor rix,
|
|
@{lib}/systemd/systemd rpx -> systemd-user,
|
|
|
|
@{bin}/ldconfig rPx -> systemd-service,
|
|
@{bin}/mandb rPx -> systemd-service,
|
|
@{bin}/savelog rPx -> systemd-service,
|
|
@{coreutils_path} rPx -> systemd-service,
|
|
@{sh_path} rPx -> systemd-service,
|
|
|
|
@{bin}/** PUx,
|
|
@{lib}/** PUx,
|
|
audit /etc/cron.*/* PUx,
|
|
audit /etc/init.d/* PUx,
|
|
audit /usr/share/*/* PUx,
|
|
|
|
@{lib}/systemd/systemd-oomd rPx -> systemd//&systemd-oomd,
|
|
@{lib}/systemd/systemd-timesyncd rPx -> systemd//&systemd-timesyncd,
|
|
|
|
/ r,
|
|
/boot/ r,
|
|
/boot/efi/ r,
|
|
/efi/ r,
|
|
/tmp/ r,
|
|
/usr/ r,
|
|
/var/lib/*/ r,
|
|
/var/tmp/ r,
|
|
@{lib}/ r,
|
|
|
|
/etc/binfmt.d/{,**} r,
|
|
/etc/conf.d/{,**} r,
|
|
/etc/credstore.encrypted/{,**} r,
|
|
/etc/credstore/{,**} r,
|
|
/etc/environment r,
|
|
/etc/environment.d/{,**} r,
|
|
/etc/machine-id r,
|
|
/etc/modules-load.d/{,**} r,
|
|
/etc/systemd/{,**} r,
|
|
/etc/udev/hwdb.d/{,**} r,
|
|
|
|
/var/lib/systemd/{,**} rw,
|
|
owner /var/tmp/systemd-private-*/{,**} rw,
|
|
|
|
/tmp/namespace-dev-@{rand6}/{,**} rw,
|
|
/tmp/systemd-private-*/{,**} rw,
|
|
|
|
@{run}/ r,
|
|
@{run}/credentials/{,**} rw,
|
|
@{run}/dbus/system_bus_socket rw,
|
|
@{run}/spice-vdagentd/spice-vdagent-sock rw,
|
|
@{run}/systemd/{,**} rw,
|
|
@{run}/udev/control rw,
|
|
@{run}/udev/data/* r,
|
|
@{run}/udev/tags/systemd/ r,
|
|
@{run}/user/@{uid}/{,**} rwlk,
|
|
owner @{run}/* rw,
|
|
owner @{run}/*/ rw,
|
|
owner @{run}/*/* rw,
|
|
|
|
@{sys}/bus/ r,
|
|
@{sys}/class/ r,
|
|
@{sys}/class/power_supply/ r,
|
|
@{sys}/class/sound/ r,
|
|
@{sys}/devices/@{pci}/** r,
|
|
@{sys}/devices/**/net/** r,
|
|
@{sys}/devices/**/uevent r,
|
|
@{sys}/devices/virtual/dmi/id/{sys,board,bios}_vendor r,
|
|
@{sys}/devices/virtual/dmi/id/product_name r,
|
|
@{sys}/devices/virtual/dmi/id/product_version r,
|
|
@{sys}/devices/virtual/tty/console/active r,
|
|
@{sys}/fs/fuse/connections/ r,
|
|
@{sys}/fs/pstore/ r,
|
|
@{sys}/fs/cgroup/{,**} rw,
|
|
@{sys}/kernel/**/ r,
|
|
@{sys}/module/**/uevent r,
|
|
@{sys}/module/apparmor/parameters/enabled r,
|
|
|
|
@{PROC}/@{pid}/{uid_map,gid_map} r,
|
|
@{PROC}/@{pid}/attr/apparmor/exec w,
|
|
@{PROC}/@{pid}/cgroup r,
|
|
@{PROC}/@{pid}/cmdline r,
|
|
@{PROC}/@{pid}/comm r,
|
|
@{PROC}/@{pid}/coredump_filter r,
|
|
@{PROC}/@{pid}/environ r,
|
|
@{PROC}/@{pid}/fd/ r,
|
|
@{PROC}/@{pid}/fdinfo/@{int} r,
|
|
@{PROC}/@{pid}/gid_map w,
|
|
@{PROC}/@{pid}/loginuid rw,
|
|
@{PROC}/@{pid}/mountinfo r,
|
|
@{PROC}/@{pid}/setgroups rw,
|
|
@{PROC}/@{pid}/stat r,
|
|
@{PROC}/@{pid}/task/@{tid}/comm rw,
|
|
@{PROC}/@{pid}/uid_map w,
|
|
@{PROC}/cmdline r,
|
|
@{PROC}/devices r,
|
|
@{PROC}/pressure/* r,
|
|
@{PROC}/swaps r,
|
|
@{PROC}/sys/fs/binfmt_misc/ r,
|
|
@{PROC}/sys/fs/nr_open r,
|
|
@{PROC}/sys/kernel/* r,
|
|
@{PROC}/sys/kernel/random/* rw,
|
|
@{PROC}/sys/net/ipv{4,6}/** rw,
|
|
@{PROC}/sysvipc/{shm,sem,msg} r,
|
|
owner @{PROC}/@{pid}/oom_score_adj rw,
|
|
|
|
/dev/ r,
|
|
/dev/bus/usb/ r,
|
|
/dev/hwrng r,
|
|
/dev/kmsg w,
|
|
/dev/rfkill rw,
|
|
/dev/shm/ rw,
|
|
/dev/tty rw,
|
|
/dev/tty@{int} rwk,
|
|
owner /dev/console rwk,
|
|
owner /dev/hugepages/ rw,
|
|
owner /dev/initctl rw,
|
|
owner /dev/input/event@{int} rw,
|
|
owner /dev/mqueue/ rw,
|
|
owner /dev/ttyS@{int} rwk,
|
|
|
|
include if exists <usr/systemd.d>
|
|
include if exists <local/systemd>
|
|
}
|