diff options
author | Ray Strode <rstrode@redhat.com> | 2012-11-05 17:07:05 -0500 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2012-11-14 12:01:26 -0500 |
commit | fcea4da3fb57f09c23e1de3b59f6fa3107f30291 (patch) | |
tree | 17fe7f355db927a59f0a37f21929dbe3f805b1bb /daemon/gdm-slave.c | |
parent | 5d797bbbfc489389ad686d3a61897df39da73782 (diff) | |
download | gdm-fcea4da3fb57f09c23e1de3b59f6fa3107f30291.tar.gz |
daemon: allow NULs in X11 cookie
We currently allow the slave access to its X server via two
mechanisms:
1) we set XAUTHORITY to point to the X servers Xauthority file
2) we call XSetAuthorization with the cookie from the Xauthority file
1) may fail if the user's hostname changes at the wrong moment, and
a bug in the code meant that 2 would fail if NULs are encoded in the
auth cookie.
This commit fixes 2) to work with embedded NUL bytes.
https://bugzilla.gnome.org/show_bug.cgi?id=687691
(cherry picked from commit eaabecd70f79c89f6bfd912557c0cbb7718d4c63)
Diffstat (limited to 'daemon/gdm-slave.c')
-rw-r--r-- | daemon/gdm-slave.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c index 948406a4..15df03a8 100644 --- a/daemon/gdm-slave.c +++ b/daemon/gdm-slave.c @@ -98,7 +98,7 @@ struct GdmSlavePrivate char *parent_display_name; char *parent_display_x11_authority_file; char *windowpath; - char *display_x11_cookie; + GBytes *display_x11_cookie; gboolean display_is_initial; GdmDBusDisplay *display_proxy; @@ -665,10 +665,13 @@ gdm_slave_connect_to_x11_display (GdmSlave *slave) sigprocmask (SIG_BLOCK, &mask, &omask); /* Give slave access to the display independent of current hostname */ - XSetAuthorization ("MIT-MAGIC-COOKIE-1", - strlen ("MIT-MAGIC-COOKIE-1"), - slave->priv->display_x11_cookie, - strlen (slave->priv->display_x11_cookie)); + if (slave->priv->display_x11_cookie != NULL) { + XSetAuthorization ("MIT-MAGIC-COOKIE-1", + strlen ("MIT-MAGIC-COOKIE-1"), + (gpointer) + g_bytes_get_data (slave->priv->display_x11_cookie, NULL), + g_bytes_get_size (slave->priv->display_x11_cookie)); + } slave->priv->server_display = XOpenDisplay (slave->priv->display_name); @@ -736,9 +739,12 @@ gdm_slave_set_slave_bus_name (GdmSlave *slave) static gboolean gdm_slave_real_start (GdmSlave *slave) { - gboolean res; - char *id; - GError *error; + gboolean res; + char *id; + GError *error; + GVariant *x11_cookie; + const char *x11_cookie_bytes; + gsize x11_cookie_size; g_debug ("GdmSlave: Starting slave"); @@ -826,7 +832,7 @@ gdm_slave_real_start (GdmSlave *slave) error = NULL; res = gdm_dbus_display_call_get_x11_cookie_sync (slave->priv->display_proxy, - &slave->priv->display_x11_cookie, + &x11_cookie, NULL, &error); if (! res) { @@ -835,6 +841,18 @@ gdm_slave_real_start (GdmSlave *slave) return FALSE; } + x11_cookie_bytes = g_variant_get_fixed_array (x11_cookie, + &x11_cookie_size, + sizeof (char)); + + if (x11_cookie_bytes != NULL && x11_cookie_size > 0) { + g_bytes_unref (slave->priv->display_x11_cookie); + slave->priv->display_x11_cookie = g_bytes_new (x11_cookie_bytes, + x11_cookie_size); + } + + g_variant_unref (x11_cookie); + error = NULL; res = gdm_dbus_display_call_get_x11_authority_file_sync (slave->priv->display_proxy, &slave->priv->display_x11_authority_file, @@ -2175,7 +2193,7 @@ gdm_slave_finalize (GObject *object) g_free (slave->priv->parent_display_name); g_free (slave->priv->parent_display_x11_authority_file); g_free (slave->priv->windowpath); - g_free (slave->priv->display_x11_cookie); + g_bytes_unref (slave->priv->display_x11_cookie); G_OBJECT_CLASS (gdm_slave_parent_class)->finalize (object); } |