summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
authorXavier Chantry <shiningxc@gmail.com>2009-07-17 15:48:57 +0200
committerDan McGee <dan@archlinux.org>2009-07-20 17:13:25 +0200
commitbfd6817112b34b552e9139bdc582d048bcba38b9 (patch)
tree1c33649fec71af2d5a16618bd9627689c0a54285 /lib/libalpm/add.c
parenta3ecbec6b584b3595c041850e4c8bf242f7ce74a (diff)
downloadpacman-bfd6817112b34b552e9139bdc582d048bcba38b9.tar.gz
pacman-bfd6817112b34b552e9139bdc582d048bcba38b9.tar.xz
Fix fileconflict004
When one package wants to replace a directory by a file, we check that all files in that directory were owned by that package. Additionally pacman can be more verbose when the extraction of the symlink (or file) fails. The patch to add.c looks more complex than it is, I just moved and reindented code to handle cases 10 and 11 together. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 4bd52dea..ddbcfeea 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -353,28 +353,30 @@ static int extract_single_file(struct archive *archive,
if(_alpm_lstat(filename, &lsbuf) != 0 || stat(filename, &sbuf) != 0) {
/* cases 1,2,3: couldn't stat an existing file, skip all backup checks */
} else {
- if(S_ISDIR(lsbuf.st_mode) && S_ISDIR(entrymode)) {
- /* case 12: existing dir, ignore it */
- if(lsbuf.st_mode != entrymode) {
- /* if filesystem perms are different than pkg perms, warn user */
- int mask = 07777;
- _alpm_log(PM_LOG_WARNING, _("directory permissions differ on %s\n"
- "filesystem: %o package: %o\n"), entryname, lsbuf.st_mode & mask,
- entrymode & mask);
- alpm_logaction("warning: directory permissions differ on %s\n"
+ if(S_ISDIR(lsbuf.st_mode)) {
+ if(S_ISDIR(entrymode)) {
+ /* case 12: existing dir, ignore it */
+ if(lsbuf.st_mode != entrymode) {
+ /* if filesystem perms are different than pkg perms, warn user */
+ int mask = 07777;
+ _alpm_log(PM_LOG_WARNING, _("directory permissions differ on %s\n"
+ "filesystem: %o package: %o\n"), entryname, lsbuf.st_mode & mask,
+ entrymode & mask);
+ alpm_logaction("warning: directory permissions differ on %s\n"
"filesystem: %o package: %o\n", entryname, lsbuf.st_mode & mask,
- entrymode & mask);
+ entrymode & mask);
+ }
+ _alpm_log(PM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
+ entryname);
+ archive_read_data_skip(archive);
+ return(0);
+ } else {
+ /* case 10/11: trying to overwrite dir with file/symlink, don't allow it */
+ _alpm_log(PM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
+ entryname);
+ archive_read_data_skip(archive);
+ return(1);
}
- _alpm_log(PM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
- entryname);
- archive_read_data_skip(archive);
- return(0);
- } else if(S_ISDIR(lsbuf.st_mode) && S_ISLNK(entrymode)) {
- /* case 11: existing dir, symlink in package, ignore it */
- _alpm_log(PM_LOG_DEBUG, "extract: skipping symlink extraction of %s\n",
- entryname);
- archive_read_data_skip(archive);
- return(0);
} else if(S_ISLNK(lsbuf.st_mode) && S_ISDIR(entrymode)) {
/* case 9: existing symlink, dir in package */
if(S_ISDIR(sbuf.st_mode)) {
@@ -390,12 +392,6 @@ static int extract_single_file(struct archive *archive,
archive_read_data_skip(archive);
return(1);
}
- } else if(S_ISDIR(lsbuf.st_mode) && S_ISREG(entrymode)) {
- /* case 10: trying to overwrite dir tree with file, don't allow it */
- _alpm_log(PM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
- entryname);
- archive_read_data_skip(archive);
- return(1);
} else if(S_ISREG(lsbuf.st_mode) && S_ISDIR(entrymode)) {
/* case 6: trying to overwrite file with dir */
_alpm_log(PM_LOG_DEBUG, "extract: overwriting file with dir %s\n",