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");
}
}