Commit Graph

2019 Commits

Author SHA1 Message Date
Colin Walters 17f264a487 repo: Add unconfigured-state to remote config options
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
2016-12-09 17:46:54 +00:00
Dan Nicholson 640e92ef37 repo: Fix annotations for remote_fetch_summary functions
These are out parameters, so add the (out) annotation and switch
(nullable) to (optional) since the latter is used for the purpose of
optional out parameters.

Closes: #629
Approved by: cgwalters
2016-12-09 13:07:42 +00:00
Colin Walters c19fae0282 tree-wide: Switch to autoptr for GOptionContext
We were leaking in a few places that I noticed in an ASAN run.  Also,
this was one of the last non-autoptr cleanup sections we have in
`out:` cleanup sections, making us a lot closer to a potential
full-tree rewrite to `return FALSE`.

Closes: #624
Approved by: jlebon
2016-12-08 16:48:20 +00:00
Colin Walters 58e318d678 [ASAN] sysroot: Squash a leak in lockfile acquisition
I installed `parallel` in my dev container, which got me
the sysroot locking tests, which caught this leak when
built with ASAN.

Closes: #623
Approved by: jlebon
2016-12-08 16:18:19 +00:00
Colin Walters 7f2830cb4e build: Make libsoup optional again
The "remote cookies" code broke this.  While I'm not sure anyone is
actually using ostree-without-http, it isn't too hard to keep the
build time conditional going.  Further, this work is preparatory for
libcurl porting.

Closes: #621
Approved by: jlebon
2016-12-08 16:04:16 +00:00
Colin Walters 7519457382 fetcher: Define an abstraction over SoupURI
This is preparatory work for a potential libcurl backend.

Closes: #616
Approved by: jlebon
2016-12-07 23:00:58 +00:00
Colin Walters 099576ee4a lib: Ensure we use _GNU_SOURCE in enum templates
Due to the way glib-mkenums runs the preprocessor itself, it
doesn't pick up the `AC_USE_SYSTEM_EXTENSIONS()` that we have in
`configure.ac`.

This blew up in an obscure way when I later wanted to `#include
"libglnx.h"` in one of the headers, since it needs the `basename()`
from `string.h` which is only available with `_GNU_SOURCE`.

Closes: #616
Approved by: jlebon
2016-12-07 23:00:58 +00:00
Colin Walters 37965644ff tree-wide: Use g_hash_table_add() where applicable
Just noticed a few while reading some code, decided to do a quick
cleanup.  It's shorter and clearer.

Closes: #614
Approved by: jlebon
2016-12-06 17:45:23 +00:00
Colin Walters 247a8718bb lib: Remove unused ostree_metalink_get_uri()
While doing something else I noticed it was unused.

Closes: #615
Approved by: jlebon
2016-12-06 16:27:52 +00:00
Colin Walters 0fb3645fed pull: Write .commitpartial for local pulls first too
This is what we do for non-local (i.e. HTTP) pulls; we wnat to
correctly handle being interrupted during partial pulls.

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

Closes: #613
Approved by: jlebon
2016-12-06 16:13:53 +00:00
Colin Walters 4c8fc92aa0 lib: Always checksum content in deltas
This is a follow up to conversation on list - in practice, if we're
backing away from summary signing, then it makes sense to remove the
special casing for checksums in deltas around summary signatures.

This is also related to the recent change to enable GPG checking for
commits in deltas - now we have a more coherent story between the
previous pull path and deltas.

I didn't do any performance checking, and while it's slightly annoying
that we're now doing sha256 on the delta content twice (once for the
part and once per object)...sha256 is pretty fast, I think most users
are I/O bound anyways, and it'd drop even farther if we started using
openssl.

Closes: #612
Approved by: jlebon
2016-12-06 15:59:35 +00:00
Colin Walters 7bb0ff46a4 Define and use cleanup helpers for libarchive
This should fix some of the ASAN leaks around libarchive usage,
and is generally better.

Closes: #609
Approved by: jlebon
2016-12-05 15:20:56 +00:00
Colin Walters 667b734c79 [ASAN] set-origin: Squash a leak
Just a minor leak in the commandline.

Closes: #598
Approved by: jlebon
2016-11-30 18:51:26 +00:00
Colin Walters 161193966c [ASAN] bootconfig: Drop a pointless strdup in parser
Not entirely sure how this was leaking, but anyways it showed
up in ASAN, and it's pointless to strdup here.

