3146 Commits

Author SHA1 Message Date
Colin Walters
a6eb8bbcf6 tests: Support TEST_SKIP_CLEANUP=err
I find myself often wanting to debug interactively failing tests.
This makes it more convenient to keep around the temporary directories
just for those tests, rather than accumulating tons of tempdirs from
the successful tests as well.

Closes: #588
Approved by: jlebon
2016-11-21 16:11:55 +00:00
Colin Walters
41ef2aeb38 pull: Do GPG verify commit objects when using deltas
The fact that we weren't doing this is at best an oversight, and
for some deployment models a security vulnerability.  Having both
`gpg-verify` and `gpg-verify-summary` shows that we were intending
them to be orthogonal/independent.

Lately I've been advocating moving towards pinned TLS instead of
gpg-signed summaries, and if we follow that path, performing GPG
verification of commit objects even if using deltas is more important,
as it provides an at-rest verifiable authenticity and integrity
mechanism.

Content providers which are signing their summary files and/or using
TLS (particularly pinned TLS) for transport should treat this as a
nice-to-have.  However, for providers which are serving content over
plain HTTP and relying on GPG, this is a critical update.

Closes: https://github.com/ostreedev/ostree/issues/517

Closes: #589
Approved by: jlebon
2016-11-21 15:55:09 +00:00
Colin Walters
cb57338a12 pull: Use new per-remote API for GPG verification
Trivial change, but makes things more obvious.  And we get test
coverage of the new API for free.

Closes: #589
Approved by: jlebon
2016-11-21 15:55:09 +00:00
Colin Walters
abbd7acaf3 pull: Dedup code for checking for > 0 valid results
We have a public API for this, let's use it internally.

Closes: #589
Approved by: jlebon
2016-11-21 15:55:09 +00:00
Colin Walters
c1c70bceb7 [TSAN] Rework assertions to always access refcount atomically
`-fsanitize=address` complained that the `refcount > 0` assertions
were reading without atomics.  We can fix this by reworking them
to read the previous value.

Closes: #582
Approved by: jlebon
2016-11-17 19:41:57 +00:00
Colin Walters
f0519e541f [TSAN] main: Stop calling g_set_prgname()
It turns out this is basically racy with the presence of other
threads.  It was really cosmetic so let's stop doing it and make
`-fsanitize=thread` happy.

Closes: #582
Approved by: jlebon
2016-11-17 19:41:57 +00:00
Colin Walters
b5c4e6d99a [UBSAN] deltas: Don't call memset(NULL, NULL, 0) with no xattrs
This is actually fine in practice, but it triggers this
`-fsanitize=undefined` warning I saw in the test suite log:

```
src/libostree/ostree-repo-static-delta-compilation.c:160:10: runtime error: null pointer passed as argument 1, which is declared to never be null
```

Closes: #584
Approved by: jlebon
2016-11-17 19:20:20 +00:00
William Manley
0ee9e221be ostree commit: Fix combining trees with multiple --tree=ref arguments
You'd expect

    ostree commit --tree=ref=A --tree=ref=B

to produce a commit with the union of the trees given.  Instead you'd get
a commit with the contents of just the latter commit.  This was due to an
optimisation where we'd skip filling out the `files` and `subdirs`
members of the mtree, just filling in the metadata instead.  This backfires
becuase this same code relies on checking the `files` and `subdirs` members
itself to work out whether the mtree is empty.

This commit removes the optimisation, fixing the bug.  Maybe there's a way
to keep the optimisation and still fix the bug but it's not obvious to
me.

Closes: #581
Approved by: cgwalters
2016-11-17 14:45:55 +00:00
Colin Walters
24bf257ee9 lib: Add an API to GPG verify a commit given a remote
Conceptually we've been moving towards having our GPG verification
paths be per-remote.  The code internally supports this, but we
didn't expose an API to use it conveniently.

This came up when trying to add a new `gpgkeypath` option, since
right now rpm-ostree manually finds keyrings for the remote, and
hence it wasn't looking at the keypath, and said "Unknown key"
in status.

