From 4c2ae54097dcd07b5dc74a03a620f1f25c51b6e7 Mon Sep 17 00:00:00 2001 From: "j-h.choi" Date: Fri, 17 Jan 2020 11:04:17 +0900 Subject: [PATCH] Change the function name from updateAssemblyInfo() to copySmackAndOwnership() --- NativeLauncher/inc/utils.h | 4 ++-- NativeLauncher/tool/ni_common.cc | 8 ++++---- NativeLauncher/tool/tac_common.cc | 10 +++++----- NativeLauncher/util/utils.cc | 18 +++++++++--------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/NativeLauncher/inc/utils.h b/NativeLauncher/inc/utils.h index c894c45..3e8c154 100644 --- a/NativeLauncher/inc/utils.h +++ b/NativeLauncher/inc/utils.h @@ -163,12 +163,12 @@ typedef std::function FileReader; void scanFilesInDir(const std::string& directory, FileReader reader, unsigned int depth); /** - * @brief update assembly file info. + * @brief copy smack and ownership. * @param[in] get path * @param[in] set path * @param[in] symbolic link */ -void updateAssemblyInfo(const std::string& getPath, const std::string& setPath, bool isSymlink = false); +void copySmackAndOwnership(const std::string& fromPath, const std::string& toPath, bool isSymlink = false); /** * @brief create the new directory. diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc index 6fc442f..2326722 100644 --- a/NativeLauncher/tool/ni_common.cc +++ b/NativeLauncher/tool/ni_common.cc @@ -112,7 +112,7 @@ static std::string getAppNIPath(const std::string& niPath) if (!isFileExist(niDirPath)) { if (mkdir(niDirPath.c_str(), 0755) == 0) { - updateAssemblyInfo(prevPath, niDirPath); + copySmackAndOwnership(prevPath, niDirPath); } else { fprintf(stderr, "Fail to create app ni directory (%s)\n", niDirPath.c_str()); } @@ -267,7 +267,7 @@ static ni_error_e crossgen(const std::string& dllPath, const std::string& appPat // Do not use niExist() function to check whether ni file created or not. // niEixst() return false for System.Private.Corelib.dll if (isFileExist(absNiPath)) { - updateAssemblyInfo(absDllPath, absNiPath); + copySmackAndOwnership(absDllPath, absNiPath); #ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT if (baseAddr != 0) { updateBaseAddrFile(absNiPath, baseAddr); @@ -508,7 +508,7 @@ ni_error_e createTACPkgRoot(const std::string& pkgId, DWORD flags) if (!bf::exists(symNIPath)) { bf::create_symlink(originNiPath, symNIPath); fprintf(stderr, "%s symbolic link file generated successfully.\n", symNIPath.c_str()); - updateAssemblyInfo(tacDir.c_str(), symNIPath.c_str(), true); + copySmackAndOwnership(tacDir.c_str(), symNIPath.c_str(), true); std::string NIFileName = symNIPath.substr(symNIPath.rfind('/') + 1); if (!removeFile(concatPath(binNIDir, NIFileName))) { @@ -610,7 +610,7 @@ ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& if (!bf::exists(setNiPath)) { bf::create_symlink(originNiPath, setNiPath); fprintf(stderr, "%s symbolic link file generated successfully.\n", setNiPath.c_str()); - updateAssemblyInfo(tacDir.c_str(), setNiPath.c_str(), true); + copySmackAndOwnership(tacDir.c_str(), setNiPath.c_str(), true); } } } diff --git a/NativeLauncher/tool/tac_common.cc b/NativeLauncher/tool/tac_common.cc index 0c8df03..4c50abe 100644 --- a/NativeLauncher/tool/tac_common.cc +++ b/NativeLauncher/tool/tac_common.cc @@ -275,14 +275,14 @@ tac_error_e disableTACPackage(const std::string& pkgId) fprintf(stderr, "Failed to copy of %s\n", dllPath.c_str()); return TAC_ERROR_UNKNOWN; } - updateAssemblyInfo(binDir.c_str(), concatPath(binDir, fileName).c_str()); + copySmackAndOwnership(binDir.c_str(), concatPath(binDir, fileName).c_str()); } else { std::string niPath = concatPath(binNIDir, fileName); if (!copyFile(originPath, niPath)) { fprintf(stderr, "Failed to copy of %s\n", niPath.c_str()); return TAC_ERROR_UNKNOWN; } - updateAssemblyInfo(binDir.c_str(), niPath.c_str()); + copySmackAndOwnership(binDir.c_str(), niPath.c_str()); } } } @@ -329,7 +329,7 @@ tac_error_e enableTACPackage(const std::string& pkgId) fprintf(stderr, "Cannot create directory: %s\n", tacDir.c_str()); return TAC_ERROR_UNKNOWN; } - updateAssemblyInfo(binDir.c_str(), tacDir.c_str()); + copySmackAndOwnership(binDir.c_str(), tacDir.c_str()); std::vector enableNuget; for (auto& npAssembly : depsJsonParser(rootPath, execName, getTPA())) { @@ -353,7 +353,7 @@ tac_error_e enableTACPackage(const std::string& pkgId) if (bf::exists(originNIPath)) { bf::create_symlink(originNIPath, concatPath(tacDir, NIFileName)); fprintf(stderr, "%s symbolic link file generated successfully.\n", concatPath(tacDir, NIFileName).c_str()); - updateAssemblyInfo(tacDir.c_str(), concatPath(tacDir, NIFileName).c_str(), true); + copySmackAndOwnership(tacDir.c_str(), concatPath(tacDir, NIFileName).c_str(), true); if (!removeFile(concatPath(binNIDir, NIFileName))) { fprintf(stderr, "Failed to remove of %s\n", concatPath(binNIDir, NIFileName).c_str()); @@ -363,7 +363,7 @@ tac_error_e enableTACPackage(const std::string& pkgId) } bf::create_symlink(originPath, concatPath(tacDir, fileName)); fprintf(stderr, "%s symbolic link file generated successfully.\n", concatPath(tacDir, fileName).c_str()); - updateAssemblyInfo(tacDir.c_str(), concatPath(tacDir, fileName).c_str(), true); + copySmackAndOwnership(tacDir.c_str(), concatPath(tacDir, fileName).c_str(), true); if (!removeFile(concatPath(binDir, fileName))) { fprintf(stderr, "Failed to remove of %s\n", concatPath(binDir, fileName).c_str()); diff --git a/NativeLauncher/util/utils.cc b/NativeLauncher/util/utils.cc index c4df8b0..34c328d 100644 --- a/NativeLauncher/util/utils.cc +++ b/NativeLauncher/util/utils.cc @@ -350,37 +350,37 @@ void scanFilesInDir(const std::string& directory, FileReader reader, unsigned in closedir(dir); } -void updateAssemblyInfo(const std::string& getPath, const std::string& setPath, bool isSymlink) +void copySmackAndOwnership(const std::string& fromPath, const std::string& toPath, bool isSymlink) { char* label = NULL; struct stat info; if (isSymlink) { // change smack label for symbolic link. - if (smack_lgetlabel(getPath.c_str(), &label, SMACK_LABEL_ACCESS) == 0) { - if (smack_lsetlabel(setPath.c_str(), label, SMACK_LABEL_ACCESS) < 0) { + if (smack_lgetlabel(fromPath.c_str(), &label, SMACK_LABEL_ACCESS) == 0) { + if (smack_lsetlabel(toPath.c_str(), label, SMACK_LABEL_ACCESS) < 0) { fprintf(stderr, "Fail to set smack label\n"); } free(label); } // change owner and groups for symbolic link. - if (!stat(getPath.c_str(), &info)) { - if (lchown(setPath.c_str(), info.st_uid, info.st_gid) == -1) + if (!stat(fromPath.c_str(), &info)) { + if (lchown(toPath.c_str(), info.st_uid, info.st_gid) == -1) fprintf(stderr, "Failed to change owner and group name\n"); } } else { // change smack label - if (smack_getlabel(getPath.c_str(), &label, SMACK_LABEL_ACCESS) == 0) { - if (smack_setlabel(setPath.c_str(), label, SMACK_LABEL_ACCESS) < 0) { + if (smack_getlabel(fromPath.c_str(), &label, SMACK_LABEL_ACCESS) == 0) { + if (smack_setlabel(toPath.c_str(), label, SMACK_LABEL_ACCESS) < 0) { fprintf(stderr, "Fail to set smack label\n"); } free(label); } // change owner and groups for generated ni file. - if (!stat(getPath.c_str(), &info)) { - if (chown(setPath.c_str(), info.st_uid, info.st_gid) == -1) + if (!stat(fromPath.c_str(), &info)) { + if (chown(toPath.c_str(), info.st_uid, info.st_gid) == -1) fprintf(stderr, "Failed to change owner and group name\n"); } } -- 2.7.4