Change the function name from updateAssemblyInfo() to copySmackAndOwnership()
authorj-h.choi <j-h.choi@samsung.com>
Fri, 17 Jan 2020 02:04:17 +0000 (11:04 +0900)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Thu, 6 Feb 2020 01:11:43 +0000 (10:11 +0900)
NativeLauncher/inc/utils.h
NativeLauncher/tool/ni_common.cc
NativeLauncher/tool/tac_common.cc
NativeLauncher/util/utils.cc

index c894c45..3e8c154 100644 (file)
@@ -163,12 +163,12 @@ typedef std::function<void (const std::string&, const char*)> 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.
index 6fc442f..2326722 100644 (file)
@@ -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);
                                }
                        }
                }
index 0c8df03..4c50abe 100644 (file)
@@ -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<std::string> 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());
index c4df8b0..34c328d 100644 (file)
@@ -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");
                }
        }