shannot
shannot copied to clipboard
Ensure systemctl & journalctl are accessible from the sandbox
To match unprivileged user visibility:
- Add sandbox user to
systemd-journalgroup - bind-mount
/run/systemd/journaland/var/log/journalas read-only
For root-like visibility (incl. dmesg & /dev/kmsg):
- Create user namespace with
--unshare-user - Map user to
UID 0 - Grant
AmbientCapabilities=CAP_SYSLOGvia systemd service directive
Or, use file capabilites instead of systemd service directives:
setcap cap_syslog=ep /usr/bin/dmesg
Alternatively, pass file descriptor before entering sandbox to avoid capability grants:
exec 3< <(dmesg)
bwrap \
--ro-bind /usr /usr \
--file 3 /dmesg.log \
cat /dmesg.log