improve logic for root owned devices

pull/208/head
aptalca 5 years ago
parent 66046f9582
commit baa34948d8

@ -15,10 +15,10 @@ fi
for i in $FILES for i in $FILES
do do
VIDEO_GID=$(stat -c '%g' "$i") VIDEO_GID=$(stat -c '%g' "$i")
if ! id -G abc | grep -qw "$VIDEO_GID"; then if id -G abc | grep -qw "$VIDEO_GID"; then
if [ "${VIDEO_GID}" == '0' ]; then touch /groupadd
usermod -a -G root abc
else else
if [ ! "${VIDEO_GID}" == '0' ]; then
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}') VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
if [ -z "${VIDEO_NAME}" ]; then if [ -z "${VIDEO_NAME}" ]; then
VIDEO_NAME="video$(head /dev/urandom | tr -dc 0-9 | head -c4)" VIDEO_NAME="video$(head /dev/urandom | tr -dc 0-9 | head -c4)"
@ -26,6 +26,11 @@ do
groupmod -g "$VIDEO_GID" "$VIDEO_NAME" groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
fi fi
usermod -a -G "$VIDEO_NAME" abc usermod -a -G "$VIDEO_NAME" abc
touch /groupadd
fi fi
fi fi
done done
if [ ! -z "${FILES}" ] && [ ! -f "/groupadd" ]; then
usermod -a -G root abc
fi
Loading…
Cancel
Save