From: j-h.choi Date: Thu, 13 Oct 2022 07:56:08 +0000 (+0900) Subject: Changed API to check internet privilege X-Git-Tag: accepted/tizen/unified/20221014.123806~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=496e6363ac6bd4bdc9bf4cd9f4313d87aa5b6acf;p=platform%2Fcore%2Fdotnet%2Flauncher.git Changed API to check internet privilege Change-Id: I9952150b11e561e1d89b5d8ce4798fdcddb62e0d --- diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index 28ee598..302008a 100644 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -4,7 +4,7 @@ PROJECT("dotnet-tools") MESSAGE("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer ecore bundle dlog liblaunchpad glib-2.0 libsmack capi-appfw-app-common storage jsoncpp openssl1.1 sqlite3 libtzplatform-config security-manager) +PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer ecore bundle dlog liblaunchpad glib-2.0 libsmack capi-appfw-app-common storage jsoncpp openssl1.1 sqlite3 libtzplatform-config) FOREACH(flag ${${PROJECT_NAME}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/NativeLauncher/tool/privilege_common.cc b/NativeLauncher/tool/privilege_common.cc index 8b7ba2d..5c5f991 100644 --- a/NativeLauncher/tool/privilege_common.cc +++ b/NativeLauncher/tool/privilege_common.cc @@ -19,26 +19,45 @@ #include "privilege_common.h" #include "launcher_env.h" -#include - static const char* INTERNET_PRIVILEGE = "http://tizen.org/privilege/internet"; -static int UID_OWNER = 5001; +bool isInternetPrivilegeExisted = false; + +static int checkInternetPrivilegeCb(const char *privilegeName, void *user_data) +{ + if (!strcmp(privilegeName, INTERNET_PRIVILEGE)) { + isInternetPrivilegeExisted = true; + return -1; + } + return 0; +} void checkInternetPrivilegeAndDisableIPv6(const char* pkgId, const std::string& rootPath) { - int res = 0; - if (security_manager_app_has_privilege(pkgId, INTERNET_PRIVILEGE, UID_OWNER, &res) == SECURITY_MANAGER_SUCCESS) { - if (res != 1) { - std::string filePath = rootPath + "/bin/" + DISABLE_IPV6_FILE; - std::ofstream output(filePath); - if (exist(filePath)) { - _INFO("File to disable IPv6 is created successfully"); - } else { - _ERR("Failed to create file to disable IPv6 [%s]", pkgId); - } - output.close(); + pkgmgrinfo_pkginfo_h pkg_handle; + int ret = pkgmgrGetPkgInfo(pkgId, &pkg_handle); + if (ret != 0) { + return; + } + + ret = pkgmgrinfo_pkginfo_foreach_privilege(pkg_handle, checkInternetPrivilegeCb, NULL); + if (ret != PMINFO_R_OK) { + _SERR("Failed to pkgmgrinfo_pkginfo_foreach_privilege"); + pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle); + return; + } + + if (!isInternetPrivilegeExisted) { + std::string filePath = rootPath + "/bin/" + DISABLE_IPV6_FILE; + std::ofstream output(filePath); + if (exist(filePath)) { + _INFO("File to disable IPv6 is created successfully"); + } else { + _SERR("Failed to create file to disable IPv6 [%s]", pkgId); } + output.close(); } + + pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle); } static int checkAppPrivilegeListCb(pkgmgrinfo_appinfo_h handle, void *user_data) @@ -81,7 +100,7 @@ static void checkAppPrivilegeByAppType(const char* type) ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(filter, checkAppPrivilegeListCb, NULL); if (ret != PMINFO_R_OK) { - _SERR("Failed to pkgmgrinfo_pkginfo_filter_foreach_pkginfo"); + _SERR("Failed to pkgmgrinfo_appinfo_filter_foreach_appinfo"); pkgmgrinfo_appinfo_filter_destroy(filter); return; } diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 88c3e93..e44f13a 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -25,7 +25,6 @@ BuildRequires: pkgconfig(jsoncpp) BuildRequires: pkgconfig(openssl1.1) BuildRequires: pkgconfig(libsystemd) BuildRequires: pkgconfig(libtzplatform-config) -BuildRequires: pkgconfig(security-manager) BuildRequires: sqlite-devel BuildRequires: boost-devel BuildRequires: aul-devel