summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeremy Sanders <jeremy@jeremysanders.net>2014-06-07 07:20:58 (GMT)
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-07-29 00:46:07 (GMT)
commit92fbe1a0e53ebfc38578ab16d8d0a353550806b3 (patch)
tree21beeafc67cd8d5def9ead98faeb34a4812788bb /src
parent2ca39b80600b856f2ae10d253e2088f1714508d3 (diff)
downloadpatchelf-92fbe1a0e53ebfc38578ab16d8d0a353550806b3.zip
patchelf-92fbe1a0e53ebfc38578ab16d8d0a353550806b3.tar.gz
patchelf-92fbe1a0e53ebfc38578ab16d8d0a353550806b3.tar.bz2
Use libattr and libacl to copy permissions if available
Diffstat (limited to 'src')
-rw-r--r--src/patchelf.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc
index dcbfd38..731b9ad 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -17,6 +17,16 @@
#include <fcntl.h>
#include <limits.h>
+#ifdef HAVE_ATTR_LIBATTR_H
+# include <attr/libattr.h>
+#endif
+#ifdef HAVE_SYS_ACL_H
+# include <sys/acl.h>
+#endif
+#ifdef HAVE_ACL_LIBACL_H
+# include <acl/libacl.h>
+#endif
+
#include "elf.h"
using namespace std;
@@ -378,7 +388,14 @@ static void writeFile(string fileName, mode_t fileMode)
if (close(fd) != 0) error("close");
+#if defined(HAVE_ATTR_COPY_FILE)
+ if (attr_copy_file(fileName.c_str(), fileName2.c_str(), 0, 0) != 0) error("attr_copy_file");
+#endif
+#if defined(HAVE_PERM_COPY_FILE)
+ if (perm_copy_file(fileName.c_str(), fileName2.c_str(), 0) != 0) error("perm_copy_file");
+#else
if (chmod(fileName2.c_str(), fileMode) != 0) error("chmod");
+#endif
if (rename(fileName2.c_str(), fileName.c_str()) != 0) error("rename");
}