Fix privilege mis-grouping issue 33/74633/1 accepted/tizen/common/20160615.193611 accepted/tizen/ivi/20160616.002339 accepted/tizen/mobile/20160616.002327 accepted/tizen/tv/20160616.002320 accepted/tizen/wearable/20160616.002314 submit/tizen/20160615.050748
authorYunjin Lee <yunjin-.lee@samsung.com>
Wed, 15 Jun 2016 04:46:59 +0000 (13:46 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Wed, 15 Jun 2016 04:46:59 +0000 (13:46 +0900)
- pkgmgr passes privilege list including internal privileges and it causes misgrouping issue. fix to bypass internal privileges when getting privilege group info.
- fix not to check api version when getting privilege group info(not required).

Change-Id: I6263178b7d747b3fc9fa1bdccfa50d97e73c1246
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
capi/src/privilege_db_manager.c
capi/src/privilege_info.c

index 463b999..208f95d 100755 (executable)
@@ -374,7 +374,7 @@ int privilege_db_manager_get_privilege_group_display(privilege_db_manager_packag
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
-       char *sql = sqlite3_mprintf("select privilege_group_id from privilege_info where(profile_id=%d or profile_id=%d)and package_type_id=%d and privilege_name=%Q and api_version_issued<=%Q and api_version_expired>%Q",
+       char *sql = sqlite3_mprintf("select privilege_group_id from privilege_info where(profile_id=%d or profile_id=%d)and package_type_id=%d and privilege_name=%Q and api_version_issued<=%Q",
                                                                PRIVILEGE_DB_MANAGER_PROFILE_TYPE_COMMON, g_privilege_db_manager_profile_type, package_type, privilege_name, api_version, api_version);
 
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
index e2f60a0..dcf7dbc 100755 (executable)
@@ -38,6 +38,8 @@
 int privilege_info_privilege_list_by_pkgid_callback(const char *privilege_name, void *user_data)
 {
        LOGD("privilege name = %s", privilege_name);
+       if (strstr(privilege_name, "internal") != NULL || strstr(privilege_name, "notexist") != NULL)
+               return PRVMGR_ERR_NONE;
 
        int *groupTable = (int *)user_data;
        TryReturn(privilege_name != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege_name is NULL");
@@ -70,7 +72,7 @@ int privilege_info_privilege_list_by_pkgid_callback(const char *privilege_name,
        return PRVMGR_ERR_NONE;
 }
 
-int privilege_info_foreach_privilege_group_list_by_pkgid(const char *package_id, privilege_info_privileges_cb callback, void *user_data)
+int privilege_info_foreach_privilege_group_list_by_pkgid(const char *package_id, privilege_info_privilege_groups_cb callback, void *user_data)
 {
        LOGD("package id = %s", package_id);
 
@@ -87,9 +89,9 @@ int privilege_info_foreach_privilege_group_list_by_pkgid(const char *package_id,
 
        res = pkgmgrinfo_pkginfo_foreach_privilege(handle, privilege_info_privilege_list_by_pkgid_callback, &groupTable);
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-       TryReturn(res == PMINFO_R_OK, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] pkgmgrinfo_pkginfo_foreach_privilege is failed.")
+       TryReturn(res == PMINFO_R_OK, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] pkgmgrinfo_pkginfo_foreach_privilege is failed.");
 
-               for (i = 0; i < MAX_PRV_GROUP; i++) {
+       for (i = 0; i < MAX_PRV_GROUP; i++) {
                if (groupTable[i] == 1) {
                        res = callback(privilege_group_info_table[i].privilege_group, user_data);
                        LOGD("group = %s", privilege_group_info_table[i].privilege_group);
@@ -139,6 +141,9 @@ int privilege_info_privilege_list_callback(const char *privilege_name, void *use
                return PRVMGR_ERR_INTERNAL_ERROR;
        }
 
+       /* TBD: check if the privilege exist and whether the privilege is internal or not */
+       if (strstr(privilege_name, "internal") != NULL || strstr(privilege_name, "notexist") != NULL)
+        return PRVMGR_ERR_NONE;
        if (data.privilege_group == EXTRA_GROUP) {
                LOGD("data.privilege_group = %d", data.privilege_group);
                res = data.callback(privilege_name, data.user_data);
@@ -174,11 +179,10 @@ int privilege_info_foreach_privilege_list_by_pkgid_and_privilege_group(const cha
        if (data.privilege_group > -1) {
                pkgmgrinfo_pkginfo_h handle;
                res = pkgmgrinfo_pkginfo_get_pkginfo(package_id, &handle);
-               TryReturn(res == PMINFO_R_OK, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] pkgmgrinfo_pkginfo_get_pkginfo is failed.")
-
-                       res = pkgmgrinfo_pkginfo_foreach_privilege(handle, privilege_info_privilege_list_callback, &data);
+               TryReturn(res == PMINFO_R_OK, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] pkgmgrinfo_pkginfo_get_pkginfo is failed.");
+               res = pkgmgrinfo_pkginfo_foreach_privilege(handle, privilege_info_privilege_list_callback, &data);
                pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-               TryReturn(res == PMINFO_R_OK, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] pkgmgrinfo_pkginfo_foreach_privilege is failed.")
+               TryReturn(res == PMINFO_R_OK, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] pkgmgrinfo_pkginfo_foreach_privilege is failed.");
        }
 
        return PRVMGR_ERR_NONE;