summaryrefslogtreecommitdiff
path: root/tests/pull-test.sh
Commit message (Collapse)AuthorAgeFilesLines
* Update FSF license notices to use URL instead of addressJoseph Marrero2021-12-071-3/+1
|
* tests/pull-test: Avoid duplicating test numbersColin Walters2021-09-101-3/+4
| | | | | We do this in other places; avoids touching two numbers when adding tests. Let computers do the addition.
* Add support for "custom remotes"Colin Walters2021-09-081-2/+29
| | | | | | | | | | This will be helpful for the "ostree native container" work in https://github.com/ostreedev/ostree-rs-ext/ Basically in order to reuse GPG/signapi verification, we need to support adding a remote, even though it can't be used via `ostree pull`. (At least, not until we merge ostree-rs-ext into ostree, but even then I think the principle stands)
* pull: Cleanly error out on unknown schemesColin Walters2021-04-271-2/+10
| | | | | | | | Previous to this we'd trip an assertion `abort()` deep in the curl code if e.g. a user did `ostree remote add foo htttp://...` etc. Motivated by considering supporting "external remotes" where code outside ostree does a pull, but we want to reuse the signing verification infrastructure.
* tests/pull-test: Use mv -f in a few casesColin Walters2021-03-311-3/+3
| | | | | For some reason I'm hitting this locally because some files are mode `0`. Which is clearly a different bug but anyways we don't want to prompt.
* tests: Add a testcase to ensure we're not using the summary if we don't need itAlexander Larsson2020-10-231-2/+21
| | | | | With deltas outside the summary, if a commit is specified when pulling we don't download the summary. Verify this.
* Merge pull request #2152 from cgwalters/pull-fdatasyncOpenShift Merge Robot2020-07-201-2/+12
|\ | | | | pull: Add --per-object-fsync
| * pull: Add --per-object-fsyncColin Walters2020-07-181-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | This is the opposite of https://github.com/ostreedev/ostree/issues/1184 Motivated by OpenShift seeing etcd performance issues during OS updates: https://github.com/openshift/machine-config-operator/issues/1897 Basically, if we switch to invoking `fsync()` as we go, it makes ostree performance worse (in my tests, 31s to write 2G versus 7s if we delay sync) but it avoids *huge* outliers in `fsync()` time for etcd.
* | pull: Also append bytes writtenColin Walters2020-07-171-1/+1
|/ | | | | | This is very useful information that we get from the transaction stats. Append it to the final display if we're not inheriting the transaction.
* lib/pull: Add `timestamp-check-from-rev`Jonathan Lebon2020-05-141-1/+23
| | | | | | | | | | | The way `timestamp-check` works might be too restrictive in some situations. Essentially, we need to support the case where users want to pull an older commit than the current tip, but while still guaranteeing that it is newer than some even older commit. This will be used in Fedora CoreOS. For more information see: https://github.com/coreos/rpm-ostree/pull/2094 https://github.com/coreos/fedora-coreos-tracker/issues/481
* tests: use option "--no-sign-verify" for adding remoteDenis Pynkin2020-03-251-16/+16
| | | | | | | Option "--no-sign-verify" disable the signature verification including GPG. So use it in tests instead of "--no-gpg-verification". Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
* tests: Handle EPIPE failures when head terminatesAlex Kiernan2019-11-011-1/+1
| | | | | | | | When using musl, it appears that the default is line buffered output, so when `head -1` reads from a pipe we have to handle the source end of the pipe getting EPIPE. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
* tests/gpg: fix GPG-dependent shell tests if no GPG supportDenis Pynkin2019-08-011-29/+38
| | | | | | | | | | Skip tests or run them without GPG-related functionality if GPGME wasn't enabled in a build time. Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com> Closes: #1889 Approved by: cgwalters
* lib/pull: Allow downgrade protection with overridesJonathan Lebon2019-07-291-0/+6
| | | | | | | | | | | There's a valid use case for enabling the timestamp downgrade check while still also using override commits. We'll make use of this in Fedora CoreOS, where the agent specifies the exact commit to upgrade to, while still enforcing that it be newer. Closes: #1891 Approved by: cgwalters
* tests: Update for glib 2.59.2Jeremy Bicha2019-02-111-1/+1
| | | | | | | | | | | glib 2.59.2 uses a non-breaking space instead of a space to separate the quantity and unit in g_format_size() so update our test to handle both a plain space and a non-breaking space. See https://gitlab.gnome.org/GNOME/glib/issues/1625 Closes: #1818 Approved by: cgwalters
* Add SPDX-License-Identifier to source filesMarcus Folkesson2018-01-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | SPDX License List is a list of (common) open source licenses that can be referred to by a “short identifier”. It has several advantages compared to the common "license header texts" usually found in source files. Some of the advantages: * It is precise; there is no ambiguity due to variations in license header text * It is language neutral * It is easy to machine process * It is concise * It is simple and can be used without much cost in interpreted environments like java Script, etc. * An SPDX license identifier is immutable. * It provides simple guidance for developers who want to make sure the license for their code is respected See http://spdx.org for further reading. Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com> Closes: #1439 Approved by: cgwalters
* lib: Validate metadata structure more consistently during pullColin Walters2018-01-121-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we were doing e.g. `ot_util_filename_validate()` specifically inline in dirtree objects, but only *after* writing them into the staging directory (by default). In (non-default) cases such as not using a transaction, such an object could be written directly into the repo. A notable gap here is that `pull-local --untrusted` was *not* doing this verification, just checksums. We harden that (and also the static delta writing path, really *everything* that calls `ostree_repo_write_metadata()` to also do "structure" validation which includes path traversal checks. Basically, let's try hard to avoid having badly structured objects even in the repo. One thing that sucks in this patch is that we need to allocate a "bounce buffer" for metadata in the static delta path, because GVariant imposes alignment requirements, which I screwed up and didn't fulfill when designing deltas. It actually didn't matter before because we weren't parsing them, but now we are. In theory we could check alignment but ...eh, not worth it, at least not until we change the delta compiler to emit aligned metadata which actually may be quite tricky. (Big picture I doubt this really matters much right now but I'm not going to pull out a profiler yet for this) The pull test was extended to check we didn't even write a dirtree with path traversal into the staging directory. There's a bit of code motion in extracting `_ostree_validate_structureof_metadata()` from `fsck_metadata_object()`. Then `_ostree_verify_metadata_object()` builds on that to do checksum verification too. Closes: #1412 Approved by: jlebon
* tests: Add a test case for path traversal in a dirtreeColin Walters2018-01-121-1/+16
| | | | | | | | | | | | | | | | | | | | I was reading about a recent security issue with both EMC and VMWare: https://arstechnica.com/information-technology/2018/01/emc-vmware-security-bugs-throw-gasoline-on-cloud-security-fire/ It's a classic path traversal problem, and that made me think more about our handling of this in libostree. Fortunately of course, not being new to this rodeo, long ago I *did* consider path traversal. Inside the pull code, we call `ot_util_filename_validate()`. Also, `fsck` does this too. I have further followups here, but let's add some test cases for this. I crafted a repository with a `../` in a dirtree object by patching libostree to inject it, and that's included as a tarball. This patch covers the two cases where we do already have checks; pulling via HTTP, and in `fsck`. Closes: #1412 Approved by: jlebon
* Add public API for fsck, use it before loading metadataColin Walters2017-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | A while ago I did `truncate -s 0 /path/to/repo/00/123.commit`, and expected a checksum error, but I actually got a validation error due to us loading the commit into a variant and trying to parse out the parent checksum, etc. I first started by changing the `load_and_fsck_one_object()` function to checksum before loading, but the problem is that we do a traverse of all objects first. Fixing this is going to require an `OSTREE_REPO_COMMIT_TRAVER_FLAG_FSCK` or something. In the meantime at least though, let's add a public API to fsck a single object which *does* checksum cleanly before parsing the object, and change the `fsck` command to use it. We then change the fsck binary to do this while iterating over the refs and finding the commit object. This way we'll at least get a checksum first for commit objects, even if not dirtree/dirmeta. Closes: #1364 Approved by: jlebon
* lib/pull: Avoid error if current with --require-static-deltasColin Walters2017-11-061-0/+6
| | | | | | | | | | | | | | | | | | | | A tricky thing here that caused this to go past a lot of our tests is that the code was mostly OK if there was an available delta from an older commit. But this case broke if we e.g. had a new OS deployment and did a `--require-static-deltas` pull, i.e. the initial state. I cleaned up our "find static delta state" function to return an enumeration, and extended it with an "already have the commit" state. A problem I then hit is that we've historically fetched detached metadata for non-delta pulls, even if the commit hasn't changed. I decided not to do that for `--require-static-deltas` pulls for now; otherwise the code gets notably more complex. Closes: https://github.com/ostreedev/ostree/issues/1321 Closes: #1323 Approved by: jlebon
* lib/pull: When --require-static-deltas, use them even for file:/// reposColin Walters2017-10-311-2/+14
| | | | | | | | | I didn't fully spelunk this, but from what `static-delta-generate-crosscheck.sh` had, we appeared to be doing this before, and it's clearly useful for local testing rather than needing to spin up a HTTP server. Closes: #1313 Approved by: jlebon
* tests: Add test-pull-bareuseronlyColin Walters2017-10-171-23/+46
| | | | | | | | | | | | I was going to fix a bug in the static deltas code and I noticed we were missing `pull-test.sh` coverage for bareuseronly 🙈. Obviously fixing this requires duplicating some of the bits we have in `basic-test.sh`; need to hoist that into `libtest.sh`. For now though let's get the coverage. Closes: #1270 Approved by: jlebon
* lib/pull: Fix regression with pull-local for nonexistent refsColin Walters2017-10-021-1/+9
| | | | | | | | | | | | | | I was reading the pull code for the last release, and spotted a bug in commit f923c2e1eaebe0c781f07d34ae1a03f94357bccd - in the case where the ref doesn't exist, we don't set an error, tripping an assertion in the main code. The previous code wanted the ref to always exist, so just flip back the boolean for "ignore noent". I moved the `g_strchomp()` just into the HTTP path - if a local repo is corrupted in this way it's something to fix in that repo. Closes: #1238 Approved by: pwithnall
* tests: Add 404 tests for dirtree objects tooColin Walters2017-09-281-1/+11
| | | | | | | | | I now believe the flatpak issue we were hitting was https://github.com/ostreedev/ostree/pull/1185 but let's add these tests anyways for more coverage. Closes: #888 Approved by: jlebon
* lib/pull: Add status for imported objectsColin Walters2017-09-271-1/+1
| | | | | | | | | | | | | | | | | | | | | Followup for recent work in commits: - 8a7a35970928331a028ccddd04590ac300dbd26e - 1a9a473580e9066f5d4a969932d703b5b104b2b7 Keep track of how many objects we imported, and print that for `ostree pull-local` (also do this even if noninteractive, like we did for `pull`). In implementing this at first I used separate variables for import from repo vs import from localcache, but that broke some of the tests that checked those values. It's easier to just merge them; we know from looking at whether or not `remote_repo_local` is set whether or not we were doing a "HTTP pull with localcache" versus a true `pull-local` and can use that when rendering status. Closes: #1219 Approved by: jlebon
* src/pull: Support local pulls for collection–refsPhilip Withnall2017-09-271-1/+1
| | | | | | | | | | | | | | | | Previously, collection–refs could only be pulled from a repository if it had a summary file (which listed them). There was no way to pull from a local repository which doesn’t have a summary file, and where the refs were stored as refs/remotes/$remote/$ref, with a config section linking that $remote to the queried collection ID. Fix that by explicitly supporting pull_data->remote_repo_local in fetch_ref_contents(). Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1182 Approved by: cgwalters
* lib/pull: Default checksum for archive mirror, add TRUSTED_HTTP flagColin Walters2017-09-261-2/+59
| | | | | | | | | | | | | | | | | | | | | | I now think commit fab1e113db558cb7d6754e243919558df92d4864 was a mistake; because it breaks the mental model that at least I'd built up that "local repos don't have checksums verified, HTTP does". For example, a problem with this is (with that mental model in place) it's easy for people who set up mirrors like this to then do local pulls, and at that point we've done a deployment with no checksum verification. Further, since then we did PR #671 AKA commit 3d38f03 which is really most of the speed hit. So let's switch the default even for this case to doing checksum verification, and add `ostree pull --http-trusted`. People who are in situations where they know they want this can find it and turn it on. Closes: https://github.com/ostreedev/ostree/issues/1211 Closes: #1212 Approved by: jlebon
* lib: Move bareuseronly verification into commit/coreColin Walters2017-09-211-1/+1
| | | | | | | | | | | | | | | | Conceptually `ostree-repo-pull.c` should be be written using just public APIs; we theoretically support building without HTTP for people who just want to use the object store portion and do their own fetching. We have some nontrivial behaviors in the pull layer though; one of those is the "bareuseronly" verification. Make a new internal API that accepts flags, move it into `commit.c`. This is prep for further work in changing object import to support reflinks. Closes: #1193 Approved by: jlebon
* lib/pull: Add support for timestamp-check option, use in upgraderColin Walters2017-08-211-1/+26
| | | | | | | | | | | | For both flatpak and ostree-as-host, we really want to verify up front during pulls that we're not being downgraded. Currently both flatpak and `OstreeSysrootUpgrader` do this before deployments, but at that point we've already downloaded all the data, which is annoying. Closes: https://github.com/ostreedev/ostree/issues/687 Closes: #1055 Approved by: jlebon
* bin/pull: Fix @ override syntax when pulling multiple refsColin Walters2017-08-071-1/+5
| | | | | | | | | | | Coverity spotted an infloop here since we were incrementing `i++` instead of `j++`. But adding a test revealed other bugs - we need to keep the arrays in sync. Coverity CID: 1452204 Closes: #1041 Approved by: pwithnall
* core: Sanitize error text validating refs (e.g. against HTML)Colin Walters2017-07-191-1/+12
| | | | | | | | | | | | | | | See: https://github.com/projectatomic/rpm-ostree/issues/885 If we get a successful Apache directory listing HTML when fetching what we intend to be a ref, we'd dump the HTML into the error. I did some scanning of the pull code, and this was the only case I saw offhand where we were dumping text out into an error. Which makes sense, since most of our formats are binary, the exeptions I think are just `repo/config` and `repo/refs/`. Closes: #1015 Approved by: mbarnes
* tests: Run pull tests for bare/bare-userColin Walters2017-07-101-1/+1
| | | | | | | | | | | | | We have variants of `test-basic` for all 4 modes, but not for pull-test, which for some reason was named `pull-archive`, but mostly pulls *into* bare repos. The test code was structured like the basic one where it called into a `pull-test.sh`, so let's actually use it for 2/3 bare modes. (I tried to extend it to `bare-user-only` but it failed, going to look at that after this). This is related to https://github.com/ostreedev/ostree/issues/991 Closes: #998 Approved by: jlebon
* pull: Cleanly error when doing local pulls of remote-prefixed refsColin Walters2017-07-051-1/+21
| | | | | | | | | | | | | | | | | | In the storage PR I was trying to do a `pull-local` of the whole `/ostree/repo` on the system, which ended up triggering a `g_critical()` in the collections code, since we tried to parse a remote-prefixed ref `fedora:fedora/26/x86_64/atomic-host` as a ref. I'm not sure offhand what our behavior in this case *should* be. I think git only clones local refs, but I need to check. This corner case arises only with `pull-local`. But in any case, while we were previously saying this is programmer error, since it's so easy to pass various unchecked input into the pull machinery, make invalid refs an explicit error. Closes: #992 Approved by: jlebon
* cmdline/pull: Print final status even if noninteractiveColin Walters2017-06-291-2/+4
| | | | | | | | | | | | | Previously, `ostree pull` was silent if not on a tty. I don't see a reason not to print the final status line at least. This is prep for more work in the test suite, so I can write assertions on the output. But it should also be nicer for people who e.g. do an `ostree pull` in a Jenkins job or whatever. Closes: #981 Approved by: jlebon
* tree-wide: Replace various uses of `archive-z2` → `archive`Colin Walters2017-06-291-5/+5
| | | | | | | | | | | | The `-z2` is annoying now since it's really a legacy; we've long since supported typing `archive`. Convert the docs fully and explain that. Also do some (but not all) of the tests just to encourage newer tests to use `archive` too. Closes: #980 Approved by: jlebon
* pull: When mirroring, only replace summary if we're doing a full mirrorAlexander Larsson2017-06-161-1/+28
| | | | | | | | | | | | We're hitting this in flathub, where we have a bunch of local builds, but we also mirror a few refs from the gnome runtime repo into it. Its fixable by re-doing the summary, but for a short time the wrong version is visible. Fixes https://github.com/ostreedev/ostree/issues/846 Closes: #935 Approved by: cgwalters
* lib/pull: Extend BAREUSERONLY_FILES flag to HTTP requestsColin Walters2017-06-151-7/+29
| | | | | | | | | | | | For the flatpak PR: https://github.com/flatpak/flatpak/pull/849 It's really more convenient if this works for HTTP pulls as well, since flatpak does various types of pulling, and we can just set the flag everywhere. Further, we might as well reject the content as early as possible. Closes: #930 Approved by: alexlarsson
* lib/pull: Add OSTREE_REPO_PULL_FLAGS_BAREUSERONLY_FILESColin Walters2017-06-131-1/+8
| | | | | | | | | | | | | | | This is an option which is intended mostly for flatpak; see: https://github.com/flatpak/flatpak/issues/845 We're adding an option for pulling into *all* repo modes that has an effect similar to the `bare-user-only` change from https://github.com/ostreedev/ostree/pull/909 This way one can pull content into e.g. a root-owned `bare` repository and ensure that there aren't any setuid or world-writable files. Closes: #926 Approved by: alexlarsson
* pull-test: Add some 404 testsColin Walters2017-05-261-1/+18
| | | | | | | See: https://github.com/flatpak/flatpak/issues/816 Closes: #887 Approved by: jlebon
* pull: complete detached meta fetch before scanningJonathan Lebon2017-05-181-11/+35
| | | | | | | | | | | | | | | | | | | | | | If somehow a repo has gpg verification on but doesn't have signatures present for the existing commit, ostree would error out if it needs to scan the commit object (e.g. if there are no updates available). An instance of this is currently happening in Fedora AH, in which signatures are not shipped in the ISO due to filesystem restrictions. Another possible scenario is if a content provider switches from not signing commits to signing them; even if older commits are retroactively signed, clients' local commit objects would error out if they needed scanning. This patch adds a check to ensure that we always attempt to fetch the detached metadata and wait for its result (whether it exists or not) before moving on to scan their corresponding commit objects. See also: https://github.com/projectatomic/rpm-ostree/issues/630 Closes: #873 Approved by: cgwalters
* pull: Support deltas for explicit commitsColin Walters2017-04-121-5/+30
| | | | | | | | | | | | | | | | | | | | | | | | | I think the majority of OSTree usage calls pull with refs, not explicit commits. We even added special "override syntax" with `@` (e.g. `ostree pull foo@ab12c34`) as a hybrid. However, some users may want to still pull explicit commits for whatever reason. The old static delta logic looked at the previous commit of the ref. However, in https://github.com/ostreedev/ostree/pull/710 we enhanced the logic to look at all local commits. It's now a lot more natural to teach the delta logic to support revisions, e.g. `ostree pull someorigin ab12c34`. This also fixes the problem that before, `--require-static-deltas` was completely ignored when processing revisions. This is a nontrivial refactoring of the logic, but the end result feels a lot more readable to me. Closes: https://github.com/ostreedev/ostree/issues/783 Closes: #787 Approved by: cgwalters
* repo+tests: Add [core]disable-xattrs=true, use it on overlayfsColin Walters2017-03-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | There are a lot of things suboptimal about this approach, but on the other hand we need to get our CI back up and running. The basic approach is to - in the test suite, detect if we're on overlayfs. If so, set a flag in the repo, which gets picked up by a few strategic places in the core to turn on "ignore xattrs". I also had to add a variant of this for the sysroot work. The core problem here is while overlayfs will let us read and see the SELinux labels, it won't let us write them. Down the line, we should improve this so that we can selectively ignore e.g. `security.*` attributes but not `user.*` say. Closes: https://github.com/ostreedev/ostree/issues/758 Closes: #759 Approved by: jlebon
* pull: don't use static deltas if archive repoJonathan Lebon2017-03-021-1/+11
| | | | | | | | | | | | | | | In https://github.com/ostreedev/ostree/pull/408, we disabled the use of static deltas when mirroring. Later, https://github.com/ostreedev/ostree/pull/506 loosened this up again so that we could use static deltas when mirroring into bare{-user} repos. However, the issue which originally spurrred #408 is even more generic than that: we want to avoid static deltas for any archive repo, not just when doing a mirror pull. This patch tightens this up, and also relocates the decision code to make it easier to read. Closes: #715 Approved by: cgwalters
* pull: Fold together deltapart+fallback count for displayColin Walters2017-02-171-1/+2
| | | | | | | | | | | | It's just simpler, and I'm not sure people are going to care much about the difference by default. We already folded in the fallback sizes into the download totals, so folding in the count makes things consistent; previously you could see e.g. `3/3 parts, 100MB/150MB` and be confused. Closes: #678 Approved by: giuseppe
* Sourced test snippets: remove shebang and make non-executableSimon McVittie2017-01-191-2/+2
| | | | | | | | | | | They are installed non-executable, which makes Debian's Lintian packaging consistency check complain that #! is only useful in executable scripts. But in fact they are not useful to execute directly (they rely on setup being done in the script that sources them), so just chmod them -x. Closes: #652 Approved by: cgwalters
* repo: Add unconfigured-state to remote config optionsColin Walters2016-12-091-1/+10
| | | | | | | | | | | | | | | | This is a migration from the origin version. It's nicer to have it in the remote, since that's what one needs to change. Then tools don't need to mess with the origin file.o In fact in this scenario one can keep the "media source" like `file:///install/repo` or whatever, since conceptually that's where it came from. We're just providing a better error. Closes: https://github.com/ostreedev/ostree/issues/626 Closes: #627 Approved by: jlebon
* pull: Don't do deltas with --commit-metadata-onlyColin Walters2016-11-041-1/+18
| | | | | | | | | | | | | We should just download the commit objects directly, as it's obviously a lot more efficient than deltas. I had to generate a summary file in more places in the tests, since once created, it needs to be updated. Closes: https://github.com/ostreedev/ostree/issues/528 Closes: #566 Approved by: jlebon
* pull: Don't execute static deltas when mirroringColin Walters2016-07-251-1/+12
| | | | | | | | | | | | | We don't presently support this, since the static delta code assumes it can just `mmap()` file objects. We could at some point implement this, but for now just skip executing deltas when doing `archive -> archive` mirroring. I noticed this when trying to mirror a repo in Jenkins in [CAHC](https://wiki.centos.org/SpecialInterestGroup/Atomic/Devel). Closes: #408 Approved by: giuseppe
* tests: Port to glib-tap.mk, make `make check` run all of the testsColin Walters2016-03-031-0/+2
| | | | | | | | | | | | | | | | | | OSTree's code for testing predates the `glib-tap.mk` making its way into GLib. Let's switch to it, as it provides a number of advantages. By far the biggest advantage is that `make check` can start to run most of the tests *in addition* to having them work installed. This commit keeps the installed tests working, but `make check` turns out to be really broken because...our TAP usage has bitrotted to say the least. Fix that all up. Do some hacks so that the tests work uninstalled as well - in particular, `glib-tap.mk` and the bits encoded into `g_test_build_filename()` assume *recursive* Automake (blah). Work around that by creating a symlink when installed to loop back.
* Fix make syntax-checkGiuseppe Scrivano2016-03-011-4/+4
| | | | Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>