Skip to content

Commit

Permalink
Use nsenter and CAP_NET_ADMIN for udev instead of privileged mode
Browse files Browse the repository at this point in the history
  • Loading branch information
zb140 committed Oct 12, 2022
1 parent 7af20d7 commit bcbe684
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions compose/headless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ services:
# BASE_APP_IMAGE: ${BUILD_BASE_APP_IMAGE}
runtime: ${DOCKER_RUNTIME}
network_mode: ${UDEVD_NETWORK}
# The xorg container needs to be privileged to have access to all of the devices it requires.
# NOTE: actually, all it _really_ needs is CAP_SYS_TTY_CONFIG plus a
# devices: entry for each required device. Unfortunately, the list of
# required devices will vary based on host and is hard to predict.
privileged: true
volumes:
# Shared with Sunshine in order to get mouse and joypad working
Expand Down Expand Up @@ -60,12 +64,9 @@ services:
# args:
# BASE_IMAGE: ${BUILD_BASE_IMAGE}
# BASE_APP_IMAGE: ${BUILD_BASE_APP_IMAGE}
# # Setting network to host
# # There must be a way to avoid this but I can't figure it out
# # We need to be on the host network in order to get the PF_NETLINK socket
# # You can listen to events even without that socket but Xorg and RetroArch will not pickup the devices
network_mode: host
privileged: true

cap_add:
- NET_ADMIN
volumes:
- udev:/run/udev/

Expand Down
4 changes: 2 additions & 2 deletions images/udevd/scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -e
function start_udev() {
# mount_dev
if command -v udevd &>/dev/null; then
unshare --net udevd --daemon &> /dev/null
nsenter udevd --daemon &> /dev/null
else
unshare --net /lib/systemd/systemd-udevd --daemon &> /dev/null
nsenter /lib/systemd/systemd-udevd --daemon &> /dev/null
fi
udevadm trigger &> /dev/null
}
Expand Down

0 comments on commit bcbe684

Please sign in to comment.