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 9da7ab42e2c9623e3045cc7ae3bc753acc302a58..f432afe90f84376f06e8b202f8ad00b7a501e3ac 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 0277a3e0027221b4f5832dae25d1a603ffbc194c..0837cebe67e38f4ece4c81d0d880d2e72a624baa 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 0c43967eade4d9e1d3d126e56c9f55c48ea3cf2a..9ca9a93344af69d43759fca569ced286b3768858 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 ceff9d6d5e6d60fb5b5989233a96c2085e57ae75..f05291cce8e4451e80fc3113568ebb39d85bb938 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 597fe7b8c32a9ac2603d1b07ff10e229025538ca..bebe9f24cfe0bf988e37106f27c1020eb245a6d4 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 4a440570762176e251b48da2f9fdda5085506a58..c9f5701ea5a6565b9c595ec55d79b092c510826d 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 4716f73dcbe70ce57586b37b527ac699bdc92e5f..3300f9b57bbfccca35eb477cc88ace4ec422b44b 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 01d90e8aef7dccffef7ba745f2a443eece8aa3a8..5fc45b574396bc1178a5f3cecfe9cae0ed9a550c 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 8a31b41809a7440bb9214fcf0e101675ad18be3b..7214877a89493ddcb587387387fd324dfbc293c1 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 7a2ffe8e5d98cf8d8707c57b73e42418dedd089f..8cad2c80d36303d83904542bfb22a6cec703b679 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 bfd0bfb88b0e688f56cf0214993adf0c3c0163dc..2e1b2ea8f25f8b7254f71b9a46af353deee0e219 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;
 }