From 1a1133063a270bce9f40b9e712ee1fa9a6d4d75c Mon Sep 17 00:00:00 2001 From: Jay Freeman Date: Sat, 14 Jun 2008 20:42:54 +0000 Subject: Maintain permissions during codehashing. git-svn-id: http://svn.telesphoreo.org/trunk@311 514c082c-b64e-11dc-b46d-3d985efe055d --- util/ldid.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'util') 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 #include +#include +#include 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); -- cgit v1.2.3