xpra icon
Bug tracker and wiki

Opened 13 days ago

Closed 9 days ago

#1614 closed defect (fixed)

Sound sub-system is not ownering XDG_RUNTIME_DIR when xpra is started from the system proxy server.

Reported by: Kundan Owned by: Kundan
Priority: major Milestone: 2.2
Component: sound Version: trunk
Keywords: Cc:

Description

Sound sub-system is not ownering the XDG_RUNTIME_DIR when it is getting created through systemd.

xpra Command.

XDG_RUNTIME_DIR=/tmp/10 xpra start :10 --bind-tcp=192.168.0.20:10000 --start="xterm" -d sound

Due to it, multiple xpra server's with different display no's can't be created with their own pulseaudio servers on Ubuntu 16.04.

I was also, not able to see PULSEAUDIO_SERVER in xprop -root. So, I don't know how the xpra instances and pulseaudio servers are connected.

A current workaround to my problem is:-

systemctl stop xpra

After this, things work as earlier.

Attachments (12)

xprop_systemctl.txt (8.6 KB) - added by Kundan 13 days ago.
xprop -root output from the started xterm after successful attach.
pactl_systemctl.txt (417 bytes) - added by Kundan 13 days ago.
pactl info output from the xterm after attach.
xpra_server_systemctl.log (3.0 KB) - added by Kundan 13 days ago.
xpra server output log when created through systemctl.
xpra_systemd_sound.log (7.2 KB) - added by Kundan 12 days ago.
xpra sound failure when systemd is enabled and XDG_RUNTIME_DIR environment variable is used.
pactl_systemd_new.txt (409 bytes) - added by Kundan 12 days ago.
pactl info output from the xterm after attach reporting the correct values.
debug.diff (793 bytes) - added by Kundan 11 days ago.
debug diff used.
pactl_info_new.txt (465 bytes) - added by Kundan 11 days ago.
pactl info after using --env.
xpra_journal_log.txt (10.5 KB) - added by Kundan 11 days ago.
log in journalctl -u xpra, The last sections would be more meaningful.
xpra_output_log.txt (4.3 KB) - added by Kundan 11 days ago.
xpra output of the command used, mentioning pulseaudio daemon already running means pulseaudio won't start because XDG_RUNTIME_DIR variable is same as older.
stop_override.diff (1.7 KB) - added by Kundan 10 days ago.
Stopping the override of os environment variables by protected_env.
xpra_log_with_debug_with_overwrite.log (6.3 KB) - added by Kundan 10 days ago.
xpra log without applying my diff of stopping overwrite.
xpra_log_debug_without_overwrite.log (6.3 KB) - added by Kundan 10 days ago.
xpra log after applying my diff of stop overwrite.

Download all attachments as: .zip

Change History (25)

Changed 13 days ago by Kundan

Attachment: xprop_systemctl.txt added

xprop -root output from the started xterm after successful attach.

Changed 13 days ago by Kundan

Attachment: pactl_systemctl.txt added

pactl info output from the xterm after attach.

Changed 13 days ago by Kundan

Attachment: xpra_server_systemctl.log added

xpra server output log when created through systemctl.

comment:1 Changed 13 days ago by Antoine Martin

Owner: changed from Antoine Martin to Kundan

Try using start-env instead:

xpra start :10 --bind-tcp=192.168.0.20:10000 --start="xterm" -d sound --start-env=XDG_RUNTIME_DIR=/tmp/10

comment:2 Changed 12 days ago by Kundan

Owner: changed from Kundan to Antoine Martin

Hi Antoine,

I tried the suggested option.
After this, the xterm started and attached in the client shows the right pulseaudio server string with pactl info. The pavucontrol started from the xterm also shows the devices correctly.

But, neither microphone forwarding nor speaker forwarding works.

The reason seems to be the failures reported in the xpra log, where neither pactl info nor pactl list is reporting the expected values. Both are refusing the connection.

I am also able to see some other issues in the log like,
IndexError: list index out of range

I don't know, whether they are related.

Last edited 12 days ago by Antoine Martin (previous) (diff)

Changed 12 days ago by Kundan

Attachment: xpra_systemd_sound.log added

xpra sound failure when systemd is enabled and XDG_RUNTIME_DIR environment variable is used.

Changed 12 days ago by Kundan

Attachment: pactl_systemd_new.txt added

pactl info output from the xterm after attach reporting the correct values.

comment:3 Changed 12 days ago by Antoine Martin

Owner: changed from Antoine Martin to Kundan

Please try with r16643 or later and --env= instead of --start-env=, as this will affect all the subprocesses, including pactl. (start-env is meant to be used for start and start-child options).

The IndexError is unrelated and was already fixed in r16610.

comment:4 Changed 11 days ago by Kundan

Hi Antoine,

I tried with this option as well. The command used was:-

xpra start :10 --bind-tcp=192.168.0.20:10000 --start="xterm" --env="XDG_RUNTIME_DIR=/tmp/10" -d server

