1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-16 06:15:08 -05:00

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>
This commit is contained in:
Dan McGee 2007-06-27 19:27:26 -04:00
parent 77bbe58197
commit 5a3b595837

View File

@ -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);
}