Make sure the runtime directory exists
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Tue, 8 Mar 2016 18:15:08 +0000 (12:15 -0600)
committerMike Gorse <mgorse@suse.com>
Tue, 8 Mar 2016 18:15:08 +0000 (12:15 -0600)
It may happen that the home directory of the user does not contain the
runtime directory yet, when it's a freshly-created home for instance.
In that case, establishing the p2p socket in spi_atk_create_socket
will fail since it only tries to create a socket in that directory
without checking that the directory exists.

https://bugzilla.gnome.org/show_bug.cgi?id=763274

atk-adaptor/bridge.c

index 76543e95db8106e2d2fadb69c922dc5fc298dafa..e76e833bd751bd155066c6d9b36d8c18ad102559 100644 (file)
@@ -873,16 +873,20 @@ spi_atk_create_socket (SpiBridge *app)
 #ifndef DISABLE_P2P
   DBusServer *server;
   DBusError error;
+  const gchar *user_runtime_dir = g_get_user_runtime_dir ();
+
+  if (g_mkdir_with_parents (user_runtime_dir, 0700) != 0)
+    return -1;
 
   if (getuid () != 0)
   {
-    app->app_tmp_dir = g_build_filename (g_get_user_runtime_dir (),
+    app->app_tmp_dir = g_build_filename (user_runtime_dir,
                                          "at-spi2-XXXXXX", NULL);
     if (!g_mkdtemp (app->app_tmp_dir))
     {
       g_free (app->app_tmp_dir);
       app->app_tmp_dir = NULL;
-      return FALSE;
+      return -1;
     }
   }
 
@@ -890,7 +894,7 @@ spi_atk_create_socket (SpiBridge *app)
     app->app_bus_addr = g_strdup_printf ("unix:path=%s/socket", app->app_tmp_dir);
   else
     app->app_bus_addr = g_strdup_printf ("unix:path=%s/at-spi2-socket-%d",
-                                         g_get_user_runtime_dir (), getpid ());
+                                         user_runtime_dir, getpid ());
 
   if (!spi_global_app_data->app_bus_addr)
     return -1;