[pulseaudio-discuss] [PATCH v2] core-util: Fail if XDG_RUNTIME_DIR belongs to someone else
David Henningsson
david.henningsson at canonical.com
Mon Sep 8 04:53:24 PDT 2014
On 2014-09-08 13:44, Tanu Kaskinen wrote:
> On Mon, 2014-09-08 at 13:32 +0200, David Henningsson wrote:
>> Usually, PA will use the PULSE_SERVER X11 property instead of using XDG_RUNTIME_DIR,
>> so this environment variable does not matter.
>>
>> If this property is not available, or if one is using the pacmd cli protocol,
>> the client will go ahead and call pa_make_secure_dir on XDG_RUNTIME_DIR/pulse.
>> This will either fail (if you're another regular user), or succeed (if you're root).
>> Both scenarios are bad - failing will cause the connection to fail, and succeeding
>> is even worse, as it can cause *other* connections to fail (as the directory
>> ownership has changed).
>>
>> Instead fail and complain loudly.
>>
>> BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=83007
>> Signed-off-by: David Henningsson <david.henningsson at canonical.com>
>> ---
>> src/pulsecore/core-util.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> v2: Don't blame systemd anymore. Make error message translatable.
>>
>> diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
>> index d7a95d6..6bb6317 100644
>> --- a/src/pulsecore/core-util.c
>> +++ b/src/pulsecore/core-util.c
>> @@ -1816,6 +1816,14 @@ char *pa_get_runtime_dir(void) {
>> /* Use the XDG standard for the runtime directory. */
>> d = getenv("XDG_RUNTIME_DIR");
>> if (d) {
>> + struct stat st;
>> + if (stat(d, &st) == 0 && st.st_uid != getuid()) {
>> + pa_log(_("XDG_RUNTIME_DIR (%s) is not owned by us (uid %d), but by uid %d!\n"
>> + "(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.)"),
>
> I'd prefer to not add any line breaks to log messages, because the new
> line will not be aligned with the first line, since the first line will
> likely have some prefix stuff in it. If you really want to force a long
> message to have multiple lines, I think it's better to call pa_log()
> multiple times.
>
> Otherwise looks good!
Thanks, pushed (after removing the line break as you wished).
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
More information about the pulseaudio-discuss
mailing list