index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
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/util.c | |
parent | 77bbe581973d41d57edb96488fa2cf73fddc1641 (diff) |
-rw-r--r-- | lib/libalpm/util.c | 15 |
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); } |