Commit Graph

3230 Commits

Author SHA1 Message Date
Krzesimir Nowak
1ceb17ff11 apidoc: Add missing enums to sections file
So they and their values show up in the documentation.

Closes: #812
Approved by: cgwalters
2017-04-26 11:41:38 +00:00
Colin Walters
3d1b47803f repo: More porting to new style
I was planning to change some of the object loading code in the
future, so here's some porting.

Note that I rewrote `_ostree_repo_has_loose_object()` since it
used an error return across multiple functions.

Honestly I'm not sure about this `TEMP_FAILURE_RETRY()` business...
in reality we're going to end up with a ton of code linked in
process that doesn't do it.  Unix sucks =(  But I'm keeping
what was there out of consistency.

Closes: #809
Approved by: jlebon
2017-04-25 20:01:13 +00:00
Colin Walters
8d58ab1002 repo: Port object listing func to use libglnx more + new style
This did a `closedir` in the `goto out` section before, but it
turns out more nicely if we follow the usual pattern of doing
the `open(O_DIRECTORY)` in the callee function and handle `ENOENT`
there.

Closes: #809
Approved by: jlebon
2017-04-25 20:01:13 +00:00
Colin Walters
e8efd1c8dc checkout: Add SELinux labeling for checkout, use in deploy
This is a variant of the efforts in https://github.com/ostreedev/ostree/pull/741
Working on `rpm-ostree livefs`, I realized though I needed to just
check out *new* files directly into the live `/etc` (and possibly
delete obsolete files).

The way the current `/etc` merge works is fundamentally different from
that.  So my plan currently is to probably do something like:

 - Compute diff
 - Check out each *new* file individually (as a copy)
 - Optionally delete obsolete files

Also, a few other things become more important - in the current deploy code, we
copy all of the files, then relabel them. But we shouldn't expose to *live*
systems the race conditions of doing that, plus we should only relabel files we
checked out.

By converting the deploy's /etc code to use this, we fix the same TODO item
there around atomically having the label set up as we create files. And further,
if we kill the `/var` relabeling which I think is unnecessary since Anaconda
does it, we could delete large chunks of code there.

In the implementation, there are two types of things: regular files, and
symlinks. For regular files, in the `O_TMPFILE` case, we have the ability to
do *everything* atomically (including SELinux labeling) before linking it into
place. So let's just use that. For symlinks, we use `setfscreatecon()`.

Closes: #797
Approved by: jlebon
2017-04-25 16:52:33 +00:00
Colin Walters
654b0c4877 tests/installed: New installed, privileged tests using Fedora AH
Our container-driven tests can't e.g. test SELinux sanely, and
have to support being run as root *and* non-root too.

Use redhat-ci to provision a VM and run tests directly there. These are
installed tests too.

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

Closes: #807
Approved by: jlebon
2017-04-25 15:15:06 +00:00
Colin Walters
8b4196d8f7 tests: Factor out a libtest-core.sh
This could be shared more easily with e.g. rpm-ostree, but what I'm currently
working on is installed, privileged (potentially destructive, i.e. VM) tests
that will source this separately from the current `libtest.sh`. That does work
installed, but in practice is oriented around unit (uninstalled, unprivileged)
tests.

Closes: #807
Approved by: jlebon
2017-04-25 15:15:06 +00:00
Colin Walters
511b31cfb5 checkout: Merge union/add logic for copies during checkout
We really have an astonishing variety of similar functions which write files and
symlinks. I was working on a different PR and the duplication between the
union-mode and add-mode/none-mode checkout functions bothered me.

I realized that the "handle EEXIST" tri-state maps directly to the
`GLnxLinkTmpfileReplaceMode`, so deduping things makes even more sense.

Closes: #801
Approved by: jlebon
2017-04-25 13:52:35 +00:00
Colin Walters
b7afe91e21 repo/checkout: Cache lookups of dirmeta objects
I was reading a strace the other day and noticed we were loading the same
`.dirmeta` object many times. Unlike the other object types, `.dirmeta` objects
don't accumulate much over time; there are only so many directory metadata types.
(Without SELinux involved it'd probably be 5-6 I'd guess offhand).

For `fedora-atomic/25/x86_64/docker-host` there are currently 34 `.dirmeta` in
the tree.

But how many times during a checkout did we load those 34 dirmeta objects?
With a quick strace:

