From: Junghyun Yeon Date: Mon, 16 May 2016 04:32:52 +0000 (+0900) Subject: Integrate blacklist and restrictiom mode X-Git-Tag: submit/tizen/20160520.050106^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6567750c0dbb03e467b21360b00b5c66be586e1;p=platform%2Fcore%2Fappfw%2Fslp-pkgmgr.git Integrate blacklist and restrictiom mode Remove APIs related with pkg blacklist function and Integrate into restriction mode Related changes : pkgmgr-server https://review.tizen.org/gerrit/#/c/69473/ Change-Id: I046a58850c41a442f3ae02b2b1478ef561ad0747 Signed-off-by: Junghyun Yeon --- diff --git a/client/include/package-manager.h b/client/include/package-manager.h index f797bf5..c488df4 100644 --- a/client/include/package-manager.h +++ b/client/include/package-manager.h @@ -904,55 +904,6 @@ int pkgmgr_client_register_license(pkgmgr_client *pc, const char *resp_data); */ int pkgmgr_client_decrypt_package(pkgmgr_client *pc, const char *drm_file_path, const char *decrypted_file_path); -/** - * @brief Add a package to blacklist - * - * This API adds a package to blacklist.\n - * - * @param[in] pc The pointer to pkgmgr_client instance - * @param[in] pkgid package id - * @return 0 if success, error code(<0) if fail\n - * @retval PKGMGR_R_OK success - * @retval PKGMGR_R_EINVAL invalid argument - * @retval PKGMGR_R_ECOMM communication error - * @retval PKGMGR_R_EPRIV privilege denied - */ -int pkgmgr_client_add_blacklist(pkgmgr_client *pc, const char *pkgid); -int pkgmgr_client_usr_add_blacklist(pkgmgr_client *pc, const char *pkgid, uid_t uid); - -/** - * @brief Remove a package to blacklist - * - * This API removes a package to blacklist.\n - * - * @param[in] pc The pointer to pkgmgr_client instance - * @param[in] pkgid package id - * @return 0 if success, error code(<0) if fail\n - * @retval PKGMGR_R_OK success - * @retval PKGMGR_R_EINVAL invalid argument - * @retval PKGMGR_R_ECOMM communication error - * @retval PKGMGR_R_EPRIV privilege denied - */ -int pkgmgr_client_remove_blacklist(pkgmgr_client *pc, const char *pkgid); -int pkgmgr_client_usr_remove_blacklist(pkgmgr_client *pc, const char *pkgid, uid_t uid); - -/** - * @brief Check whether a package is blacklisted - * - * This API checks whether the given package is blacklisted.\n - * - * @param[in] pc The pointer to pkgmgr_client instance - * @param[in] pkgid package id - * @param[out] blacklist whether blacklisted or not - * @return 0 if success, error code(<0) if fail\n - * @retval PKGMGR_R_OK success - * @retval PKGMGR_R_EINVAL invalid argument - * @retval PKGMGR_R_ECOMM communication error - * @retval PKGMGR_R_EPRIV privilege denied - */ -int pkgmgr_client_check_blacklist(pkgmgr_client *pc, const char *pkgid, bool *blacklist); -int pkgmgr_client_usr_check_blacklist(pkgmgr_client *pc, const char *pkgid, bool *blacklist, uid_t uid); - /** * @brief This API is enabled the splash screen * @@ -1036,6 +987,63 @@ int pkgmgr_client_usr_unset_restriction_mode(pkgmgr_client *pc, int mode, uid_t int pkgmgr_client_get_restriction_mode(pkgmgr_client *pc, int *mode); int pkgmgr_client_usr_get_restriction_mode(pkgmgr_client *pc, int *mode, uid_t uid); +/** + * @brief Set restriction mode bit for package specified. + * @details You can combine multiple status using OR operation which you want to restrict. + * + * This API sets restriction bit for pkg operation to not allow user to do it.\n + * + * @param[in] pc The pointer to pkgmgr_client instance + * @param[in] pkgid pkgid to be restricted + * @param[in] mode restriction mode bit + * @return 0 if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ECOMM communication error + * @retval PKGMGR_R_EPRIV privilege denied + * @see pkgmgr_restriction_mode + */ +int pkgmgr_client_set_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int mode); +int pkgmgr_client_usr_set_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int mode, uid_t uid); + +/** + * @brief Unset restriction mode bit for package specified + * @details You can combine multiple status using OR operation which you want to unset + * + * This API unsets restriction bit to remove restriction of pkg operation. + * + * @param[in] pc The pointer to pkgmgr_client instance + * @param[in] pkgid pkg id to be remove in restriction. + * @param[in] mode restriction mode bit + * @return 0 if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ECOMM communication error + * @retval PKGMGR_R_EPRIV privilege denied + * @see pkgmgr_restriction_mode + */ +int pkgmgr_client_unset_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int mode); +int pkgmgr_client_usr_unset_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int mode, uid_t uid); + +/** + * @brief Get restriction bit of package operation + * + * This API gets restriction bit for restricted package operation.\n + * + * @param[in] pc The pointer to pkgmgr_client instance + * @param[in] pkgid pkg id to be remove in restriction. + * @param[out] mode restriction mode bit + * @return 0 if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ECOMM communication error + * @retval PKGMGR_R_EPRIV privilege denied + * @see pkgmgr_restriction_mode + */ +int pkgmgr_client_get_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int *mode); +int pkgmgr_client_usr_get_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, uid_t uid, int *mode); + + /** @} */ diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index 946779e..1e16f3c 100644 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -2306,191 +2306,200 @@ API int pkgmgr_client_decrypt_package(pkgmgr_client *pc, return PKGMGR_R_OK; } -API int pkgmgr_client_usr_add_blacklist(pkgmgr_client *pc, const char *pkgid, - uid_t uid) +API int pkgmgr_client_enable_splash_screen(pkgmgr_client *pc, const char *appid) { + return pkgmgr_client_usr_enable_splash_screen(pc, appid, _getuid()); +} + +API int pkgmgr_client_usr_enable_splash_screen(pkgmgr_client *pc, + const char *appid, uid_t uid) +{ + int ret; GVariant *result; - int ret = PKGMGR_R_ECOMM; pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc; - if (pc == NULL || pkgid == NULL) { - ERR("invalid parameter"); + if (pc == NULL || appid == NULL) { + ERR("Invalid parameter"); return PKGMGR_R_EINVAL; } - ret = comm_client_request(mpc->info.request.cc, "add_blacklist", - g_variant_new("(us)", uid, pkgid), &result); + ret = __change_op_cb_for_enable_disable_splash_screen(mpc, true); + if (ret < 0) { + ERR("__change_op_cb_for_enable_disable_splash_screen failed"); + return PKGMGR_R_ESYSTEM; + } + + ret = comm_client_request(mpc->info.request.cc, + "enable_app_splash_screen", + g_variant_new("(us)", uid, appid), &result); if (ret != PKGMGR_R_OK) { ERR("request failed: %d", ret); return ret; } g_variant_get(result, "(i)", &ret); + if (ret != PKGMGR_R_OK) { + g_variant_unref(result); + return ret; + } + g_variant_unref(result); return ret; } -API int pkgmgr_client_add_blacklist(pkgmgr_client *pc, const char *pkgid) +API int pkgmgr_client_disable_splash_screen(pkgmgr_client *pc, + const char *appid) { - return pkgmgr_client_usr_add_blacklist(pc, pkgid, _getuid()); + return pkgmgr_client_usr_disable_splash_screen(pc, appid, + _getuid()); } -API int pkgmgr_client_usr_remove_blacklist(pkgmgr_client *pc, - const char *pkgid, uid_t uid) +API int pkgmgr_client_usr_disable_splash_screen(pkgmgr_client *pc, + const char *appid, uid_t uid) { + int ret; GVariant *result; - int ret = PKGMGR_R_ECOMM; pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc; - if (pc == NULL || pkgid == NULL) { - ERR("invalid parameter"); + if (pc == NULL || appid == NULL) { + ERR("Invalid parameter"); return PKGMGR_R_EINVAL; } - ret = comm_client_request(mpc->info.request.cc, "remove_blacklist", - g_variant_new("(us)", uid, pkgid), &result); + ret = __change_op_cb_for_enable_disable_splash_screen(mpc, false); + if (ret < 0) { + ERR("__change_op_cb_for_enable_disable_splash_screen failed"); + return ret; + } + + ret = comm_client_request(mpc->info.request.cc, + "disable_app_splash_screen", + g_variant_new("(us)", uid, appid), &result); if (ret != PKGMGR_R_OK) { ERR("request failed: %d", ret); return ret; } g_variant_get(result, "(i)", &ret); + if (ret != PKGMGR_R_OK) { + g_variant_unref(result); + return ret; + } + g_variant_unref(result); return ret; } -API int pkgmgr_client_remove_blacklist(pkgmgr_client *pc, - const char *pkgid) -{ - return pkgmgr_client_usr_remove_blacklist(pc, pkgid, _getuid()); -} - -API int pkgmgr_client_usr_check_blacklist(pkgmgr_client *pc, const char *pkgid, - bool *blacklist, uid_t uid) +static int __set_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int mode, uid_t uid) { GVariant *result; int ret = PKGMGR_R_ECOMM; - gint b; pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc; - if (pc == NULL || pkgid == NULL) { + if (pc == NULL || pkgid == NULL || strlen(pkgid) == 0 || mode <= 0) { ERR("invalid parameter"); return PKGMGR_R_EINVAL; } - ret = comm_client_request(mpc->info.request.cc, "check_blacklist", - g_variant_new("(us)", uid, pkgid), &result); + ret = comm_client_request(mpc->info.request.cc, "set_restriction_mode", + g_variant_new("(usi)", uid, pkgid, mode), &result); if (ret != PKGMGR_R_OK) { ERR("request failed: %d", ret); return ret; } - g_variant_get(result, "(ii)", &b, &ret); + g_variant_get(result, "(i)", &ret); g_variant_unref(result); - if (ret != PKGMGR_R_OK) - return ret; - - if (b) - *blacklist = true; - else - *blacklist = false; - return PKGMGR_R_OK; + return ret; } -API int pkgmgr_client_check_blacklist(pkgmgr_client *pc, const char *pkgid, - bool *blacklist) +API int pkgmgr_client_usr_set_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int mode, uid_t uid) { - return pkgmgr_client_usr_check_blacklist(pc, pkgid, blacklist, - _getuid()); + return __set_pkg_restriction_mode(pc, pkgid, mode, uid); } -API int pkgmgr_client_enable_splash_screen(pkgmgr_client *pc, const char *appid) +API int pkgmgr_client_set_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int mode) { - return pkgmgr_client_usr_enable_splash_screen(pc, appid, _getuid()); + return pkgmgr_client_usr_set_pkg_restriction_mode(pc, pkgid, mode, _getuid()); } -API int pkgmgr_client_usr_enable_splash_screen(pkgmgr_client *pc, - const char *appid, uid_t uid) +static int __unset_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int mode, uid_t uid) { - int ret; GVariant *result; + int ret = PKGMGR_R_ECOMM; pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc; - if (pc == NULL || appid == NULL) { - ERR("Invalid parameter"); + if (pc == NULL || pkgid == NULL || strlen(pkgid) == 0 || mode <= 0) { + ERR("invalid parameter"); return PKGMGR_R_EINVAL; } - ret = __change_op_cb_for_enable_disable_splash_screen(mpc, true); - if (ret < 0) { - ERR("__change_op_cb_for_enable_disable_splash_screen failed"); - return PKGMGR_R_ESYSTEM; - } - ret = comm_client_request(mpc->info.request.cc, - "enable_app_splash_screen", - g_variant_new("(us)", uid, appid), &result); + "unset_restriction_mode", + g_variant_new("(usi)", uid, pkgid, mode), &result); if (ret != PKGMGR_R_OK) { ERR("request failed: %d", ret); return ret; } g_variant_get(result, "(i)", &ret); - if (ret != PKGMGR_R_OK) { - g_variant_unref(result); - return ret; - } - g_variant_unref(result); return ret; + } -API int pkgmgr_client_disable_splash_screen(pkgmgr_client *pc, - const char *appid) +API int pkgmgr_client_usr_unset_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int mode, uid_t uid) { - return pkgmgr_client_usr_disable_splash_screen(pc, appid, - _getuid()); + return __unset_pkg_restriction_mode(pc, pkgid, mode, uid); } -API int pkgmgr_client_usr_disable_splash_screen(pkgmgr_client *pc, - const char *appid, uid_t uid) +API int pkgmgr_client_unset_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int mode) +{ + return pkgmgr_client_usr_unset_pkg_restriction_mode(pc, pkgid, mode, _getuid()); +} + +static int __get_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int *mode, uid_t uid) { - int ret; GVariant *result; + int ret = PKGMGR_R_ECOMM; + gint m; pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc; - if (pc == NULL || appid == NULL) { - ERR("Invalid parameter"); + if (pc == NULL || pkgid == NULL || strlen(pkgid) == 0) { + ERR("invalid parameter"); return PKGMGR_R_EINVAL; } - ret = __change_op_cb_for_enable_disable_splash_screen(mpc, false); - if (ret < 0) { - ERR("__change_op_cb_for_enable_disable_splash_screen failed"); - return ret; - } - ret = comm_client_request(mpc->info.request.cc, - "disable_app_splash_screen", - g_variant_new("(us)", uid, appid), &result); + "get_restriction_mode", + g_variant_new("(us)", uid, pkgid), &result); if (ret != PKGMGR_R_OK) { ERR("request failed: %d", ret); return ret; } - g_variant_get(result, "(i)", &ret); - if (ret != PKGMGR_R_OK) { - g_variant_unref(result); + g_variant_get(result, "(ii)", &m, &ret); + g_variant_unref(result); + if (ret != PKGMGR_R_OK) return ret; - } - g_variant_unref(result); + *mode = m; - return ret; + return PKGMGR_R_OK; +} + +API int pkgmgr_client_usr_get_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, uid_t uid, int *mode) +{ + return __get_pkg_restriction_mode(pc, pkgid, mode, uid); +} + +API int pkgmgr_client_get_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int *mode) +{ + return pkgmgr_client_usr_get_pkg_restriction_mode(pc, pkgid, _getuid(), mode); } API int pkgmgr_client_usr_set_restriction_mode(pkgmgr_client *pc, int mode, @@ -2506,7 +2515,7 @@ API int pkgmgr_client_usr_set_restriction_mode(pkgmgr_client *pc, int mode, } ret = comm_client_request(mpc->info.request.cc, "set_restriction_mode", - g_variant_new("(ui)", uid, mode), &result); + g_variant_new("(usi)", uid, "", mode), &result); if (ret != PKGMGR_R_OK) { ERR("request failed: %d", ret); return ret; @@ -2537,7 +2546,7 @@ API int pkgmgr_client_usr_unset_restriction_mode(pkgmgr_client *pc, int mode, ret = comm_client_request(mpc->info.request.cc, "unset_restriction_mode", - g_variant_new("(ui)", uid, mode), &result); + g_variant_new("(usi)", uid, "", mode), &result); if (ret != PKGMGR_R_OK) { ERR("request failed: %d", ret); return ret; @@ -2569,7 +2578,7 @@ API int pkgmgr_client_usr_get_restriction_mode(pkgmgr_client *pc, ret = comm_client_request(mpc->info.request.cc, "get_restriction_mode", - g_variant_new("(u)", uid), &result); + g_variant_new("(us)", uid, ""), &result); if (ret != PKGMGR_R_OK) { ERR("request failed: %d", ret); return ret;