Skip to content

Commit 621a1dc

Browse files
aptalcathelamer
authored andcommitted
fix video device permissions
1 parent c6d1618 commit 621a1dc

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
268268

269269
## Versions
270270

271+
* **02.08.19:** - Attempt to automatically fix permissions on /dev/dri and /dev/dvb.
271272
* **28.06.19:** - Rebasing to alpine 3.10.
272273
* **27.03.19:** - Rebase to Alpine 3.9, fix init logic to only chown once.
273274
* **23.03.19:** - Switching to new Base images, shift to arm32v7 tag.

readme-vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ app_setup_block: |
125125
126126
# changelog
127127
changelogs:
128+
- { date: "02.08.19:", desc: "Attempt to automatically fix permissions on /dev/dri and /dev/dvb." }
128129
- { date: "28.06.19:", desc: "Rebasing to alpine 3.10." }
129130
- { date: "27.03.19:", desc: "Rebase to Alpine 3.9, fix init logic to only chown once." }
130131
- { date: "23.03.19:", desc: "Switching to new Base images, shift to arm32v7 tag." }

root/etc/cont-init.d/50-gid-video

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
# check for the existence of a video and/or tuner device
4+
if [ -e /dev/dri ] || [ -e /dev/dvb ]; then
5+
if [ -e /dev/dri ]; then
6+
VIDEO_GID=$(stat -c '%g' /dev/dri/* | grep -v '^0$' | head -n 1)
7+
else
8+
VIDEO_GID=$(stat -c '%g' /dev/dvb/* | grep -v '^0$' | head -n 1)
9+
fi
10+
# just add abc to root if stuff in dri/dvb is root owned
11+
if [ -z "${VIDEO_GID}" ]; then
12+
usermod -a -G root abc
13+
exit 0
14+
fi
15+
else
16+
exit 0
17+
fi
18+
19+
# Check if this GID matches the current abc user
20+
ABCGID=$(getent group abc | awk -F: '{print $3}')
21+
if [ "${ABCGID}" == "${VIDEO_GID}" ]; then
22+
exit 0
23+
fi
24+
25+
# Check if the GID is taken and swap to 65533
26+
CURRENT=$(getent group ${VIDEO_GID} | awk -F: '{print $1}')
27+
if [ -z "${CURRENT}" ] || [ "${CURRENT}" == 'video' ]; then
28+
groupmod -g ${VIDEO_GID} video
29+
usermod -a -G video abc
30+
else
31+
groupmod -g 65533 ${CURRENT}
32+
groupmod -g ${VIDEO_GID} video
33+
usermod -a -G video abc
34+
fi

0 commit comments

Comments
 (0)