1. Add APIs for checing valid/internal/privacy privilege and table for the APIs 2... 14/76914/1 accepted/tizen/common/20160629.222347 accepted/tizen/ivi/20160629.020408 accepted/tizen/mobile/20160629.020426 accepted/tizen/tv/20160629.020401 accepted/tizen/wearable/20160629.020415 submit/tizen/20160628.064857
authorYunjin Lee <yunjin-.lee@samsung.com>
Tue, 28 Jun 2016 01:57:44 +0000 (10:57 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Tue, 28 Jun 2016 01:57:44 +0000 (10:57 +0900)
Change-Id: I47b0e61ca3a6bd31cfce83033d4e36aa0cd772ec
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
15 files changed:
capi/include/privilege_db_manager.h
capi/include/privilege_info.h
capi/res/dbspace/core_db_generator.sh
capi/res/dbspace/core_mapping_db_generator.sh
capi/res/dbspace/internal_only.list [new file with mode: 0644]
capi/res/dbspace/tv_core_db_generator.sh
capi/res/dbspace/tv_core_mapping_db_generator.sh
capi/res/dbspace/tv_wrt_db_generator.sh
capi/res/dbspace/tv_wrt_mapping_db_generator.sh
capi/res/dbspace/wrt_db_generator.sh
capi/res/dbspace/wrt_mapping_db_generator.sh
capi/src/privilege_db_manager.c
capi/src/privilege_info.c
test/tc-common.c
test/tc-privilege-info.c

index aaf6cc3..6e57e8c 100755 (executable)
@@ -72,7 +72,7 @@ int privilege_db_manager_get_privilege_description(privilege_db_manager_package_
 
 int privilege_db_manager_get_privilege_group_display(privilege_db_manager_package_type_e package_type, const char* privilege_name, const char* api_version, int* privilege_group_number);
 
-int __privilege_db_manager_is_privacy(const char* privilege);
+int privilege_db_manager_is(char type, const char* privilege);
 int __privilege_db_manager_get_privacy_list(GList** privacy_list);
 int __privilege_db_manager_get_privilege_list_by_privacy(const char* privacy, GList **privilege_list);
 
index 992e359..d15b7ea 100644 (file)
@@ -111,6 +111,20 @@ EXPORT_API int privilege_info_get_privilege_display_name(const char *privilege,
 EXPORT_API int privilege_info_get_privilege_description(const char *privilege, char **description);
 
 /**
+ * @brief Determines whether the given privilege is valid.
+ * @param [in]  privilege The privilege
+ * @return 1 if true(=is valid privilege. the privilege can be granted by security-manager and checked by cynara), 0 if false, and -1 on error
+ */
+EXPORT_API int privilege_info_is_valid(const char *privilege);
+
+/**
+ * @brief Determines whether the given privilege is internal privilege.
+ * @param [in]  privilege The privilege
+ * @return 1 if true(=is internal privilege), 0 if false, and -1 on error
+ */
+EXPORT_API int privilege_info_is_internal(const char *privilege);
+
+/**
  * @brief Determines whether the given privilege is privacy related or not.
  * @param [in]  privilege The privilege
  * @return 1 if true(=is privacy related privilege), 0 if false, and -1 on error
index de631a9..b637d87 100755 (executable)
@@ -11,6 +11,9 @@ target_profile=$1
 echo "Creating PRIVILEGE_INFO table ..."
 sqlite3 $DB_NAME "CREATE TABLE PRIVILEGE_INFO (PROFILE_ID NUMERIC, PROFILE TEXT, PACKAGE_TYPE_ID NUMERIC, PACKAGE_TYPE TEXT, PRIVILEGE_LEVEL_ID NUMERIC, PRIVILEGE_LEVEL TEXT, API_VERSION_ISSUED TEXT, API_VERSION_EXPIRED TEXT, DOCUMENTED INTEGER, PRIVILEGE_NAME TEXT, IS_PRIVACY NUMERIC, PRIVACY_GROUP TEXT, PRIVILEGE_DISPLAY TEXT, PRIVILEGE_DESCRIPTION TEXT, PRIVILEGE_GROUP_ID NUMERIC, PRIVLEGE_GROUP TEXT, CHANGED_TO_2_3_1 TEXT, CHANGED_TO_2_4_0 TEXT);"
 
+echo "Create Valid Privilege Info Table..."
+sqlite3 $DB_NAME "CREATE TABLE VALID_PRIVILEGE_INFO (PRIVILEGE_NAME TEXT UNIQUE, IS_PRIVACY NUMERIC, IS_INTERNAL NUMERIC);"
+
 echo "Inserting data ..."
 IFS=$'\n'
 for i in `cat core_privilege_info.csv`
@@ -151,7 +154,11 @@ do
        echo "Inserting $PRIVILEGE_NAME ..."
 
        sqlite3 $DB_NAME "insert into privilege_info values ( $PROFILE_ID, '$PROFILE', $PACKAGE_TYPE_ID, '$PACKAGE_TYPE', $PRIVILEGE_LEVEL_ID, '$PRIVILEGE_LEVEL', '$API_VERSION_ISSUED', '$API_VERSION_EXPIRED', '$DOCUMENTED', '$PRIVILEGE_NAME', '$IS_PRIVACY', '$PRIVACY_GROUP', '$PRIVILEGE_DISPLAY', '$PRIVILEGE_DESCRIPTION', $PRIVILEGE_GROUP_ID, '$PRIVILEGE_GROUP', '$CHANGED_TO_2_3_1', '$CHANGED_TO_2_4_0')"
+       sqlite3 $DB_NAME "insert into valid_privilege_info (privilege_name, is_privacy, is_internal) values ('$PRIVILEGE_NAME', '$IS_PRIVACY', 0)"
 done
 
-echo "Check inserted data"
-sqlite3 $DB_NAME "select * from privilege_info"
+for internal_privilege in `cat internal_only.list`
+do
+       echo "Inserting $internal_privilege ..."
+       sqlite3 $DB_NAME "insert into valid_privilege_info (privilege_name, is_privacy, is_internal) values ('$internal_privilege', 0, 1)"
+done
index ec5e5ec..c5040cb 100755 (executable)
@@ -52,7 +52,6 @@ do
        echo "Inserting $PRIVILEGE_NAME $MAPPED_PRIVILEGE_NAME..."
 
        sqlite3 $DB_NAME "insert into privilege_mapping values ( $PROFILE_ID, '$PROFILE', '$PRIVILEGE_NAME','$FROM_API_VERSION', '$TO_API_VERSION', '$MAPPED_PRIVILEGE_NAME')"
+       sqlite3 .core_privilege_info.db "insert or ignore into valid_privilege_info values ('$MAPPED_PRIVILEGE_NAME', 0, 1)"
 done
 
-echo "Check inserted data"
-#sqlite3 $DB_NAME "select * from privilege_mapping"
diff --git a/capi/res/dbspace/internal_only.list b/capi/res/dbspace/internal_only.list
new file mode 100644 (file)
index 0000000..db77a57
--- /dev/null
@@ -0,0 +1,29 @@
+http://tizen.org/privilege/internal/appdebugging
+http://tizen.org/privilege/internal/buxton
+http://tizen.org/privilege/internal/buxton/account.read
+http://tizen.org/privilege/internal/buxton/camcorder
+http://tizen.org/privilege/internal/buxton/contact.read
+http://tizen.org/privilege/internal/buxton/location
+http://tizen.org/privilege/internal/buxton/message.read
+http://tizen.org/privilege/internal/buxton/network.get
+http://tizen.org/privilege/internal/buxton/nfc
+http://tizen.org/privilege/internal/buxton/nfc.cardemulation
+http://tizen.org/privilege/internal/buxton/readonly
+http://tizen.org/privilege/internal/buxton/telephony
+http://tizen.org/privilege/internal/dbus
+http://tizen.org/privilege/internal/default/partner
+http://tizen.org/privilege/internal/default/platform
+http://tizen.org/privilege/internal/default/public
+http://tizen.org/privilege/internal/inputdevice.block
+http://tizen.org/privilege/internal/usermanagement
+http://tizen.org/privilege/internal/web/appmanager.certificate
+http://tizen.org/privilege/internal/web/datasync
+http://tizen.org/privilege/internal/web/fullscreen
+http://tizen.org/privilege/internal/web/tv.audio
+http://tizen.org/privilege/internal/web/tv.channel
+http://tizen.org/privilege/internal/web/tv.display
+http://tizen.org/privilege/internal/web/tv.inputdevice
+http://tizen.org/privilege/internal/web/tv.window
+http://tizen.org/privilege/internal/web/unlimitedstorage
+http://tizen.org/privilege/internal/web/websetting
+http://tizen.org/privilege/notexist
index 33e8f70..fc62603 100755 (executable)
@@ -144,5 +144,3 @@ do
        sqlite3 $DB_NAME "insert into privilege_info values ( $PROFILE_ID, '$PROFILE', $PACKAGE_TYPE_ID, '$PACKAGE_TYPE', $PRIVILEGE_LEVEL_ID, '$PRIVILEGE_LEVEL', '$API_VERSION_ISSUED', '$API_VERSION_EXPIRED', '$DOCUMENTED', '$PRIVILEGE_NAME', '$IS_PRIVACY', '$PRIVACY_GROUP', '$PRIVILEGE_DISPLAY', '$PRIVILEGE_DESCRIPTION', $PRIVILEGE_GROUP_ID, '$PRIVILEGE_GROUP', '$CHANGED_TO_2_4_0')"
 done
 
-echo "Check inserted data"
-sqlite3 $DB_NAME "select * from privilege_info"
index 093b8e5..ee86bd6 100755 (executable)
@@ -53,5 +53,3 @@ do
        sqlite3 $DB_NAME "insert into privilege_mapping values ( $PROFILE_ID, '$PROFILE', '$PRIVILEGE_NAME','$FROM_API_VERSION', '$TO_API_VERSION', '$MAPPED_PRIVILEGE_NAME')"
 done
 
-echo "Check inserted data"
-sqlite3 $DB_NAME "select * from privilege_mapping"
index 8b11d12..a09831f 100755 (executable)
@@ -133,5 +133,3 @@ do
        sqlite3 $DB_NAME "insert into privilege_info values ( $PROFILE_ID, '$PROFILE', $PACKAGE_TYPE_ID, '$PACKAGE_TYPE', $PRIVILEGE_LEVEL_ID, '$PRIVILEGE_LEVEL', '$API_VERSION_ISSUED', '$API_VERSION_EXPIRED', '$DOCUMENTED', '$PRIVILEGE_NAME', '$PRIVILEGE_DISPLAY', '$PRIVILEGE_DESCRIPTION', $PRIVILEGE_GROUP_ID, '$PRIVILEGE_GROUP', '$CHANGED_TO_2_4_0')"
 done
 
-echo "Check inserted data"
-sqlite3 $DB_NAME "select * from privilege_info"
index 83234aa..9ade85b 100755 (executable)
@@ -52,5 +52,3 @@ do
        sqlite3 $DB_NAME "insert into privilege_mapping values ( $PROFILE_ID, '$PROFILE', '$PRIVILEGE_NAME','$FROM_API_VERSION', '$TO_API_VERSION', '$MAPPED_PRIVILEGE_NAME')"
 done
 
-echo "Check inserted data"
-sqlite3 $DB_NAME "select * from privilege_mapping"
index 94e7202..8978e9a 100755 (executable)
@@ -136,5 +136,3 @@ do
        sqlite3 $DB_NAME "insert into privilege_info values ( $PROFILE_ID, '$PROFILE', $PACKAGE_TYPE_ID, '$PACKAGE_TYPE', $PRIVILEGE_LEVEL_ID, '$PRIVILEGE_LEVEL', '$API_VERSION_ISSUED', '$API_VERSION_EXPIRED', '$DOCUMENTED', '$PRIVILEGE_NAME', '$PRIVILEGE_DISPLAY', '$PRIVILEGE_DESCRIPTION', $PRIVILEGE_GROUP_ID, '$PRIVILEGE_GROUP','$CHANGED_TO_2_3_1', '$CHANGED_TO_2_4_0')"
 done
 
-echo "Check inserted data"
-#sqlite3 $DB_NAME "select * from privilege_info"
index 4c2498b..ccf37c4 100755 (executable)
@@ -50,7 +50,6 @@ do
        echo "Inserting $PRIVILEGE_NAME $MAPPED_PRIVILEGE_NAME..."
 
        sqlite3 $DB_NAME "insert into privilege_mapping values ( $PROFILE_ID, '$PROFILE', '$PRIVILEGE_NAME','$FROM_API_VERSION', '$TO_API_VERSION', '$MAPPED_PRIVILEGE_NAME')"
+       sqlite3 .core_privilege_info.db "insert or ignore into valid_privilege_info values ('$MAPPED_PRIVILEGE_NAME', 0, 1)"
 done
 
-echo "Check inserted data"
-#sqlite3 $DB_NAME "select * from privilege_mapping"
index 208f95d..c50fa80 100755 (executable)
@@ -69,13 +69,16 @@ int __initialize_db(char type, sqlite3 ** db, privilege_db_manager_package_type_
        return PRIVILEGE_DB_MANAGER_ERR_NONE;
 }
 
-void __finalize_db(sqlite3 * db, sqlite3_stmt * stmt)
+void __finalize_db(sqlite3 * db, sqlite3_stmt * stmt, char* sql)
 {
        if (stmt != NULL)
                sqlite3_finalize(stmt);
 
        if (db != NULL)
                sqlite3_close(db);
+
+       if (sql != NULL)
+               sqlite3_free(sql);
 }
 
 int __make_privilege_list_str(GList *privilege_list, char** privilege_list_str)
@@ -84,11 +87,10 @@ int __make_privilege_list_str(GList *privilege_list, char** privilege_list_str)
        char* temp_privilege_list_str = NULL;
        for (l = privilege_list; l != NULL; l = l->next) {
                char *privilege_name = (char *)l->data;
-               if (temp_privilege_list_str == NULL) {
+               if (temp_privilege_list_str == NULL)
                        temp_privilege_list_str = sqlite3_mprintf("'%q'", privilege_name);
-               } else {
+               else
                        temp_privilege_list_str = sqlite3_mprintf("%s, '%q'", temp_privilege_list_str, privilege_name);
-               }
        }
        *privilege_list_str = temp_privilege_list_str;
        return 0;
@@ -130,11 +132,12 @@ int privilege_db_manager_check_black_list(int uid, privilege_db_manager_package_
        LOGD("check black list with uid = %d, package_type = %d, privilege_list = %s", uid, package_type, privilege_list_str);
        char *sql = sqlite3_mprintf("select distinct privilege_name from black_list where privilege_name in(%s)and uid=%d and package_type=%d", privilege_list_str, uid, package_type);
        sqlite3_free(privilege_list_str);
+       TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
 
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        if (ret != SQLITE_OK) {
                LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
-               sqlite3_close(db);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
        }
 
@@ -147,8 +150,7 @@ int privilege_db_manager_check_black_list(int uid, privilege_db_manager_package_
        if (count > 0)
                LOGE("Privilege list contains banned privileges!");
 
-       __finalize_db(db, stmt);
-       sqlite3_free(sql);
+       __finalize_db(db, stmt, sql);
 
        return count;
 }
@@ -183,10 +185,12 @@ int privilege_db_manager_get_privilege_list(const char *api_version, privilege_d
 
        char *sql = sqlite3_mprintf("select privilege_name, privilege_level_id, %s, api_version_issued, api_version_expired from privilege_info where(profile_id=%d or profile_id=%d)and package_type_id=%d", changed_to_version, PRIVILEGE_DB_MANAGER_PROFILE_TYPE_COMMON, g_privilege_db_manager_profile_type, package_type);
        free(changed_to_version);
+       TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
+
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        if (ret != SQLITE_OK) {
                LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
-               sqlite3_close(db);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
        }
 
@@ -194,7 +198,7 @@ int privilege_db_manager_get_privilege_list(const char *api_version, privilege_d
                ret = sqlite3_step(stmt);
                if (ret == SQLITE_ROW) {
                        privilege_info_db_row_s *privilege_info_db_row = (privilege_info_db_row_s *)malloc(sizeof(privilege_info_db_row_s));
-                       TryReturn(privilege_info_db_row != NULL, free(privilege_info_db_row), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] privilege_info_db_row's malloc is failed.");
+                       TryReturn(privilege_info_db_row != NULL, free(privilege_info_db_row); __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] privilege_info_db_row's malloc is failed.");
 
                        privilege_info_db_row->profile = NULL;
                        privilege_info_db_row->package_type = NULL;
@@ -212,25 +216,29 @@ int privilege_db_manager_get_privilege_list(const char *api_version, privilege_d
 
                        privilege_info_db_row->privilege_name = strdup((char *)sqlite3_column_text(stmt, 0));
                        TryReturn(privilege_info_db_row->privilege_name != NULL, free(privilege_info_db_row->privilege_name);
-                                         free(privilege_info_db_row), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] privilege_name's strdup is failed.");
+                                         free(privilege_info_db_row);
+                                         __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] privilege_name's strdup is failed.");
                        privilege_info_db_row->privilege_level_id = sqlite3_column_int(stmt, 1);
                        privilege_info_db_row->changed_to = strdup((char *)sqlite3_column_text(stmt, 2));
                        TryReturn(privilege_info_db_row->changed_to != NULL, free(privilege_info_db_row->privilege_name);
                                          free(privilege_info_db_row->changed_to);
-                                         free(privilege_info_db_row), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] changed_to's strdup is failed.");
+                                         free(privilege_info_db_row);
+                                         __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] changed_to's strdup is failed.");
 
                        privilege_info_db_row->issued_version = strdup((char *)sqlite3_column_text(stmt, 3));
                        TryReturn(privilege_info_db_row->issued_version != NULL, free(privilege_info_db_row->privilege_name);
                                          free(privilege_info_db_row->changed_to);
                                          free(privilege_info_db_row->issued_version);
-                                         free(privilege_info_db_row), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] issued_version's strdup is failed.");
+                                         free(privilege_info_db_row);
+                                         __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] issued_version's strdup is failed.");
 
                        privilege_info_db_row->expired_version = strdup((char *)sqlite3_column_text(stmt, 4));
                        TryReturn(privilege_info_db_row->expired_version != NULL, free(privilege_info_db_row->privilege_name);
                                          free(privilege_info_db_row->changed_to);
                                          free(privilege_info_db_row->issued_version);
                                          free(privilege_info_db_row->expired_version);
-                                         free(privilege_info_db_row), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] expired_version's strdup is failed.");
+                                         free(privilege_info_db_row);
+                                         __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] expired_version's strdup is failed.");
 
                        temp_privilege_list = g_list_append(temp_privilege_list, privilege_info_db_row);
                }
@@ -238,8 +246,7 @@ int privilege_db_manager_get_privilege_list(const char *api_version, privilege_d
 
        *privilege_list = temp_privilege_list;
 
-       __finalize_db(db, stmt);
-       sqlite3_free(sql);
+       __finalize_db(db, stmt, sql);
 
        return PRIVILEGE_DB_MANAGER_ERR_NONE;
 }
@@ -258,15 +265,16 @@ int privilege_db_manager_get_mapped_privilege_list(const char *api_version, priv
 
        char *privilege_list_str = NULL;
        ret = __make_privilege_list_str(privilege_list, &privilege_list_str);
-       TryReturn(ret == 0 && privilege_list_str != NULL, , PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] making privilege_list_str for where in query is failed.");
+       TryReturn(ret == 0 && privilege_list_str != NULL, sqlite3_close(db), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] making privilege_list_str for where in query is failed.");
 
        char *sql = sqlite3_mprintf("select distinct mapped_privilege_name from privilege_mapping where privilege_name in(%s)and(profile_id=%d or profile_id=%d)and from_api_version<=%Q and to_api_version>%Q", privilege_list_str, PRIVILEGE_DB_MANAGER_PROFILE_TYPE_COMMON, g_privilege_db_manager_profile_type, api_version, api_version);
        sqlite3_free(privilege_list_str);
+       TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
 
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        if (ret != SQLITE_OK) {
                LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
-               sqlite3_close(db);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
        }
 
@@ -280,8 +288,7 @@ int privilege_db_manager_get_mapped_privilege_list(const char *api_version, priv
 
        *mapped_privilege_list = temp_privilege_list;
 
-       __finalize_db(db, stmt);
-       sqlite3_free(sql);
+       __finalize_db(db, stmt, sql);
 
        return PRIVILEGE_DB_MANAGER_ERR_NONE;
 }
@@ -303,11 +310,12 @@ int privilege_db_manager_get_privilege_display(privilege_db_manager_package_type
        } else {
                sql = sqlite3_mprintf("select privilege_display 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", PRIVILEGE_DB_MANAGER_PROFILE_TYPE_COMMON, g_privilege_db_manager_profile_type, package_type, privilege_name, api_version, api_version);
        }
+       TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
 
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        if (ret != SQLITE_OK) {
                LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
-               sqlite3_close(db);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
        }
 
@@ -316,13 +324,13 @@ int privilege_db_manager_get_privilege_display(privilege_db_manager_package_type
                LOGD("privilege_display = %s", (char *)sqlite3_column_text(stmt, 0));
 
                *privilege_display = strdup((char *)sqlite3_column_text(stmt, 0));
-               TryReturn(*privilege_display != NULL, , PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] privilege_name's strdup is failed.");
-               __finalize_db(db, stmt);
+               TryReturn(*privilege_display != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] privilege_name's strdup is failed.");
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_NONE;
        }
 
-       __finalize_db(db, stmt);
-       sqlite3_free(sql);
+       __finalize_db(db, stmt, sql);
+
        return PRIVILEGE_DB_NO_EXIST_RESULT;
 }
 
@@ -341,11 +349,12 @@ int privilege_db_manager_get_privilege_description(privilege_db_manager_package_
                sql = sqlite3_mprintf("select privilege_description from privilege_info where(profile_id=%d or profile_id=%d)and package_type_id=%d and privilege_name=%Q", PRIVILEGE_DB_MANAGER_PROFILE_TYPE_COMMON, g_privilege_db_manager_profile_type, package_type, privilege_name);
        else
                sql = sqlite3_mprintf("select privilege_description 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", PRIVILEGE_DB_MANAGER_PROFILE_TYPE_COMMON, g_privilege_db_manager_profile_type, package_type, privilege_name, api_version, api_version);
+       TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
 
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        if (ret != SQLITE_OK) {
                LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
-               sqlite3_close(db);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
        }
 
@@ -354,14 +363,14 @@ int privilege_db_manager_get_privilege_description(privilege_db_manager_package_
                LOGD("privilege_description = %s", (char *)sqlite3_column_text(stmt, 0));
 
                *privilege_description = strdup((char *)sqlite3_column_text(stmt, 0));
-               TryReturn(*privilege_description != NULL, , PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] privilege_name's strdup is failed.");
+               TryReturn(*privilege_description != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] privilege_name's strdup is failed.");
 
-               __finalize_db(db, stmt);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_NONE;
        }
 
-       __finalize_db(db, stmt);
-       sqlite3_free(sql);
+       __finalize_db(db, stmt, sql);
+
        return PRIVILEGE_DB_NO_EXIST_RESULT;
 }
 
@@ -377,10 +386,11 @@ int privilege_db_manager_get_privilege_group_display(privilege_db_manager_packag
        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);
 
+       TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        if (ret != SQLITE_OK) {
                LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
-               sqlite3_close(db);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
        }
 
@@ -389,43 +399,57 @@ int privilege_db_manager_get_privilege_group_display(privilege_db_manager_packag
                *privilege_group_number = (int)sqlite3_column_int(stmt, 0);
                LOGD("privilege_group_number = %d", *privilege_group_number);
 
-               __finalize_db(db, stmt);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_NONE;
        }
 
-       __finalize_db(db, stmt);
-       sqlite3_free(sql);
+       __finalize_db(db, stmt, sql);
+
        return PRIVILEGE_DB_NO_EXIST_RESULT;
 }
 
-int __privilege_db_manager_is_privacy(const char* privilege)
+int privilege_db_manager_is(char type, const char* privilege)
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int is_privacy = 0;
+       int res = 0;
        int ret = __initialize_db('i', &db, PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_CORE);
        TryReturn(ret == PRIVILEGE_DB_MANAGER_ERR_NONE, , ret, "[PRIVILEGE_DB_MANAGER] DB INITIALIZE FAIL");
 
-       char *sql = sqlite3_mprintf("select is_privacy from privilege_info where(profile_id=%d or profile_id=%d)and package_type_id=%d and privilege_name=%Q",
-                                                               PRIVILEGE_DB_MANAGER_PROFILE_TYPE_COMMON, g_privilege_db_manager_profile_type, PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_CORE, privilege);
+       char *sql = sqlite3_mprintf("select * from valid_privilege_info where privilege_name=%Q", privilege);
+       TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
-       TryReturn (ret == SQLITE_OK, sqlite3_close(db), -PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
+       TryReturn(ret == SQLITE_OK, __finalize_db(db, stmt, sql), -PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
 
        ret = sqlite3_step(stmt);
        if (ret == SQLITE_ROW) {
-               is_privacy = sqlite3_column_int(stmt, 0);
-               ret = PRIVILEGE_DB_MANAGER_ERR_NONE;
+               LOGD("privilege: %s, is-privacy : %d, is-internal : %d", (char*)sqlite3_column_text(stmt, 0), sqlite3_column_int(stmt, 1), sqlite3_column_int(stmt, 2));
+               switch (type) {
+               case 'v':
+                       res = 1;
+                       break;
+               case 'p':
+                       res = sqlite3_column_int(stmt, 1);
+                       break;
+               case 'i':
+                       res = sqlite3_column_int(stmt, 2);
+                       break;
+               default:
+                       LOGE("Undefined type for privilege_db_manager_is()");
+                       return PRIVILEGE_DB_MANAGER_ERR_INVALID_TYPE;
+               }
        } else if (ret == SQLITE_DONE) {
-               LOGD("[PRIVILEGE_DB_MANAGER] NO DATA TO READ. ret = %d", ret);
-               ret = PRIVILEGE_DB_MANAGER_ERR_NONE;
+               LOGD("[PRIVILEGE_DB_MANAGER] NO DATA TO READ. %s is invalid privilege. ret = %d", privilege, ret);
+       } else {
+               res = -1;
        }
 
-       __finalize_db(db, stmt);
-       sqlite3_free(sql);
-       if (ret > 0)
+       __finalize_db(db, stmt, sql);
+
+       if (res < 0)
                return -ret;
        else
-               return is_privacy;
+               return res;
 }
 
 int __privilege_db_manager_get_privacy_list(GList **privacy_list)
@@ -437,11 +461,11 @@ int __privilege_db_manager_get_privacy_list(GList **privacy_list)
                return ret;
 
        char *sql = sqlite3_mprintf("select DISTINCT privacy_group from privilege_info where is_privacy=1 order by privacy_group");
-       ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
+       TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        if (ret != SQLITE_OK) {
                LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
-               sqlite3_close(db);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
        }
 
@@ -456,8 +480,7 @@ int __privilege_db_manager_get_privacy_list(GList **privacy_list)
 
        *privacy_list = temp_privacy_list;
 
-       __finalize_db(db, stmt);
-       sqlite3_free(sql);
+       __finalize_db(db, stmt, sql);
 
        return PRIVILEGE_DB_MANAGER_ERR_NONE;
 
@@ -472,10 +495,11 @@ int __privilege_db_manager_get_privilege_list_by_privacy(const char* privacy, GL
                return ret;
 
        char *sql = sqlite3_mprintf("select distinct privilege_name from privilege_info where is_privacy=1 and privacy_group=%Q", privacy);
+       TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        if (ret != SQLITE_OK) {
                LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
-               sqlite3_close(db);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
        }
 
@@ -490,8 +514,7 @@ int __privilege_db_manager_get_privilege_list_by_privacy(const char* privacy, GL
 
        *privilege_list = temp_privilege_list;
 
-       __finalize_db(db, stmt);
-       sqlite3_free(sql);
+       __finalize_db(db, stmt, sql);
 
        return PRIVILEGE_DB_MANAGER_ERR_NONE;
 
@@ -506,10 +529,11 @@ int privilege_db_manager_get_black_list(int uid, privilege_db_manager_package_ty
                return ret;
        LOGD("Get privilege_name from black_list where uid = %d, package_type = %d", uid, package_type);
        char* sql = sqlite3_mprintf("select privilege_name from black_list where uid=%d and package_type=%d", uid, package_type);
+       TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        if (ret != SQLITE_OK) {
                LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
-               sqlite3_close(db);
+               __finalize_db(db, stmt, sql);
                return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
        }
 
@@ -527,8 +551,7 @@ int privilege_db_manager_get_black_list(int uid, privilege_db_manager_package_ty
 
        *privilege_list = temp_privilege_list;
 
-       __finalize_db(db, stmt);
-       sqlite3_free(sql);
+       __finalize_db(db, stmt, sql);
 
        return PRIVILEGE_DB_MANAGER_ERR_NONE;
 }
@@ -547,25 +570,26 @@ int privilege_db_manager_set_black_list(int uid, privilege_db_manager_package_ty
                char *privilege_name = (char *)l->data;
                LOGD("insert uid = %d, package_type = %d, privilege_name = %s", uid, package_type, privilege_name);
                char* sql = sqlite3_mprintf("insert or ignore into black_list (uid, package_type, privilege_name) values (%d, %d, %Q)", uid, package_type, privilege_name);
+               TryReturn(sql != NULL, sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL); __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
                ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
                if (ret != SQLITE_OK) {
                        LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
                        sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
-                       sqlite3_close(db);
+                       __finalize_db(db, stmt, sql);
                        return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
                }
                ret = sqlite3_step(stmt);
                if (ret != SQLITE_DONE) {
                        __get_db_error(ret);
                        sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
-                       __finalize_db(db, stmt);
+                       __finalize_db(db, stmt, sql);
                        return ret;
                }
                sqlite3_free(sql);
        }
 
        sqlite3_exec(db, "COMMIT TRANSACTION", NULL, NULL, NULL);
-       __finalize_db(db, stmt);
+       __finalize_db(db, stmt, NULL);
        return PRIVILEGE_DB_MANAGER_ERR_NONE;
 }
 
@@ -583,24 +607,25 @@ int privilege_db_manager_unset_black_list(int uid, privilege_db_manager_package_
                char *privilege_name = (char *)l->data;
                LOGD("delete from black_list where uid = %d, package_type = %d, privilege_name = %s", uid, package_type, privilege_name);
                char* sql = sqlite3_mprintf("delete from black_list where uid=%d and package_type=%d and privilege_name=%Q", uid, package_type, privilege_name);
+               TryReturn(sql != NULL, sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL); __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
                ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
                if (ret != SQLITE_OK) {
                        LOGE("[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
                        sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
-                       sqlite3_close(db);
+                       __finalize_db(db, stmt, sql);
                        return PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY;
                }
                ret = sqlite3_step(stmt);
                if (ret != SQLITE_DONE) {
                        __get_db_error(ret);
                        sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
-                       __finalize_db(db, stmt);
+                       __finalize_db(db, stmt, sql);
                        return ret;
                }
                sqlite3_free(sql);
        }
 
        sqlite3_exec(db, "COMMIT TRANSACTION", NULL, NULL, NULL);
-       __finalize_db(db, stmt);
+       __finalize_db(db, stmt, NULL);
        return PRIVILEGE_DB_MANAGER_ERR_NONE;
 }
index dcf7dbc..4b35e3c 100755 (executable)
 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)
+       int ret = privilege_info_is_internal(privilege_name);
+       if (ret == 1)
                return PRVMGR_ERR_NONE;
+       else if (ret != 0)
+               return PRVMGR_ERR_INTERNAL_ERROR;
 
        int *groupTable = (int *)user_data;
        TryReturn(privilege_name != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege_name is NULL");
@@ -47,7 +50,7 @@ int privilege_info_privilege_list_by_pkgid_callback(const char *privilege_name,
 
        int group_id = 6;
        /* core */
-       int ret = privilege_db_manager_get_privilege_group_display(PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_CORE, privilege_name, "9.9", &group_id);
+       ret = privilege_db_manager_get_privilege_group_display(PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_CORE, privilege_name, "9.9", &group_id);
        if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE) {
                LOGD("group_id = %d", group_id);
                groupTable[group_id] = 1;
@@ -141,9 +144,11 @@ 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;
+       ret = privilege_info_is_internal(privilege_name);
+       if (ret == 1)
+               return PRVMGR_ERR_NONE;
+       else if (ret != 0)
+               return PRVMGR_ERR_INTERNAL_ERROR;
        if (data.privilege_group == EXTRA_GROUP) {
                LOGD("data.privilege_group = %d", data.privilege_group);
                res = data.callback(privilege_name, data.user_data);
@@ -538,7 +543,30 @@ int privilege_info_is_privacy(const char* privilege)
 {
        TryReturn(privilege != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
 
-       int ret = __privilege_db_manager_is_privacy(privilege);
+       int ret = privilege_db_manager_is('p', privilege);
+       LOGD("%s is privacy? %d", privilege, ret);
+       if (ret != 0 && ret != 1)
+               ret = -1;
+       return ret;
+}
+
+int privilege_info_is_valid(const char* privilege)
+{
+       TryReturn(privilege != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
+
+       int ret = privilege_db_manager_is('v', privilege);
+       LOGD("%s is valid? %d", privilege, ret);
+       if (ret != 0 && ret != 1)
+               ret = -1;
+       return ret;
+}
+
+int privilege_info_is_internal(const char* privilege)
+{
+       TryReturn(privilege != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
+
+       int ret = privilege_db_manager_is('i', privilege);
+       LOGD("%s is internal? %d", privilege, ret);
        if (ret != 0 && ret != 1)
                ret = -1;
        return ret;
index 15e76e2..2fbed51 100755 (executable)
@@ -66,13 +66,13 @@ char* __get_result_string(char type, int ret)
                else if (ret == PRIVILEGE_DB_MANAGER_ERR_INVALID_TYPE)
                        return "PRIVILEGE_DB_MANAGER_ERR_INVALID_TYPE";
                else if (ret == PRIVILEGE_DB_MANAGER_ERR_DB_BUSY_FAIL)
-            return "PRIVILEGE_DB_MANAGER_ERR_DB_BUSY_FAIL";
+                       return "PRIVILEGE_DB_MANAGER_ERR_DB_BUSY_FAIL";
                else if (ret == PRIVILEGE_DB_MANAGER_ERR_DB_CONSTRAINT_FAIL)
-            return "PRIVILEGE_DB_MANAGER_ERR_DB_CONSTRAINT_FAIL";
+                       return "PRIVILEGE_DB_MANAGER_ERR_DB_CONSTRAINT_FAIL";
                else if (ret == PRIVILEGE_DB_MANAGER_ERR_DB_FULL_FAIL)
-            return "PRIVILEGE_DB_MANAGER_ERR_DB_FULL_FAIL";
+                       return "PRIVILEGE_DB_MANAGER_ERR_DB_FULL_FAIL";
                else if (ret == PRIVILEGE_DB_MANAGER_ERR_DB_UPDATE_FAIL)
-            return "PRIVILEGE_DB_MANAGER_ERR_DB_UPDATE_FAIL";
+                       return "PRIVILEGE_DB_MANAGER_ERR_DB_UPDATE_FAIL";
                break;
        default:
                break;
@@ -140,7 +140,7 @@ void __tcinfo(tcinfo_type_e type, ...)
                        visibility = PRVMGR_PACKAGE_VISIBILITY_PUBLIC;
                else if (strncmp(visibility_string, "partner", strlen(visibility_string)) == 0)
                        visibility = PRVMGR_PACKAGE_VISIBILITY_PARTNER;
-               else if(strncmp(visibility_string, "platform", strlen(visibility_string)) == 0)
+               else if (strncmp(visibility_string, "platform", strlen(visibility_string)) == 0)
                        visibility = PRVMGR_PACKAGE_VISIBILITY_PLATFORM;
                else
                        printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!WRONG CERT LEVEL!!!!!!!!!!!!!!!!!!!!!");
@@ -151,9 +151,9 @@ void __tcinfo(tcinfo_type_e type, ...)
                __color_to_bold_yellow();
                api_version = va_arg(ap, char*);
                char* pkg_type_string = va_arg(ap, char*);
-               if(strncmp("core", pkg_type_string, strlen("core")) == 0 )
+               if (strncmp("core", pkg_type_string, strlen("core")) == 0)
                        pkg_type = PRVMGR_PACKAGE_TYPE_CORE;
-               else if(strncmp("wrt", pkg_type_string, strlen("wrt")) == 0)
+               else if (strncmp("wrt", pkg_type_string, strlen("wrt")) == 0)
                        pkg_type = PRVMGR_PACKAGE_TYPE_WRT;
                else
                        printf("!!!!!!!!!!!!!!!!!!!!!!WRONG PACKAGE TYPE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
index 99e893b..98a7e1e 100755 (executable)
@@ -106,6 +106,90 @@ static void __check_get_privilege_group_display_name_result(privilege_manager_er
        }
        __color_to_origin();
 }
+static void __test_privilege_info_is_valid()
+{
+       int ret;
+       printf("privilege : http://tizen.org/privilege/account.read\n");
+       ret = privilege_info_is_valid("http://tizen.org/privilege/account.read");
+       if (ret == 1) {
+               success_cnt++;
+               printf("SUCCESS: http://tizen.org/privilege/account.read is valid\n");
+       } else {
+               fail_cnt++;
+               printf("Test FAILED. ret =  %d\n", ret);
+       }
+       __print_line();
+
+       printf("privilege : http://tizen.org/privilege/internal/default/public\n");
+       ret = privilege_info_is_valid("http://tizen.org/privilege/internal/default/public");
+       if (ret == 1) {
+               success_cnt++;
+               printf("SUCCESS: http://tizen.org/privilege/internal/default/public is valid\n");
+       } else {
+               fail_cnt++;
+               printf("Test FAILED. ret =  %d\n", ret);
+       }
+       __print_line();
+
+       printf("privilege : http://tizen.org/privilege/internettttttt\n");
+       ret = privilege_info_is_valid("http://tizen.org/privilege/internettttttt");
+       if (ret == 0) {
+               success_cnt++;
+               printf("SUCCESS: http://tizen.org/privilege/internettttttt is invalid\n");
+       } else {
+               fail_cnt++;
+               printf("Test FAILED. ret = %d\n", ret);
+       }
+       __print_line();
+
+}
+
+static void __test_privilege_info_is_internal()
+{
+       int ret;
+       printf("privilege : http://tizen.org/privilege/internal/default/public\n");
+       ret = privilege_info_is_internal("http://tizen.org/privilege/internal/default/public");
+       if (ret == 1) {
+               success_cnt++;
+               printf("SUCCESS: http://tizen.org/privilege/internal/default/public is internal\n");
+       } else {
+               fail_cnt++;
+               printf("Test FAILED. ret =  %d\n", ret);
+       }
+       __print_line();
+
+       printf("privilege : http://tizen.org/privilege/internal/dbus\n");
+       ret = privilege_info_is_internal("http://tizen.org/privilege/internal/dbus");
+       if (ret == 1) {
+               success_cnt++;
+               printf("SUCCESS: http://tizen.org/privilege/internal/dbus is internal\n");
+       } else {
+               fail_cnt++;
+               printf("Test FAILED. ret = %d\n", ret);
+       }
+       __print_line();
+
+       printf("privilege : http://tizen.org/privilege/internet\n");
+       ret = privilege_info_is_internal("http://tizen.org/privilege/internet");
+       if (ret == 0) {
+               success_cnt++;
+               printf("SUCCESS: http://tizen.org/privilege/internet is NOT internal\n");
+       } else {
+               fail_cnt++;
+               printf("Test FAILED. ret = %d\n", ret);
+       }
+       __print_line();
+       printf("privilege : http://tizen.org/privilege/internettttt\n");
+       ret = privilege_info_is_internal("http://tizen.org/privilege/internettttt");
+       if (ret == 0) {
+               success_cnt++;
+               printf("SUCCESS: http://tizen.org/privilege/internettttt is NOT internal\n");
+       } else {
+               fail_cnt++;
+               printf("Test FAILED. ret = %d\n", ret);
+       }
+       __print_line();
+}
 static void __test_privilege_info_is_privacy()
 {
        int ret;
@@ -132,14 +216,14 @@ static void __test_privilege_info_is_privacy()
        __print_line();
 
        printf("privilege : http://tizen.org/privilege/internettttt\n");
-    ret = privilege_info_is_privacy("http://tizen.org/privilege/internettttt");
-    if (ret == 0) {
-        success_cnt++;
-        printf("SUCCESS: http://tizen.org/privilege/internettttt is NOT PRIVACY\n");
-    } else {
-        fail_cnt++;
-        printf("Test FAILED. ret = %d\n", ret);
-    }
+       ret = privilege_info_is_privacy("http://tizen.org/privilege/internettttt");
+       if (ret == 0) {
+               success_cnt++;
+               printf("SUCCESS: http://tizen.org/privilege/internettttt is NOT PRIVACY\n");
+       } else {
+               fail_cnt++;
+               printf("Test FAILED. ret = %d\n", ret);
+       }
        __print_line();
 }
 
@@ -304,6 +388,12 @@ int main()
        __tcinfo(function, "privilege_info_is_privacy");
        __test_privilege_info_is_privacy();
 
+       __tcinfo(function, "privilege_info_is_internal");
+       __test_privilege_info_is_internal();
+
+       __tcinfo(function, "privilege_info_is_valid");
+       __test_privilege_info_is_valid();
+
        __tcinfo(function, "privilege_info_get_privilege_display_name");
        __test_privilege_info_get_privilege_display_name();