Bug 852015

Summary: Pulseaudio fails to start after running yast or other xdg-su programs
Product: [openSUSE] openSUSE 13.1 Reporter: Forgotten User O0tUa48jAE <forgotten_O0tUa48jAE>
Component: BasesystemAssignee: systemd maintainers <systemd-maintainers>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P5 - None CC: caf4926, dimstar, forgotten_bjrImjCDxY, forgotten_DV81ZEWZkN, systemd-maintainers, tiwai, werner
Version: Final   
Target Milestone: ---   
Hardware: All   
OS: openSUSE 13.1   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: 1012-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch

Description Forgotten User O0tUa48jAE 2013-11-24 13:43:26 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0

running some programs e.g. yast - through xdg-su changes the owner of /run/user/1000/pulse to root. This causes pulseaudio to fail with the message:

"Failed to create secure directory (/run/user/1000/pulse): Permission denied"

Application that use pulseaudio do not work when this has happened and output the message above.

This occurs in the xfce environment after installing pulseaudio, no settings changed.

This is the same problem as Bug 829076 in opensuse 12.3.



Reproducible: Always

Steps to Reproduce:
1. install pulseaudio in the xfce DE
2. run yast
3. try to run pulseaudio volume control
Actual Results:  
Connection to pulseaudio failed message displayed

Expected Results:  
Application working
Comment 1 Forgotten User O0tUa48jAE 2013-11-24 13:49:02 UTC
Very similar bug in ubuntu:

https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1197395
Comment 2 Forgotten User DV81ZEWZkN 2013-11-24 21:01:25 UTC
@Johan,
please test polkit packages from
http://download.opensuse.org/repositories/home:/sumski:/bnc852015/openSUSE_13.1/
Comment 3 Forgotten User O0tUa48jAE 2013-11-24 21:24:57 UTC
I added the repository you linked to, but it turns out it was older and it did not get installed. My installed version is 112-2.1.
Comment 4 Forgotten User DV81ZEWZkN 2013-11-24 21:31:55 UTC
(In reply to comment #3)
> I added the repository you linked to, but it turns out it was older and it did
> not get installed.
http://en.opensuse.org/SDB:Vendor_change_update#Full_repository_Vendor_change
Comment 5 Forgotten User O0tUa48jAE 2013-11-25 12:53:16 UTC
Tested, no difference.

When starting up computer /run/user/1000/pulse is owned by me and pulseaudio works. 

After running yast it is owned by root and pulseaudio says:

"Failed to create secure directory (/run/user/1000/pulse): Permission denied"
Comment 6 Takashi Iwai 2013-11-25 15:15:19 UTC
Reading through Ubuntu and Redhat bugs, it seems that we need a fix in systemd.  Added Werner and Frederic to Cc.

The patch 
  https://bugzilla.redhat.com/attachment.cgi?id=823388
doesn't work unfortunately in our case, because uid referred at that point is actually the user who called (xdg-)su.  The patch has to be improved, as the patch author mentioned:
  https://bugzilla.redhat.com/show_bug.cgi?id=753882#c69

Meanwhile, we need a fix for this bad bug, and the fix below can be applied in parallel with systemd side:
   http://lists.freedesktop.org/archives/pulseaudio-discuss/2013-November/019121.html

This should be harmless if the fix will be fixed in systemd side.  So, basically we can take it as a temporary fix for 13.1 for now.

I built a package with the fix (removing a text blaming systemd developers as it's just annoying) at OBS home:tiwai:branches:openSUSE:13.1:Update/pulseaudio.
Give it a try.  Updating only libpulse0.rpm should suffice, I guess, but in doubt, just update all :)
Comment 7 Dr. Werner Fink 2013-11-25 15:31:53 UTC
Hmmm ... IMHO xdg-su nore any tool using xdg-su should change the ownership nor the permissions of and below /run/user/<pid>/ ... shouldn't it?
Comment 8 Takashi Iwai 2013-11-25 15:45:09 UTC
Right, it shouldn't.  PA currently doesn't check the validity of the given environment, so the root can override it.  One can fix in PA side.  This is what I did now.

OTOH, the root cause is that xdg-su passes the invalid $XDG_RUNTIME_DIR.  It's added explicitly in pam_systemd, and it's wrong.  So, fixing each application isn't the best fix for all these issues.
Comment 9 Forgotten User O0tUa48jAE 2013-11-25 16:15:16 UTC
What is the URL to this one, so I can try it?
OBS home:tiwai:branches:openSUSE:13.1:Update/pulseaudio.
Comment 10 Takashi Iwai 2013-11-25 16:22:41 UTC
Yes, it contains the fixed packages.
Comment 11 Forgotten User O0tUa48jAE 2013-11-25 20:30:32 UTC
Do you have an URL, like this?
http://download.opensuse.org/repositories/home:/sumski:/bnc852015/openSUSE_13.1/

I'm not familiar with opensuse and do not know where to find fixed package.
Comment 12 Takashi Iwai 2013-11-26 07:47:45 UTC
The project isn't published, so you need to retrieve packages via osc.

   % osc getbinaries home:tiwai:branches:openSUSE:13.1:Update pulseaudio standard x86_64
Comment 13 Forgotten User O0tUa48jAE 2013-11-26 09:38:00 UTC
Got it. Unfortunately it didn't help.

I installed:
libpulse0-4.0.git.270.g9490a-3.1.x86_64.rpm
pulseaudio-4.0.git.270.g9490a-3.1.x86_64.rpm

the restarted pulseaudio with:
pulseaudio -k

Same problem after running yast.
Comment 14 Takashi Iwai 2013-11-26 09:55:17 UTC
You need to relogin.
Comment 15 Forgotten User O0tUa48jAE 2013-11-26 12:34:05 UTC
rebooted just to be sure, no difference.
Comment 16 Takashi Iwai 2013-11-26 12:38:56 UTC
Scratch the packages.  The fixes haven't been committed into that repo properly.
The right packages are being built now.  Retest later if you want.
Comment 17 Dr. Werner Fink 2013-11-26 14:03:01 UTC
I'm playing around with the current upstream patch (backported to systemd 208)

 http://cgit.freedesktop.org/systemd/systemd/commit/src?id=baae0358f349870544884e405e82e4be7d8add9f

and found that this does avoid setting XDG_RUNTIME_DIR but if this variable already exists in the environment then this will *not* help.
Comment 18 Takashi Iwai 2013-11-26 14:18:00 UTC
Hrm, can't do just pam_putenv(handle, "XDG_RUNTIME_DIR") in the error case work?

diff --git a/src/login/pam-module.c b/src/login/pam-module.c
index be5901fd7735..b9f6a98e44b7 100644
--- a/src/login/pam-module.c
+++ b/src/login/pam-module.c
@@ -388,6 +388,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                         pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
                         return r;
                 }
