summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAge
...
* Always process validity value returned by gpgmeDan McGee2011-08-25
| | | | | | | Don't force 'never'; you should be checking both the status and validity anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix small memory leak in sig check codeDan McGee2011-08-25
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* strtrim: don't move empty stringDan McGee2011-08-25
| | | | | | | | | | There were many cases where the string coming in was a blank line, e.g. "\n\0", length 1. The trim routine starts by trimming leading spaces, thus trimming everything. We would then proceed to do a memmove of the NULL byte, which is completely worthless as we can just assign it instead. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove argument from check_pgp_helperDan McGee2011-08-25
| | | | | | | This one wasn't all that necessary as we only used it in one place in the function, which can be checked easily enough at the call site. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove trans is NULL check in QUESTION/EVENT/PROGRESS macrosDan McGee2011-08-25
| | | | | | | trans cannot (and better not) be NULL at any point when these are being called. Signed-off-by: Dan McGee <dan@archlinux.org>
* Finish large file download attack preventionDan McGee2011-08-25
| | | | | | | | | This handles the no Content-Length header problem as stated in the comments of FS#23413. We add a quick check to the callback that will force an abort if the downloaded data exceeds the payload size, and then check for this error in the post-download cleanup code. Signed-off-by: Dan McGee <dan@archlinux.org>
* Use off_t rather than double where possibleDan McGee2011-08-25
| | | | | | | | Beautiful of libcurl to use floating point types for what are never fractional values. We can do better, and we usually want these values in their integer form anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
* Add new 'lt' and 'zh_TW' translations from transifexDan McGee2011-08-25
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Update existing translations from TransifexDan McGee2011-08-25
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Improved alpm_list_mmerge() performance (fixed coding style)Diogo Sousa2011-08-24
| | | | | | | | | | Improved alpm_list_mmerge() performance by removing an extra pass to obtain the tail node. This was actually suggested by a TODO comment. Signed-off-by: Diogo Sousa <diogogsousa@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* vercmp: ensure 2.0a and 2.0.a do not compare equalDan McGee2011-08-23
| | | | | | | | | | | | | | | | We had this interesting set of facts conundrum, according to vercmp return values: 2.0a < 2.0 2.0 < 2.0.a 2.0a == 2.0.a This introduces a code change that ensures '2.0a < 2.0.a' as would be expected by the first two comparisons. Unfortunately this stays us a bit further from upstream RPM code, but those are the breaks (in RPM, the versions involving 'a' do in fact compare the same, but they are both greater than the bare '2.0'). Signed-off-by: Dan McGee <dan@archlinux.org>
* Style-match rpmvercmp code with upstreamDan McGee2011-08-23
| | | | | | | Not sure how or why some of this differed, but it is easy enough to set it back to how it was so it is easier to diff. Signed-off-by: Dan McGee <dan@archlinux.org>
* sync: halt file discovery if repo has no serversDave Reisner2011-08-23
| | | | | | | | | | | | | | | | | | | | | This avoids error spam when no servers are configured for a repo and a sync operation is performed: Proceed with installation? [Y/n] y :: Retrieving packages from testing... warning: failed to retrieve some files from testing warning: failed to retrieve some files from testing warning: failed to retrieve some files from testing warning: failed to retrieve some files from testing warning: failed to retrieve some files from testing warning: failed to retrieve some files from testing warning: failed to retrieve some files from testing warning: failed to retrieve some files from testing warning: failed to retrieve some files from testing warning: failed to retrieve some files from testing Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: prevent need to copy struct in mask_signal()Dan McGee2011-08-22
| | | | | | | Since we store this directly in the download function, just rework mask_signal() to take a pointer to a location to store the original. Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: extract tempfile creation to its own functionDave Reisner2011-08-22
| | | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: move (un)masking of signals to separate functionsDave Reisner2011-08-22
| | | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: move curl option setting to static functionDave Reisner2011-08-22
| | | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: add open_mode to payload structDave Reisner2011-08-22
| | | | | | | | | This is a precursor to a following patch which will move the setting of options to a separate function. With the open mode as part of the struct, we can avoid modifying stack allocated variables. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: rename cd_filename to content_disp_nameDave Reisner2011-08-22
| | | | | | | | This is more in line with the menagerie of file name members that we now have on the payload struct. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: move tempfile and destfile to payload structDave Reisner2011-08-22
| | | | | | | | | | These are private to the download operation already, so glob them onto the struct. This is an ugly rename patch, with the only logical change being that destfile and tempfile are now freed by the payload_free function. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove alpm_option_get_* usage from backendDan McGee2011-08-19
| | | | | | These are all available directly on the handle without indirection. Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: remove unused macroDave Reisner2011-08-19
| | | | | | | This was a vestige leftover from the libfetch days of yore. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: delete zero length downloads on curl errorDave Reisner2011-08-19
| | | | | | | | In the case of a non-operation (e.g. DNS resolver error), delete the leftover 0 byte .part file. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: rename payload->filename to payload->remote_nameDave Reisner2011-08-19
| | | | | | | | | This is a far more accurate description of what this is, since it's more than likely not really a filename at all, but the name after a final slash on a URL. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: remove code duplicationDave Reisner2011-08-19
| | | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Rework finding a writable cache directoryDan McGee2011-08-19
| | | | | | | | | | | | | | | | | | | | This is a refactor and refresh of the code used to find where we should download packages. * Incorporate suggestions from FS#25435 to use TMPDIR from the environment if set, otherwise fall back to /tmp as before. * Make the writability tests a bit more in depth. We now do a three part check consisting of: - S_ISDIR(): is this even a directory - access(W_OK): is this directory writable by the current user. Unfortunately for root, this almost always returns that it is, but in the case of a RO mount or NFS share inaccessible to root, this check will exclude the directory. - mode & (any write bit): is there a writable bit set on this directory. This makes it possible to enforce a read-only cache directory by setting permissions to 0555, for example. Signed-off-by: Dan McGee <dan@archlinux.org>
* Be more robust when copying package dataDan McGee2011-08-19
| | | | | | | | | | | | | | | | This changes the signature of _alpm_pkg_dup() to return an integer error code and provide the new package in a passed pointer argument. All callers are now more robust with checking the return value of this function to ensure a fatal error did not occur. We allow load failures to proceed as otherwise we have a chicken and egg problem- if a 'desc' local database entry is missing, the best way of restoring said file is `pacman -Sf --dbonly packagename`. This patch fixes a segfault that was occurring in this case. Fixes the segfault reported in FS#25667. Signed-off-by: Dan McGee <dan@archlinux.org>
* lib/dload: unlink on response code >=400Dave Reisner2011-08-19
| | | | | | | ftp and http both define >=400 as being "something bad happened" Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: add 'unlink_on_fail' to payload structDave Reisner2011-08-19
| | | | | | | | | Let callers of _alpm_download state whether we should delete on fail, rather than inferring it from context. We still override this decision and always unlink when a temp file is used. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* lib/dload: prevent possible NULL dereferenceDave Reisner2011-08-19
| | | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* sync: fix garbled output in conflict promptDave Reisner2011-08-19
| | | | | | | | | | | | | | | $ pacman -S cronie resolving dependencies... looking for inter-conflicts... :: cronie and fcron are in conflict (@.). Remove fcron? [y/N] n $ sudo pacman -S pacman resolving dependencies... looking for inter-conflicts... :: pacman and pacman-git are in conflict (pKÈ). Remove pacman-git? [y/N] Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Convert resolvedep() to use _alpm_depcmp_literal()Dan McGee2011-08-18
| | | | | | | | | The whole first loop is trying to check literals only, so teach it to do so. Also, reorder operations to make more sense by putting the strcmp() first in the literal loop, and using a very cheap name_hash check first in the second loop. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix replacement of provider issueDan McGee2011-08-18
| | | | | | | | | When we switched to using alpm_depcmp() in resolving replacments, we had some interesting behavior with regard to providers and packages not found in repositories. Teach the replacement resolving code to not look at provisions at all to be slightly more sane. Signed-off-by: Dan McGee <dan@archlinux.org>
* Add an _alpm_depcmp_literal() functionDan McGee2011-08-18
| | | | | | | This omits the finding of matching provisions and only checks the package itself against the provided dep. Signed-off-by: Dan McGee <dan@archlinux.org>
* Replacements refactor: extract check_replacers()Dan McGee2011-08-18
| | | | | | | This moves code that was inline in alpm_sync_sysupgrade() to its own method. Signed-off-by: Dan McGee <dan@archlinux.org>
* Replacements refactor: extract check_literal()Dan McGee2011-08-18
| | | | | | | This moves code that was inline in alpm_sync_sysupgrade() to its own method. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove usages of alpm_list_next() in backendDan McGee2011-08-18
| | | | | | | Another function call that can be replaced by a single pointer dereference. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove use of no-op accessor functions in libraryDan McGee2011-08-18
| | | | | | | | | The functions alpm_db_get_name(), alpm_pkg_get_name(), and alpm_pkg_get_version() are not necessary at all, so remove the calling and indirection when used in the backend, which makes things slightly more efficient and reduces code size. Signed-off-by: Dan McGee <dan@archlinux.org>
* Enhance and utilize database status flagsDan McGee2011-08-18
| | | | | | | | | | | | | | | | | | * Move is_local standalone field to status enum * Create VALID/INVALID flag pair * Create EXISTS/MISSING flag pair With these additional fields, we can be more intelligent with database loading and messages to the user. We now only warn once if a sync database does not exist and do not continue to try to load it once we have marked it as missing. The reason for the flags existing in pairs is so the unknown case can be represented. There should never be a time when both flags in the same group are true, but if they are both false, it represents the unknown case. Care is taken to always manipulate both flags at the same time. Signed-off-by: Dan McGee <dan@archlinux.org>
* lib/libalpm/dload.c: Use STRDUP() instead of strdup()Lukas Fleischer2011-08-18
| | | | | | | | Use the STRDUP macro instead of strdup() for the sake of better error handling on memory allocation failures. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Dan McGee <dan@archlinux.org>
* lib/libalpm/dload.c: Add ASSERT() to alpm_fetch_pkgurl()Lukas Fleischer2011-08-18
| | | | | | | | Return with ALPM_ERR_WRONG_ARGS instead of causing a potential segfault if alpm_fetch_pkgurl() is invoked with a NULL URL. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Dan McGee <dan@archlinux.org>
* lib/dload: refactor deletion on failureDave Reisner2011-08-17
| | | | | | | | | | | This moves all the delete-on-fail logic to under cleanup label. This also implies should_unlink when a payload is received that doesn't allow resuming. Fixes .db.sig.part files leftover in the sync dir. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* lib/dload: avoid renaming download to 0 length destfileDave Reisner2011-08-17
| | | | | | | This leverages earlier work that avoids a rename when destfile is unset. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Avoid stat() on NULL path in curl_download_internal()Lukas Fleischer2011-08-17
| | | | | | | | | stat()'s behaviour is undefined if the first argument is NULL and might be prone to segfault. Add an additional check to skip the stat() invocation if no destfile is used. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Dan McGee <dan@archlinux.org>
* Skip rename() on NULL destfile in curl_download_internal()Lukas Fleischer2011-08-17
| | | | | | | | Avoid a potential segfault that may occur if we use a temporary file and fail to build the destination file name from the effective URL. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix compilation using --without-gpgmeDan McGee2011-08-16
| | | | | | | This function is used regardless of whether gpgme support is enabled, so make sure it is always accessible. Signed-off-by: Dan McGee <dan@archlinux.org>
* dload: zero out pm_errno in curl_download_internalDave Reisner2011-08-16
| | | | | | | | | | This reverts some hacky behavior from 5fc3ec and resets the handle's pm_errno where it should be reset -- prior to each download. This prevents a transaction with a download from being aborted when a package is successfully grabbed from a secondary server. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Update message catalogsDan McGee2011-08-15
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Update translations from TransifexDan McGee2011-08-15
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Only check necessary signatures and checksumsDan McGee2011-08-15
| | | | | | | | | | | The precedence goes as follows: signature > sha256sum > md5sum Add some logic and helper methods to check what we have available when loading a package, and then only check what is necessary to verify the package. This should speed up sync database verifies as we no longer will be doing both a checksum and a signature validation. Signed-off-by: Dan McGee <dan@archlinux.org>