summaryrefslogtreecommitdiff
path: root/util/ldid.cpp
diff options
context:
space:
mode:
authorJay Freeman <saurik@saurik.com>2008-06-14 20:42:54 +0000
committerJay Freeman <saurik@saurik.com>2008-06-14 20:42:54 +0000
commit1a1133063a270bce9f40b9e712ee1fa9a6d4d75c (patch)
tree32d12ef4aa011f9c0f3602475aaeb51f74a603f6 /util/ldid.cpp
parentd72422f747c36feb6235ff8ff19c005688b2db16 (diff)
Maintain permissions during codehashing.
git-svn-id: http://svn.telesphoreo.org/trunk@311 514c082c-b64e-11dc-b46d-3d985efe055d
Diffstat (limited to 'util/ldid.cpp')
-rw-r--r--util/ldid.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/ldid.cpp b/util/ldid.cpp
index d38e6b3f3..dc1902e54 100644
--- a/util/ldid.cpp
+++ b/util/ldid.cpp
@@ -45,6 +45,8 @@
#include <vector>
#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/stat.h>
struct fat_header {
uint32_t magic;
@@ -337,6 +339,7 @@ int main(int argc, const char *argv[]) {
const char *path(file->c_str());
const char *base = strrchr(path, '/');
char *temp(NULL), *dir;
+ mode_t mode = 0;
if (base != NULL)
dir = strndup(path, base++ - path + 1);
@@ -506,6 +509,10 @@ int main(int argc, const char *argv[]) {
}
if (temp) {
+ struct stat info;
+ _syscall(stat(path, &info));
+ _syscall(chown(temp, info.st_uid, info.st_gid));
+ _syscall(chmod(temp, info.st_mode));
_syscall(unlink(path));
_syscall(rename(temp, path));
free(temp);