Commit Graph

3609 Commits

Author SHA1 Message Date
Jonathan Lebon
3604b8152a libotutil/checksum-utils: fix openssl compilation
Closes: #1261
Approved by: cgwalters
2017-10-11 16:05:52 +00:00
Dan Nicholson
a5b7660c94 lib/deploy: Ignore FIFREEZE/FITHAW errors when already in state
If the filesystem is already frozen, FIFREEZE returns EBUSY, and if the
filesystem is already thawed, FITHAW returns EINVAL. It's very unlikely
these issues would arise on a real ostree system since the sysroot would
be locked during the freeze/thaw cycle.

However, when multiple fake sysroots are used during the test suite (run
as root), the tests could race to run the freeze/thaw cycle without
locking. Furthermore, there's no reason why an independent process might
be trying to freeze the filesystem while ostree was deploying. Ignore
but warn for these errors since there's not much ostree can do about it,
anyways.

Closes: #1260
Approved by: cgwalters
2017-10-11 15:40:20 +00:00
Colin Walters
1c9975cbd1 lib: Add a lighter weight internal checksum wrapper
The faster (OpenSSL/GnuTLS) code lived in a `GInputStream` wrapper, and that
adds a lot of weight (GObject + vtable calls). Move it into a simple
autoptr-struct wrapper, and use it in the metadata path, so we're
now using the faster checksums there too.

This also drops a malloc there as the new API does hexdigest in place to a
buffer.

