On Mon, 20 Mar 2023 17:22:57 +1100
Eyal Lebedinsky <fedora(a)eyal.emu.id.au> wrote:
Fedora 36 up-to-date.
$ uname -a
Linux e4.eyal.emu.id.au 6.1.15-100.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC
Fri Mar 3 17:22:46 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
I have a script running as root (using sudo) and in it I play a sound
paplay /audio/ogg/beginning.ogg
and it always worked.
I think this should work, if the user that you are sudoing from is the
first user to log into the system. I notice that if I log in (now with
pipewire as the sound server), and then login as another user, that new
user has no access to sound. This is by design for security reasons.
But, I think the logic should be, if you sudo from the user who has
sound, the ability to use sound should transfer. You aren't becoming
root, you are just temporarily gaining the powers of root as a user,
and there doesn't seem to be a security hole if you continue to use
sound, as it is still you.
But, I just tried it, playing a video with mplayer. And the video
worked, but the sound didn't. My guess is that this used to be a
loophole in the sound restriction logic, and someone patched it
recently, because they disagree that sudo should be able to play sound
in the scenario above.
Is there a simple way to allow playing sounds in this context?
I don't know if pipewire continued the practice, but it used to be
possible to start pulseaudio as a sound server that everyone could
access, rather than as a service restricted to a single user. When
started as a server, every user logged in had access to sound. It was
a configuration setting, so you should look in the pipewire
documentation to see if it is also possible with pipewire.
Maybe it is the same solution that Roberto recommended.