Merge pull request #208 from linuxserver/render
Improve logic for dri and dvb device permissionspull/214/head 1.16.6.1592-b9d49bdb7-ls52
commit
3b510c8452
@ -1,34 +1,26 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
|
|
||||||
# check for the existence of a video and/or tuner device
|
FILES=$(find /dev/dri /dev/dvb -type c -print 2>/dev/null)
|
||||||
if [ -e /dev/dri ] || [ -e /dev/dvb ]; then
|
|
||||||
if [ -e /dev/dri ]; then
|
for i in $FILES
|
||||||
VIDEO_GID=$(stat -c '%g' /dev/dri/* | grep -v '^0$' | head -n 1)
|
do
|
||||||
|
VIDEO_GID=$(stat -c '%g' "$i")
|
||||||
|
if id -G abc | grep -qw "$VIDEO_GID"; then
|
||||||
|
touch /groupadd
|
||||||
else
|
else
|
||||||
VIDEO_GID=$(stat -c '%g' /dev/dvb/* | grep -v '^0$' | head -n 1)
|
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
|
fi
|
||||||
# just add abc to root if stuff in dri/dvb is root owned
|
usermod -a -G "$VIDEO_NAME" abc
|
||||||
if [ -z "${VIDEO_GID}" ]; then
|
touch /groupadd
|
||||||
usermod -a -G root abc
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
else
|
fi
|
||||||
exit 0
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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
|
||||||
|
Loading…
Reference in new issue