Improve permission fixing for render & dvb devices

This commit is contained in:
aptalca
2019-10-02 12:49:38 -04:00
committed by Ryan Kuba
parent f5de72e0bf
commit 10471d1275
3 changed files with 23 additions and 20 deletions

View File

@@ -222,6 +222,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
## Versions ## Versions
* **02.10.19:** - Improve permission fixing for render & dvb devices.
* **31.07.19:** - Add AMD drivers for vaapi support on x86. * **31.07.19:** - Add AMD drivers for vaapi support on x86.
* **13.06.19:** - Add Intel drivers for vaapi support on x86. * **13.06.19:** - Add Intel drivers for vaapi support on x86.
* **07.06.19:** - Initial release. * **07.06.19:** - Initial release.

View File

@@ -63,6 +63,7 @@ app_setup_block: |
# changelog # changelog
changelogs: changelogs:
- { date: "02.10.19:", desc: "Improve permission fixing for render & dvb devices." }
- { date: "31.07.19:", desc: "Add AMD drivers for vaapi support on x86." } - { date: "31.07.19:", desc: "Add AMD drivers for vaapi support on x86." }
- { date: "13.06.19:", desc: "Add Intel drivers for vaapi support on x86." } - { date: "13.06.19:", desc: "Add Intel drivers for vaapi support on x86." }
- { date: "07.06.19:", desc: "Initial release." } - { date: "07.06.19:", desc: "Initial release." }

View File

@@ -1,25 +1,26 @@
#!/usr/bin/with-contenv bash #!/usr/bin/with-contenv bash
# Check for the existence of the Intel video device FILES=$(find /dev/dri /dev/dvb -type c -print 2>/dev/null)
if [ -e /dev/dri ]; then
VIDEO_GID=$(stat -c '%g' /dev/dri/* | grep -v '^0$' | head -n 1)
else
exit 0
fi
# Check if this GID matches the current abc user for i in $FILES
ABCGID=$(getent group abc | awk -F: '{print $3}') do
if [ "${ABCGID}" == "${VIDEO_GID}" ]; then VIDEO_GID=$(stat -c '%g' "$i")
exit 0 if id -G abc | grep -qw "$VIDEO_GID"; then
fi touch /groupadd
else
if [ ! "${VIDEO_GID}" == '0' ]; then
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
if [ -z "${VIDEO_NAME}" ]; then
VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c8)"
groupadd "$VIDEO_NAME"
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
fi
usermod -a -G "$VIDEO_NAME" abc
touch /groupadd
fi
fi
done
# Check if the GID is taken and swap to 65533 if [ -n "${FILES}" ] && [ ! -f "/groupadd" ]; then
CURRENT=$(getent group ${VIDEO_GID} | awk -F: '{print $1}') usermod -a -G root abc
if [ -z "${CURRENT}" ] || [ "${CURRENT}" == 'video' ]; then
groupmod -g ${VIDEO_GID} video
usermod -a -G video abc
else
groupmod -g 65533 ${CURRENT}
groupmod -g ${VIDEO_GID} video
usermod -a -G video abc
fi fi