From 5a3b59583740c033a5e27b61c3c38bebfd580acc Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 27 Jun 2007 19:27:26 -0400 Subject: Fix wrong permissions on pacnew extraction First reported here: http://bbs.archlinux.org/viewtopic.php?pid=261861 Newly created files were done with the standard umask, so those that are extracted seperately and copied to a .pacnew extension will have the wrong permissions. This should hopefully fix this. Signed-off-by: Dan McGee --- lib/libalpm/util.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 52cf09f9..e67a13ad 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include /* libarchive */ #include @@ -150,12 +152,25 @@ int _alpm_copyfile(const char *src, const char *dest) return(1); } + /* do the actual file copy */ while((len = fread(buf, 1, 4096, in))) { fwrite(buf, 1, len, out); } fclose(in); fclose(out); + + /* chmod dest to permissions of src, as long as it is not a symlink */ + struct stat statbuf; + if(stat(src, &statbuf)) { + if(! S_ISLNK(statbuf.st_mode)) { + chmod(dest, statbuf.st_mode); + } + } else { + /* stat was unsuccessful */ + return(1); + } + return(0); } -- cgit v1.2.3-70-g09d2