1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-03-01 09:51:50 -05:00
Nagy Gabor 472e51b975 Use archive_entry_set_perm instead of archive_entry_set_mode
This patch fixes FS#12148 ('unstable' regular file).
I also changed the other archive_entry_set_mode usage in add.c to
archive_entry_set_perm.

Since I cannot find any relevant info in libarchive manual, I quote
Tim Kientzle (the author of libarchive) here, and I say thank you for
his help.

*** Tim Kientzle wrote *************************************

This is the problem in libalpm/util.c:

323    if(S_ISREG(st->st_mode)) {
324            archive_entry_set_mode(entry, 0644);
325    } else if(S_ISDIR(st->st_mode)) {
326            archive_entry_set_mode(entry, 0755);
327    }

Your example unstable.db.tar.gz is not empty.  It has
one entry in it, called "./".  That entry is marked
as a directory.  But, when you call archive_entry_set_mode(),
you are changing the file type!  archive_read_extract()
then creates the file /var/unstable as you requested.
(archive_read_extract() will replace an empty directory
with a file.)

You should either set the mode value correctly:

323    if(S_ISREG(st->st_mode)) {
324            archive_entry_set_mode(entry, IFREG | 0644);
325    } else if(S_ISDIR(st->st_mode)) {
326            archive_entry_set_mode(entry, IFDIR | 0755);
327    }

Or use archive_entry_set_perm(), which does not change
the file type:

323    if(S_ISREG(st->st_mode)) {
324            archive_entry_set_perm(entry, 0644);
325    } else if(S_ISDIR(st->st_mode)) {
326            archive_entry_set_perm(entry, 0755);
327    }

************************************************************

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-18 13:35:17 -06:00
..
2009-01-05 19:06:39 -06:00
2008-08-23 08:47:07 -05:00
2008-01-27 11:54:25 -06:00
2008-06-04 15:38:47 -05:00
2008-07-19 11:04:38 -05:00
2008-07-13 09:16:55 -05:00
2008-04-10 20:53:28 -05:00
2008-06-04 15:38:47 -05:00
2008-06-03 21:31:31 -05:00
2008-06-03 21:31:31 -05:00
2008-06-04 15:38:47 -05:00
2009-01-02 23:40:20 -06:00
2008-08-23 08:47:07 -05:00
2008-01-27 12:05:33 -06:00
2008-03-10 18:57:36 -05:00
2008-07-24 22:16:28 -05:00