shannot icon indicating copy to clipboard operation
shannot copied to clipboard

Ensure systemctl & journalctl are accessible from the sandbox

Open corv89 opened this issue 1 year ago • 2 comments

corv89 avatar Oct 23 '25 11:10 corv89

To match unprivileged user visibility:

  1. Add sandbox user to systemd-journal group
  2. bind-mount /run/systemd/journal and /var/log/journal as read-only

For root-like visibility (incl. dmesg & /dev/kmsg):

  1. Create user namespace with --unshare-user
  2. Map user to UID 0
  3. Grant AmbientCapabilities=CAP_SYSLOG via systemd service directive

corv89 avatar Oct 24 '25 16:10 corv89

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

corv89 avatar Oct 24 '25 16:10 corv89