#include "privilege_common.h"
#include "launcher_env.h"
-#include <app-runtime.h>
-
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)
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;
}