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.
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());
}
// 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);
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))) {
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);
}
}
}
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());
}
}
}
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())) {
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());
}
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());
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");
}
}