summaryrefslogtreecommitdiff
path: root/lib/libalpm/add.c
Commit message (Collapse)AuthorAge
* libalpm: Use archive_read_extract2Armin K2017-04-12
| | | | | | | | | | | | | | archive_read_extract() forces resolution of uid/gid to names when extracting the tarball. This can lead to wrong file ownership when using pacman with -r option and when uid/gid differ in the host and in the chroot. archive_read_extract2() uses uid's and gid's only. See also: https://lists.archlinux.org/pipermail/pacman-dev/2017-March/021912.html Signed-off-by: Armin K <krejzi@email.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* extract db files with dbonlyAndrew Gregory2017-01-04
| | | | | | | | | | | Some database files (install, mtree, and changelog) are extracted directly from the package, but DBONLY was skipping extraction altogether, causing those files to be missing after the transaction. Fixes #52052 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* Update copyright yearsAllan McRae2017-01-04
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Release resources on error paths.Tobias Stoeckmann2016-08-30
| | | | | | | | Some resources (memory or file descriptors) are not released on all error paths. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Allan McRae <allan@archlinux.org>
* do not rely on localdb for hook matchingAndrew Gregory2016-02-23
| | | | | | | | | | | | Relying on localdb to determine which trigger operations should match is completely broken for PostTransaction hooks because the localdb has already been updated. Store a copy of the old version of any packages being updated to use instead. Fixes FS#47996 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* only remove pacnew file if it is newAndrew Gregory2016-02-21
| | | | | | | | | | | Check if we overwrote an exiting pacnew file before unlinking it. Otherwise, updating to a version with an unchanged file would delete existing pacnew files. FS#47993 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* Update copyright years for 2016Allan McRae2016-01-04
| | | | | | make update-copyright OLD=2015 NEW=2016 Signed-off-by: Allan McRae <allan@archlinux.org>
* always unlink files before extractionAndrew Gregory2015-12-05
| | | | | | | | | | | | libarchive will not extract a directory over an existing directory symlink, making it impossible to replace a symlink with a directory across packages. Adding the ARCHIVE_EXTRACT_UNLINK and ARCHIVE_EXTRACT_SECURE_SYMLINKS causes libarchive to unlink the existing symlink and prevents it from extracting any paths that contain a symlink, which we should not be doing anyway. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* Do not warn about downgrades when only downloading packageAllan McRae2015-07-12
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Silence warning from clangAllan McRae2015-05-12
| | | | | | | | clang is wrong - dbfile is always used initialized in that function. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
* Merge branch 'maint'Allan McRae2015-02-12
|\
| * Disable directory ownership warningsAllan McRae2015-02-12
| | | | | | | | | | | | | | There was a lot of confusion regarding these warnings, particularly for packages that create users post_install and then chown the directories. Signed-off-by: Allan McRae <allan@archlinux.org>
* | Update copyright notices for 2015Allan McRae2015-02-01
| | | | | | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* | extract_single_file: consolidate extraction logicAndrew Gregory2015-01-21
| | | | | | | | | | | | Also adds checks that the filename does not exceed PATH_MAX. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
* | extract_single_file: use .pacnew for check filesAndrew Gregory2015-01-21
| | | | | | | | | | | | | | | | Prevents the need to rename the file if we end up keeping it and ensures that pacnew files always reflect the most recent version by overwriting stale copies. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
* | remove support for .pacorig filesAndrew Gregory2015-01-21
| | | | | | | | | | | | | | | | Leave user files in place and save new config files with a .pacnew extension. This reduces the complexity of file extraction and respects the principle that pacman shouldn't modify files it didn't create. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
* | extract_single_file: use full path in messagesAndrew Gregory2015-01-21
| | | | | | | | | | | | | | | | If an error occurs the actual path being extracted is more useful than the original path from the package file list. The original path is still used for checks that use it directly. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
* | extract_single_file: factor out db file extractionAndrew Gregory2015-01-21
| | | | | | | | | | | | | | alpm's database files (.INSTALL, .MTREE, etc.) should be extracted no matter what; skip mtree/needbackup/noextract/noupgrade checks for them. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
* | extract_single_file: reduce indentationAndrew Gregory2015-01-21
| | | | | | | | | | | | Puts all of the conflict cases at the same level. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
* | extract_single_file: consolidate needbackup checksAndrew Gregory2015-01-21
|/ | | | | | We need to know if a file needs to be backed up for all extracted files. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
* extract_single_file: fix memory leak in error conditionAllan McRae2014-11-18
| | | | | | The memory assigned to checkfile was leaked in the error condition. Signed-off-by: Allan McRae <allan@archlinux.org>
* Remove logging of NoExtract eventsAllan McRae2014-11-18
| | | | | | | With globbing in NoExtract, these log events can quickly pile up hiding important information from the log. Signed-off-by: Allan McRae <allan@archlinux.org>
* move _alpm_lstat into util-commonAndrew Gregory2014-08-03
| | | | Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
* Add events on pacnew/pacsave/pacorig file creationOlivier Brunel2014-03-03
| | | | | | | | | | | | | | ALPM still adds a warning to the log, but doesn't emit an event about said warning, instead using a specific event to let the frontend what happened/how to inform the user. Note that there are 2 cases for installing a .pacnew file, to not overwrite user changes and because file is in NoUpgrade. In the later case the warning was a bit different: it happened before and said "extracting" instead of "installed." Now both happen after and are phrased the same. Signed-off-by: Olivier Brunel <jjk@jjacky.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* restrict transaction package originsAndrew Gregory2014-03-03
| | | | | | | | | This moves the "wrong args" error up from trans_commit to add_pkg when used with a local pkg and adds the error for remove_pkg when used with a sync pkg, which currently just removes the db entry. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* Update the event callbackOlivier Brunel2014-03-03
| | | | | | | | | | | | Instead of using two void* arguments for all events, we now send one pointer to an alpm_event_t struct. This contains the type of event that was triggered. With this information, the pointer can then be typecasted to the event-specific struct in order to get additional arguments. Signed-off-by: Olivier Brunel <jjk@jjacky.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* Check if a file is in the package's file list before extractingFlorian Pritz2014-03-03
| | | | Signed-off-by: Florian Pritz <bluewind@xinu.at>
* Remove ts and sw from vim modeline when noet is setFlorian Pritz2014-01-28
| | | | | | | | | | | | Forcing vim users to view files with a tabstop of 2 seems really unnecessary when noet is set. I find it much easier to read code with ts=4 and I dislike having to override the modeline by hand. Command run: find . -type f -exec sed -i '/vim.* noet/s# ts=2 sw=2##' {} + Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Allan McRae <allan@archlinux.org>
* Use O_CLOEXEC as much as possible when opening filesDan McGee2014-01-06
| | | | | | | | | | | | | | | | | | | When calling open(), use O_CLOEXEC as much as possible to ensure the file descriptor is closed when and if a process using libalpm forks. For most of these cases, and especially in utility functions, the file descriptor is opened and closed in the same function, so we don't have too much to worry about. However, for things like the log file and database lock file, we should ensure descriptors aren't left hanging around for children to touch. This patch is inspired by the problem in FS#36161, where an open file descriptor to the current working directory prevents chroot() from working on FreeBSD. We don't need this file descriptor in the child process, so open it (and now several others) with O_CLOEXEC. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
* Update copyright years for 2014Allan McRae2014-01-06
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* alpm: Rename a variable for future clarityOlivier Brunel2013-12-15
| | | | | | | We will be adding event structs in the following patches. Signed-off-by: Olivier Brunel <jjk@jjacky.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* Fix whitespace and other formatting issuesJason St. John2013-11-15
| | | | | | | | | This commit: -- replaces space-based indents with tabs per the coding standards -- removes extraneous whitespace (e.g. extra spaces between function args) -- adds missing braces for a one-line if statement Signed-off-by: Jason St. John <jstjohn@purdue.edu>
* log important events from the backendAndrew Gregory2013-11-15
| | | | | | | | | | | | | This ensures that important events will be logged and consistent regardless of the frontend. The need for global context in the event callback is also removed. The event is logged before any post_* scripts run, so this also moves the post_* script output underneath the event in the log. Fixes FS#36504 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* Do not refer to FlySpray numbersAllan McRae2013-08-21
| | | | | | | | These references to bug numbers assume we will forever be using that bug tracker. It is better to properly comment the code instead (which was done in almost all cases anyway). Signed-off-by: Allan McRae <allan@archlinux.org>
* Warn when directory ownership differs between filesystem and packageAllan McRae2013-07-30
| | | | | | | | | | | | | We currently only warn if a directory's permissions differ, but using -Qkk on my system shows that directory permissions tend to change in packages reasonably frequently without notice. Provide a warning in such cases so that it can be altered. Example output: (1/1) reinstalling nginx warning: directory ownership differs on /var/lib/nginx/proxy/ filesystem: 33:0 package: 0:0 Signed-off-by: Allan McRae <allan@archlinux.org>
* do not check error from close(2)Dave Reisner2013-07-05
| | | | | | | | | | | | | | | On operating systems we support, the behavior is always such that the kernel will do the right thing as far as invalidating the file descriptor, regardless of the eventual return value. Therefore, potentially looping and calling close multiple times is wrong. At best, we call close again on an invalid FD and throw a spurious EBADF error. At worst, we might close an FD which doesn't belong to us when a multi-threaded application opens its own file descriptor between iterations of the loop. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
* Enable inverted patterns in NoExtract and NoUpgrade.Patrick Steinhardt2013-06-26
| | | | | | | | It is now possible to invert patterns in NoExtract and NoUpgrade. This feature allows users to whitelist certain files that were previously blacklisted by another entry. Signed-off-by: Allan McRae <allan@archlinux.org>
* Install unchanged backup files to get correct timestamps.Patrick Steinhardt2013-06-26
| | | | | | Fixes FS#35515. Signed-off-by: Allan McRae <allan@archlinux.org>
* extract_single_file: consolidate symlink casesAndrew Gregory2013-06-03
| | | | | Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* add.c: refactor backup file modification checksAndrew Gregory2013-05-29
| | | | | | | | | | | | | The previous implementation was overly complex with unnecessary checks and nested conditionals. By reordering the tests and changing them to all be checks for positive hash matches rather than non-matches, we can collapse several cases and make the process much more linear. This removes the need to set hash_orig = "" just to reach some of the checks and corrects a faulty assumption that files are equivalent when the hashing process fails. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* Fix spelling errors using 'codespell' toolAnatol Pomozov2013-04-18
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* make status/log messages reflect version changeSimon Gomizelj2013-03-10
| | | | | | | | | Currently pacman either prints 'adding' or 'upgrading' when installing a package. This make pacman print and log the other possible actions: 'downgrade' and 'reinstall' Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* Provide full path names in warning messagesRichard Pougnet2013-02-24
| | | | | | | Fix FS#31556 by printing filename instead of entryname. Thus, removing a lot of confusion from the output. Signed-off-by: Allan McRae <allan@archlinux.org>
* Use libarchive compat header for relevant symbolsDave Reisner2013-01-29
| | | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
* add caller prefix to alpm_logactionAndrew Gregory2013-01-28
| | | | | | | prefix defaults to "UNKOWN" if null or an empty string is provided. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* Update copyright year for 2013Allan McRae2013-01-03
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Extract .MTREE file into local package databaseAllan McRae2012-12-14
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Make alpm_pkg_find publicAllan McRae2012-12-14
| | | | | | This function is particularly useful, so make it public. Signed-off-by: Allan McRae <allan@archlinux.org>
* Merge branch 'maint'Dan McGee2012-05-20
|\ | | | | | | | | Conflicts: scripts/pacman-key.sh.in
| * Ensure pre_upgrade scriptlet gets old package versionDan McGee2012-05-04
| | | | | | | | | | | | | | | | This was accidentally broken in the refactor done in commit 73139ccb. Fixes FS#29371. Signed-off-by: Dan McGee <dan@archlinux.org>