X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git;a=blobdiff_plain;f=atk-adaptor%2Fbridge.c;h=98806398ef0d4ca9c5aeb34841febca075033a38;hp=69527c67bb9ce9b64ec225bf7800e4a1a1932abd;hb=7fc3c0ed67c52371855c5db456f26f27dfd22126;hpb=cf4cb7b2e7d546579735002e68fe0d5a2beceaac diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c index 69527c6..9880639 100644 --- a/atk-adaptor/bridge.c +++ b/atk-adaptor/bridge.c @@ -270,7 +270,6 @@ register_application (SpiBridge * app) DBusMessageIter iter; DBusError error; DBusPendingCall *pending; - const int max_addr_length = 128; /* should be long enough */ dbus_error_init (&error); @@ -298,16 +297,24 @@ register_application (SpiBridge * app) if (message) dbus_message_unref (message); - /* could this be better, we accept some amount of race in getting the temp name*/ - /* make sure the directory exists */ - mkdir ("/tmp/at-spi2/", S_IRWXU|S_IRWXG|S_IRWXO|S_ISVTX); - chmod ("/tmp/at-spi2/", S_IRWXU|S_IRWXG|S_IRWXO|S_ISVTX); - app->app_bus_addr = g_malloc(max_addr_length * sizeof(char)); #ifndef DISABLE_P2P - sprintf (app->app_bus_addr, "unix:path=/tmp/at-spi2/socket-%d-%d", getpid(), - rand()); -#else - app->app_bus_addr [0] = '\0'; + if (getuid () != 0) + { + app->app_tmp_dir = g_build_filename (g_get_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; + } + } + + if (app->app_tmp_dir) + 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 ()); #endif return TRUE; @@ -338,6 +345,20 @@ deregister_application (SpiBridge * app) dbus_connection_send (app->bus, message, NULL); if (message) dbus_message_unref (message); + + if (app->app_bus_addr) + { + unlink (app->app_bus_addr); + g_free (app->app_bus_addr); + app->app_bus_addr = NULL; + } + + if (app->app_tmp_dir) + { + rmdir (app->app_tmp_dir); + g_free (app->app_tmp_dir); + app->app_tmp_dir = NULL; + } } /*---------------------------------------------------------------------------*/ @@ -525,6 +546,9 @@ setup_bus (void) DBusServer *server; DBusError err; + if (!spi_global_app_data->app_bus_addr) + return -1; + dbus_error_init(&err); server = dbus_server_listen(spi_global_app_data->app_bus_addr, &err); if (server == NULL)