From ba3d6b25bf3445fd80473238e85bb7ea97a70da7 Mon Sep 17 00:00:00 2001 From: "jiseob.jang" Date: Thu, 28 Jul 2016 17:04:38 +0900 Subject: [PATCH] apply pkgmgr-installer Change-Id: I623f5d80ea6282938467d5d70c2b2705166b02a9 Signed-off-by: jiseob.jang --- CMakeLists.txt | 2 +- packaging/libaccount-service.spec | 3 ++- src/CMakeLists.txt | 1 + src/account_offline.c | 26 ++++++++++++++++++++++---- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9646c1..bb201f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,6 @@ SET(EXEC_PREFIX ${_prefix}) #SET(LIBDIR "\${prefix}/lib") #SET(INCLUDEDIR "\${prefix}/include ") SET(VERSION_MAJOR 0) -SET(VERSION "${VERSION_MAJOR}.4.4") +SET(VERSION "${VERSION_MAJOR}.4.5") ADD_SUBDIRECTORY(src) diff --git a/packaging/libaccount-service.spec b/packaging/libaccount-service.spec index dadd1e2..0e08e81 100644 --- a/packaging/libaccount-service.spec +++ b/packaging/libaccount-service.spec @@ -1,7 +1,7 @@ Name: libaccount-service Summary: Account DB library -Version: 0.4.4 +Version: 0.4.5 Release: 1 Group: Social & Content/API License: Apache-2.0 @@ -15,6 +15,7 @@ BuildRequires: pkgconfig(glib-2.0) >= 2.26 BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(account-common) BuildRequires: pkgconfig(db-util) +BuildRequires: pkgconfig(pkgmgr-installer) %if "%{?profile}" == "tv" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4e829a1..82554d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,7 @@ pkg_check_modules(clientpkgs REQUIRED vconf account-common db-util + pkgmgr-installer ) FOREACH(flag ${clientpkgs_CFLAGS}) diff --git a/src/account_offline.c b/src/account_offline.c index 01c9e8d..a58b542 100644 --- a/src/account_offline.c +++ b/src/account_offline.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -157,7 +158,11 @@ static int _account_global_db_open(int mode) ACCOUNT_MEMSET(account_db_dir, 0x00, sizeof(account_db_dir)); ACCOUNT_MEMSET(account_db_path, 0x00, sizeof(account_db_path)); - uid = getuid(); + if (pkgmgr_installer_info_get_target_uid(&uid) < 0) { + ACCOUNT_ERROR("pkgmgr_installer_info_get_target_uid() fail"); + return ACCOUNT_ERROR_DB_NOT_OPENED; + } + if (uid != OWNER_ROOT && uid != GLOBAL_USER) { ACCOUNT_ERROR("global db open fail. user not both root or global user"); return ACCOUNT_ERROR_PERMISSION_DENIED; @@ -277,7 +282,11 @@ ACCOUNT_INTERNAL_API int account_type_insert_to_db_offline(account_type_h accoun goto RETURN; } - uid = getuid(); + if (pkgmgr_installer_info_get_target_uid(&uid) < 0) { + ACCOUNT_ERROR("pkgmgr_installer_info_get_target_uid() fail"); + return ACCOUNT_ERROR_DB_NOT_OPENED; + } + if (uid != OWNER_ROOT && uid != GLOBAL_USER) { _ERR("current process is not root user nor global user, uid=%d", uid); goto RETURN; @@ -333,7 +342,12 @@ ACCOUNT_INTERNAL_API int account_type_delete_by_app_id_offline(const char *app_i goto RETURN; } - uid_t uid = getuid(); + uid_t uid; + if (pkgmgr_installer_info_get_target_uid(&uid) < 0) { + ACCOUNT_ERROR("pkgmgr_installer_info_get_target_uid() fail"); + return ACCOUNT_ERROR_DB_NOT_OPENED; + } + if (uid != OWNER_ROOT && uid != GLOBAL_USER) { _ERR("current daemon is not root user, uid=%d", uid); goto RETURN; @@ -374,7 +388,11 @@ ACCOUNT_INTERNAL_API int account_delete_from_db_by_package_name_offline(const ch ACCOUNT_RETURN_VAL((package_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("package_name is null!")); - uid = getuid(); + if (pkgmgr_installer_info_get_target_uid(&uid) < 0) { + ACCOUNT_ERROR("pkgmgr_installer_info_get_target_uid() fail"); + return ACCOUNT_ERROR_DB_NOT_OPENED; + } + if (uid != 0) { _ERR("current process user is not root, uid=%d", uid); return_code = ACCOUNT_ERROR_PERMISSION_DENIED; -- 2.34.1