Add function to free privilege list 98/208098/4 accepted/tizen_4.0_unified tizen_4.0 accepted/tizen/4.0/unified/20190620.073944 accepted/tizen/4.0/unified/20190620.074021 submit/tizen_4.0/20190618.115013 submit/tizen_4.0/20190619.121700
authorYunjin Lee <yunjin-.lee@samsung.com>
Tue, 18 Jun 2019 07:25:32 +0000 (16:25 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Tue, 18 Jun 2019 09:20:58 +0000 (18:20 +0900)
- Add function to free privilege list, dynamically allocated by
privilege_manager, privilege_info, privilege_db_manager APIs and updated
header description accordingly.

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

index 87e9de39cf2f59bfcdcb771e7df4b1b97310647f..fe01a47185dfcde3e4986777411fd2f2ba898def 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2013-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright(c) 2013-2019 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0(the License);
  * you may not use this file except in compliance with the License.
        extern "C" {
 #endif
 
+/**
+ * @brief Free GList allocated by privilege_db_manager APIs
+ * @param [in] list The GList allocated by privilege_db_manager APIs
+ */
+void privilege_db_manager_list_free(GList* list);
+
 /**
  * @brief Get all privilege information of the target profile and package type
  * @remarks @a privilege_list must be released by you.
@@ -42,7 +48,7 @@ int privilege_db_manager_get_privilege_list(const char* api_version, privilege_m
 
 /**
  * @brief Get mapped privilege list for the given api-version and privilege list.
- * @remarks @a privilege_list must be released by you.
+ * @remarks @a privilege_list must be released by using privilege_db_manager_list_free().
  * @remarks @a mapped_privilege_list must be released by you.
  * @param [in]  api_version The api-version to get mapped privilege list
  * @param [in]  package_type The package type
@@ -155,7 +161,7 @@ int privilege_db_manager_is_user_settable(const char* pkgid, const char* privacy
 
 /**
  * @brief Get all privacy list
- * @remarks @a privacy_list must be released by you.
+ * @remarks @a privacy_list must be released by using privilege_db_manager_list_free().
  * @param [out] privacy_list The privacy list.
  * @return 0 on success, otherwise a negative error value.
  * @retval #PRIVILEGE_DB_MANAGER_ERR_NONE  Successful.
@@ -167,7 +173,7 @@ int privilege_db_manager_get_privacy_list(GList** privacy_list);
 
 /**
  * @brief Get list of privileges included in the given privacy group.
- * @remarks @a privilege_list must be released by you.
+ * @remarks @a privilege_list must be released by using privilege_db_manager_list_free().
  * @param [in]  privacy_name The privacy name
  * @param [out] privilege_list The privilege list.
  * @return 0 on success, otherwise a negative error value.
@@ -192,6 +198,7 @@ int privilege_db_manager_get_privacy_by_privilege(const char* privilege, char**
 
 /**
  * @brief Get privilege list of the same privacy group that the given privilege is included in.
+ * @remarks @a privilege_list must be released by using privilege_db_manager_list_free().
  * @param [in]  privilege The privilege
  * @param [out] privilege_list The privilege list of the same privacy group.
  * @return 0 on success, otherwise a negative error value.
@@ -241,6 +248,7 @@ int privilege_db_manager_is_disabled_privilege(uid_t uid, const char* privilege)
 
 /**
  * @brief Get blacklisted privileges according to the policy type, uid, and package type.
+ * @remarks @a privilege_list must be released by using privilege_db_manager_list_free().
  * @param [in] policy_type The policy type indicates which blacklist to get(PRVMGR_POLICY_TYPE_PREVENT for dpm blacklist and PRVMGR_POLICY_TYPE_DISABLE for mdm blacklist).
  * @param [in]  uid The uid
  * @param [in]  package_type The package type
@@ -394,6 +402,7 @@ int privilege_db_manager_is_critical_privilege(const uid_t uid, const char* pkgi
 
 /**
  * @brief Get all privacy package list of the user
+ * @remarks @a package_list must be released by using privilege_db_manager_list_free().
  * @param [in]  uid The uid
  * @param [out] package_list The package list
  * @return 0 on success, otherwise a negative error value.
@@ -407,6 +416,7 @@ int privilege_db_manager_get_all_privacy_package_list(const uid_t uid, GList** p
 
 /**
  * @brief Get privacy list of the application package
+ * @remarks @a privacy_list must be released by using privilege_db_manager_list_free().
  * @param [in]  uid The uid
  * @param [in]  pkgid The package ID
  * @param [out] privacy_list The privacy list
@@ -421,6 +431,7 @@ int privilege_db_manager_get_privacy_list_by_pkgid(const uid_t uid, const char*
 
 /**
  * @brief Get package list with the given privacy
+ * @remarks @a package_list must be released by using privilege_db_manager_list_free().
  * @param [in]  uid The uid
  * @param [in]  privacy The privacy name
  * @param [out] package_list The package list
@@ -435,6 +446,7 @@ int privilege_db_manager_get_package_list_by_privacy(const uid_t uid, const char
 
 /**
  * @brief Get package's privilege list related to the given privacy
+ * @remarks @a privilege_list must be released by using privilege_db_manager_list_free().
  * @param [in]  uid The uid
  * @param [in]  pkgid The package id
  * @param [in]  privacy The privacy name
index 5a9dd14f536b9b42ffb8918009ec53c57ab45344..61092adf03e8c75380c558fee85df8f924f287b1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2013-2019 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
 extern "C" {
 #endif
 
+/**
+ * @brief Free GList allocated by privilege_info APIs
+ * @param [in] list The GList allocated by privilege_info APIs
+ */
+void privilege_info_list_free(GList* list);
+
 /**
  * @brief Called to get a privilege group once for specific package.
  * @param[in] privilege_group The privilege group
@@ -154,7 +160,7 @@ EXPORT_API int privilege_info_get_privilege_type(uid_t uid, const char* pkgid, c
 
 /**
  * @brief Gets all privacy list.
- * @remarks @a privacy_list must be released with g_list_free() by you.
+ * @remarks @a privacy_list must be released by using privilege_info_list_free().
  * @param [out]  privacy_list The privacy list
  * @return 0 on success, otherwise a nonzero error value.
  * @retval #PRVMGR_ERR_NONE Successful
@@ -164,7 +170,7 @@ EXPORT_API int privilege_info_get_privacy_list(GList **privacy_list);
 
 /**
  * @brief Gets privacy display.
- * @remarks @a privacy_display must be released with g_list_free() by you.
+ * @remarks @a privacy_display must be released with free() by you.
  * @param [in] privacy The privacy
  * @param [out] privacy_display The privacy display
  * @return 0 on success, otherwise a nonzero error value.
@@ -175,7 +181,7 @@ EXPORT_API int privilege_info_get_privacy_display(const char* privacy, char** pr
 
 /**
  * @brief Gets privilege list with the given privacy.
- * @remarks @a privilege_list must be released with g_list_free() by you.
+ * @remarks @a privilege_list must be released by using privilege_info_list_free().
  * @param [in]  privacy The privacy
  * @param [out] privilege_list The list of privileges mapped to the given privacy
  * @return 0 on success, otherwise a nonzero error value.
@@ -187,7 +193,7 @@ EXPORT_API int privilege_info_get_privilege_list_by_privacy(const char *privacy,
 
 /**
  * @brief Gets privacy id of the given privilege.
- * @remarks @a privacy must be released with g_list_free() by you.
+ * @remarks @a privacy must be released with free() by you.
  * @param [in]  privilege The privilege
  * @param [out] privacy The privacy id of the given privilege
  * @return 0 on success, otherwise a nonzero error value.
@@ -199,7 +205,7 @@ EXPORT_API int privilege_info_get_privacy_by_privilege(const char *privilege, ch
 
 /**
  * @brief Gets the list of privilges marked as dpm black list.
- * @remarks @a privilege_list must be released with g_list_free() by you.
+ * @remarks @a privilege_list must be released by using privilege_info_list_free().
  * @param [in] uid The UID
  * @param [in] package_type The privilege_manager_package_type_e
  * @param [out] privilege_list The list for privileges marked as black list
@@ -212,7 +218,7 @@ EXPORT_API int privilege_info_get_black_list(int uid, privilege_manager_package_
 
 /**
  * @brief Gets the list of privilges marked as mdm black list for the given uid.
- * @remarks @a privilege_list must be released with g_list_free() by you.
+ * @remarks @a privilege_list must be released by using privilege_info_list_free().
  * @param [in] uid The UID
  * @param [out] privilege_list The list for privileges marked as black list
  * @return 0 on success, otherwise a nonzero error value.
@@ -223,7 +229,7 @@ EXPORT_API int privilege_info_get_mdm_black_list(uid_t uid, GList **privilege_li
 
 /**
  * @brief Get privilege list of the same privacy group that the given privilege is included in.
- * @remarks @a privilege_list must be released with g_list_free() by you.
+ * @remarks @a privilege_list must be released by using privilege_info_list_free().
  * @remarks @a privilege_list is NULL when the given privilege is not a privacy privilege.
  * @param [in] privilege privilege
  * @param [out] privilege_list The privilege list of the same privacy group
index 6f80d870588c058dacba3e25614011fcd6bc98d0..3ab3edf23bf73f793a54f29dfb69298b90864ee4 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2013-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright(c) 2013-2019 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0(the License);
  * you may not use this file except in compliance with the License.
 extern "C" {
 #endif
 
+/**
+ * @brief Free GList allocated by privilege_manager APIs
+ * @param [in] list The GList allocated by privilege_manager APIs
+ */
+EXPORT_API void privilege_manager_list_free(GList* list);
+
 /**
  * @brief verify privilege in the privilege list by checking its name and level at given api version.
- * @remarks @a privilege_list must be released with g_list_free() by you.
- * @remarks @a error_message must be released with g_list_free() by you.
+ * @remarks @a error_message must be released with free() by you.
  * @param [in] uid The uid of the user who's trying to install the application.
  * @param [in] api_version The api version of the application
  * @param [in] privilege_manager_package_type_e The privilege_manager_package_type_e
@@ -49,8 +54,7 @@ EXPORT_API int privilege_manager_verify_privilege(uid_t uid, const char* api_ver
 
 /**
  * @brief get mapped privilege list of input privilege list according to the given package type, api version, and profile.
- * @remarks @a privilege_list must be released with g_list_free() by you.
- * @remarks @a mapped_privilege_list must be released with g_list_free() by you.
+ * @remarks @a mapped_privilege_list must be released by using privilege_manager_list_free().
  * @param [in] api_version The api version of the application
  * @param [in] privilege_manager_package_type_e The privilege_manager_package_type_e
  * @param [in] privilege_list The privilege_list
@@ -115,8 +119,7 @@ EXPORT_API int privilege_manager_unset_mdm_black_list(uid_t uid, GList* privileg
 
 /**
  * @brief verify metadata level in the metadata list.
- * @remarks @a metadata_list must be released with free() by you.
- * @remarks @a error_messsage must be released with free() by you.
+ * @remarks @a error_message must be released with free() by you.
  * @param [in] api_version The API Version
  * @param [in] metadata_list The metadata_list
  * @param [in] privilege_manager_visibility_e The privilege_manager_visibility_e
index 5636e983400ad2ab2927528ad8e4c18b61f67acb..b95f013cb5f6d5a5c326ebd9d9c0e61fbd525d58 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2013-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright(c) 2013-2019 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0(the License);
  * you may not use this file except in compliance with the License.
@@ -195,6 +195,11 @@ static void __get_db_error(int *ret)
        }
 }
 
+void privilege_db_manager_list_free(GList* list)
+{
+       g_list_free_full(list, free);
+}
+
 int privilege_db_manager_check_black_list(uid_t uid, privilege_manager_package_type_e package_type, GList* privilege_list)
 {
        sqlite3 *db = NULL;
index 262f123ff8bc92fff3135f538630966ae998ae89..354e1d0ac3fe10e99c30308756e93ac071a6a9be 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2013-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright(c) 2013-2019 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0(the License);
  * you may not use this file except in compliance with the License.
                return returnValue;     \
        }
 
+void privilege_info_list_free(GList* list)
+{
+       g_list_free_full(list, free);
+}
+
 int privilege_info_privilege_list_by_pkgid_callback(const char *privilege_name, void *user_data)
 {
        int ret = privilege_info_is_internal(privilege_name);
index 6f6ddd75fdb78f614c56f2b3a3612c2414483e8c..ba5ea62a4ab116f74c390967953fe2cba9abd669 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2013-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright(c) 2013-2019 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0(the License);
  * you may not use this file except in compliance with the License.
@@ -260,6 +260,11 @@ static char *__make_guide_message(privilege_manager_package_type_e package_type,
        }
 }
 
+void privilege_manager_list_free(GList* list)
+{
+       g_list_free_full(list, free);
+}
+
 int privilege_manager_verify_privilege(uid_t uid, const char *api_version, privilege_manager_package_type_e package_type, GList * privilege_list, privilege_manager_visibility_e visibility, char **error_message)
 {
        GList *l;