Skip to content

Commit baa3494

Browse files
committed
improve logic for root owned devices
1 parent 66046f9 commit baa3494

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,22 @@ fi
1515
for i in $FILES
1616
do
1717
VIDEO_GID=$(stat -c '%g' "$i")
18-
if ! id -G abc | grep -qw "$VIDEO_GID"; then
19-
if [ "${VIDEO_GID}" == '0' ]; then
20-
usermod -a -G root abc
21-
else
18+
if id -G abc | grep -qw "$VIDEO_GID"; then
19+
touch /groupadd
20+
else
21+
if [ ! "${VIDEO_GID}" == '0' ]; then
2222
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
2323
if [ -z "${VIDEO_NAME}" ]; then
2424
VIDEO_NAME="video$(head /dev/urandom | tr -dc 0-9 | head -c4)"
2525
groupadd "$VIDEO_NAME"
2626
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
2727
fi
2828
usermod -a -G "$VIDEO_NAME" abc
29+
touch /groupadd
2930
fi
3031
fi
31-
done
32+
done
33+
34+
if [ ! -z "${FILES}" ] && [ ! -f "/groupadd" ]; then
35+
usermod -a -G root abc
36+
fi

0 commit comments

Comments
 (0)