Closes: #598
Approved by: jlebon
2016-11-30 18:51:26 +00:00
Colin Walters d83d5b4a29 [ASAN] metalink: Fix leaks of buffer
We should be religious about the "only set output variables on
success", otherwise it makes leaks more likely.

But the real leak was us simply not using autoptr in one place.

Closes: #598
Approved by: jlebon
2016-11-30 18:51:26 +00:00
Colin Walters 1bb6e51486 [ASAN] sysroot: Fix leak/double free of keyfile origin
Use autoptr rather than manual cleanup.  The double free isn't a
security problem, since we trust origin files.

Closes: #598
Approved by: jlebon
2016-11-30 18:51:26 +00:00
Colin Walters 3a459bac2d traverse: Use g_hash_table_add
And "move semantics" via `g_steal_pointer()`.  Just a minor code
cleanup I noticed when I was hunting for a leak, which ended up being
elsewhere.

Closes: #598
Approved by: jlebon
2016-11-30 18:51:26 +00:00
Colin Walters a1224e2de7 [ASAN] cmdline: Fix minor leak in delta cmdline entrypoint
Small, but it's important to stay clean.

Closes: #598
Approved by: jlebon
2016-11-30 18:51:26 +00:00
Colin Walters ab0400b722 [ASAN] deltas: Fix minor memory leak
We were leaking the checksum, ensure we free it in both normal and
error paths.

Closes: #598
Approved by: jlebon
2016-11-30 18:51:26 +00:00
Colin Walters 79cb421ee2 [ASAN] delta compilation: More leak fixes
Now that I remembered to do `env G_SLICE=always-malloc`, lots more
leaks become apparent.  Nothing major.

Closes: #598
Approved by: jlebon
2016-11-30 18:51:26 +00:00
Alexander Larsson d57036f6a2 delta compilation: Fix leak
We need to ref-sik the new varian for g_autoptr to work

Closes: #597
Approved by: cgwalters
2016-11-28 16:25:29 +00:00
Alexander Larsson 36f7824cb0 pull: Don't leak delta superblock variants
Closes: #596
Approved by: cgwalters
2016-11-28 15:56:22 +00:00
Alexander Larsson 239cb1494f pull_with_options: Don't leak csum_v
Closes: #596
Approved by: cgwalters
2016-11-28 15:56:22 +00:00
Alexander Larsson fc107e5bb4 ostree-repo-traverse: Don't leak floating GVariant
ostree_object_name_serialize returns a floating ref, so we need
to sink it before putting in the hashtable.

Closes: #595
Approved by: cgwalters
2016-11-28 14:53:50 +00:00
Alexander Larsson c9b158e9f2 pull: scan_commit_object() - don't load variant twice
ostree_repo_load_commit already loaded the object, no need
to load it twice.

Closes: #595
Approved by: cgwalters
2016-11-28 14:53:50 +00:00
Jasper St. Pierre 70d140d61c ostree-repo-traverse: Remove an accidental print statement
Closes: #594
Approved by: jlebon
2016-11-23 22:21:16 +00:00
Colin Walters 7584dc0f25 Release 2016.14
Closes: #593
Approved by: jlebon
2016-11-23 16:20:49 +00:00
Jasper St. Pierre fd6ba80d07 ostree-repo: Make the lock with a long-lasting FD
glnx_make_lock_file requires that the dfd passed in survives the
lifetime of the lock. Since dfd_iter.fd gets cleaned up after the
function returns, this isn't the case. dfd_iter.fd should be equivalent
to tmpdir_dfd, since we iter on ".", and that survives past the
function, so just use that instead.

Closes: #591
Approved by: cgwalters
2016-11-22 02:32:33 +00:00
Jasper St. Pierre fbce608177 ostree-repo-static-delta-processing: Don't close(-1)
Ultimately harmless, but causes somewhat scary strace messages.

Closes: #591
Approved by: cgwalters
2016-11-22 02:32:33 +00:00
Jasper St. Pierre a8f5c20209 ostree-repo: Fix parameter name
Closes: #591
Approved by: cgwalters
2016-11-22 02:32:33 +00:00
Colin Walters 49b8a72622 [ASAN] lib: Squash various leaks in library and commandline
The pull one is the most likely to affect users.  Otherwise mostly
just cleaning up `-fsanitize=address`.

Closes: #587
Approved by: jlebon
2016-11-21 16:34:06 +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
Colin Walters 36c8946870 Release 2016.13
Closes: #570
Approved by: jlebon
2016-11-10 17:24:39 +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 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