|
|
7bcd4f |
From 8635ffc16aeff6a07d675f861fe0dea03ea81d7e Mon Sep 17 00:00:00 2001
|
|
|
7bcd4f |
From: Colin Walters <walters@verbum.org>
|
|
|
7bcd4f |
Date: Thu, 21 Nov 2013 17:39:37 -0500
|
|
|
7bcd4f |
Subject: [PATCH] pkexec: Work around systemd injecting broken XDG_RUNTIME_DIR
|
|
|
7bcd4f |
|
|
|
7bcd4f |
This workaround isn't too much code, and it's often better to fix bugs
|
|
|
7bcd4f |
in two places anyways.
|
|
|
7bcd4f |
|
|
|
7bcd4f |
For more information:
|
|
|
7bcd4f |
|
|
|
7bcd4f |
See https://bugzilla.redhat.com/show_bug.cgi?id=753882
|
|
|
7bcd4f |
See http://lists.freedesktop.org/archives/systemd-devel/2013-November/014370.html
|
|
|
7bcd4f |
---
|
|
|
7bcd4f |
src/programs/pkexec.c | 33 ++++++++++++++++++++++++++++++---
|
|
|
7bcd4f |
1 file changed, 30 insertions(+), 3 deletions(-)
|
|
|
7bcd4f |
|
|
|
7bcd4f |
diff --git a/src/programs/pkexec.c b/src/programs/pkexec.c
|
|
|
7bcd4f |
index 005e1fe..a7ca8e0 100644
|
|
|
7bcd4f |
--- a/src/programs/pkexec.c
|
|
|
7bcd4f |
+++ b/src/programs/pkexec.c
|
|
|
7bcd4f |
@@ -143,8 +143,22 @@ pam_conversation_function (int n,
|
|
|
7bcd4f |
return PAM_CONV_ERR;
|
|
|
7bcd4f |
}
|
|
|
7bcd4f |
|
|
|
7bcd4f |
+/* A work around for:
|
|
|
7bcd4f |
+ * https://bugzilla.redhat.com/show_bug.cgi?id=753882
|
|
|
7bcd4f |
+ */
|
|
|
7bcd4f |
+static gboolean
|
|
|
7bcd4f |
+xdg_runtime_dir_is_owned_by (const char *path,
|
|
|
7bcd4f |
+ uid_t target_uid)
|
|
|
7bcd4f |
+{
|
|
|
7bcd4f |
+ struct stat stbuf;
|
|
|
7bcd4f |
+
|
|
|
7bcd4f |
+ return stat (path, &stbuf) == 0 &&
|
|
|
7bcd4f |
+ stbuf.st_uid == target_uid;
|
|
|
7bcd4f |
+}
|
|
|
7bcd4f |
+
|
|
|
7bcd4f |
static gboolean
|
|
|
7bcd4f |
-open_session (const gchar *user_to_auth)
|
|
|
7bcd4f |
+open_session (const gchar *user_to_auth,
|
|
|
7bcd4f |
+ uid_t target_uid)
|
|
|
7bcd4f |
{
|
|
|
7bcd4f |
gboolean ret;
|
|
|
7bcd4f |
gint rc;
|
|
|
7bcd4f |
@@ -186,7 +200,19 @@ open_session (const gchar *user_to_auth)
|
|
|
7bcd4f |
{
|
|
|
7bcd4f |
guint n;
|
|
|
7bcd4f |
for (n = 0; envlist[n]; n++)
|
|
|
7bcd4f |
- putenv (envlist[n]);
|
|
|
7bcd4f |
+ {
|
|
|
7bcd4f |
+ const char *envitem = envlist[n];
|
|
|
7bcd4f |
+
|
|
|
7bcd4f |
+ if (g_str_has_prefix (envitem, "XDG_RUNTIME_DIR="))
|
|
|
7bcd4f |
+ {
|
|
|
7bcd4f |
+ const char *eq = strchr (envitem, '=');
|
|
|
7bcd4f |
+ g_assert (eq);
|
|
|
7bcd4f |
+ if (!xdg_runtime_dir_is_owned_by (eq + 1, target_uid))
|
|
|
7bcd4f |
+ continue;
|
|
|
7bcd4f |
+ }
|
|
|
7bcd4f |
+
|
|
|
7bcd4f |
+ putenv (envlist[n]);
|
|
|
7bcd4f |
+ }
|
|
|
7bcd4f |
free (envlist);
|
|
|
7bcd4f |
}
|
|
|
7bcd4f |
|
|
|
7bcd4f |
@@ -913,7 +939,8 @@ main (int argc, char *argv[])
|
|
|
7bcd4f |
* As evident above, neither su(1) (and, for that matter, nor sudo(8)) does this.
|
|
|
7bcd4f |
*/
|
|
|
7bcd4f |
#ifdef POLKIT_AUTHFW_PAM
|
|
|
7bcd4f |
- if (!open_session (pw->pw_name))
|
|
|
7bcd4f |
+ if (!open_session (pw->pw_name,
|
|
|
7bcd4f |
+ pw->pw_uid))
|
|
|
7bcd4f |
{
|
|
|
7bcd4f |
goto out;
|
|
|
7bcd4f |
}
|
|
|
7bcd4f |
--
|
|
|
7bcd4f |
1.8.3.1
|
|
|
7bcd4f |
|