From: j-h.choi Date: Wed, 21 Feb 2024 05:05:44 +0000 (+0900) Subject: Changed the creation location of the NI file to configure smack for RPK X-Git-Tag: accepted/tizen/unified/20240306.174234~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fdotnet%2Flauncher.git;a=commitdiff_plain;h=cc0b219c237b8b49cd92408911bbe7d8c72f8a4b Changed the creation location of the NI file to configure smack for RPK When the RPK(resource package) is installed through pkgcmd, AOT is performed. At this time, there was an issue that the smack label did not change for the NI created in the lib folder. Because the installer does not have the capability of cap_mac_admin. Change-Id: I74d47104d9edf07187fd1bd942a2993c280a7219 --- diff --git a/NativeLauncher/inc/ni_common.h b/NativeLauncher/inc/ni_common.h index 28b387f..e1c7e85 100644 --- a/NativeLauncher/inc/ni_common.h +++ b/NativeLauncher/inc/ni_common.h @@ -41,6 +41,7 @@ #define NI_FLAGS_SKIP_RO_APP 0x0400 #define NI_FLAGS_RM_ORIGIN_AFTER_NI 0x0800 #define NI_FLAGS_SET_PRIORITY 0x1000 +#define NI_FLAGS_RESOURCE_NI 0x2000 typedef std::function afterCreate; diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc index 6ab3e10..bacf923 100644 --- a/NativeLauncher/tool/ni_common.cc +++ b/NativeLauncher/tool/ni_common.cc @@ -233,6 +233,7 @@ static bool createDirsAndCopyOwnerShip(std::string& target_path, const std::stri static std::string getNIFilePath(const std::string& absDllPath, NIOption* opt) { std::string dllPath = absDllPath; + std::string fileName = getFileName(absDllPath); if (opt->flags & NI_FLAGS_APPNI) { std::string niDirPath; std::string niTmpDirPath; @@ -253,10 +254,13 @@ static std::string getNIFilePath(const std::string& absDllPath, NIOption* opt) niTmpDirPath = prevPath; _SERR("fail to create dir (%s)", niTmpDirPath.c_str()); } - dllPath = concatPath(niTmpDirPath, getFileName(absDllPath)); + dllPath = concatPath(niTmpDirPath, fileName); } else { - dllPath = concatPath(niDirPath, getFileName(absDllPath)); + dllPath = concatPath(niDirPath, fileName); } + } else if (opt->flags & NI_FLAGS_RESOURCE_NI) { + std::string rpkDir = concatPath(__pm->getAppRootPath(), APP_NI_SUB_DIR); + dllPath = createDir(rpkDir) ? concatPath(rpkDir, fileName) : concatPath(__pm->getAppRootPath(), fileName); } size_t index = dllPath.find_last_of("."); @@ -466,6 +470,11 @@ static ni_error_e crossgen2PostAction(const std::string& dllPath, const std::str } } + if (opt->flags & NI_FLAGS_RESOURCE_NI) { + moveFile(niPath, changeExtension(dllPath, ".dll", ".ni.dll")); + removeAll(concatPath(__pm->getAppRootPath(), APP_NI_SUB_DIR)); + } + if (!(opt->flags & NI_FLAGS_INPUT_BUBBLE && opt->flags & NI_FLAGS_NO_PIPELINE)) { _SOUT("Native image %s generated successfully.", outFile.c_str()); } @@ -825,7 +834,7 @@ static ni_error_e removeAndCreateNI(const char* pkgId, NIOption* pOptions) } _SOUT("Complete make native image for pkg (%s)", pkgId); - return NI_ERROR_NONE; + return NI_ERROR_NONE; } static bool isReadOnlyPkg(std::string pkgId) @@ -1026,7 +1035,6 @@ ni_error_e createNIUnderTAC(const std::string& targetPath, const std::string& re return NI_ERROR_NONE; } - ni_error_e createNIUnderDirs(const std::string& rootPaths, NIOption* opt) { ni_error_e ret = NI_ERROR_NONE; @@ -1082,6 +1090,7 @@ ni_error_e createNIUnderPkgRoot(const std::string& pkgId, NIOption* opt) _SERR("Failed to get root path from [%s]", pkgId.c_str()); return NI_ERROR_INVALID_PACKAGE; } + __pm->setAppRootPath(rootPath); char* extraDllPaths = pluginGetExtraDllPath(); if (extraDllPaths && extraDllPaths[0] != '\0') { @@ -1091,7 +1100,10 @@ ni_error_e createNIUnderPkgRoot(const std::string& pkgId, NIOption* opt) std::string targetDirs; if (isRPK(pkgId)) { - opt->flags &= ~NI_FLAGS_APPNI; + opt->flags &= ~NI_FLAGS_APPNI; // added to exclude logic of APP_NI + opt->flags |= NI_FLAGS_RESOURCE_NI; // added flag for RPK type + opt->flags |= NI_FLAGS_NO_PIPELINE; // added the flag to set the output path + std::string paths = getResourcePaths(rootPath); if (paths.empty()) { _SERR("Failed to get rpk paths from [%s]", pkgId.c_str()); @@ -1099,9 +1111,8 @@ ni_error_e createNIUnderPkgRoot(const std::string& pkgId, NIOption* opt) } targetDirs = paths; } else { - __pm->setAppRootPath(rootPath); - opt->flags |= NI_FLAGS_APPNI; + opt->flags &= ~NI_FLAGS_RESOURCE_NI; // added to exclude logic of RESOURCE_NI if (isReadOnlyArea(rootPath)) { opt->flags |= NI_FLAGS_APP_UNDER_RO_AREA; @@ -1189,7 +1200,7 @@ ni_error_e removeNIUnderPkgRoot(const std::string& pkgId) if (isDirectory(path)) { removeNIUnderDirs(path); } - } + } } else { __pm->setAppRootPath(rootPath); diff --git a/NativeLauncher/tool/r2r_checker.cc b/NativeLauncher/tool/r2r_checker.cc index 06ef6e4..b4a337a 100644 --- a/NativeLauncher/tool/r2r_checker.cc +++ b/NativeLauncher/tool/r2r_checker.cc @@ -115,13 +115,11 @@ static bool hasValidR2RHeader(void* pAddr) IMAGE_DATA_DIRECTORY* pCorDir = getCorDirectoryEntry(pNTHeaders); if (!pCorDir) { - _SERR("Invalid Cor Data Directory"); return false; } IMAGE_COR20_HEADER* pCor = (IMAGE_COR20_HEADER*)getDirectoryData(pAddr, pNTHeaders, pCorDir); if (!pCor) { - _SERR("Invalid Cor Header"); return false; }