From 2b14dd6a9b02aa2be46276517404f9ee3818eb87 Mon Sep 17 00:00:00 2001 From: Jocelyn Le Sage Date: Mon, 10 Oct 2022 13:49:35 -0400 Subject: [PATCH] Fixed handling of supplementary groups for sound device. --- rootfs/etc/cont-init.d/55-check-snd.sh | 4 ---- rootfs/etc/services.d/app/sgid | 28 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100755 rootfs/etc/services.d/app/sgid diff --git a/rootfs/etc/cont-init.d/55-check-snd.sh b/rootfs/etc/cont-init.d/55-check-snd.sh index 1e917f3..58b805c 100755 --- a/rootfs/etc/cont-init.d/55-check-snd.sh +++ b/rootfs/etc/cont-init.d/55-check-snd.sh @@ -13,9 +13,5 @@ fi # Save the associated group. SND_GRP="$(find "$SND_DEV" -maxdepth 1 -not -type d -exec stat -c "%g" {} \; | sort -u | tail -n1)" echo "sound device group $SND_GRP." -if [ -f /var/run/s6/container_environment/SUP_GROUP_IDS ]; then - echo -n "," >> /var/run/s6/container_environment/SUP_GROUP_IDS -fi -echo -n "$SND_GRP" >> /var/run/s6/container_environment/SUP_GROUP_IDS # vim: set ft=sh : diff --git a/rootfs/etc/services.d/app/sgid b/rootfs/etc/services.d/app/sgid new file mode 100755 index 0000000..48f972d --- /dev/null +++ b/rootfs/etc/services.d/app/sgid @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Get the supplementary group ID(s) needed to access sound device. These are +# added to the ones provided by $SUP_GROUP_IDS. +# + +set -e # Exit immediately if a command exits with a non-zero status. +set -u # Treat unset variables as an error. + +SND_DEV="/dev/snd" + +SUP_GROUP_IDS="${SUP_GROUP_IDS:-}" + +# Add group associated to the sound device. +if [ -d "$SND_DEV" ]; then + # Save the associated group. + SND_GRP="$(find "$SND_DEV" -maxdepth 1 -not -type d -exec stat -c "%g" {} \; | sort -u | tail -n1)" + + if [ -n "$SUP_GROUP_IDS" ]; then + SUP_GROUP_IDS="$SUP_GROUP_IDS,$SND_GRP" + else + SUP_GROUP_IDS="$SND_GRP" + fi +fi + +echo "$SUP_GROUP_IDS" | tr ',' '\n' + +# vim:ft=sh:ts=4:sw=4:et:sts=4