Adding an API fixes this nicely.

Closes: #576
Approved by: giuseppe
2016-11-17 11:33:41 +00:00
Colin Walters
f244c70277 Add "gpgkeypath" option to remotes
For Project Atomic, we already have RPM signatures which use files in
`/etc/pki/rpm-gpg`.  It's convenient to simply bind the OSTree remote
configuration to those file paths, rather than having duplicate key
data.

This does mean that we need to parse the files for verification, so we
end up importing them into the verifier's temporary keyring, which is
a bit ugly, but it's what other projects do.

Closes: https://github.com/ostreedev/ostree/issues/573

Closes: #575
Approved by: giuseppe
2016-11-17 09:44:07 +00:00
Colin Walters
3cd5e6b41a lib: Split out helper function to create GPG context
In prep for future work.

Closes: #575
Approved by: giuseppe
2016-11-17 09:44:07 +00:00
Colin Walters
a6cfe62eb8 lib: Define and use cleanup functions for gpgme
Just a cleanup in preparation for future work.

Closes: #575
Approved by: giuseppe
2016-11-17 09:44:07 +00:00
Alexander Larsson
bd45e7ac19 commit: Fix reading xattrs from OstreeRepoFile:s
When doing commit --tree=ref=XXX while at the same time applying some
form of modifier, ostree dies trying to read the xattrs using the
raw syscalls. We fix this by falling back to ostree_repo_file_get_xattrs()
in this case.

Also adds a testcase for this.

Closes: #577
Approved by: cgwalters
2016-11-16 22:30:33 +00:00
Colin Walters
814aa96825 pull: Redo logic for "scanning"
What in the code is called "scanning" is ensuring (potentially
recursively) have an object, and if not, fetching it.  And then if
it's metadata, parsing it and finding new objects to fetch.

This logic has grown fairly complex.  What I'm trying to fix
right now is that if we're doing a pull-local to a remote repository
via `sshfs` (FUSE) we still end up scanning, which is inefficient.

We can take advantage of the "commitpartial" logic here - if a commit
isn't partial, it's complete, hence we don't need to scan it.

At the same time, I'm changing the logic here to *always* do scans for
dirtree objects.  This will fix cases where multiple commits share
dirtree objects.  We have "commitpartial" metadata, but no such concept
of partial/complete for dirtrees.

But, we'll only ever scan dirtrees if we scan commits, which is
what the section above fixes.

Closes: https://github.com/ostreedev/ostree/issues/543

Closes: #564
Approved by: alexlarsson
2016-11-16 22:17:25 +00:00
Colin Walters
37c07d2f1c pull: Add support for http-headers option
Some deployments may want to gate access to content based on things
like OAuth.  In this model, the client system would normally compute a
token and pass it to the server via an API.

We could theoretically support this in the remote config too, but
that'd be a bit weird for OAuth as the information is dynamic.
Therefore this cleans up the code a little bit to more clearly handle
the case that the fetcher is initialized from both remote config
data plus pull options.

Closes: #574
Approved by: giuseppe
2016-11-16 10:04:22 +00:00
Jonathan Lebon
4b7ab5167c .redhat-ci.yml: no longer install libubsan & clang
Since they're now part of the auto-built image.

Closes: #572
Approved by: cgwalters
2016-11-10 18:10:58 +00:00
Colin Walters
676f0a2797 travis: Drop debian unstable since we can't fetch packages reliably
I don't know what's going on, I suspect mirror churn.  Anyways,
it seems to be consistently failing now, so let's drop it.

Closes: #571
Approved by: jlebon
2016-11-10 17:39:06 +00:00
Colin Walters
36c8946870 Release 2016.13
Closes: #570
Approved by: jlebon
v2016.13
2016-11-10 17:24:39 +00:00
Jonathan Lebon
39e7293e3f .redhat-ci.yml: use new build key
This allows us to more concisely separate building from testing, which
in turn gives us a nicer inheritance pattern in our case.

