From 5c23edb8946dd432cb3dc3a6e240925f7498ac56 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 19 Dec 2016 14:22:47 +0900 Subject: [PATCH] Add uid check routine at cleardata functions - Calling cleardata with global uid will not be allowed because cleardata will only works for userdata of each user, not pkg itself Change-Id: I1d1ff1e24f593c080060f16580a40ace17f845f7 Signed-off-by: Junghyun Yeon --- client/include/package-manager.h | 3 +++ client/src/pkgmgr.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/include/package-manager.h b/client/include/package-manager.h index d744200..7a93e55 100644 --- a/client/include/package-manager.h +++ b/client/include/package-manager.h @@ -550,6 +550,7 @@ int pkgmgr_client_activate_global_app_for_uid(pkgmgr_client *pc, const char *app * * This API is for package-manager client application.\n * + * @remarks You should call this function with regular uid * @param[in] pc pkgmgr_client * @param[in] pkg_type package type * @param[in] pkgid package id @@ -750,6 +751,7 @@ int pkgmgr_client_usr_request_size_info(uid_t uid); * * This API is for package-manager client application.\n * + * @remarks You should call this function with regular uid * @param[in] pkgid package id * @return 0 if success, error code(<0) if fail\n * @retval PKGMGR_R_OK success @@ -765,6 +767,7 @@ int pkgmgr_client_usr_clear_cache_dir(const char *pkgid, uid_t uid); * * This API is for package-manager client application.\n * + * @remarks You should call this function with regular uid * @return 0 if success, error code(<0) if fail\n * @retval PKGMGR_R_OK success * @retval PKGMGR_R_EINVAL invalid argument diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index 76acb22..c594e1f 100644 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -1197,7 +1197,7 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, int ret; struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc; - if (pc == NULL || appid == NULL) { + if (pc == NULL || appid == NULL || uid == GLOBAL_USER) { ERR("invalid parameter"); return PKGMGR_R_EINVAL; } @@ -1209,7 +1209,7 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, ret = pkgmgr_client_connection_send_request(client, "cleardata", g_variant_new("(us)", uid, appid), &result); - if (ret == PKGMGR_R_OK) { + if (ret != PKGMGR_R_OK) { ERR("request failed: %d", ret); return ret; } @@ -1433,7 +1433,7 @@ API int pkgmgr_client_usr_clear_cache_dir(const char *pkgid, uid_t uid) int ret; struct pkgmgr_client_t *client; - if (pkgid == NULL) { + if (pkgid == NULL || uid == GLOBAL_USER) { ERR("invalid parameter"); return PKGMGR_R_EINVAL; } @@ -1470,7 +1470,7 @@ API int pkgmgr_client_clear_usr_all_cache_dir(uid_t uid) API int pkgmgr_client_clear_all_cache_dir(void) { return pkgmgr_client_usr_clear_cache_dir( - PKG_CLEAR_ALL_CACHE, getuid()); + PKG_CLEAR_ALL_CACHE, _getuid()); } API int pkgmgr_client_get_size(pkgmgr_client *pc, const char *pkgid, -- 2.7.4