1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 00:08:50 -05:00
pacman/lib/libalpm
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
..
po Update Czech translation 2009-01-05 19:06:39 -06:00
.gitignore Remove unnecessary entries from .gitignore files 2007-07-16 16:49:28 -04:00
add.c Use archive_entry_set_perm instead of archive_entry_set_mode 2009-01-18 13:35:17 -06:00
add.h Update GNU GPL boilerplate and copyright dates 2007-12-10 22:55:39 -06:00
alpm_list.c alpm_list_remove treat NULL needle as "nothing" 2008-07-17 20:20:13 -05:00
alpm_list.h Cleanup usages of alpm_list_find and alpm_list_remove. 2008-05-13 15:49:02 -05:00
alpm.c Remove unnecessary header file, move one macro to util.c 2008-04-06 20:20:20 -05:00
alpm.h Cleanup of _alpm_pkg_compare_versions. 2008-08-23 08:47:07 -05:00
backup.c memleak fix: ensure backup fname isn't lost if unused 2008-03-23 16:55:52 -05:00
backup.h Update GNU GPL boilerplate and copyright dates 2007-12-10 22:55:39 -06:00
be_files.c Separate local db directory creation and db write 2009-01-02 23:52:32 -06:00
be_package.c Don't display filename on -Qip operation. 2008-06-04 16:25:31 -05:00
cache.c Remove unnecessary unistd.h header inclusion 2008-10-12 21:30:15 -05:00
cache.h Update GNU GPL boilerplate and copyright dates 2007-12-10 22:55:39 -06:00
conflict.c Remove unnecessary unistd.h header inclusion 2008-10-12 21:30:15 -05:00
conflict.h New _alpm_conflict_dup function 2008-01-27 11:54:25 -06:00
db.c Remove unnecessary unistd.h header inclusion 2008-10-12 21:30:15 -05:00
db.h Separate local db directory creation and db write 2009-01-02 23:52:32 -06:00
delta.c Add regex to delta code so we don't segfault when reading line 2008-11-30 17:17:00 -06:00
delta.h Use correct C type for file sizes 2008-06-04 15:38:47 -05:00
deps.c Use NULL instead of "" as no causingpkg 2008-07-19 11:04:38 -05:00
deps.h sync_addtarget rework 2008-07-13 09:16:55 -05:00
dload.c Print proxy information when downloading 2008-12-10 19:45:15 -06:00
dload.h Remove unnecessary import in dload.h 2008-04-10 20:53:28 -05:00
error.c Fix some fallout from the delta/download changes 2008-04-26 13:03:53 -05:00
graph.h Use correct C type for file sizes 2008-06-04 15:38:47 -05:00
group.c Cleanup usages of alpm_list_find and alpm_list_remove. 2008-05-13 15:49:02 -05:00
group.h Cleanup usages of alpm_list_find and alpm_list_remove. 2008-05-13 15:49:02 -05:00
handle.c Reimplement TotalDownload functionality 2008-06-04 15:38:53 -05:00
handle.h Reimplement TotalDownload functionality 2008-06-04 15:38:53 -05:00
log.c Remove unnecessary header file, move one macro to util.c 2008-04-06 20:20:20 -05:00
log.h Update GNU GPL boilerplate and copyright dates 2007-12-10 22:55:39 -06:00
Makefile.am Refactor pkg_load/parse_descfile into a new backend file 2008-05-11 20:07:55 -05:00
md5.c libalpm/md5: Fix license header 2008-06-03 21:31:31 -05:00
md5.h libalpm/md5: Fix license header 2008-06-03 21:31:31 -05:00
package.c Remove unnecessary unistd.h header inclusion 2008-10-12 21:30:15 -05:00
package.h Use correct C type for file sizes 2008-06-04 15:38:47 -05:00
remove.c Log pacsave warnings to pacman.log 2009-01-02 23:40:20 -06:00
remove.h Update GNU GPL boilerplate and copyright dates 2007-12-10 22:55:39 -06:00
sync.c Cleanup of _alpm_pkg_compare_versions. 2008-08-23 08:47:07 -05:00
sync.h pmsyncpkg_t cleanup 2008-01-27 12:05:33 -06:00
trans.c Correctly close the pipe used for scriptlet execution 2008-10-18 23:59:28 -05:00
trans.h Remove trans->targets 2008-03-10 18:57:36 -05:00
util.c Use archive_entry_set_perm instead of archive_entry_set_mode 2009-01-18 13:35:17 -06:00
util.h Remove unused strverscmp substitute 2008-07-24 22:16:28 -05:00