See also: https://github.com/jlebon/redhat-ci/issues/11

Closes: #569
Approved by: cgwalters
2016-11-09 17:35:40 +00:00
Colin Walters
24ac4ff190 deltas: Only keep one file open at a time during compilation
Otherwise it's possible for us to exhaust available file descriptors
or (on 32 bit) run up against mmap limits.

In the rollsum case, we didn't need to hold open the "from" object
at all.  And in the bsdiff case, we weren't even looking at either of
the files until we started processing.

Also, while we have the patient open, switch to using O_TMPFILE
if available.

Closes: #567
Approved by: giuseppe
2016-11-07 11:17:59 +00:00
Sjoerd Simons
2b150f52f8 Update documentation for cookie handling commands
Closes: #531
Approved by: cgwalters
2016-11-05 17:34:09 +00:00
Sjoerd Simons
6af8db6fc4 tests: Add test for the cookie jar handling
Closes: #531
Approved by: cgwalters
2016-11-05 17:34:09 +00:00
Sjoerd Simons
6303e2d67b trivial-httpd: Add support for checking cookies
Allow passsing a list of cookie key/values to trivial-httpd which should
be provided to allow downloads

Closes: #531
Approved by: cgwalters
2016-11-05 17:34:09 +00:00
Sjoerd Simons
be9a3a7a19 OsreeFetcher: Treat 403 as not found
Private Cloudfront instances return 403 for objects which don't exist
rather then a 404.