Prep for more work in the commit path to avoid `GInputStream` for local file
commits, and ["adopting" files](https://github.com/ostreedev/ostree/pull/1255).

Closes: #1256
Approved by: jlebon
2017-10-10 21:25:40 +00:00
Colin Walters
bba7eb8069 commit: Add _CONSUME modifier flag
For many cases of commit, we can actually optimize things by simply "adopting"
the object rather than writing a new copy. For example, in rpm-ostree package
layering.

We can only make that optimization though if we take ownership of the file. This
commit hence adds an API where a caller tells us to do so. For now, that just
means we `unlink()` the files/dirs as we go, but we can now later add the
"adopt" optimization.

Closes: #1255
Approved by: jlebon
2017-10-10 13:02:08 +00:00
Colin Walters
fc33ae018d lib/deltas: Move variant read helper into the deltas code
What the deltas code is doing is weird/unfortunate.  The name
`ot_variant_read()` conflicts too much with `ot_variant_read_fd()`.
Since nothing else uses it, move it into the deltas code.

Closes: #1254
Approved by: jlebon
2017-10-05 15:41:00 +00:00
Colin Walters
a903f96673 lib/util: Delete some unused functions
Hooray, dead code.

Closes: #1254
Approved by: jlebon
2017-10-05 15:41:00 +00:00
Colin Walters
2e3889a4eb lib/pull: Change fetcher to return O_TMPFILE
A lot of the libostree code is honestly too complex for its
own good (this is mostly my fault).  The way we do HTTP writes
is still one of those.  The way the fetcher writes tempfiles,
then reads them back in is definitely one of those.

Now that we've dropped the "partial object" bits in:
https://github.com/ostreedev/ostree/pull/1176 i.e. commit
0488b4870e
we can simplify things a lot more by having the fetcher
return an `O_TMPFILE` rather than a filename.

For trusted archive mirroring, we need to enable linking
in the tmpfiles directly.

Otherwise for at least content objects they're compressed, so we couldn't link
them in. For metadata, we need to do similar logic to what we have around
`mmap()` to only grab a tmpfile if the size is large enough.

Closes: #1252
Approved by: jlebon
2017-10-05 14:58:20 +00:00
Colin Walters
7f6af94c5a lib/utils: Port a bit to decl-after-stmt style
Add add some more comments.

Closes: #1247
Approved by: jlebon
2017-10-05 13:28:59 +00:00
Philip Withnall
9350e8a488 lib/repo: Clarify that ostree_repo_remote_fetch_summary() doesn’t verify
Make that a bit clearer in the documentation.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1253
Approved by: cgwalters
2017-10-05 12:48:28 +00:00
Colin Walters
5c7d2dd8be Deduplicate and fix up our use of mmap()
Buried in this large patch is a logical fix:

```
-  if (!map)
-    return glnx_throw_errno_prefix (error, "mmap");
+  if (map == (void*)-1)
+    return glnx_null_throw_errno_prefix (error, "mmap");
```

Which would have helped me debug another patch I was working
on.  But it turns out that actually correctly checking for
errors from `mmap()` triggers lots of other bugs - basically
because we sometimes handle zero-length variants (in detached
metadata).  When we start actually returning errors due to
this, things break.  (It wasn't a problem in practice before
because most things looked at the zero size, not the data).

Anyways there's a bigger picture issue here - a while ago
we made a fix to only use `mmap()` for reading metadata from disk
only if it was large enough (i.e. `>16k`).  But that didn't
help various other paths in the pull code and others that were
directly doing the `mmap()`.

Fix this by having a proper low level fs helper that does "read all data from
fd+offset into GBytes", which handles the size check. Then the `GVariant` bits
are just a clean layer on top of this. (At the small cost of an additional
allocation)

Side note: I had to remind myself, but the reason we can't just use
`GMappedFile` here is it doesn't support passing an offset into `mmap()`.

Closes: #1251
Approved by: jlebon
2017-10-04 20:42:39 +00:00
Jonathan Lebon
c511ca0fae lib/commit: minor coverity fix
Appease Coverity by using the same condition for both the ternary check
and the if-condition later on. It should be smart enough to figure out
that `dir_enum == NULL` implies that `dfd_iter != NULL` from the
assertion at the top of the function.

Coverity CID: #1457318

Closes: #1250
Approved by: cgwalters
2017-10-04 15:50:38 +00:00
Colin Walters
351ffdb977 lib/sysroot: Fix pointer going out of scope in unlock code
Fixes Coverity CID #1457317

Closes: #1249
Approved by: jlebon
2017-10-04 14:56:31 +00:00
Colin Walters
e80efe0b06 lib/core: Init struct stat buffer
Regression from d57410a7e6

Fixes Coverity CID #1457316

Closes: #1249
Approved by: jlebon
2017-10-04 14:56:31 +00:00
Jonathan Lebon
0c36433736 tree: fix compiler warnings
Mostly innocuous warnings, except for -Wtautological-compare, which
caught a shady guint64 subtraction.

Closes: #1245
Approved by: cgwalters
2017-10-04 12:54:53 +00:00
Jonathan Lebon
8a61f54239 ci: really turn on warnings
We didn't have `-Wall` in our `CFLAGS`. It's normally injected by
`configure.ac`, but because we *did* have `-Werror`, it was skipped.
Now, we just turn it on unconditionally directly in `build.sh`.

Closes: #1245
Approved by: cgwalters
2017-10-04 12:54:53 +00:00
Philip Withnall
43977dffde docs: Clarify %NULL argument to ostree_sysroot_new()
It’s equivalent to ostree_sysroot_new_default().

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1246
Approved by: cgwalters
2017-10-04 12:54:23 +00:00
Jonathan Lebon
c3c13846ad app/main: use HAVE_LIBCURL_OR_LIBSOUP for pull CLI
We want `pull` to be included as long as we have at least either
`libcurl` or `libsoup` to back it. Of course, this is a moot point for
now since `libsoup` is currently a build requirement.

Closes: #1244
Approved by: cgwalters
2017-10-03 19:42:58 +00:00
Philip Withnall
86e072bdbe lib/repo-commit: Import detached metadata even if hardlink exists
Spotted while reading through the code, it looks like the
copy_detached_metadata() call is accidentally omitted if a hardlink
already exists for the .commit object.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1242
Approved by: cgwalters
2017-10-03 16:31:13 +00:00
Matthew Leeds
133e9ae733 lib/gpg: Print debug info when reading GPG keys
This commit adds debug output whenever libostree reads GPG keys, which
can come from different locations in the file system. This is especially
helpful in debugging "GPG signatures found, but none are in trusted
keyring" errors, which in my case was caused by OSTree looking in
/usr/local/share/ostree/trusted.gpg.d/ rather than
/usr/share/ostree/trusted.gpg.d/.

Closes: #1241
Approved by: cgwalters
2017-10-03 13:09:33 +00:00
Colin Walters
be100e0ee2 lib/pull: Minor cleanup to metadata scanning function, add docs
I'm regretting a bit having the `guint8*csum` variant of checksums
except for the serialized form.  Once we start doing processing
it's easier to just have it remain hex.

Do an on-stack conversion for the metadata scanning function; this
drops a malloc and also just looks nicer.

Also add some long-awaited function comments to the two.

Closes: #1240
Approved by: jlebon
2017-10-02 19:55:54 +00:00
Philip Withnall
030e3efbc4 lib/bloom: Add some missing preconditions on n_bytes
These shouldn’t change the bloom filter’s behaviour at all, but make it
a bit more obvious what the programmatical limitations are on the sizes
it can deal with.

In reality, those sizes should never be reached because they won’t fit
in a DNS-SD record.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1239
Approved by: cgwalters
2017-10-02 18:08:55 +00:00
Colin Walters
9fffc27cfb lib/uboot: Port to fd-relative
Prep for `ostree_sysroot_new_at()`.

Closes: #1237
Approved by: jlebon
2017-10-02 16:19:59 +00:00
Colin Walters
fcb1e87f82 lib/syslinux: Port to fd-relative
Prep for `ostree_sysroot_new_at()`.  Also just generally nicer.

Closes: #1237
Approved by: jlebon
2017-10-02 16:19:59 +00:00
Colin Walters
b8c15ae859 lib/pull: Fix regression with pull-local for nonexistent refs
I was reading the pull code for the last release, and spotted
a bug in commit f923c2e1ea - 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
2017-10-02 16:02:28 +00:00
Colin Walters
06c731bfa3 lib/sysroot: Add some more comments
Also avoid gtk-doc style for private functions, as it tries to parse them and
complains since they aren't public.

Closes: #1230
Approved by: jlebon
2017-10-02 15:12:09 +00:00
Colin Walters
7da4c2162d lib/commit: Add some gtk-doc and internal doc comments
Just making more of an effort for this for obvious reasons. We had a few public
APIs not documented too.

Closes: #1230
Approved by: jlebon
2017-10-02 15:12:09 +00:00
Jonathan Lebon
517109c5ea build-sys: Post-release version bump
Closes: #1236
Approved by: cgwalters
2017-10-02 15:11:42 +00:00
Colin Walters
64f3257d88 Release 2017.12
Closes: #1234
Approved by: jlebon
2017-10-02 14:44:34 +00:00
Philip Withnall
feeb3548f4 ostree/summary: Generate an ostree-metadata ref when updating summary
This is the new way of publishing repository metadata, rather than as
additional-metadata in the summary file. The use of an ostree-metadata
ref means that the metadata from multiple upstream collections is not
conflated when doing P2P mirroring of many repositories.

The new ref is only generated if the repository has a collection ID set.
The old summary file continues to be generated for backwards
compatibility (and because it continues to be the canonical ref →
checksum map for the repository).

The new code is only used if configured with --enable-experimental-api.

Includes unit tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1158
Approved by: cgwalters
2017-10-02 13:39:41 +00:00
Philip Withnall
16aa4d728a ostree/summary: Eliminate redundant gotos from error handling path
There is no error handling to do, so just return everywhere instead.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1158
Approved by: cgwalters
2017-10-02 13:39:41 +00:00
Philip Withnall
d1a5652bdd man: Fix a copypasta error in ostree-summary.xml
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1158
Approved by: cgwalters
2017-10-02 13:39:41 +00:00
Philip Withnall
1f666eb07d lib/bloom: Fix a -Wconversion warning in OstreeBloom
Compiling with -Wconversion warns on this line, as the conversion from
guint64 to guint8 is implicit (but safe: there is no bug here, since the
implicit cast is applied after the modulus arithmetic).

Make the cast explicit to silence -Wconversion.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1231
Approved by: cgwalters
2017-10-01 12:24:46 +00:00
Philip Withnall
1673601510 lib/bloom: Fix bloom hashing on 32-bit architectures
There was an implicit cast from guint64 to gsize (which is 32-bit on
armhf, for example) before the modulus arithmetic which safely narrows
the index.

Fix that by using a guint64 intermediate variable and making the cast
explicit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1231
Approved by: cgwalters
2017-10-01 12:24:46 +00:00
Jonathan Lebon
4262a4b016 tests/installed: also run test-basic-c
Since we now have a subtest there that needs full xattr support.

Closes: #1170
Approved by: cgwalters
2017-09-30 00:05:07 +00:00
Jonathan Lebon
a06bd82cd4 tests: check for relabeling rather than overlay
Instead of checking for overlayfs, let's explicitly check for our
ability to relabel files since we now have a `libtest` function to do
this. Also port that logic to `libostreetest`.

Note that overlayfs *does* allow manipulating user xattrs. So ideally,
we should break down `OSTREE_NO_XATTRS` further to distinguish between
tests that use bare repos from other modes.

We check the current directory instead of `/` so that developers can
just point `TEST_TMPDIR` to a non-overlayfs mount point when hacking
from a container.

Closes: #1170
Approved by: cgwalters
2017-09-30 00:05:07 +00:00
Jonathan Lebon
8fe4536257 lib/commit: don't query devino cache for modified files
We can't use the cache if the file we want to commit has been modified
by the client through the file info or xattr modifiers. We would
prematurely look into the cache in `write_dfd_iter_to_mtree_internal`,
regardless of whether any filtering applied.

We remove that path there, and make sure that we only use the cache if
there were no modifications. We rename the `get_modified_xattrs` to
`get_final_xattrs` to reflect the fact that the xattrs may not be
modified.

One tricky bit that took me some time was that we now need to store the
st_dev & st_ino values in the GFileInfo because the cache lookup relies
on it. I'm guessing we regressed on this at some point.

This patch does slightly change the semantics of the xattr callback.
Previously, returning NULL from the cb meant no xattrs at all. Now, it
means to default to the on-disk state. We might want to consider putting
that behind a flag instead. Though it seems like a more useful behaviour
so that callers can only override the files they want to without losing
original on-disk state (and if they don't want that, just return an
empty GVariant).

Closes: #1165

Closes: #1170
Approved by: cgwalters
2017-09-30 00:05:07 +00:00
Jonathan Lebon
e4a90caeb9 tests/libtest.sh: always nuke repo and files
This allows users to easily re-initialize the test repo.

Closes: #1170
Approved by: cgwalters
2017-09-30 00:05:07 +00:00
Colin Walters
a7f04a14b5 libarchive: Fix assertion error if used with CANONICAL_PERMISSIONS
I was trying to do a change for rpm-ostree to use
`OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS`
for container builds with `bare-user-only,` but hit an assertion here
ultimtely because we weren't setting `standard::type`.

Rather than hand-rolling `GFileInfo` creation, use the stat buffer conversion
code which is more robust and used in multiple places already.

Closes: #1227
Approved by: jlebon
2017-09-28 19:59:24 +00:00
Philip Withnall
6c7302fcdd tests/repo: Drop modeline from top of file
As per commit 6e4146a3.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1203
Approved by: cgwalters
2017-09-28 14:08:40 +00:00
Philip Withnall
467fcff349 tests: Update some tests to use OSTREE_REPO_MODE_ARCHIVE not ARCHIVE_Z2
The latter is deprecated now.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1203
Approved by: cgwalters
2017-09-28 14:08:40 +00:00
Philip Withnall
df1d0a5fc6 tests: Add a manual integration test for OstreeRepoFinderMount
Test an end-to-end flow of pulling refs from an online
repository → local OS repository → create a USB stick of
them → pull to a local OS repository on another machine.

This is a manual test, as it requires a throwaway USB stick which the
test can format as ext4 or vfat to test the flow works with both file
systems.

Run it as:

MOUNT_INTEGRATION_DEV=/dev/sdb1 make check \
  TESTS=tests/test-repo-finder-mount-integration.sh

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1203
Approved by: cgwalters
2017-09-28 14:08:40 +00:00
Colin Walters
15096ac49e tests: Add 404 tests for dirtree objects too
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
2017-09-28 13:05:55 +00:00
Colin Walters
aa067aeafa tree-wide: Bump libglnx, port to new lockfile init
In particular I'd like to get the copy fix in, since it might affect users for
the keyring bits.

Update submodule: libglnx

Closes: #1225
Approved by: jlebon
2017-09-27 20:08:34 +00:00
Colin Walters
5b860fba05 lib/pull: Don't request deltas for unchanged commits
I noticed this while debugging why I was seeing "2 metadata objects" fetched for
a different PR. I knew 1 was detached meta, but the other turned out to be this.

There's no reason to request a delta if the ref is unchanged.

Closes: #1220
Approved by: jlebon
2017-09-27 19:04:11 +00:00
Colin Walters
3314140415 tests/commit-sign: Update a bit to more modern style
I was trying to debug this while working on another PR. Add `echo ok` lines and
also use `assert_file_has_content` more directly; there's no reason to use an
intermediate `grep` since if it fails it won't print the original file.

Closes: #1220
Approved by: jlebon
2017-09-27 19:04:11 +00:00
Colin Walters
d319e75982 lib/diff: Add compile-time ABI check on 64 bit arches
Like what was done for most of the `ostree-repo.h` values.  Prep
for adding a new option.

Closes: #1223
Approved by: jlebon
2017-09-27 18:20:10 +00:00
Colin Walters
b71a913e21 ci: Record primary context results using g-d-t-r --log-directory
So the output isn't all intermingled.  I just pushed a commit
to add `--log-directory`, so we need to build it from git master
for now.

Closes: #1218
Approved by: jlebon
2017-09-27 18:08:06 +00:00
Philip Withnall
9d8c1ec7df lib/repo-pull: Fix remote names in refspecs from non-mirror P2P pulls
Propagate the refspec_name from the OstreeRemote returned by an
OstreeRepoFinder through to the set_ref() call.

This changes ostree_repo_pull_with_options() to accept the
previously-disallowed combination of passing override-remote-name in
options and also setting a remote name in remote_name_or_baseurl.
ostree_repo_pull_with_options() will continue to pull using the remote
config named in remote_name_or_baseurl as before; but will now use the
remote name from override-remote-name when it’s setting the refs at the
end of the pull. This is consistent with the documentation for
override-remote-name.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1202
Approved by: cgwalters
2017-09-27 16:38:07 +00:00
Philip Withnall
69e332a0c0 lib/remote: Store name of remote providing keyring for dynamic remotes
When pulling from a dynamic (peer to peer) remote, the remote’s name is
set to a unique, generated string which doesn’t exist in repo/config. If
doing a non-mirror pull, however, we don’t want to use this name in the
refspecs for newly created or updated refs — we want to use the name of
the remote which provided the keyring for the pull (this will be a
remote from repo/config whose collection ID matches that being used for
the peer to peer pull).

Store both names in OstreeRemote. The name to use for refspecs is stored
as refspec_name, and is typically NULL unless it differs from name.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1202
Approved by: cgwalters
2017-09-27 16:38:07 +00:00
Philip Withnall
22c1fdfbd3 lib/repo: Change resolve_keyring_for_collection() to return a remote
Instead of returning just the keyring filename, return the entire
OstreeRemote, which has the keyring filename as one of its members. This
will simplify some upcoming changes, and allows slightly improved debug
logging.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1202
Approved by: cgwalters
2017-09-27 16:38:07 +00:00