View previous topic :: View next topic |
Author |
Message |
wintcape n00b
Joined: 28 Aug 2022 Posts: 4
|
Posted: Mon Nov 28, 2022 4:16 pm Post subject: Get sound in Steam chroot installation? |
|
|
Here is my script to run Steam from inside a chrooted environment with a user 'steam':
Code: | #!/bin/sh
ARCH=linux64
DIR=/opt/steam
# ========== DO NOT MODIFY BELOW THIS LINE ========== #
mount --types proc /proc $DIR/proc
mount --rbind /sys $DIR/sys
mount --make-rslave $DIR/sys
mount --rbind /dev $DIR/dev
mount --make-rslave $DIR/dev
mount --rbind /run $DIR/run
mount --make-slave $DIR/run
mount --rbind /var/db/repos/gentoo $DIR/var/db/repos/gentoo
mount -o bind /dev/pts $DIR/dev/pts
xhost +local:
$ARCH chroot $DIR su -c 'steam -no-cef-sandbox' steam
xhost -local:
umount --verbose -l $DIR/proc
umount --verbose -l $DIR/sys
umount --verbose -l $DIR/dev
umount --verbose -l $DIR/run
umount --verbose -l $DIR/pts
umount --verbose -l $DIR/var/db/repos/gentoo
|
This launches Steam and Steam games fine, but I use Pulseaudio and pulsemixer for sound, and no entries appear in the pulsemixer menu for any Steam games that I run. Sound works on all my non-chroot applications. What do I have to set up to get sound working in the chroot environment? |
|
Back to top |
|
|
capezotte n00b
Joined: 13 Nov 2022 Posts: 7 Location: South America
|
Posted: Mon Nov 28, 2022 5:07 pm Post subject: |
|
|
The quickest solution is running your chroot under your UID. By default, XDG_RUNTIME_DIR (where the D-Bus and PA IPC endpoints are located - usually /run/user/$(id -u)) can only be accessed by your UID, so applications under your "steam" UID are locked out of it.
If you're chrooting steam for security purposes/due to not trusting proprietary software, I'd rather use Flatpak or Firejail. Allowing chrooted applications to access the "outside" D-Bus without introducing easy sandbox escapes involves ultimately duplicating what these solutions already do. |
|
Back to top |
|
|
wintcape n00b
Joined: 28 Aug 2022 Posts: 4
|
Posted: Mon Nov 28, 2022 8:13 pm Post subject: |
|
|
capezotte wrote: | The quickest solution is running your chroot under your UID. By default, XDG_RUNTIME_DIR (where the D-Bus and PA IPC endpoints are located - usually /run/user/$(id -u)) can only be accessed by your UID, so applications under your "steam" UID are locked out of it. |
Running $(id -u steam) inside the chroot and $(id -u) outside the chroot yields the same UID. What else would I need to change? |
|
Back to top |
|
|
capezotte n00b
Joined: 13 Nov 2022 Posts: 7 Location: South America
|
Posted: Mon Nov 28, 2022 11:31 pm Post subject: |
|
|
Arch wiki people report also needing to bind /var/lib/dbus inside the chroot. PA in my chroot works just fine without it, but it might help you.
While you're at it, does paplay some_file.wav work in your chroot? |
|
Back to top |
|
|
wintcape n00b
Joined: 28 Aug 2022 Posts: 4
|
Posted: Tue Nov 29, 2022 4:37 pm Post subject: |
|
|
capezotte wrote: | Arch wiki people report also needing to bind /var/lib/dbus inside the chroot. PA in my chroot works just fine without it, but it might help you.
While you're at it, does paplay some_file.wav work in your chroot? |
Added the following line to my chroot script:
Code: | mount --rbind /var/lib/dbus $DIR/var/lib/dbus
|
This happens in chroot when trying to paplay:
Code: | # paplay sound.wav
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
|
Playing the same sound outside the chroot works. |
|
Back to top |
|
|
capezotte n00b
Joined: 13 Nov 2022 Posts: 7 Location: South America
|
Posted: Tue Nov 29, 2022 10:28 pm Post subject: |
|
|
Just to be sure, is XDG_RUNTIME_DIR kept in the environment after you sudo? `sudo -E' (or adding it to env_keep in sudoers) should do it.
(For bonus info, try strace -e connect paplay ... inside the chroot -- it should have a line with sun_path="$XDG_RUNTIME_DIR/pulse/native").
I've renamed the user inside my chroot and it still worked (so username 'steam' being the problem is ruled out); it failed with the exact error message you posted after unsetting it. |
|
Back to top |
|
|
rh n00b
Joined: 19 Sep 2006 Posts: 58
|
|
Back to top |
|
|
|