Change the fetcher to assume 403 is ok for download that are "optional"
rather then erroring out at that step (e.g. trying to download a static
delta if the remote repo doesn't have those)

Closes: #531
Approved by: cgwalters
2016-11-05 17:34:09 +00:00
Sjoerd Simons
0613b4a479 remote: Add commands to add and remove cookies for a remote
Add commands to add and remove cookies to a remotes cookie jar.

Closes: #531
Approved by: cgwalters
2016-11-05 17:34:09 +00:00
Sjoerd Simons
6b467b9dbc remote: Add command to list cookies
Closes: #531
Approved by: cgwalters
2016-11-05 17:34:09 +00:00
Sjoerd Simons
96356aa192 pull: Add per-remote cookie jar
Optionally read cookie jars for a remote to be used when downloading
data. This can be used for private repositories which require specific
cookies to be present, e.g. repositories hosted on Amazon cloudfront
using signed cookies.

Closes: #531
Approved by: cgwalters
2016-11-05 17:34:09 +00:00
Colin Walters
2139f0e437 pull: Don't do deltas with --commit-metadata-only
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
2016-11-04 16:04:23 +00:00
Colin Walters
730f723869 repo: Don't put remote refs in the summary file
I was doing a chain of mirroring like A -> B -> C

And repo B had A as a remote.  When I added B as
a remote to C, the summary file of B had a ref
upstream:foo/bar/baz, which caused all pulls from
B to C to fail, since the summary file is only
expected to have refs, not refspecs.

Closes: https://github.com/ostreedev/ostree/issues/561

Closes: #565
Approved by: jlebon
2016-11-04 15:16:09 +00:00
Sjoerd Simons
f0e493bf29 Filter bootloader supplied kernel cmdline options
Various bootloader add kernel commandline options dynamically, filter
these out when grabbing boot options from /proc/cmdline. Specifically
grub adds BOOT_IMAGE and systemd-boot adds initrd.

Closes: #560
Approved by: cgwalters
2016-11-01 18:00:37 +00:00
Simon McVittie
8ae03d6497 load_metadata_internal: don't leak GBytes
Found by valgrind memcheck. g_variant_new_from_bytes takes a ref to the
bytes, so we need to release the original ref.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #556
Approved by: cgwalters
2016-10-30 22:11:15 +00:00
Simon McVittie
24af123c53 Fix some leaks of floating GVariants
ostree_repo_pull_with_options() and ostree_repo_remote_change() don't
sink floating GVariant arguments, and doing so now would be an
ABI change; so don't rely on them to do so.

Leak found with valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #556
Approved by: cgwalters
2016-10-30 22:11:15 +00:00
Simon McVittie
53f1fabfbe ot_remote_builtin_show_url: autofree context
Leak found with valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #556
Approved by: cgwalters
2016-10-30 22:11:15 +00:00
Simon McVittie
1fc2a1202e ostree_repo_pull_with_options: clear dirs array
Leak found with valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #556
Approved by: cgwalters
2016-10-30 22:11:15 +00:00
Simon McVittie
4739709742 keyfile_set_from_vardict: free the string array
g_variant_get_strv is (transfer container): the caller is expected to
free the array, but not the individual strings.

Leak found with valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #556
Approved by: cgwalters
2016-10-30 22:11:15 +00:00
Simon McVittie
c8a6b037ef _ostree_sysroot_write_deployments_internal: stop leaking hash table
It appears the result of assign_bootserials() is never actually used,
but I haven't changed it to return void right now.

Leak found with valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #556
Approved by: cgwalters
2016-10-30 22:11:15 +00:00
Simon McVittie
ff28ac4a30 ostree_sysroot_upgrader_finalize: free new_revision
Leak found with valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #556
Approved by: cgwalters
2016-10-30 22:11:15 +00:00
Simon McVittie
4c32344b8e ostree_admin_option_context_parse: explicitly clean up when exiting early
The cleanup attribute doesn't clean up before calling a noreturn
function like exit(). Explicitly clean up the pointer variables
(but don't assume that a simple g_object_unref() would be OK either,
in case the behaviour of the cleanup attribute changes).

This isn't a real leak since we're about to exit anyway, but if we
don't fix it then valgrind memcheck will make the tests fail.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #559
Approved by: cgwalters
2016-10-30 21:37:38 +00:00
Simon McVittie
213d5013ce ostree_builtin_pull: consistently set free-function on refs_to_fetch
We are relying on the GPtrArray to free its contents, but we only
give it a free-function on one code path.

Found by valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #559
Approved by: cgwalters
2016-10-30 21:37:38 +00:00
Simon McVittie
22ed96d23c ot_admin_builtin_set_origin: don't leak options GVariant
Found by valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #559
Approved by: cgwalters
2016-10-30 21:37:38 +00:00
Simon McVittie
e757f736e7 _ostree_kernel_args_replace_take: don't leak when replacing
If !existed, then we add arg to kargs->order, where it will be freed
by that array's free-function. However, if the kernel argument did
already exist, we have to either free arg ourselves (and make sure
the old key is what appears in the hash table), or do a linear search
on kargs->order to replace the old key with the new.

Leak found by valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #559
Approved by: cgwalters
2016-10-30 21:37:37 +00:00
Simon McVittie
a0e7d411c1 Distribute valgrind suppressions in tarballs
Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #557
Approved by: cgwalters
2016-10-29 18:41:56 +00:00
Simon McVittie
4eb55a687d Distribute test scripts even if we wouldn't run them
This fixes a "make dist" tarball produced on a minimal system and run on a
non-minimal system. Automake knows that files that are only conditionally
included in dist_whatever_WHATEVER are to be distributed, but it does not
do the same for files that are only conditionally included in EXTRA_DIST,
which is how glib-tap.mk's various variables like dist_test_scripts work.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #557
Approved by: cgwalters
2016-10-29 18:41:56 +00:00
Simon McVittie
7091d288f7 Force C.UTF-8 or C locale for tests
Otherwise several tests fail, for example in this build done in a French
locale by Debian's reproducible builds initiative, to check whether
the resulting binaries are identical to what was produced in an
English locale:

<https://tests.reproducible-builds.org/debian/logs/unstable/amd64/ostree_2016.11-1.build2.log.gz>

(test-basic)
# error: Cannot write to repository: Permission non accordée
...
File 'error-message' doesn't match regexp 'Permission denied'

(test-help)
# Utilisation :
#   ostree [OPTION...] COMMAND
...
File 'out' doesn't match regexp '[Uu]sage'

(test-pull-metalink)
# error: Erreur à la ligne 1, caractère 1 : Le document doit commencer avec un élément (par ex. <book>)
...
File 'err.txt' doesn't match regexp 'Document must begin with an element'

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #558
Approved by: cgwalters
2016-10-29 18:12:42 +00:00
Colin Walters
a15dc7f191 ci: Use -fsanitize=undefined by default
It's fast enough to use for CI testing by default, and it
can catch a lot of bad things.

Closes: #552
Approved by: jlebon
2016-10-28 17:47:50 +00:00
Colin Walters
05dc77d7e5 remote-refs: Add NULL terminator to options array
Caught by `-fsanitize=undefined`.

Closes: #552
Approved by: jlebon
2016-10-28 17:47:50 +00:00
Colin Walters
396563e7e9 libglnx: Bump to master (for -fsanitize fixes)
Closes: #552
Approved by: jlebon
2016-10-28 17:47:50 +00:00
Giuseppe Scrivano
c4c8937b20 static-delta: find a similar filename using what is before '.' or '-'
Improve the heuristic to use only the part before the first '.' when
looking for a similar file in the current directory.

last versions of dracut generate reproducible initramfs files, but we
still fallback to the full file download if there is any minimal
change that causes a different checksum and file name.

This change extends that case to deal better with similar files that
have a different suffix.

This is the difference generating a static delta from
fedora-atomic/f24/x86_64/docker-host to fedora-atomic/f24/x86_64/testing/docker-host

before the patch:

fallback for 111ec866aa7ce3688407fa4a1ae7c9fca93dcee0b851fc9434c59ff947830cc7 (47.0 MB)
fallback for c6a898265de22b02c89ea2f35d132628d0ee1c0a058052ed14fee5799c17904c (47.0 MB)
fallback for fbce656249ece77260887ed873e445561b9d43bcb28a32e759c0b1bab89e7137 (6.6 MB)
fallback for cfdb51457e47e0a0fe0bac38991a21279d2646ff2f019630c7b52a0cd3451397 (6.6 MB)
part 0 n:1972 compressed:11239809 uncompressed:33747412
part 1 n:1079 compressed:9683681 uncompressed:55641397
part 2 n:1507 compressed:15050265 uncompressed:44448838
part 3 n:101 compressed:1865881 uncompressed:31896086
part 4 n:278 compressed:2452585 uncompressed:52811323
part 5 n:18 compressed:67621 uncompressed:100220
uncompressed=218645276 compressed=40359842 loose=545102
rollsum=49 objects, 2117254 bytes
bsdiff=4067 objects

after the patch:

part 0 n:843 compressed:19844109 uncompressed:95443178
part 1 n:1223 compressed:11188609 uncompressed:33330401
part 2 n:990 compressed:15762905 uncompressed:61214132
part 3 n:1441 compressed:20614573 uncompressed:31534195
part 4 n:163 compressed:2734997 uncompressed:51356423
part 5 n:285 compressed:2480813 uncompressed:52902904
part 6 n:14 compressed:59125 uncompressed:75341
uncompressed=325856574 compressed=72685131 loose=533283
rollsum=51 objects, 57235332 bytes
bsdiff=4073 objects

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #554
Approved by: cgwalters
2016-10-28 17:04:25 +00:00
Jonathan Lebon
0333260559 delta: return valid enum member
If we can't figure out what endianness a delta is, we should just throw
ENDIAN_INVALID.

Resolves: #550

Closes: #553
Approved by: cgwalters
2016-10-27 22:16:32 +00:00
Colin Walters
7f2960db43 Define an initializer for GVariant{Builder,Dict}
So we build warning-free on GLib (< 2.50, >= 2.50).  This
is a band aid until we hard-require >= 2.50.

Closes: #547
Approved by: jlebon
2016-10-27 18:49:15 +00:00