From: Mateusz Moscicki Date: Wed, 28 Jun 2023 13:59:03 +0000 (+0200) Subject: Revert "Allow to change the default connection type to private" X-Git-Tag: accepted/tizen/unified/20230703.093326^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7916aa8b6d7953afea4d42afbe54436702e176da;p=platform%2Fcore%2Fsystem%2Flibsyscommon.git Revert "Allow to change the default connection type to private" This reverts commit 81ca03541a0b4c72570b65875ce03c6be86e753b. Change-Id: I871cf09f17724070d7e4c437d4638e87c33a5eae --- diff --git a/src/libgdbus/libgdbus.c b/src/libgdbus/libgdbus.c index 3046ab1..32c15ed 100644 --- a/src/libgdbus/libgdbus.c +++ b/src/libgdbus/libgdbus.c @@ -34,7 +34,6 @@ #define DBUS_REPLY_TIMEOUT (10000) static GBusType g_default_bus_type = G_BUS_TYPE_SYSTEM; -static gboolean g_default_priv = false; pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; void gdbus_set_default_bus_type(GBusType bus_type) @@ -94,13 +93,9 @@ typedef struct { static dbus_handle_s g_dh[2]; static dbus_handle_s *_gdbus_get_connection(GBusType bus_type); -static dbus_handle_s *_gdbus_get_connection_private(GBusType bus_type); dbus_handle_s * _gdbus_get_default_connection(void) { - if (g_default_priv) - return _gdbus_get_connection_private(gdbus_get_default_bus_type()); - return _gdbus_get_connection(gdbus_get_default_bus_type()); } @@ -564,7 +559,7 @@ char **gdbus_get_owner_list(dbus_handle_h handle, const char *bus_name) return strv; } -int _gdbus_free_connection(dbus_handle_h handle, gboolean close_any_connection) +int gdbus_free_connection(dbus_handle_h handle) { dcl_gdbus(); dbus_handle_s *pdh = NULL; @@ -648,8 +643,8 @@ int _gdbus_free_connection(dbus_handle_h handle, gboolean close_any_connection) } /* close connection */ - if (pdh->priv || close_any_connection) { - _E("close connection\n"); + if (pdh->priv) { + _E("close private connection\n"); if (!g_dbus_connection_close_sync(pdh->conn, NULL, &err)) { _E("Error closing connection %s\n", err->message); @@ -674,12 +669,6 @@ int _gdbus_free_connection(dbus_handle_h handle, gboolean close_any_connection) // todo: signal ? } -int gdbus_free_connection(dbus_handle_h handle) -{ - return _gdbus_free_connection(handle, false); -} - - #define buf_cal_free_space(size, nwrite) ((size - nwrite - 1) > 0 ? (size - nwrite - 1) : 0) #define buf_block_size 8192 @@ -2893,31 +2882,3 @@ GVariant *gdbus_make_simple_array(const char *sig, int *param) g_variant_builder_unref(builder); return var; } - -int gdbus_switch_to_private_connection(void) -{ - // This function is called by launchpad during the application preparation - // process. Launchpad is running with high privileges (label User). If a call - // to dbus is made before the process privileges are changed to lower (wich is - // what happens now), any method call sent with this connection will be - // visible as a call from a privileged process. - // - // From outside glib we can't effectively close the current connection so as - // to receive a new one (with application label), so this function forces to - // use of a private connection. - - // Close current connection so that it can not be used. - dbus_handle_s *connection = _gdbus_get_connection(gdbus_get_default_bus_type()); - int ret; - if ((ret = _gdbus_free_connection(connection, true)) != 0) - return ret; - - // Switch to a private connection. - pthread_mutex_lock(&g_mutex); - g_default_priv = true; - pthread_mutex_unlock(&g_mutex); - - _I("Switched to private connection."); - - return 0; -} diff --git a/src/libgdbus/libgdbus.h b/src/libgdbus/libgdbus.h index 8313715..659b2e4 100644 --- a/src/libgdbus/libgdbus.h +++ b/src/libgdbus/libgdbus.h @@ -278,8 +278,6 @@ GVariant *gdbus_make_simple_array (const char *sig, int check_systemd_active (void); -int gdbus_switch_to_private_connection (void); - #ifdef __cplusplus } #endif