Bypass the tidl pkgmgr signal 16/307316/6
authorInkyun Kil <inkyun.kil@samsung.com>
Thu, 7 Mar 2024 05:48:16 +0000 (14:48 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Tue, 26 Mar 2024 23:54:13 +0000 (08:54 +0900)
- As the communication protocol of Pkgmgr has been changed from dbus to tidl,
  it sends out signals via the EventSystem.
  Therefore, Pkgmgr signals can be passed through.

Related patch : https://review.tizen.org/gerrit/c/platform/core/appfw/event-system/+/308452

Change-Id: I49cc4610c0986ee34e93376597f3ecd0d9d108b3
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
include/eventsystem_internal.h
src/eventsystem.c
tests/unit_tests/src/test_eventsystem.cc

index 044f06d51fe5157b1a5676654603c0f31c3f5ac3..961a87d9661ae18578782267af740fd6172fbb56 100644 (file)
@@ -301,6 +301,9 @@ extern "C" {
 #define EVT_VAL_NETWORK_BT "bt"
 #define EVT_VAL_NETWORK_NET_PROXY "net_proxy"
 
+/** This event name is for Pkgmgr-server */
+#define RESERVED_NAME_FOR_USER_PKGMGRSIGNAL "event.signal_agent.tidl_iface_PkgSignal"
+
 #ifdef __cplusplus
 }
 #endif
index e1ea13dfc1389bcbe6cfba63c02ce08ca2eb9ed1..09f01fcd01142b5262af432da7e8949912b8232e 100644 (file)
@@ -27,6 +27,8 @@
 #define VALID_LAST_COUNT_FOR_EVENTNAME (VALID_COUNT_OF_EVENTNAME_TOKEN + 1)
 #define MAX_COUNT_FOR_EVENTNAME_CHECK (VALID_LAST_COUNT_FOR_EVENTNAME + 1)
 
+#define REGULAR_USER 5000
+
 #define FREE_AND_NULL(ptr) do { \
        if (ptr) { \
                free((void *)ptr); \
@@ -351,6 +353,16 @@ static int __check_validation_user_defined_name(const char *event_name)
        return ret;
 }
 
+static bool __is_pkgmgr_signal_user_event(const char *event_name)
+{
+       int reserved_name_len = strlen(RESERVED_NAME_FOR_USER_PKGMGRSIGNAL);
+
+       if (strncmp(event_name, RESERVED_NAME_FOR_USER_PKGMGRSIGNAL, reserved_name_len) == 0)
+               return true;
+
+       return false;
+}
+
 static int __check_interface_validation_user(char *interface_name)
 {
        int len = strlen(EVENT_SYSTEM_PREFIX);
@@ -1308,6 +1320,9 @@ static int __eventsystem_check_privilege_validation(const char *event_name)
        if (!_initialized)
                __initialize();
 
+       if (getuid() < REGULAR_USER)
+               return ES_R_OK;
+
        if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, ES_TYPE_SYSTEM) < 0) {
                _E("getting gdbus-connetion error");
                ret = ES_R_ERROR;
@@ -1997,8 +2012,9 @@ API int eventsystem_register_application_event(const char *event_name,
                                g_dbus_connection_signal_unsubscribe(conn, subscription_id);
                                __destroy_eventmap(em);
                        } else {
-                               if (__eventsystem_setup_trusted_peer(event_name,
-                                                       s_info.own_name_session_bus) < 0) {
+                               if (!__is_pkgmgr_signal_user_event(event_name) &&
+                                               __eventsystem_setup_trusted_peer(event_name,
+                                               s_info.own_name_session_bus) < 0) {
                                        _E("failed to setup trusted peer");
                                        ret = ES_R_ERROR;
                                        g_dbus_connection_signal_unsubscribe(conn, subscription_id);
index a10befbc70ec866e6c8924b5b95c35b590420501..b525595ac98ed81b5c01e1494d879a9b778d1290 100644 (file)
@@ -32,6 +32,10 @@ using ::testing::Invoke;
 using ::testing::Return;
 using ::testing::SetArgPointee;
 
+extern "C" uid_t getuid() {
+  return 5001;
+}
+
 class Mocks : public ::testing::NiceMock<GioMock> {};
 
 class EventSystemTest : public TestFixture {