Add function to free privilege list 19/208119/1 submit/tizen/20190619.103358
authorYunjin Lee <yunjin-.lee@samsung.com>
Tue, 18 Jun 2019 07:25:32 +0000 (16:25 +0900)
committerTomasz Swierczek <t.swierczek@samsung.com>
Tue, 18 Jun 2019 11:56:42 +0000 (13:56 +0200)
- Add function to free privilege list, dynamically allocated by
privilege_manager, privilege_info, privilege_db_manager APIs and updated
header description accordingly.

Change-Id: I56a711716eb06cc41e795d544090a763a596898d
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 64258e039edcab40fed9f2055c5c3d61b0d49a12..deef6646fb89320cc6f60f7f82ed5829a093327a 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.
@@ -41,7 +47,7 @@ int privilege_db_manager_get_privilege_list(privilege_manager_package_type_e pac
 
 /**
  * @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
@@ -154,7 +160,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.
@@ -166,7 +172,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.
@@ -191,6 +197,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.
@@ -240,6 +247,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
@@ -392,6 +400,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.
@@ -405,6 +414,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
@@ -419,6 +429,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
@@ -433,6 +444,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 2a2dc2b1bd80d7e5da2227785c626e87f40474c9..ab6248c5f366573f06c3f366797fb461567b4b9a 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
@@ -91,8 +95,7 @@ EXPORT_API int privilege_manager_unset_black_list(int uid, privilege_manager_pac
 
 /**
  * @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 c910a5053a58bc9b24a27e345c2f1c4a93d6ac46..8e7fce73faf45780ef1e97d1bd7ffeda2e072ecb 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.
@@ -188,6 +188,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 fdaf770795525f4cf269c77b2a9e2afff67c1fa2..79f9f67ab1b227c492a8dea0dc0d5fb43efb171e 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 6298620300b90e878922d6308777745402e46ef3..373abc5dd8da35725196235009784ba765cf77d5 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.
@@ -202,6 +202,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;