Remove pkgmgr-installer dependency 72/308672/1 accepted/tizen/unified/20240401.021604 accepted/tizen/unified/x/20240401.013231
authorIlho Kim <ilho159.kim@samsung.com>
Thu, 28 Mar 2024 12:49:08 +0000 (21:49 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Thu, 28 Mar 2024 12:49:08 +0000 (21:49 +0900)
Change-Id: I00b354e83b055725a2b78465d13cbac92d7c8c4c
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
CMakeLists.txt
packaging/aul.spec
src/parser/boot-sequencer/CMakeLists.txt
src/parser/boot-sequencer/parser_plugin.cc
src/parser/component/CMakeLists.txt
src/parser/component/src/component_plugin_parser_db.c
src/parser/exec-checker/CMakeLists.txt
src/parser/exec-checker/src/plugin_manager.cc
src/parser/metadata/alias-appid/CMakeLists.txt
src/parser/metadata/allowed-appid/CMakeLists.txt
src/parser/metadata/common/metadata_plugin.cc

index 9da7ab4..f432afe 100644 (file)
@@ -56,7 +56,6 @@ PKG_CHECK_MODULES(LIBTZPLATFORM_CONFIG_DEPS REQUIRED libtzplatform-config)
 PKG_CHECK_MODULES(LIBXML_DEPS REQUIRED libxml-2.0)
 PKG_CHECK_MODULES(PARCEL_DEPS REQUIRED parcel)
 PKG_CHECK_MODULES(PKGMGR_INFO_DEPS REQUIRED pkgmgr-info)
-PKG_CHECK_MODULES(PKGMGR_INSTALLER_DEPS REQUIRED pkgmgr-installer)
 PKG_CHECK_MODULES(SQLITE3_DEPS REQUIRED sqlite3)
 PKG_CHECK_MODULES(TTRACE_DEPS REQUIRED ttrace)
 PKG_CHECK_MODULES(UUID_DEPS REQUIRED uuid)
index 0277a3e..0837ceb 100644 (file)
@@ -31,7 +31,6 @@ BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(libxml-2.0)
 BuildRequires:  pkgconfig(parcel)
 BuildRequires:  pkgconfig(pkgmgr-info)
-BuildRequires:  pkgconfig(pkgmgr-installer)
 BuildRequires:  pkgconfig(sqlite3)
 BuildRequires:  pkgconfig(ttrace)
 BuildRequires:  pkgconfig(uuid)
index 0c43967..9ca9a93 100644 (file)
@@ -22,7 +22,6 @@ APPLY_PKG_CONFIG(${TARGET_BOOT_SEQUENCER_PARSER_PLUGIN} PUBLIC
   LIBTZPLATFORM_CONFIG_DEPS
   LIBXML_DEPS
   PKGMGR_INFO_DEPS
-  PKGMGR_INSTALLER_DEPS
 )
 
 INSTALL(TARGETS ${TARGET_BOOT_SEQUENCER_PARSER_PLUGIN}
index ceff9d6..f05291c 100644 (file)
@@ -16,8 +16,8 @@
 
 #include "parser_plugin.hh"
 
+#include <dlfcn.h>
 #include <pkgmgr-info.h>
-#include <pkgmgr_installer_info.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -28,6 +28,9 @@
 #include "cert_checker.hh"
 #include "log_private.hh"
 
+#define LIBPKGMGR_INSTALLER LIBDIR "/libpkgmgr_installer.so.0"
+#define GET_TARGET_UID_FUNCTION "pkgmgr_installer_info_get_target_uid"
+
 namespace boot_sequencer {
 namespace {
 
@@ -52,8 +55,27 @@ std::string GetAttribute(xmlNode* node, const char* key) {
 }
 
 uid_t GetTargetUid() {
+  static void* handle = nullptr;
+  static int (*dl_func)(uid_t*);
+
+  if (handle == nullptr) {
+    handle = dlopen(LIBPKGMGR_INSTALLER, RTLD_GLOBAL | RTLD_LAZY);
+    if (!handle) {
+      _E("Failed to open library: %s, : %s", LIBPKGMGR_INSTALLER, dlerror());
+      return false;
+    }
+    dl_func = reinterpret_cast<int (*)(uid_t*)>(
+            dlsym(handle, GET_TARGET_UID_FUNCTION));
+    if (dl_func == nullptr) {
+      _E("cannot find %s symbol in %s", GET_TARGET_UID_FUNCTION, LIBPKGMGR_INSTALLER);
+      dlclose(handle);
+      handle = nullptr;
+      return false;
+    }
+  }
+
   uid_t target_uid;
-  pkgmgr_installer_info_get_target_uid(&target_uid);
+  dl_func(&target_uid);
   return target_uid;
 }
 
index 597fe7b..bebe9f2 100644 (file)
@@ -19,7 +19,6 @@ APPLY_PKG_CONFIG(${TARGET_COMPONENT_PLUGIN_PARSER} PUBLIC
   LIBTZPLATFORM_CONFIG_DEPS
   LIBXML_DEPS
   PKGMGR_INFO_DEPS
-  PKGMGR_INSTALLER_DEPS
   SQLITE3_DEPS
 )
 
index 4a44057..c9f5701 100644 (file)
 #include <linux/limits.h>
 #include <sqlite3.h>
 #include <tzplatform_config.h>
-#include <pkgmgr_installer_info.h>
 #include <dlog.h>
 
 #include "component_plugin_parser_db.h"
 #include "component_plugin_parser_private.h"
 
 #define LIBCAPI_SYSTEM_INFO LIBDIR"/libcapi-system-info.so.0"
+#define LIBPKGMGR_INSTALLER LIBDIR "/libpkgmgr_installer.so.0"
+#define GET_TARGET_UID_FUNCTION "pkgmgr_installer_info_get_target_uid"
 
 #define BUSY_WAITING_USEC 50000
 #define BUSY_WAITING_MAX 40
@@ -90,7 +91,25 @@ uid_t component_plugin_parser_db_get_target_uid(void)
        if (target_uid != (uid_t)-1)
                return target_uid;
 
-       ret = pkgmgr_installer_info_get_target_uid(&target_uid);
+       static void* handle = NULL;
+       static int (*dl_func)(uid_t*);
+
+       if (handle == NULL) {
+               handle = dlopen(LIBPKGMGR_INSTALLER, RTLD_GLOBAL | RTLD_LAZY);
+               if (!handle) {
+                       LOGE("Failed to open library: %s, : %s", LIBPKGMGR_INSTALLER, dlerror());
+                       return false;
+               }
+               dl_func = dlsym(handle, GET_TARGET_UID_FUNCTION);
+               if (dl_func == NULL) {
+                       LOGE("cannot find %s symbol in %s", GET_TARGET_UID_FUNCTION, LIBPKGMGR_INSTALLER);
+                       dlclose(handle);
+                       handle = NULL;
+                       return false;
+               }
+       }
+
+       ret = dl_func(&target_uid);
        if (ret < 0)
                LOGE("Failed to get target uid. error(%d)", ret);
 
index 4716f73..3300f9b 100644 (file)
@@ -19,7 +19,6 @@ APPLY_PKG_CONFIG(${TARGET_CHECK_EXEC_PLUGIN_PARSER} PUBLIC
   LIBTZPLATFORM_CONFIG_DEPS
   LIBXML_DEPS
   PKGMGR_INFO_DEPS
-  PKGMGR_INSTALLER_DEPS
 )
 
 INSTALL(TARGETS ${TARGET_CHECK_EXEC_PLUGIN_PARSER}
index 01d90e8..5fc45b5 100644 (file)
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
+#include <dlfcn.h>
 #include <libxml/tree.h>
 #include <pkgmgr-info.h>
-#include <pkgmgr_installer_info.h>
 #include <unistd.h>
 
 #include <memory>
@@ -27,6 +27,9 @@
 #include "exec_checker_private.hh"
 #include "plugin_manager.hh"
 
+#define LIBPKGMGR_INSTALLER LIBDIR "/libpkgmgr_installer.so.0"
+#define GET_TARGET_UID_FUNCTION "pkgmgr_installer_info_get_target_uid"
+
 namespace plugin {
 namespace {
 
@@ -68,13 +71,32 @@ void PluginManager::Init(xmlDocPtr doc, std::string package) {
 }
 
 int PluginManager::Process() {
+  static void* handle = nullptr;
+  static int (*dl_func)(uid_t*);
   xmlNode* root = xmlDocGetRootElement(doc_);
   if (root == nullptr) {
     LOGE_STD("Failed to get root element");
     return -1;
   }
+
+  if (handle == nullptr) {
+    handle = dlopen(LIBPKGMGR_INSTALLER, RTLD_GLOBAL | RTLD_LAZY);
+    if (!handle) {
+      LOGE_STD("Failed to open library: %s, : %s", LIBPKGMGR_INSTALLER, dlerror());
+      return false;
+    }
+    dl_func = reinterpret_cast<int (*)(uid_t*)>(
+            dlsym(handle, GET_TARGET_UID_FUNCTION));
+    if (dl_func == nullptr) {
+      LOGE_STD("cannot find %s symbol in %s", GET_TARGET_UID_FUNCTION, LIBPKGMGR_INSTALLER);
+      dlclose(handle);
+      handle = nullptr;
+      return false;
+    }
+  }
+
   uid_t uid;
-  int ret = pkgmgr_installer_info_get_target_uid(&uid);
+  int ret = dl_func(&uid);
   if (ret != PMINFO_R_OK) {
     LOGE_STD("Failed to get target uid. (%s)", package_.c_str());
     return -1;
index 8a31b41..7214877 100644 (file)
@@ -19,7 +19,6 @@ APPLY_PKG_CONFIG(${TARGET_ALIAS_APPID_PLUGIN} PUBLIC
   GLIB_DEPS
   LIBTZPLATFORM_CONFIG_DEPS
   LIBXML_DEPS
-  PKGMGR_INSTALLER_DEPS
   SQLITE3_DEPS
 )
 
index 7a2ffe8..8cad2c8 100644 (file)
@@ -19,7 +19,6 @@ APPLY_PKG_CONFIG(${TARGET_ALLOWED_APPID_PLUGIN} PUBLIC
   GLIB_DEPS
   LIBTZPLATFORM_CONFIG_DEPS
   LIBXML_DEPS
-  PKGMGR_INSTALLER_DEPS
   SQLITE3_DEPS
 )
 
index bfd0bfb..2e1b2ea 100644 (file)
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
+#include <dlfcn.h>
 #include <unistd.h>
-#include <pkgmgr_installer_info.h>
 
 #include "common/database.hh"
 #include "common/exception.hh"
@@ -23,6 +23,9 @@
 #include "common/metadata_plugin.hh"
 #include "common/metadata_type.hh"
 
+#define LIBPKGMGR_INSTALLER LIBDIR "/libpkgmgr_installer.so.0"
+#define GET_TARGET_UID_FUNCTION "pkgmgr_installer_info_get_target_uid"
+
 namespace plugin {
 
 void MetadataPlugin::AddAppEventArgs(const std::string& pkgid,
@@ -84,8 +87,27 @@ Database* MetadataPlugin::GetDB() {
 }
 
 uid_t MetadataPlugin::GetUid() {
+  static void* handle = nullptr;
+  static int (*dl_func)(uid_t*);
+
+  if (handle == nullptr) {
+    handle = dlopen(LIBPKGMGR_INSTALLER, RTLD_GLOBAL | RTLD_LAZY);
+    if (!handle) {
+      _E("Failed to open library: %s, : %s", LIBPKGMGR_INSTALLER, dlerror());
+      return false;
+    }
+    dl_func = reinterpret_cast<int (*)(uid_t*)>(
+            dlsym(handle, GET_TARGET_UID_FUNCTION));
+    if (dl_func == nullptr) {
+      _E("cannot find %s symbol in %s", GET_TARGET_UID_FUNCTION, LIBPKGMGR_INSTALLER);
+      dlclose(handle);
+      handle = nullptr;
+      return false;
+    }
+  }
+
   uid_t target_uid;
-  pkgmgr_installer_info_get_target_uid(&target_uid);
+  dl_func(&target_uid);
   return target_uid;
 }