[cowdancer] 07/11: file.c: Preserve permissions on copy
James Clarke
jrtc27-guest at moszumanska.debian.org
Mon May 2 01:19:59 UTC 2016
This is an automated email from the git hooks/post-receive script.
jrtc27-guest pushed a commit to branch master
in repository cowdancer.
commit f91e0cb8c07dd0913be47df2c3e5411f5a582613
Author: James Clarke <jrtc27 at jrtc27.com>
Date: Mon May 2 00:44:13 2016 +0100
file.c: Preserve permissions on copy
---
file.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/file.c b/file.c
index 3e4f55e..b7afebc 100644
--- a/file.c
+++ b/file.c
@@ -36,6 +36,7 @@
#include <sys/stat.h>
#include <assert.h>
#include <alloca.h>
+#include <errno.h>
#include "file.h"
/**
@@ -51,6 +52,7 @@ int copy_file(const char*orig, const char*dest)
int fin=-1;
int fout=-1;
size_t count;
+ struct stat st;
if (!buf)
{
@@ -89,6 +91,26 @@ int copy_file(const char*orig, const char*dest)
perror("file copy: close ");
goto out;
}
+
+ if (0>stat(orig, &st))
+ {
+ fprintf(stderr,
+ "Error calling stat '%s': %s\n",
+ orig,
+ strerror(errno));
+ goto out;
+ }
+
+ if (chmod(dest, st.st_mode))
+ {
+ fprintf(stderr,
+ "Error calling chmod('%s' 0%llo): %s\n",
+ orig,
+ (unsigned long long) st.st_mode,
+ strerror(errno));
+ goto out;
+ }
+
ret=0;
out:
free(buf);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pbuilder/cowdancer.git
More information about the Pbuilder-maint
mailing list