```
$ strace -s 2048 -f -o strace.log ostree --repo=repo-build checkout -U fedora-atomic/25/x86_64/docker-host host-test-checkout
$ grep dirmeta strace.log | wc -l
7165
```

After, as you'd expect, we just loaded `34` from disk.  We do
6 system calls (`openat+fstat+fstat+read+read+close`) per dirmeta,
so we dropped a total of 42780 system calls - which is about 20% of the total
system calls made.

`perf record` tells me that we're spending ~40 of our time in the kernel during
a checkout, so reducing syscall traffic helps. Though most of that appears to be
in the VFS and XFS layers for `linkat` (which isn't surprising).

So how much did perf improve? Well, on my workstation, I get a lot of
fluctuation in timing, sometimes by 30%, so this was well within the noise. But
it's well worth speeding up checkout, and I think this optimization will shine
more as we improve performance elsewhere.

Closes: #795
Approved by: jlebon
2017-04-25 13:40:53 +00:00
Colin Walters
4fc65b808a repo: Drop unused cache variables leftover from pack files
These are leftovers from the packfile code and should have been
deleted in commit: 2a0601efc7

I noticed this now since I wanted to add a new type of caching.

Closes: #795
Approved by: jlebon
2017-04-25 13:40:53 +00:00
Colin Walters
f2e92d81f9 lib/util: Delete some leftover pre-libglnx directory opening functions
These were migrated into libglnx; port the few callers to use that.

Closes: #808
Approved by: jlebon
2017-04-25 13:30:07 +00:00
Colin Walters
55603a0c52 Rename "osname" → "stateroot"
I never really liked the term "osname". I feel "stateroot" is a *lot* clearer,
since the osname/stateroot mostly just holds `/var`. Further it avoids the `os`
prefix which is already overloaded.

Some of the existing docs already talked about "operating system state", which
further reinforces this.

There's *lot* more things than this which reference the term "osname", but I
don't want to change *everything* yet in this patch in case we decide to do
something different - this just gets the highlights.

Closes: #794
Approved by: jlebon
2017-04-24 16:09:51 +00:00
Colin Walters
0c4aeff1cb lib/core: Complete conversion to new code style
No surprises here, all quite straightforward.

Closes: #789
Approved by: jlebon
2017-04-24 15:58:08 +00:00
Colin Walters
6060abbb4b repo: Add a "force copy" flag to checkout
This is intended to be used for copying `/usr/etc` → `/etc` for
deployments.

A TODO here is to use `glnx_file_copy_at()` if the repo mode allows
it - then we'd use reflinks if available.

Closes: #804
Approved by: jlebon
2017-04-24 15:26:11 +00:00
Colin Walters
3f1bcab27f lib/cleanup: Port some of the cleanup code to fd-relative and new style
There aren't many users of `g_file_enumerator_iterate()` left - those
remaining are usually good candidates for porting.  There's some more
porting to do in this file; a mix of trivial and harder.  This
one is a good candidate for an individual commit.

Closes: #803
Approved by: jlebon
2017-04-24 14:45:19 +00:00
Colin Walters
50ca653ff6 repo/checkout: Finish conversion to new code style
I plan to make some future changes here, and wanted to do this
first.

Random side note; how about converting the do/while loops for `EINTR` to
`TEMP_FAILURE_RETRY()`? We're very inconsistent about that...

Closes: #792
Approved by: jlebon
2017-04-20 21:00:34 +00:00
Francesco Giannelli
dea2025531 switchroot: Document a bit more, add demo shell implementation
This could help others who want to integrate with other init
systems/initramfs.

Commit-message-by: Colin Walters <walters@verbum.org>

Closes: #784
Approved by: cgwalters
2017-04-19 18:52:05 +00:00
Colin Walters
49a525f6a5 repo: Optimize bare-user content object reads a bit
`perf record ostree checkout ...` for a bare-user repo was telling
me we were spending a good 13% of our time in the depchain of `ot_lgexattrat()`.
The problem here is that traversing the `/proc` path turns out to be
somewhat expensive - there are LSM (SELinux) checks, etc.

For regular files, opening and just getting the xattr, then closing is still
quite cheap. For symlinks, we'll always need to open anyways.

This appears to shave about ~0.1 seconds off of a checkout of
`fedora-atomic/25/x86_64/docker-host` on my workstation.

Oh, and this was the last user of `ot_lgexattrat()` so we can kill it, which is
nice - the xattr code should really live in libglnx.

Closes: #796
Approved by: jlebon
2017-04-19 15:00:08 +00:00
Colin Walters
0d8cd2f077 cmdline: Start conversion to new code style
This is just a few.  I'm tempted to try out the coccinelle
patch for this.

Closes: #793
Approved by: jlebon
2017-04-19 14:41:00 +00:00
Colin Walters
d197bfd133 sysroot: Continue conversion of some simpler functions to new style
This is only about 40%, and mostly simpler functions.  It's
nice to switch to `g_autoptr(GMatchInfo)` instead of our inline version.

I decided to add more usage of `ot_transfer_out_value()`, though it'd
be nice to try to have a copy of that in libglnx (or possibly glib).

Closes: #791
Approved by: jlebon
2017-04-19 14:10:24 +00:00
Colin Walters
44456c6dc1 lib/boot: Convert bootconfig parser to new code style
This is a small one.

Closes: #790
Approved by: jlebon
2017-04-19 13:26:20 +00:00
Colin Walters
f6f967f8d9 Bump release for 2017.5
This commit won't actually *be* 2017.5 since due to the way our infrastructure
works, we still want to increment git master to 2017.5.

See https://github.com/ostreedev/ostree/pull/800

Closes: #800
Approved by: jlebon
2017-04-18 18:21:13 +00:00
Colin Walters
08964d595d checkout: Fix bare-user symlink checkouts
Logic error introduced after refactoring; we hoisted the
`is_bare_user_symlink` variable to the top, but its computation
below.  But the `is_bare` symlink depended on it.

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

Closes: #799
Approved by: jlebon
2017-04-18 14:35:45 +00:00
Colin Walters
b9df96db8b pull: Support deltas for explicit commits
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
2017-04-12 21:30:33 +00:00
Colin Walters
8742287b11 Release 2017.4
Closes: #786
Approved by: jlebon
2017-04-12 18:41:22 +00:00
Colin Walters
d3385a3014 checkout: Provide useful error with checkout -H and incompat mode
Previously we'd assert and dump core if one used `checkout -H` without
`-U` on a bare-user repo, because we'd hit the bare-user symlink case.

Rework the code to handle this, and add tests. I hit this when I was going to
suggest to someone to use `-H` to ensure they were getting hardlinks.

Closes: #779
Approved by: jlebon
2017-04-12 17:06:44 +00:00
Colin Walters
6a7ee4860f Fix a few gtk-doc warnings
Just continuing to chip away at this.

Closes: #788
Approved by: jlebon
2017-04-12 15:36:46 +00:00
Colin Walters
076dfeba6b curl: Enable pipelining for HTTP/2
Testing a fetch of `fedora-atomic/.../docker-host` from
an nginx instance over `https://127.0.0.1` using Fedora 25
versions.  Average over 3 runs:

Before: ~24.6 seconds
After: ~19 seconds

Speedup: ~30%

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

Closes: #780
Approved by: jlebon
2017-04-12 15:25:40 +00:00
Colin Walters
6fa0fa750f sysroot/deploy: More code style conversion
In particular the 26-variable monster 👹 in `install_deployment_kernel()` is
slain🗡. I didn't touch every function here, trying to keep things gradual.

Closes: #781
Approved by: jlebon
2017-04-11 16:42:13 +00:00
Colin Walters
89d663d94a soup: Hold a ref to the pending URI during completion processing
It was reported that in the range request handling, we called `remove_pending()`
twice (once in processing it, and once potentially in the local_error cleanup),
and this could be viewed as a use-after-free. However, right now the range
cleanup and `local_error` being set are mututally exclusive.
Further, the task object already holds a strong reference, so I observed the
refcount was 2. For both of these reasons, there is no use-after-free in
practice.

Reported-By: "Siddharth Sharma" <siddharth@redhat.com>

Closes: #774
Approved by: jlebon
2017-04-05 20:44:11 +00:00
Colin Walters
a0e15ecbed repo/core: Convert some functions to new code style
I was planning to change one here, decided to do a conversion
of some of the simpler functions in this file to keep up momentum.

Closes: #776
Approved by: jlebon
2017-04-05 17:57:20 +00:00
Colin Walters
c937305c0e core: Fix default value of disable_xattrs
Sigh.  Rather awful regression from https://github.com/ostreedev/ostree/pull/759

Closes: #775
Approved by: jlebon
2017-04-04 15:54:46 +00:00
Colin Walters
b74e4e79cc ci: Add a check that submodule changes include "Update submodule: "
To prevent repeats of https://github.com/ostreedev/ostree/pull/693

I tested this script in https://github.com/cgwalters/playground/pull/48

Closes: #770
Approved by: jlebon
2017-04-04 15:44:19 +00:00
Colin Walters
9016e9e8be Add flag to make SELinux label failure fatal, add hack for /proc
I was working on `rpm-ostree livefs` which does some ostree-based
filesystem diffs, and noticed that we were ending up with `/proc`
not being labeled in our base trees.

Reading the selinux-policy source, indeed we have:

```
/proc			-d	<<none>>
/proc/.*			<<none>>
```

This dates pretty far back.  We really don't want unlabeled
content in ostree.  In this case it's mostly OK since the kernel
will assign a label, but again *everything* should be labeled via
OSTree so that it's all consistent, which will fix `ostree diff`.

Notably, `/proc` is the *only* file path that isn't covered when composing a
Fedora Atomic Host. So I added a hack here to hardcode it (although I'm a bit
uncertain about whether it should really be `proc_t` on disk before systemd
mounts or not).

Out of conservatism, I made this a flag, so if we hit issues down the line, we
could easily change rpm-ostree to stumble on as it did before.

Closes: #768
Approved by: jlebon
2017-04-04 15:31:49 +00:00
Colin Walters
8d4dec1b53 sepolicy: Fix regressions from introduction of sepolicy_new_at()
Being bitten by lack of PR testing here.  There are two bugs:

- First and foremost, I forgot that GObject will call the property setters with
  the defaults.  This meant we were getting both path="/var/tmp/blah" and fd=-1,
  and we were accepting -1 as a fd, which then got converted into AT_FDCWD
  which was wrong.
- Since these properties are construct only and mutually exclusive, don't
  try to handle one resetting the other.  Assert that exactly one of them is set.

Closes: #769
Approved by: jlebon
2017-03-30 19:49:46 +00:00
Colin Walters
305db981d4 Add Coccinelle usage: one for blacklisting, one for patch collection
This is inspired by the [Coccinelle](http://coccinelle.lip6.fr/) usage
in systemd.  I also took it a bit further and added infrastructure
to have spatches which should never apply.  This acts as a blacklist.

The reason to do the latter is that coccinelle is *way* more powerful than the
regular expresssions we have in `make syntax-check`.

I started with blacklisting `g_error_free()` directly. The reason that's bad is
it leaves a dangling pointer.

Closes: #754
Approved by: jlebon
2017-03-30 19:19:54 +00:00
Colin Walters
ee626c2654 libutil: Delete some unused error handling APIs
The first one is better as `err`, the second might as well just call `err` too.

Closes: #767
Approved by: jlebon
2017-03-30 13:14:43 +00:00
Colin Walters
5f45ab0bb1 libutil: Delete some unused checksum helper API
This code was last used in 9618232f4d
which is sooo old and outdated.  Delete.

Closes: #767
Approved by: jlebon
2017-03-30 13:14:43 +00:00
Colin Walters
0ce7ab3827 libutil: Delete unused GVariant I/O functions
These are dead due to fd-relative porting probably.

Closes: #767
Approved by: jlebon
2017-03-30 13:14:43 +00:00
Colin Walters
2571e21b41 libutil: Delete unused threadpool wrapper
This is dead code since 9cc9804195 where
pull-local became just a wrapper for pull, which has its own threading.

Closes: #767
Approved by: jlebon
2017-03-30 13:14:43 +00:00
Colin Walters
8fea1937df lib: Delete old unused GFile helpers
This is all unused since the fd-relative/no-GFile porting. Delete delete delete!

Closes: #767
Approved by: jlebon
2017-03-30 13:14:43 +00:00
Colin Walters
8392faaffc lib: Delete old GFile path helpers, and migrate single last user
I happened to read this file and realized there's a lot of cruft left over from
the time when I liked `GFile` and `malloc()`ing like 50 times just to make a
pathname string. Delete it.

Closes: #767
Approved by: jlebon
2017-03-30 13:14:43 +00:00
Colin Walters
b51ce8cb0a lib: Fix OSTREE_CHECK_VERSION()
Actually trying to use this in rpm-ostree, it kept returning successfully when I
didn't expect it to... The first conditional was always succeeding even when I
was asking for a newer minor.

Closes: #766
Approved by: jlebon
2017-03-28 20:41:28 +00:00
Colin Walters
97961ed2ce build: Expose autocleanups unconditionally, start using them
I'd like to do this in rpm-ostree at least. Originally I was looking at porting
to `G_DECLARE_FINAL_TYPE` but eh, this is easier for now and won't bump our GLib
dependency which might matter for our embedded users.

For now I just did a few replacements in the `remote` command line. A full port
can come as we do other code cleanups.

This will actually break the flatpak build right now, but
that's easy to fix.  And we concluded in e.g.
https://bugs.freedesktop.org/show_bug.cgi?id=95065#c5
it's a bug for downstream projects to do that.

Closes: #756
Approved by: jlebon
2017-03-28 20:19:15 +00:00
Colin Walters
d994aee0a1 repo/commit: Change most of this file to new code style
I didn't touch everything since at least `commit_loose_object_trusted`
does this:

```
 out:
  if (G_UNLIKELY (error && *error))
    g_prefix_error (error, "Writing object %s.%s: ", checksum, ostree_object_type_to_string (objtype));
```

Which...it'd be interesting to make into an autocleanup. But for now just
keeping up with converting things bit by bit.

Closes: #761
Approved by: jlebon
2017-03-28 19:29:54 +00:00
Colin Walters
5333a429ce sysroot: Don't cache sepolicy
In [this commit](6ce80f9685)
for some reason I added a `sepolicy` member to the sysroot.  I
have no idea why I did that, and it's conceptually wrong
since the policy is specific to a *deployment*.

This bit me when I was working on [a pull request](https://github.com/ostreedev/ostree/pull/763)
elsewhere, since at that point it was `NULL`.

We already pass around the sepolicy in the deployment code, so just stop caching
it.

Closes: #764
Approved by: jlebon
2017-03-28 19:09:58 +00:00
Colin Walters
562cb55f51 ci: Enable -Werror=unused-result with -Wp,-D_FORTIFY_SOURCE=2
(Also rename the other CI contexts to be more consistent)

We pass this right now. I just noticed an instance of this in bwrap, and I think
we should be trying to match the RPM build baseline.

Closes: #765
Approved by: jlebon
2017-03-28 18:56:18 +00:00
Daniel J Walsh
a88881039e sysroot/unlock: Ensure overlay label on /usr is usr_t
Otherwise, we get `tmp_t` by default which can break a lot of things; we noticed
this with `atomic scan`.

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

Closes: #763
Approved by: rhatdan
2017-03-28 13:50:28 +00:00
Colin Walters
79c3eb63be pull: Also skip partial commits for deltas if no summary file
I was playing around in a FAH vagrant box, and hit:

```
Receiving delta parts: 3/4 453.2 kB/s 1.8 MB/145.8 MB
error: opcode set-read-source: No such file object b6e54ba3471b9c116ce6b9bfbf9e55fec60d35cfdb9ae5ae1ee219af02a591b7
```

This is because this host version doesn't yet have
https://github.com/ostreedev/ostree/pull/710
which incidentally fixed this for the case where the OS vendor is using
summary files.

Some organizations may not be using summary files - at least we still try to
support that case. So let's copy the logic very recently added in that commit to
handle the legacy case too.

No new tests since this is a nice-to-have - we really do
expect people to be using summary files now.

Closes: #739
Approved by: jlebon
2017-03-27 17:51:11 +00:00
Anton Gerasimov
3b09620c27 Define TARGET_PREFIX to use with grub2 deployment
Closes: #760
Approved by: cgwalters
2017-03-27 15:49:50 +00:00
Alexander Larsson
7c8f95c86f Add basic tests for bare-user-only repo modes
This is somewhat complicated by such repos only properly supporting
some subset of file metadata (uid/gid 0, etc). We fix this by
always commiting with filters that make it work.

Closes: #750
Approved by: cgwalters
2017-03-27 13:48:41 +00:00