diff options
author | Dan McGee <dan@archlinux.org> | 2007-06-27 19:27:26 -0400 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-06-27 20:32:37 -0400 |
commit | 5a3b59583740c033a5e27b61c3c38bebfd580acc (patch) | |
tree | 36195054747e574acf9cecec1d182d01c7eef169 /lib/libalpm | |
parent | 77bbe581973d41d57edb96488fa2cf73fddc1641 (diff) | |
download | pacman-5a3b59583740c033a5e27b61c3c38bebfd580acc.tar.xz |
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 <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r-- | lib/libalpm/util.c | 15 |
1 files changed, 15 insertions, 0 deletions
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 <time.h> #include <syslog.h> #include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> /* libarchive */ #include <archive.h> @@ -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); } |