+        } else {
+                pam_putenv(handle, "XDG_RUNTIME_DIR");
         }
 
         if (!isempty(seat)) {
Comment 19 Dr. Werner Fink 2013-11-26 14:36:40 UTC
Something similar I've added to the backport of the upstream patch ... build is running
Comment 20 Dr. Werner Fink 2013-11-26 14:43:44 UTC
(In reply to comment #19)

... this has some side effect. Using su or sudo twice on the same XTerm does a logout of the full Xsession.
Comment 21 Dr. Werner Fink 2013-11-26 15:25:28 UTC
With SR#208541 it works ... the trick is not to check for errors in this case *and* to use unsetenv() to remove the curent existing XDG_RUNTIME_DIR variable of the current process.
Comment 22 Takashi Iwai 2013-11-26 15:36:03 UTC
Great.  I checked the package in Base:System/systemd, and it looks fine.  The bug is no longer seen as far as I've tested on KVM.

Could you submit the fix for openSUSE 13.1, too?
Comment 23 Dr. Werner Fink 2013-11-26 15:37:25 UTC
Created attachment 569177 [details]
1012-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch

and this is the patch
Comment 24 Bernhard Wiedemann 2013-11-26 16:00:56 UTC
This is an autogenerated message for OBS integration:
This bug (852015) was mentioned in
https://build.opensuse.org/request/show/208541 Factory / systemd
Comment 26 Dominique Leuenberger 2013-11-30 15:11:42 UTC
That might be related to bug 814626
Comment 27 Bernhard Wiedemann 2013-12-03 13:00:59 UTC
This is an autogenerated message for OBS integration:
This bug (852015) was mentioned in
https://build.opensuse.org/request/show/209274 13.1 / systemd
Comment 28 Dr. Werner Fink 2013-12-03 13:03:33 UTC
fixed
Comment 29 Bernhard Wiedemann 2013-12-03 14:00:41 UTC
This is an autogenerated message for OBS integration:
This bug (852015) was mentioned in
https://build.opensuse.org/request/show/209283 13.1 / systemd
Comment 30 Swamp Workflow Management 2013-12-09 18:04:45 UTC
openSUSE-RU-2013:1850-1: An update that has three recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 849071,851393,852015
CVE References: 
Sources used:
openSUSE 13.1 (src):    systemd-208-9.1, systemd-mini-208-9.1, systemd-rpm-macros-2-9.1
Comment 31 Jiri Slaby 2014-01-09 15:04:21 UTC
*** Bug 829076 has been marked as a duplicate of this bug. ***
Comment 32 Thomas Blume 2015-10-19 10:53:22 UTC
*** Bug 814626 has been marked as a duplicate of this bug. ***
Comment 33 Swamp Workflow Management 2016-02-03 14:23:05 UTC
openSUSE-RU-2016:0320-1: An update that has 146 recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 737690,742774,750845,818044,838475,841544,849870,852015,852021,852232,853293,854884,856389,856392,856858,857204,858864,859072,859365,860574,860937,861316,861489,863217,864745,864904,865834,866732,866933,867128,867663,867664,867840,868019,868230,868439,868931,869142,869603,872929,873432,873444,874665,875502,876587,876694,877021,877674,878525,880438,880732,881125,881559,881942,882393,882714,883565,884271,884403,885232,885288,886211,886599,886852,888178,888215,888612,889297,889357,890977,892096,892162,892300,893797,895087,896664,897799,897801,897803,898233,898240,898432,900558,901481,902240,902901,903009,903963,904214,904517,904828,905550,906709,906900,907318,907393,908476,909358,910643,911347,912030,912334,913517,916420,918118,919095,920195,921831,921898,921920,926169,927250,927457,928265,931388,932284,933365,933512,933521,933533,934077,934901,937512,937900,938908,939571,940264,941576,944132,944799,945282,947212,948458,948555,948705,949574,949683,949739,950510,951265,951663,953241,954336,954781,955635,961576
CVE References: 
Sources used:
openSUSE 13.1 (src):    systemd-210-40.1, systemd-mini-210-40.1