summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Set DPKG_FRONTEND_LOCKED when running {pre,post}-invoke scriptsJulian Andres Klode2018-10-051-0/+80
| | | | | | | | | Some post-invoke scripts install packages, which fails because the environment variable is not set. This sets the variable for all three kinds of scripts {pre,post-}invoke and pre-install-pkgs, but we will only allow post-invoke at a later time. Gbp-Dch: full
* Deal with descriptions embedded in displayed record correctlyDavid Kalnischkies2018-09-201-2/+68
| | | | | | | | | | | | | | | The implementation of "apt-cache show" (not "apt show") incorrectly resets the currently used parser if the record itself and the description to show come from the same file (as it is the case if no Translation-* files are available e.g. after debootstrap). The code is more complex than you would hope to support some rather unusual setups involving Descriptions and their translations as tested for by ./test-bug-712435-missing-descriptions as otherwise this could be a one-line change. Regression-Of: bf53f39c9a0221b670ffff74053ed36fc502d5a0 Closes: #909155
* Merge branch 'bugfix/statusfd' into 'master'Julian Andres Klode2018-09-184-57/+78
|\ | | | | | | | | Process all of --status-fd and don't expect duplicate status msg See merge request apt-team/apt!26
| * Reorder progress report messagesDavid Kalnischkies2018-09-112-22/+22
| | | | | | | | | | | | | | | | | | | | We are seeing 'processing' messages from dpkg first, so it makes sense to translate them to "Preparing" messages instead of using "Installing" and co to override these shortly after with the "Preparing" messages. The difference isn't all to visible as later messages tend to linger far longer in the display than the ealier ones, but at least in a listing it seems more logical.
| * Don't expect duplicated dpkg status-fd messagesDavid Kalnischkies2018-09-114-50/+71
| | | | | | | | | | | | | | | | | | | | | | The progress reporting relies on parsing the status reports of dpkg which used to repeat being in the same state multiple times in the same run, but by fixing #365921 it will stop doing so. The problem is in theory just with 'config-files' in case we do purge as this (can) do remove + purge in one step, but we remove this also for the unpack + configure combination althrough we handle these currently in two independent dpkg calls.
* | Show all architectures in 'apt list' outputDavid Kalnischkies2018-09-151-4/+23
|/ | | | | | | | | The uniqueness in std::set containers is ensured by the ordering operator we provide, but it was not considering that different versions can have the same description like the different architectures for a version of a package. Closes: #908218
* Unset more environment variables in test frameworkDavid Kalnischkies2018-09-111-2/+5
| | | | | | | | | It is an uphill battle to "reset" the environment to a clean state without making it needlessly hard to use 'good' environment variables, so we just try a little harder here without really trying for completeness. Gbp-Dch: Ignore
* Don't use gpg directly in apt-key testDavid Kalnischkies2018-09-101-1/+1
| | | | | Reported-By: Guillem Jover <guillem@debian.org> Gbp-Dch: Ignore
* Fix typos reported by codespell & spellintianDavid Kalnischkies2018-08-291-1/+1
| | | | | | | | No user-visible change as it effects mostly code comments and not a single error message, manpage or similar. Reported-By: codespell & spellintian Gbp-Dch: Ignore
* Don't use invalid iterator in Fallback-Of handlingDavid Kalnischkies2018-08-292-2/+23
| | | | | | | | | | | | | cppcheck reports: (error) Iterator 't' used after element has been erased. The loop is actually fashioned to deal with this (not in the most efficient way, but in simplest and speed isn't really a concern here) IF this codepath had a "break" at the end… so I added one. Note that the tests aren't failing before (and hopefully after) the change as the undefined behavior we encounter is too stable. Thanks: David Binderman for reporting
* clear alternative URIs for mirror:// between steps (CVE-2018-0501)David Kalnischkies2018-08-202-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | APT in 1.6 saw me rewriting the mirror:// transport method, which works comparable to the decommissioned httpredir.d.o "just" that apt requests a mirror list and performs all the redirections internally with all the bells like parallel download and automatic fallback (more details in the apt-transport-mirror manpage included in the 1.6 release). The automatic fallback is the problem here: The intend is that if a file fails to be downloaded (e.g. because the mirror is offline, broken, out-of-sync, …) instead of erroring out the next mirror in the list is contacted for a retry of the download. Internally the acquire process of an InRelease file (works with the Release/Release.gpg pair, too) happens in steps: 1) download file and 2) verify file, both handled as URL requests passed around. Due to an oversight the fallbacks for the first step are still active for the second step, so that the successful download from another mirror stands in for the failed verification… *facepalm* Note that the attacker can not judge by the request arriving for the InRelease file if the user is using the mirror method or not. If entire traffic is observed Eve might be able to observe the request for a mirror list, but that might or might not be telling if following requests for InRelease files will be based on that list or for another sources.list entry not using mirror (Users have also the option to have the mirror list locally (via e.g. mirror+file://) instead of on a remote host). If the user isn't using mirror:// for this InRelease file apt will fail very visibly as intended. (The mirror list needs to include at least two mirrors and to work reliably the attacker needs to be able to MITM all mirrors in the list. For remotely accessed mirror lists this is no limitation as the attacker is in full control of the file in that case) Fixed by clearing the alternatives after a step completes (and moving a pimpl class further to the top to make that valid compilable code). mirror:// is at the moment the only method using this code infrastructure (for all others this set is already empty) and the only method-independent user so far is the download of deb files, but those are downloaded and verified in a single step; so there shouldn't be much opportunity for regression here even through a central code area is changed. Upgrade instructions: Given all apt-based frontends are affected, even additional restrictions like signed-by are bypassed and the attack in progress is hardly visible in the progress reporting of an update operation (the InRelease file is marked "Ign", but no fallback to "Release/Release.gpg" is happening) and leaves no trace (expect files downloaded from the attackers repository of course) the best course of action might be to change the sources.list to not use the mirror family of transports ({tor+,…}mirror{,+{http{,s},file,…}}) until a fixed version of the src:apt packages are installed. Regression-Of: 355e1aceac1dd05c4c7daf3420b09bd860fd169d, 57fa854e4cdb060e87ca265abd5a83364f9fa681 LP: #1787752
* Report (soon) worthless keys if gpg uses fpr for GOODSIGDavid Kalnischkies2018-08-191-0/+25
| | | | | | | | | | gpgs DETAILS documentation file declares that GOODSIG could report keyid or fingerprint since gpg2, but for the time being it is still keyid only. Who knows if that will ever change as that feels like an interface break with dangerous security implications, but lets be better safe than sorry especially as the code dealing with signed-by keyids is prepared for this already. This code is rewritten still to have them all use the same code for this type of problem.
* test: Supports records larger than 32kb in 'apt show'David Kalnischkies2018-08-191-0/+33
| | | | | | | | | | The 1.7 series rework of show started in bf53f39c9a0221b670ffff74053ed36fc502d5a0 resolved the issue already, but its always a good idea to at least bring the tests along so that we hopeful do not regress in the future with another rewrite. Tests: #905527 Gbp-Dch: Ignore
* aptwebserver: Prefetch compressors to avoid thread crashesDavid Kalnischkies2018-08-191-0/+1
| | | | | | | | | | | | | If multiple threads act on requests (like if connection comes from a webbrowser) a thread might request the supported compressors while another thread is still working on creating the list to be stored in the static cache variable. As the price to pay for atomic and co seems to high for the fringe usecase of manual usage of aptwebserver the patch just makes a call to generate the list while still single threaded. Gbp-Dch: Ignore
* CMake: Use ${PROJECT_NAME} instead of hardcoding aptDavid Kalnischkies2018-08-141-6/+7
| | | | | | | Completely pointless as it makes no difference for apt, but copying the file to other projects becomes a lot easier. Gbp-Dch: Ignore
* Handle JSON hooks that just close the file/exit and fix some other errorsJulian Andres Klode2018-06-271-0/+87
| | | | | | | | | | | | | | JSON hooks might disappear and the common idiom to work around hooks disappearing is to check for the hook in the shell snippet that is in the apt.conf file and if it does not exist, do nothing. This caused APT to fail however, expecting it to acknowledge the handshake. Ignoring ECONNRESET on handshakes solves the problem. The error case, and the other error cases also did not stop execution of the hook, causing more errors to pile up. Fix this by directly going to the closing part of the code. LP: #1776218
* Don't show acquire warning for "hidden" componentsDavid Kalnischkies2018-05-282-8/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit d7c92411dc1f4c6be098d1425f9c1c075e0c2154 introduced a warning for non-existent files from components not mentioned in Components to hint users at a mispelling or the disappearance of a component. The debian-installer subcomponent isn't actively advertised in the Release file through, so if apt ends up in acquiring a file which doesn't exist for this component (like Translation files) apt would produce a warning: W: Skipping acquire of configured file 'main/debian-installer/i18n/Translation-en' as repository 'http://deb.debian.org/debian buster InRelease' doesn't have the component 'main/debian-installer' (component misspelt in sources.list?) We prevent this in the future by checking if any file exists from this component which results in the warning to be produced still for the intended cases and silence it on the d-i case. This could potentially cause the warning not to be produced in cases it should be if some marginal file remains, but as this message is just a hint and the setup a bit pathological lets ignore it for now. There is also the possibility of having no file present as they would all be 0-length files and being a "hidden" component, but that would be easy to workaround from the repository side and isn't really actively used at the moment in the wild. Closes: #879591
* tests: Prevent stunnel4 from binding on IPv6David Kalnischkies2018-05-281-1/+1
| | | | | | | | Hardcoding the IPv4 address 127.0.0.1 stops stunnel4 from also binding on IPv6 as well which not only binds on another port but confuses our crude port extraction by splitting on ':' with ::1. Gbp-Dch: Ignore
* Merge branch 'feature/morevolatilesupport' into 'master'Julian Andres Klode2018-05-243-6/+204
|\ | | | | | | | | more volatile: build-dep foo.deb/release & show foo.deb See merge request apt-team/apt!14
| * Support local files as arguments in show commandDavid Kalnischkies2018-05-111-5/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | Now that --with-source is supported in show we can go a little further and add the "syntactic sugar" of supporting deb-files on the commandline directly to give users an alternative to remembering dpkg -I for deb files & as a bonus apt also works on changes files. Most of the code churn is actually to deal with cases probably not too common in reality like mixing packages and deb-files on the commandline and getting the right order for these multiple records. Closes: 883206
| * Support --with-source in show & search commandsDavid Kalnischkies2018-05-111-6/+30
| |
| * Support release selector for volatile files as wellDavid Kalnischkies2018-05-111-0/+94
| | | | | | | | | | | | | | | | | | | | The syntax is a bit awkward, but it is the same as for a package name and introducing another syntax wouldn't really help usability, so with apt install ./foo.deb/experimental you will get the dependencies of foo satisfied by your default release, but if this wouldn't satisfy the version requirements the candidate for this dependency is switched to the version from the experimental release. The same applies for apt build-dep ./foo.dsc/stable-backports which was the initial request.
| * Extend apt build-dep pkg/release to switch dep as neededDavid Kalnischkies2018-05-111-0/+59
| | | | | | | | | | | | apt install pkg/release follows versioned dependencies in the candidate switching if the current candidate does not satisfy the dependency, so for uniformity the same should be supported in build-dep.
* | Merge branch 'feature/byhashviaalturl' into 'master'Julian Andres Klode2018-05-242-2/+5
|\ \ | | | | | | | | | | | | Don't force the same mirror for by-hash URIs See merge request apt-team/apt!15
| * | Handle by-hash URI construction more centrallyDavid Kalnischkies2018-05-111-0/+2
| | | | | | | | | | | | | | | | | | | | | Individual items shouldn't concern themselves with these alternative locations, we can deal with this more efficiently within the infrastructure created for other alternative URIs now avoiding the need to implement this in each item.
| * | Drop alternative URIs we got a hash-based fail fromDavid Kalnischkies2018-05-112-2/+3
| |/ | | | | | | | | | | | | | | | | | | | | If we got a file but it produced a hash error, mismatched size or similar we shouldn't fallback to alternative URIs as they likely result in the same error. If we can we should instead use another mirror. We used to be a lot stricter by stopping all trys for this file if we got a non-404 (or a hash-based) failure, but that is too hard as we really want to try other mirrors (if we have them) in the hope that they have the expected and correct files.
* | Extend test-apt-get-autoremove to check debug outputFilipe Brandenburger2018-05-211-0/+25
| | | | | | | | | | | | | | | | Run `apt-get autoremove -o Debug::pkgAutoRemove=yes` and confirm the logged reason for packages to be kept is correct. Only check for specific debug lines containing 'MarkPackage:' in order to prevent new debug logging to break the test case.
* | Fix hidden test failure if not called via sudoDavid Kalnischkies2018-05-192-2/+2
| | | | | | | | | | | | | | | | id: '': no such user ./test-bug-611729-mark-as-manual: 59: [: Illegal number: Regression-of: 68842e1741a5005b1e3f0a07deffd737c65e3294 Gbp-Dch: Ignore
* | tests: Do not expect requested-by if sudo was invoked by rootJulian Andres Klode2018-05-162-2/+2
|/ | | | | If sudo was invoked by root, SUDO_UID will be 0, and apt will not print a Requested-By line.
* Fix various typos reported by spellcheckersDavid Kalnischkies2018-05-054-7/+8
| | | | | Reported-By: codespell & spellintian Gbp-Dch: Ignore
* Prevent GTest from flooding us with compiler warningsDavid Kalnischkies2018-05-0420-187/+193
| | | | | | | | | | | | | | GTest has a bunch of undefined macros which causes the compiler to spit out warnings for each one on each test file. There isn't much we can do, so we just disable the warning for the testcases. Other warnings like sign-promo and sign-compare we can avoid by being more explicit about our expected integer constants being unsigned. As we are just changing testcases, there is no user visible change which would deserve to be noted in the changelog. Gbp-Dch: Ignore Reported-By: gcc-8
* Fix build with new gtestJulian Andres Klode2018-05-041-1/+1
| | | | | | Still allow the older one to be used. Closes: #897149
* Merge branch 'pu/heavy-hooks' into 'master'Julian Andres Klode2018-04-151-0/+122
|\ | | | | | | | | json-based hooks for apt cli tools See merge request apt-team/apt!10
| * Introduce experimental new hooks for command-line toolsJulian Andres Klode2018-04-151-0/+122
| | | | | | | | | | | | | | | | | | This allows third-party package managers like snap or flatpak to hook in and suggest alternatives if packages could not be found, for example. This is still highly experimental and the protocol might change in future versions.
* | Merge branch 'pu/zstd' into 'master'Julian Andres Klode2018-04-152-2/+4
|\ \ | |/ |/| | | | | pu/zstd See merge request apt-team/apt!8
| * apt-pkg: Add support for zstdJulian Andres Klode2018-03-122-2/+4
| | | | | | | | | | | | | | zstd is a compression algorithm developed by facebook. At level 19, it is about 6% worse in size than xz -6, but decompression is multiple times faster, saving about 40% install time, especially with eatmydata on cloud instances.
* | test: export GCOV_ERROR_FILE=/dev/null to make it fail less/no testsJulian Andres Klode2018-04-061-0/+3
| |
* | Use https for Ubuntu changelogsJulian Andres Klode2018-03-151-4/+4
|/ | | | We just enabled https on changelogs.ubuntu.com, let's use it.
* Merge branch 'pu/not-valid-before' into 'master'Julian Andres Klode2018-02-192-0/+48
|\ | | | | | | | | Check that Date of Release file is not in the future See merge request apt-team/apt!3
| * Check that Date of Release file is not in the futureJulian Andres Klode2018-02-192-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | By restricting the Date field to be in the past, an attacker cannot just create a repository from the future that would be accepted as a valid update for a repository. This check can be disabled by Acquire::Check-Date set to false. This will also disable Check-Valid-Until and any future date related checking, if any - the option means: "my computers date cannot be trusted." Modify the tests to allow repositories to be up to 10 hours in the future, so we can keep using hours there to simulate time changes.
* | ensure correct file permissions for auxfilesDavid Kalnischkies2018-02-191-6/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The interesting takeaway here is perhaps that 'chmod +w' is effected by the umask – obvious in hindsight of course. The usual setup helps with hiding that applying that recursively on all directories (and files) isn't correct. Ensuring files will not be stored with the wrong permissions even if in strange umask contexts is trivial in comparison. Fixing the test also highlighted that it wasn't bulletproof as apt will automatically fix the permissions of the directories it works with, so for this test we actually need to introduce a shortcut in the code. Reported-By: Ubuntu autopkgtest CI
* | tests: set debhelper compat 10 and R³ by defaultDavid Kalnischkies2018-02-191-2/+3
| | | | | | | | | | | | | | | | | | The testpackages hardly need debhelper at all, so any version would do, and they build without root rights by definition, but declaring it explicitly can't hurt and in the case of debhelper it would be sad if our testcases break one day because the old compat level is removed. Gbp-Dch: Ignore
* | add apt-helper drop-privs command…David Kalnischkies2018-02-191-0/+7
| |
* | Work around test-method-mirror failure by setting umask at startJulian Andres Klode2018-02-191-0/+2
|/ | | | This fixes a test failure on autopkgtest.
* allow the apt/lists/auxfiles/ directory to be missingDavid Kalnischkies2018-01-192-4/+40
| | | | | | | | | | apt 1.6~alpha6 introduced aux requests to revamp the implementation of a-t-mirror. This already included the potential of running as non-root, but the detection wasn't complete resulting in errors or could produce spurious warnings along the way if the directory didn't exist yet. References: ef9677831f62a1554a888ebc7b162517d7881116 Closes: 887624
* Introduce inrelease-path option for sources.listJulian Andres Klode2018-01-171-0/+28
| | | | | | | | | | | | | | Allow specifying an alternative path to the InRelease file, so you can have multiple versions of a repository, for example. Enabling this option disables fallback to Release and Release.gpg, so setting it to InRelease can be used to ensure that only that will be tried. We add two test cases: One for checking that it works, and another for checking that the fallback does not happen. Closes: #886745
* add a testcase for the mirror methodDavid Kalnischkies2018-01-031-0/+190
| | | | Gbp-Dch: Ignore
* allow a method to request auxiliary filesDavid Kalnischkies2018-01-033-2/+6
| | | | | | | | | | | | | | | | | | | | If a method needs a file to operate like e.g. mirror needs to get a list of mirrors before it can redirect the the actual requests to them. That could easily be solved by moving the logic into libapt directly, but by allowing a method to request other methods to do something we can keep this logic contained in the method and allow e.g. also methods which perform binary patching or similar things. Previously they would need to implement their own acquire system inside the existing one which in all likelyhood will not support the same features and methods nor operate with similar security compared to what we have already running 'above' the requesting method. That said, to avoid methods producing conflicts with "proper" files we are downloading a new directory is introduced to keep the auxiliary files in. [The message magic number 351 is a tribute to the german Grundgesetz article 35 paragraph 1 which defines that all authorities of the state(s) help each other on request.]
* refactor message generation for methodsDavid Kalnischkies2018-01-031-1/+1
| | | | | | The format isn't too hard to get right, but it gets funny with multiline fields (which we don't really have yet) and its just easier to deal with it once and for all which can be reused for more messages later.
* Support cleartext signed InRelease files with CRLF line endingsDavid Kalnischkies2018-01-021-10/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 89c4c588b275 ("fix from David Kalnischkies for the InRelease gpg verification code (LP: #784473)") amended verification of cleartext signatures by a check whether the file to be verified actually starts with "-----BEGIN PGP SIGNATURE-----\n". However cleartext signed InRelease files have been found in the wild which use \r\n as line ending for this armor header line, presumably generated by a Windows PGP client. Such files are incorrectly deemed unsigned and result in the following (misleading) error: Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?) RFC 4880 specifies in 6.2 Forming ASCII Armor: That is to say, there is always a line ending preceding the starting five dashes, and following the ending five dashes. The header lines, therefore, MUST start at the beginning of a line, and MUST NOT have text other than whitespace following them on the same line. RFC 4880 does not seem to specify whether LF or CRLF is used as line ending for armor headers, but CR is generally considered whitespace (e.g. "man perlrecharclass"), hence using CRLF is legal even under the assumption that LF must be used. SplitClearSignedFile() is stripping whitespace (including CR) on lineend already before matching the string, so StartsWithGPGClearTextSignature() is adapted to use the same ignoring. As the earlier method is responsible for what apt will end up actually parsing nowadays as signed/unsigned this change has no implications for security. Thanks: Lukas Wunner for detailed report & initial patch! References: 89c4c588b275d098af33f36eeddea6fd75068342 Closes: 884922