Fix widget plugin parser 85/81785/2
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 28 Jul 2016 09:57:05 +0000 (18:57 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Tue, 2 Aug 2016 08:23:11 +0000 (01:23 -0700)
- Use pkgmgr_installer_info_get_target_uid() instead of getuid()
- Requires
[slp-pkgmgr] https://review.tizen.org/gerrit/#/c/81631/

Change-Id: I003b0c826c3ccb88aeefa612c9ccb1663dcb05e4
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
packaging/libwidget_service.spec
parser/CMakeLists.txt
parser/widget_plugin_parser_db.c

index 32097b5a5f05797f0b34d834fa81bf55d8ae812f..61f8f6d8bb1ef087421a57fca329827fc59d81a9 100644 (file)
@@ -25,6 +25,7 @@ BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(libxml-2.0)
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(cynara-client)
+BuildRequires: pkgconfig(pkgmgr-installer)
 
 %if "%{model_build_feature_widget}" == "0"
 ExclusiveArch:
index 95c56977b0e35236a240811f26e6aa6f04982fe4..c4d24d2593a3f377352508aa5c1428ecadbaa342 100644 (file)
@@ -14,6 +14,7 @@ pkg_check_modules(PKGS REQUIRED
        libxml-2.0
        dlog
        libtzplatform-config
+       pkgmgr-installer
        )
 FOREACH(FLAGS ${PKGS_CFLAGS})
        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
index 88cc4dc07887e408359b460824307f2296e1de90..d3e84acc30f7406a2e2d8dd266e0b501567614ef 100644 (file)
 
 #include <dlog.h>
 #include <tzplatform_config.h>
+#include <pkgmgr_installer_info.h>
 
 #include "widget_plugin_parser_internal.h"
 
+static int target_uid_initialized;
+static uid_t target_uid;
+
+static uid_t __get_target_uid(void)
+{
+       int ret;
+
+       if (target_uid_initialized)
+               return target_uid;
+
+       ret = pkgmgr_installer_info_get_target_uid(&target_uid);
+       if (ret < 0)
+               LOGE("Failed to get target uid - %d", ret);
+
+       return target_uid;
+}
+
 static int _bind_text(sqlite3_stmt *stmt, int idx, const char *text)
 {
        if (text)
@@ -38,7 +56,7 @@ static int _bind_text(sqlite3_stmt *stmt, int idx, const char *text)
 static const char *_get_root_path(const char *pkgid)
 {
        const char *path;
-       uid_t uid = getuid();
+       uid_t uid = __get_target_uid();
 
        if (uid == 0) {
                path = tzplatform_mkpath(TZ_SYS_RO_APP, pkgid);
@@ -257,7 +275,7 @@ int widget_parser_db_insert_widget_class(const char *pkgid, GList *widget_list)
        int ret;
        sqlite3 *db;
 
-       db = _open_db(getuid(), false);
+       db = _open_db(__get_target_uid(), false);
        if (db == NULL)
                return -1;
 
@@ -317,7 +335,7 @@ int widget_parser_db_remove_widget_class(const char *pkgid)
        int ret;
        sqlite3 *db;
 
-       db = _open_db(getuid(), false);
+       db = _open_db(__get_target_uid(), false);
        if (db == NULL)
                return -1;