summaryrefslogtreecommitdiff
path: root/apt-pkg
Commit message (Collapse)AuthorAgeFilesLines
* convert various c-style casts to C++-styleDavid Kalnischkies2017-12-139-26/+28
| | | | | | | | | | gcc was warning about ignored type qualifiers for all of them due to the last 'const', so dropping that and converting to static_cast in the process removes the here harmless warning to avoid hidden real issues in them later on. Reported-By: gcc Gbp-Dch: Ignore
* deprecate the single-line deprecation ignoring macroDavid Kalnischkies2017-12-135-5/+16
| | | | | | | | | | gcc has problems understanding this construct and additionally thinks it would produce multiple lines and stuff, so to keep using it isn't really worth it for the few instances we have: We can just write the long form there which works better. Reported-By: gcc Gbp-Dch: Ignore
* fix over-calculating dpkg commandline lengthDavid Kalnischkies2017-12-131-0/+2
| | | | | | | | | Mostly harmless as it just means that apt thinks that the dpkg commandline it is building is slightly longer than it actually is and we have various ways of avoiding generating very long lines nowadays, but calculating the right value can't hurt. Reported-By: gcc -Wmultistatement-macros
* explicitly name token in auth.conf parsing errorDavid Kalnischkies2017-12-131-2/+12
| | | | Reported-By: gcc -Wsign-promo
* don't auto-switch candidate if installed is good enoughDavid Kalnischkies2017-12-131-0/+7
| | | | | | | If we perform candidate switching in requests like "apt install foo/bar" we should first check if the dependencies of foo from release bar are already satisfied by what is already installed before checking if the candidate (or switched candidate) would.
* if insecure repo is allowed continue on all http errorsDavid Kalnischkies2017-12-131-5/+14
| | | | | | | | | | | | | | | | | If a InRelease file fails to download with a non-404 error we assumed there is some general problem with repository like a webportal or your are blocked from access (wrong auth, Tor, …). Turns out some server like S3 return 403 if a file doesn't exist. Allowing this in general seems like a step backwards as 403 is a reasonable response if auth failed, so failing here seems better than letting those users run into problems. What we can do is show our insecure warnings through and allow the failures for insecure repos: If the repo is signed it is easy to add an InRelease file and if not you are setup for trouble anyhow. References: cbbf185c3c55effe47f218a07e7b1f324973a8a6
* allow multivalue fields in deb822 sources to be foldedDavid Kalnischkies2017-11-191-44/+46
| | | | | | | | | | | | | | | The documentation said "spaces", but there is no real reason to be so strict and only allow spaces to separate values as that only leads to very long lines if e.g. multiple URIs are specified which are again hard to deal with from a user PoV which the deb822 format is supposed to avoid. It also deals with multiple consecutive spaces and strange things like tabs users will surely end up using in the real world. The old behviour on encountering folded lines is the generation of URIs which end up containing all these whitespace characters which tends to mess really bad with output and further processing. Closes: 881875
* use store: instead of gzip: to open local changelogsDavid Kalnischkies2017-10-281-2/+2
| | | | Regression-Of: cc1f94c95373670fdfdb8e2d6cf9125181f7df0c
* Don't segfault if receiving a method warning on empty queueJulian Andres Klode2017-10-251-1/+1
| | | | | | | We would like to issue a warning about seccomp support in Configuration(), but since the queue is empty, there is no current item to show the URL for and we get a segfault. Show the protocol instead.
* Run the ProxyAutoDetect script in the sandbox againJulian Andres Klode2017-10-223-1/+13
| | | | | | | | The previous change moved running the proxy detection program from the method to the main process, so it runs as root and not as _apt. This brings it back into the sandbox. Gbp-Dch: ignore
* Run Proxy-Auto-Detect script from main processJulian Andres Klode2017-10-223-6/+38
| | | | | | | This avoids running the Proxy-Auto-Detect script inside the untrusted (well, less trusted for now) sandbox. This will allow us to restrict the http method from fork()ing or exec()ing via seccomp.
* Fix testsuite for and add new fields from dpkg 1.19Julian Andres Klode2017-10-202-4/+7
| | | | | | | | | | | tagfile-order.c: Add missing fields from dpkg 1.19 For binary packages, this is Build-Essential; for source packages, it is Description. test-bug-718329-...: Ignore control.tar.*, changes in dpkg 1.19 test-apt-extracttemplates: Fix for dpkg 1.19
* send the hashes for alternative file correctlyDavid Kalnischkies2017-10-051-4/+4
| | | | | | | | | This isn't really used by the acquire system at all at the moment and the only method potentially sending this information is file://, but that used to be working correctly before broken in 2013, so better fix it now and worry about maybe using the data some day later. Regression-Of: b3501edb7091ca3aa6c2d6d96dc667b8161dd2b9
* use pkgTagSection::Key in srcRecords parserDavid Kalnischkies2017-09-261-32/+34
| | | | | | | | | Using hardcoded array-indexes in the build-dependency parsing is efficient, but less discoverable and easier to break. We can avoid this by making it even more efficient (not that it would be noticeable) allowing us to do explicitly named comparisons instead. Gbp-Dch: Ignore
* allow empty build-dependency fields in the parserDavid Kalnischkies2017-09-261-1/+4
| | | | | | | | | | | APT used to parse only wellformed files produced by repository creation tools which removed empty files as pointless before apt would see them. Now that apt can be told to parse e.g. debian/control files directly, it needs to be a little more accepting through: We had this with comments already, now let it deal with the far more trivial empty fields. Closes: #875363
* Fix translator comment location for legacy target warningJulian Andres Klode2017-09-131-3/+5
| | | | | In commit Do not warn about duplicate "legacy" targets, we we added an if, that changed the .po files...
* CMake: Properly handle Udev missingJulian Andres Klode2017-09-101-2/+2
| | | | | | | When udev is not available, the variables for libraries and include paths are set to NOTFOUND rather than an empty string and CMake exits with an error. Use a generator expression to only use these variables when UDEV_FOUND is true.
* Directly link against libudev on Linux systemsJulian Andres Klode2017-09-093-52/+28
| | | | | | | | | | | | | | | | | | | We previously dlopen()ed it, but it seems painful to do that without any real gain, except for possibly not having libudev in the address space and not having code #ifdefed for Linux. The latter means that we are a bit more likely to break stuff for non-Linux systems now if we play with udev, but at least we don't end up with it silently breaking because of a libudev ABI break. The existing function pointers in the struct were renamed and kept for compat purposes. Fixes Debian/apt#48 Also adjust prepare-release to strip [linux-any] from build-depends for travis.
* cdrom: Don't hardcode "Files" field for copying source filesJulian Andres Klode2017-09-091-1/+15
| | | | | | This fails if no Files field exists anymore, for example, because the Sources index only contains SHA256 hashes. Instead check all hashes.
* Do not warn about duplicate "legacy" targetsJulian Andres Klode2017-09-091-2/+3
| | | | | | | | | | If a source has a legacy Contents file, and two lines mention the same archive but different components, a warning would be issued that is confusing. So, as the field is named Contents-deb-legacy, let's just not print warnings for fields containing "legacy". LP: #1697120 Closes: #839259
* drop unused/unimplemented & hidden LoadReleaseInfoDavid Kalnischkies2017-09-093-13/+0
| | | | | | | | | | | The relevant calling code as well as the implementation for the deb system was removed 2 years ago with the refactoring of release information storage (b07aeb1a6e24825e534167a737043441e871de9f). This commit removes the the unused remains of this change with no practical effect on anybody (expect codesize) as the methods were declared as hidden and hence only libapt could have called it. Gbp-Dch: Ignore
* don't ask an uninit _system for supported archsDavid Kalnischkies2017-09-091-1/+1
| | | | | | | | | | A libapt user who hasn't initialized _system likely has a reason, so we shouldn't greet back with a segfault usually deep down in the callstack for no reason. If the user had intended to pick up information from the system, _system wouldn't be uninitialized after all. LP: #1613184 SRU: 1.4.y
* don't write & chmod /dev/null log filesDavid Kalnischkies2017-09-091-8/+8
| | | | | | | | | APT by default logs terminal (term.log) and actions (history.log), but if either or Dir::Log directly is set to /dev/null it continues to do so, which isn't too bad – just wasted effort – but term.log is chmodded to protect it from the general public (as it may contain otherwise private data the admin entired in the terminal) which shouldn't happen for /dev/null.
* Replace APT_CONST with APT_PURE everywhereJulian Andres Klode2017-08-2419-66/+66
| | | | | As a follow up to the last commit, let's replace APT_CONST with APT_PURE everywhere to clean stuff up.
* Redefine APT_CONST to mean APT_PUREJulian Andres Klode2017-08-241-1/+2
| | | | | | | | | | | | | | | | | | | | | Functions marked with the const attribute may not inspect any global memory. This includes targets of pointers or references passed as arguments. A pure function however is free to inspect memory, but may not have any side effects. The function StringSplit() was marked as const, but took two references to strings. When the second one was passed as a literal as in StringSplit(name, "::") the compiler cleverly figured out that we only inspect the address of "::" (since StringSplit is const) and thus optimized away the "::" content. While patching out individual broken uses of APT_CONST would be possible, this is already the second case, and there might be more, so let's redefine APT_CONST to use the pure attribute, so we don't end up with the same situation again in some time.
* don't hang if multiple sources use unavailable methodDavid Kalnischkies2017-08-041-3/+6
| | | | | | | | | | | | | | | APT clients always noticed if a method isn't supported and nowadays generate a message of the form: E: The method driver …/foobar could not be found. N: Is the package apt-transport-foobar installed? This only worked if a single source was using such an unavailable method through as we were registering the failed config the first round and the second would try to send requests to the not started method, which wouldn't work and hang instead (+ hiding the error messages as they would be shown only at the end of the execution). Closes: 870675
* don't keep configuration files open needlesslyDavid Kalnischkies2017-08-041-1/+1
| | | | Regression-Of: 3317ad864c997f4897756c0a2989c4199e9cda62
* allow the auth.conf to be root:root ownedDavid Kalnischkies2017-07-261-15/+0
| | | | | | | | | | | Opening the file before we drop privileges in the methods allows us to avoid chowning in the acquire main process which can apply to the wrong file (imagine Binary scoped settings) and surprises users as their permission setup is overridden. There are no security benefits as the file is open, so an evil method could as before read the contents of the file, but it isn't worse than before and we avoid permission problems in this setup.
* reimplement and document auth.confDavid Kalnischkies2017-07-262-187/+116
| | | | | | | | | | | | | | | | | | We have support for an netrc-like auth.conf file since 0.7.25 (closing 518473), but it was never documented in apt that it even exists and netrc seems to have fallen out of usage as a manpage for it no longer exists making the feature even more arcane. On top of that the code was a bit of a mess (as it is written in c-style) and as a result the matching of machine tokens to URIs also a bit strange by checking for less specific matches (= without path) first. We now do a single pass over the stanzas. In practice early adopters of the undocumented implementation will not really notice the differences and the 'new' behaviour is simpler to document and more usual for an apt user. Closes: #811181
* show warnings instead of errors if files are unreadableDavid Kalnischkies2017-07-267-49/+44
| | | | | | | | | | We used to fail on unreadable config/preferences/sources files, but at least for sources we didn't in the past and it seems harsh to refuse to work because of a single file, especially as the error messages are inconsistent and end up being silly (like suggesting to run apt update to fix the problem…). LP: #1701852
* use FileFd to parse all apt configuration filesDavid Kalnischkies2017-07-265-28/+69
| | | | | | Using different ways of opening files means we have different behaviour and error messages for them, so by the same for all we can have more uniformity for users and apt developers alike.
* send weak-only hashes to methodsDavid Kalnischkies2017-07-261-15/+8
| | | | | | | | | | Weak hashes like filesize can be used by methods for basic checks and early refusals even if we can't use them for hard security proposes. Normal apt operations are not affected by this as they fail if no strong hash is available, but if apt is forced to work with weak-only files or e.g. in apt-helper context it can have benefits as weak is better than no hash for the methods.
* don't move failed pdiff indexes out of partialDavid Kalnischkies2017-07-261-4/+1
| | | | | | | | | | | | | | | | | | | | | The comment says this is intended, but looking at the history reveals that the comment comes from a different era. Nowadays we don't really need it anymore (and even back then it was disputeable) as we haven't used that file for our update in the end and nothing really needs this file after the update. Triggered is this by 188f297a2af4c15cb1d502360d1e478644b5b810 which moves various error conditions forward including this code expecting the file to exist – but it doesn't need to as download could have failed. We could fix that by simple checking if the file exists and only stage it if it does, but instead we don't stage it and instead even rename it out of the way with our conventional FAILED name (if it exists). That restores support for partial mirrors (= in this case mirrors which don't ship pdiff files). Note that apt heals itself even if only such a mirror is used as the update is successful even if that error is shown. Closes: 869425
* don't try to rename failed pdiff patches twiceDavid Kalnischkies2017-07-261-2/+0
| | | | | | | | RenameOnError does the rename already, so the check for existence will always fail making this some completely harmles but also completely pointless two lines of code we are better of removing. Gbp-Dch: Ignore
* support compressed extended_states file for bug triageDavid Kalnischkies2017-07-261-4/+4
| | | | | | This file isn't compressed by default, but it might be compressed by a bugreporter and uncompressing it is extra work apt could do just as well on the fly as needed just like it does for the dpkg/status file.
* Fix memory leak in C++-thread-local _error implementationJulian Andres Klode2017-07-201-2/+2
| | | | | | | We can't allocate a pointer here, it would not get released - use an object instead. Gbp-Dch: ignore
* Use C++11 threading support instead of pthreadJulian Andres Klode2017-07-201-25/+3
| | | | This makes the code easier to read.
* Merge pull request Debian/apt#44 from willismonroe/patch-1Julian Andres Klode2017-07-171-1/+1
|\ | | | | | | | | | | Minor grammar fix [jak@d.o: Fixed up po/]
| * Minor grammar fixM. Willis Monroe2017-06-221-1/+1
| | | | | | Modified the wording of an error message when a repository no longer has a release file.
* | cacheiterators: Warn about direct include and don't include pkgcache.hJulian Andres Klode2017-07-122-2/+5
| | | | | | | | | | | | This adds a warning so existing working code will still work (as it includes pkgcache.h first anyway), but it will know that it's not right to include this file directly.
* | Reformat and sort all includes with clang-formatJulian Andres Klode2017-07-12107-519/+514
| | | | | | | | | | | | | | | | | | | | | | | | | | This makes it easier to see which headers includes what. The changes were done by running git grep -l '#\s*include' \ | grep -E '.(cc|h)$' \ | xargs sed -i -E 's/(^\s*)#(\s*)include/\1#\2 include/' To modify all include lines by adding a space, and then running ./git-clang-format.sh.
* | Drop cacheiterators.h includeJulian Andres Klode2017-07-1240-40/+0
| | | | | | | | | | Including cacheiterators.h before pkgcache.h fails because pkgcache.h depends on cacheiterators.h.
* | Handle supported components with slashes in sources.listApollon Oikonomopoulos2017-07-121-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit d7c92411dc1f4c6be098d1425f9c1c075e0c2154 parses the Components section of (In)Release and attempts to detect the distribution's supported components. While doing so, it handles component names with slashes in a special manner, assuming that the actual component is only the part after the final slash. This is done to handle security.debian.org, which usually appears in sources.list as follows: deb http://s.d.o/debian-security stretch/updates main contrib non-free while the actual release file has: Codename: stretch Components: updates/main updates/contrib updates/non-free While this special handing on APTs part indeed works for debian-security, it emits spurious warnings on repositories that actually use slashes in the component names *and* appear so in sources.list. We fix this by adding both component versions (whole and final part) to the SupportedComponents array. Closes: #868127
* | fix various typos reported by codespell & spellintianDavid Kalnischkies2017-07-082-2/+2
| | | | | | | | | | Reported-By: codespell & spellintian Gbp-Dch: Ignore
* | don't expect more downloads from failed transactionsDavid Kalnischkies2017-07-071-0/+2
| | | | | | | | | | | | | | Progress only shows if we have an idea of how much files we will acquire, but if a transaction fails before we have got an idea we ended up never showing progress even through we know that a failed transaction will not download additional files.
* | Allow http(s) and socks5h for http and https in proxy auto detectJulian Andres Klode2017-06-301-1/+16
| | | | | | | | This makes it possible to write sensible auto detect scripts.
* | Strip 0: epochs from the version hashJulian Andres Klode2017-06-281-0/+5
| | | | | | | | | | | | | | This should fix some issues with dpkg normalizing such values. Suprisingly enough apt treats the Version: field the same, even with epoch vs without, but not when searching, and does not strip the 0: from the output.
* | allow frontends to override releaseinfo change behaviourDavid Kalnischkies2017-06-283-30/+105
| | | | | | | | | | | | | | | | Having messages being printed on the error stack and confirm them by commandline flags is an okayish first step, but some frontends will probably want to have a more interactive feeling here with a proper question the user can just press yes/no for as for some frontends a commandline flag makes no sense…
* | show a Release-Notes URI if infos were changedDavid Kalnischkies2017-06-284-0/+17
| | | | | | | | | | | | | | | | This gives the repository owner a chance to explain why this change was needed – e.g. explaining the organisational changes or simply detailing the changes in the new release made. Note that this URI is also shown if the change is accepted, so it also draws attention to release notes of minor updates (if users watch apt output closely).
* | error in update on Release information changesDavid Kalnischkies2017-06-284-9/+115
| | | | | | | | | | | | | | | | | | | | | | The value of Origin, Label, Codename and co can be used in user configuration from apts own pinning to unattended upgrades. A repository changing this values can therefore have serious effects on the behaviour of apt and other tools using these values. In a first step we will generate error messages for these changes now explaining the need for explicit confirmation and provide config options and commandline flags to accept them.