But, no luck. xpra failed to create pulseaudio server because, it tried to create with the same pulseaudio string i.e /run/user/<uid>/pulse/native. When I tried on a clean system, with no pulseaudio already running. It doesn't owner the environment variable passed. It simply creates the pulseaudio with default XDG_RUNTIME_DIR. I tried to remove quotes around XDG_RUNTIME_DIR=/tmp/10. But, still couldn't get success.

With, --start-env , at least it used to pick-up the XDG_RUNTIME_DIR. But, failed to start speaker or microphone forwarding. One more issue, which I noted, is that, when pulseaudio is created this way. When we stop the xpra server through xpra stop :10. It doesn't kill the started pulseaudio server automatically.

I tried to add some debug statement to search for the issue. But couldn't make progress. I am attaching the debug statements added and the logs.

Changed 11 days ago by Kundan

Attachment: debug.diff added

debug diff used.

Changed 11 days ago by Kundan

Attachment: pactl_info_new.txt added

pactl info after using --env.

Changed 11 days ago by Kundan

Attachment: xpra_journal_log.txt added

log in journalctl -u xpra, The last sections would be more meaningful.

comment:5 Changed 11 days ago by Antoine Martin

@Kundan: please make sure that you test using r16643 or later.

Changed 11 days ago by Kundan

Attachment: xpra_output_log.txt added

xpra output of the command used, mentioning pulseaudio daemon already running means pulseaudio won't start because XDG_RUNTIME_DIR variable is same as older.

comment:6 Changed 11 days ago by Kundan

Hi Antoine,

My xpra version is xpra v2.2-r16643. It seems, it has the changes. I also, verified the server.py file in /usr/lib/python2.7/dist-packages/xpra/scripts directory. It do possess the changes. But, I fail to understand, why it's not working.

comment:7 Changed 11 days ago by Antoine Martin

Thanks for the logs. It looks like the pam config file needs tweaking for Debian / Ubuntu:

PAM _pam_load_conf_file: unable to open /etc/pam.d/system-auth
PAM _pam_load_conf_file: unable to open /etc/pam.d/postlogin

This may prevent #1105 from working as expected, but may actually help here if it causes pam auth to fail!

The XDG_RUNTIME_DIR may actually get updated by the pam authentication.
Please try to sprinkle some print statements in xpra/scripts/server.py to see where it gets overriden, maybe it is provided by pam in protected_env.

comment:8 Changed 10 days ago by Antoine Martin

With the latest r16660 beta builds on Ubuntu 16.04, I have verified that XDG_RUNTIME_DIR is correctly set in the xpra server process and the same value is also used when calling pactl.
Pulseaudio starts without errors as long as I use a different env value for XDG_RUNTIME_DIR.
If you are still having problems, please apply this patch and post the server log:

--- xpra/sound/pulseaudio/pulseaudio_pactl_util.py	(revision 16610)
+++ xpra/sound/pulseaudio/pulseaudio_pactl_util.py	(working copy)
@@ -38,7 +38,8 @@
     env["LC_ALL"] = "C"
     try:
         import subprocess
-        log("running %s", cmd)
+        log.info("running %s with env=%s", cmd, env)
+        log.info("XDG_RUNTIME_DIR=%s", env.get("XDG_RUNTIME_DIR"))
         process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, close_fds=True)
         from xpra.child_reaper import getChildReaper
         procinfo = getChildReaper().add_process(process, "pactl", cmd, True, True)

comment:9 Changed 10 days ago by Kundan

Hi Antoine,

But, I am still seeing the issue.
It seems your earlier suspicion was right. The OS envrionment variables are getting overwritten, after we have set it to our desired value.

I have created a short diff, where I am disabling the overwrite of os environment variables by protected_env in about 4 instances. And, after that, magically things start to work.

In both the cases i.e with overwrite and without overwrite, I have captured the logs with your provided debug statements. And, i.e also, proving the theory.

The xpra command used.

xpra start :10 --bind-tcp=192.168.0.20:10000 --start="xterm" --env=XDG_RUNTIME_DIR=/tmp/10 -d server


Changed 10 days ago by Kundan

Attachment: stop_override.diff added

Stopping the override of os environment variables by protected_env.

Changed 10 days ago by Kundan

xpra log without applying my diff of stopping overwrite.

Changed 10 days ago by Kundan

xpra log after applying my diff of stop overwrite.

comment:10 Changed 10 days ago by Antoine Martin

Does r16669 fix things?

comment:11 Changed 10 days ago by Kundan

Hi Antoine,

Yes, I tested the changes by modifying my installed xpra directly, and it is working properly. I will also test the changes in the beta version when it would be available tomorrow.

Thanks again, for the help and support.

comment:12 Changed 9 days ago by Kundan

Hi Antoine,

I tested with the beta version (xpra version v2.2-r16672) as well.
Things are working properly.

Thank you.

comment:13 Changed 9 days ago by Antoine Martin

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.