Re: Recently sound does not play as root

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/20/23 21:37, Eyal Lebedinsky wrote:


On 21/03/2023 15.29, Samuel Sieb wrote:
On 3/20/23 21:13, Eyal Lebedinsky wrote:
On 20/03/2023 17.22, Eyal Lebedinsky 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.

Then a few days ago it stopped and I now get an error. Something changed.

$ sudo paplay /audio/ogg/beginning.ogg
Connection failure: Connection refused
pa_context_connect() failed: Connection refused

$ sudo ogg123 -q /audio/ogg/beginning.ogg
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

=== Could not load default driver and no driver specified in config file. Exiting.

Is there a simple way to allow playing sounds in this context?

TIA

Received a few replies that suggest it is not trivial to do so. Some think it is also unwise.

My current solution is to run the affected script as my non-root user and in it run some parts with sudo
(set up to run without a sudo password to avoid script interruption).

BTW: I did try to use su/sudo back to my user, to run from inside the script (which is running as root) but it still fails.

There used to be an environment variable that pointed to the pulseaudio socket, but that seems to have changed (at least in F37). Check that the XDG_RUNTIME_DIR variable is set.  It wasn't when I tested going through root.  It should point to /run/user/<pid> which is most likely /run/user/1000 unless you aren't the first user.

Yet, it is present and set up. I expect that it is lost by sudo... yes it is.
I set it up manually and got a similar error:

[eyal@e7:~]$ sudo -i
[root@e7 ~]# set|grep XDG_RUNTIME_DIR
[root@e7 ~]# export XDG_RUNTIME_DIR=/run/user/500
[root@e7 ~]# paplay /audio/ogg/beginning.ogg
XDG_RUNTIME_DIR (/run/user/500) is not owned by us (uid 0), but by uid 500! (This could e.g. happen if you try to connect to a non-root PulseAudio as a root user, over the native protocol. Don't do that.)
Connection failure: Connection refused
pa_context_connect() failed: Connection refused

I didn't mean to use it as root. The sound system isn't going to let you do that as you found out. I meant you need to set it up after you su back to your user.
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux