From 36f3e6fed4be6947988fe27352e75bdfe9182887 Mon Sep 17 00:00:00 2001 From: Younho Park Date: Wed, 21 Sep 2016 14:07:34 +0900 Subject: [PATCH] fix for internal UTC Change-Id: Iea39953435400999d86b29d0924d580cca8dcf83 Signed-off-by: Younho Park --- packaging/libaccount-service.spec | 2 +- src/account.c | 15 ++++++++++++++- src/account_offline.c | 12 ++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/packaging/libaccount-service.spec b/packaging/libaccount-service.spec index d0cc8bb..956673a 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.5 +Version: 0.4.6 Release: 1 Group: Social & Content/API License: Apache-2.0 diff --git a/src/account.c b/src/account.c index c11544d..33050a9 100644 --- a/src/account.c +++ b/src/account.c @@ -492,6 +492,10 @@ ACCOUNT_INTERNAL_API int account_update_to_db_by_id_without_permission(account_h _ERR("pkgmgr_installer_info_get_target_uid() fail"); return ACCOUNT_ERROR_DB_NOT_OPENED; } + /* Workaround for internal UTC */ + if (uid == 0) + uid = getuid(); + bool is_success = account_manager_call_account_query_account_by_account_id_sync(acc_mgr, account_id, (int)uid, &account_serialized_old, NULL, &error); if (!is_success) { @@ -2237,7 +2241,7 @@ ACCOUNT_API int account_type_get_provider_feature_all(account_type_h account_typ feature_data = (provider_feature_s *)iter->data; if (callback(feature_data->app_id, feature_data->key, user_data) != TRUE) { - ACCOUNT_DEBUG("Callback func returs FALSE, its iteration is stopped!!!!\n"); + ACCOUNT_DEBUG("Callback func returns FALSE, its iteration is stopped!!!!\n"); return ACCOUNT_ERROR_NONE; } } @@ -2358,6 +2362,10 @@ ACCOUNT_INTERNAL_API int account_type_insert_to_db(account_type_h account_type, return ACCOUNT_ERROR_DB_NOT_OPENED; } + /* Workaround for internal UTC */ + if (uid == 0) + uid = getuid(); + bool is_success = account_manager_call_account_type_add_sync(acc_mgr, account_type_serialized, (int)uid, &db_id, NULL, &error); _account_manager_release_instance(); @@ -2429,6 +2437,11 @@ ACCOUNT_INTERNAL_API int account_type_delete_by_app_id(const char *app_id) _ERR("pkgmgr_installer_info_get_target_uid() fail"); return ACCOUNT_ERROR_DB_NOT_OPENED; } + + /* Workaround for internal UTC */ + if (uid == 0) + uid = getuid(); + bool is_success = account_manager_call_account_type_delete_by_app_id_sync(acc_mgr, app_id, (int)uid, NULL, &error); _account_manager_release_instance(); diff --git a/src/account_offline.c b/src/account_offline.c index ad92f8b..f443a42 100644 --- a/src/account_offline.c +++ b/src/account_offline.c @@ -163,6 +163,10 @@ static int _account_global_db_open(int mode) return ACCOUNT_ERROR_DB_NOT_OPENED; } + /* Workaround for internal UTC */ + if (uid == 0) + uid = getuid(); + 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; @@ -274,7 +278,7 @@ ACCOUNT_INTERNAL_API int account_type_insert_to_db_offline(account_type_h accoun _INFO("account_manager_account_type_add start"); guint pid = getpid(); - _INFO("client Id = [%u]", pid); + _INFO("client pid = [%u]", pid); return_code = _account_global_db_open(1); if (return_code != ACCOUNT_ERROR_NONE) { @@ -287,6 +291,10 @@ ACCOUNT_INTERNAL_API int account_type_insert_to_db_offline(account_type_h accoun return ACCOUNT_ERROR_DB_NOT_OPENED; } + /* Workaround for internal UTC */ + if (uid == 0) + uid = getuid(); + if (uid != OWNER_ROOT && uid != GLOBAL_USER) { _ERR("current process is not root user nor global user, uid=%d", uid); goto RETURN; @@ -393,7 +401,7 @@ ACCOUNT_INTERNAL_API int account_delete_from_db_by_package_name_offline(const ch return ACCOUNT_ERROR_DB_NOT_OPENED; } - if (uid != OWNER_ROOT || uid != GLOBAL_USER) { + if (uid != OWNER_ROOT && uid != GLOBAL_USER) { _ERR("current process user is not root, uid=%d", uid); return_code = ACCOUNT_ERROR_PERMISSION_DENIED; goto RETURN; -- 2.34.1