diff --git a/README.md b/README.md index 447212a..8655eb1 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **02.10.19:** - Improve permission fixing for render & dvb devices. * **31.07.19:** - Add AMD drivers for vaapi support on x86. * **13.06.19:** - Add Intel drivers for vaapi support on x86. * **07.06.19:** - Initial release. diff --git a/readme-vars.yml b/readme-vars.yml index 79c2f0d..1e0bd59 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -63,6 +63,7 @@ app_setup_block: | # changelog 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: "13.06.19:", desc: "Add Intel drivers for vaapi support on x86." } - { date: "07.06.19:", desc: "Initial release." } diff --git a/root/etc/cont-init.d/40-gid-video b/root/etc/cont-init.d/40-gid-video index e7ef21a..8e0dec3 100644 --- a/root/etc/cont-init.d/40-gid-video +++ b/root/etc/cont-init.d/40-gid-video @@ -1,25 +1,26 @@ #!/usr/bin/with-contenv bash -# Check for the existence of the Intel video device -if [ -e /dev/dri ]; then - VIDEO_GID=$(stat -c '%g' /dev/dri/* | grep -v '^0$' | head -n 1) -else - exit 0 -fi +FILES=$(find /dev/dri /dev/dvb -type c -print 2>/dev/null) -# Check if this GID matches the current abc user -ABCGID=$(getent group abc | awk -F: '{print $3}') -if [ "${ABCGID}" == "${VIDEO_GID}" ]; then - exit 0 -fi +for i in $FILES +do + VIDEO_GID=$(stat -c '%g' "$i") + if id -G abc | grep -qw "$VIDEO_GID"; then + 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 -CURRENT=$(getent group ${VIDEO_GID} | awk -F: '{print $1}') -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 +if [ -n "${FILES}" ] && [ ! -f "/groupadd" ]; then + usermod -a -G root abc fi