ostree.git
8 years agolib: Define an alias OSTREE_REPO_MODE_ARCHIVE
Colin Walters [Thu, 21 Sep 2017 19:48:46 +0000 (15:48 -0400)]
lib: Define an alias OSTREE_REPO_MODE_ARCHIVE

For the old `OSTREE_REPO_MODE_ARCHIVE_Z2`.  Use it mostly tree
wide except for the repo finder tests (to avoid conflicting with
some outstanding PRs).

Just noted another user coming in some of those tests and wanted to do a
cleanup.

Closes: #1209
Approved by: jlebon

8 years agolib/core: Add static assertions for OstreeRepoMode enum values
Colin Walters [Thu, 21 Sep 2017 19:44:24 +0000 (15:44 -0400)]
lib/core: Add static assertions for OstreeRepoMode enum values

Prep for adding an alias.

Closes: #1209
Approved by: jlebon

8 years agoAdd a .vimrc and .editorconfig
Jonathan Lebon [Thu, 21 Sep 2017 19:46:17 +0000 (19:46 +0000)]
Add a .vimrc and .editorconfig

The `.vimrc` requires the `exrc` option to be turned on, and
`.editorconfig` requires https://github.com/editorconfig/editorconfig-vim
apparently.

Closes: #1208
Approved by: cgwalters

8 years agotests/libtest: check that we have setfattr
Jonathan Lebon [Wed, 20 Sep 2017 17:07:54 +0000 (17:07 +0000)]
tests/libtest: check that we have setfattr

We use `setfattr` to determine whether the filesystem we're on supports
xattrs, but we need to check that `setfattr` itself is available. We
just make it a hard requirement but only if trying to run tests that ask
about xattr support.

Closes: #1207
Approved by: cgwalters

8 years agotests: allow specifying tmpdir
Jonathan Lebon [Wed, 20 Sep 2017 17:06:41 +0000 (17:06 +0000)]
tests: allow specifying tmpdir

Allow developers to override the default /var/tmp dir, which e.g. might
be on overlayfs and thus produces reduced coverage.

Closes: #1207
Approved by: cgwalters

8 years agotree-wide: Remove Emacs modelines
Colin Walters [Thu, 21 Sep 2017 19:26:06 +0000 (15:26 -0400)]
tree-wide: Remove Emacs modelines

We added a `.dir-locals.el` in commit: 9a77017d87b74c5e2895cdd64ad098018929403f
There's no need to have it per-file, with that people might think
to add other editors, which is the wrong direction.

Closes: #1206
Approved by: jlebon

8 years agolib/repo: Add ostree_repo_hash() and tests
Philip Withnall [Thu, 21 Sep 2017 19:22:09 +0000 (20:22 +0100)]
lib/repo: Add ostree_repo_hash() and tests

Add a hash function for OstreeRepo instances, which relies on the repo
being open, and hence being able to hash the device and inode of its
root directory.

Add unit tests for this and ostree_repo_equal().

Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://github.com/ostreedev/ostree/issues/1191

Closes: #1205
Approved by: cgwalters

8 years agolib/repo: Use correct name for tmpdir lockfile
Colin Walters [Thu, 21 Sep 2017 18:50:54 +0000 (14:50 -0400)]
lib/repo: Use correct name for tmpdir lockfile

Such an evil bug ðŸ™ˆ. I was just reading an strace trying to figure out what was
going on, and noticed we had the `XXXXXX` in the lockfile name. It was only
after that I realized that that this might *be* the cause of the skopeo issue.

This is another case where we definitely need more test coverage of things that
actually use the API multiple times in process; might look at dusting off the
work for the rpm-ostree test.

Closes: https://github.com/ostreedev/ostree/issues/1196
Closes: #1204
Approved by: jlebon

8 years agoci: Add an "all options disabled" context
Colin Walters [Tue, 19 Sep 2017 19:19:05 +0000 (15:19 -0400)]
ci: Add an "all options disabled" context

We keep occasionally regressing this so let's start covering it now. I'm
intentionally not running the tests since that would likely entail a lot more
conditionalizing pain.

Closes: #1194
Approved by: jlebon

8 years agolib/commit: Don't try to call linkat() for import on distinct devices
Colin Walters [Tue, 19 Sep 2017 19:07:30 +0000 (15:07 -0400)]
lib/commit: Don't try to call linkat() for import on distinct devices

While opening a repo we've recorded the device/inode for a while; use it to
avoid calling `linkat()` during object import if we know it's going to fail.

Closes: #1193
Approved by: jlebon

8 years agolib: Move bareuseronly verification into commit/core
Colin Walters [Mon, 18 Sep 2017 19:46:03 +0000 (15:46 -0400)]
lib: Move bareuseronly verification into commit/core

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

8 years agorofiles-fuse: also pass mode for O_RDONLY
Jonathan Lebon [Wed, 20 Sep 2017 18:38:16 +0000 (18:38 +0000)]
rofiles-fuse: also pass mode for O_RDONLY

In the `O_RDONLY` case, we were calling `openat` without a mode
argument. However, it's perfectly legal (albeit unusual) to do
`open(O_RDONLY|O_CREAT)`. One such application that makes use of this is
`flock(1)`.

This was actually caught by `_FORTIFY_SOURCE=2`, and once we run
`rofiles-fuse` with `-f`, the message is clear:

```
*** invalid openat64 call: O_CREAT or O_TMPFILE without mode ***:
rofiles-fuse terminated
======= Backtrace: =========
/lib64/libc.so.6(+0x7c8dc)[0x7f36d9f188dc]
/lib64/libc.so.6(__fortify_fail+0x37)[0x7f36d9fbfaa7]
/lib64/libc.so.6(+0x10019a)[0x7f36d9f9c19a]
rofiles-fuse[0x401768]
...
```

Without `_FORTIFY_SOURCE`, the file gets created, but its mode is
completely random.

I ran into this while investigating
https://github.com/projectatomic/rpm-ostree/pull/1003.

Closes: #1200
Approved by: cgwalters

8 years agotree-wide: Squash a few warnings when building with no features
Colin Walters [Thu, 21 Sep 2017 15:01:29 +0000 (11:01 -0400)]
tree-wide: Squash a few warnings when building with no features

Noticed these since I had a local configured build with no features for testing
the PAPR context for it.

Closes: #1201
Approved by: jlebon

8 years agolib/checkout: Squash a gcc maybe-uninitialized warning
Colin Walters [Thu, 21 Sep 2017 15:00:47 +0000 (11:00 -0400)]
lib/checkout: Squash a gcc maybe-uninitialized warning

gcc doesn't know that our enum cases must be exhaustive.

Closes: #1201
Approved by: jlebon

8 years agolib/repo: Move alloca() outside of loop
Colin Walters [Thu, 21 Sep 2017 15:00:09 +0000 (11:00 -0400)]
lib/repo: Move alloca() outside of loop

Just noticed this while looking at the code for a different issue.

Closes: #1201
Approved by: jlebon

8 years agolib/repo: Don't syncfs or fsync() dirs if fsync opt is disabled
Colin Walters [Mon, 18 Sep 2017 18:29:16 +0000 (14:29 -0400)]
lib/repo: Don't syncfs or fsync() dirs if fsync opt is disabled

There are use cases for not syncing at all; think build cache repos, etc. Let's
be consistent here and make sure if fsync is disabled we do no sync at all.

I chose this opportunity to add tests using the shiny new strace fault
injection.  I can forsee using this for a lot more things, so I made
the support for detecting things generic.

Related: https://github.com/ostreedev/ostree/issues/1184

Closes: #1186
Approved by: jlebon

8 years agotests/libtest: Factor out user xattr detection
Colin Walters [Mon, 18 Sep 2017 17:58:54 +0000 (13:58 -0400)]
tests/libtest: Factor out user xattr detection

Make the equivalent of a `GOnce` or Rust `lazy_static!` detecting this and share
it between the two callers.

Prep for a future similar patch for strace fault injection.

Closes: #1186
Approved by: jlebon

8 years agolib/pull: Clarify use of unsigned summary support
Matthew Leeds [Tue, 19 Sep 2017 23:34:11 +0000 (16:34 -0700)]
lib/pull: Clarify use of unsigned summary support

Update the comments and remove an unneeded variable to make it clear
that the find_remotes_async() / pull_from_remotes_async() functions use
the unsigned summary support.

This is a follow-up of commit 8c148eb7e "lib/repo-finder: Emit
gpg-verify-summary=false in dynamic remote config".

Closes: #1195
Approved by: pwithnall

8 years agotests: Reset umask to 022 while creating test repository
Simon McVittie [Tue, 19 Sep 2017 17:37:58 +0000 (18:37 +0100)]
tests: Reset umask to 022 while creating test repository

In test-basic-root.sh we make assertions about the permissions
of files like baz/cow, which were created without an explicit chmod.
We can't do that unless we control the permissions.

For some reason the "debomatic" autobuilder used to do some Debian
archive rebuilds does the entire build including build-time tests
as uid 0 with umask 002, which broke those assertions. This seems
a weird thing to do, and I've opened a bug, but it also seems
reasonable to fix this test.

This also lets us remove a couple of existing workarounds for the
same issue.

Bug-Debian: https://bugs.debian.org/876138
Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #1192
Approved by: cgwalters

8 years agoAdd support for pkcs11 URIs in TLS client key/certificate
Anton Gerasimov [Mon, 18 Sep 2017 14:29:27 +0000 (16:29 +0200)]
Add support for pkcs11 URIs in TLS client key/certificate

Closes: #1183
Approved by: cgwalters

8 years agolib/pull: Wait for pending ops to complete on error
Colin Walters [Mon, 18 Sep 2017 16:08:48 +0000 (12:08 -0400)]
lib/pull: Wait for pending ops to complete on error

I saw in a stack trace that the main thread was calling `exit()` even while
worker threads were alive and doing sha256/write/fsync etc. for objects.

The stack trace was a SEGV as the main thread was calling into library
`atexit()` handlers and we were a liblz4 destructor:

```
 #0  0x00007f2db790f8d4 _fini (liblz4.so.1)
 #1  0x00007f2dbbae1c68 __run_exit_handlers (libc.so.6)
```

(Why that library has a destructor I don't know offhand, can't find
 it in the source in a quick look)

Anyways, global library destructors and worker threads continuing simply don't
mix. Let's wait for our outstanding operations before we exit. This is also a
good idea for projects using libostree as a shared library, as we don't want
worker threads outliving operations.

Our existing pull corruption tests exercise coverage here.

I added a new `caught-error` status boolean to the progress API, and use it the
commandline to tell the user that we're waiting for outstanding ops.

Closes: #1185
Approved by: jlebon

8 years agolib/repo: Minor cleanup to object import function
Colin Walters [Mon, 18 Sep 2017 19:46:03 +0000 (15:46 -0400)]
lib/repo: Minor cleanup to object import function

We have a lot of layers of abstraction here; let's fold in the `trusted`
conditional into the call, since that's all the public API we're using does
anyways.

Prep for a future patch around object copying during imports.

Closes: #1187
Approved by: jlebon

8 years agotests: Explicitly unset LANGUAGE after setting LC_ALL
Simon McVittie [Tue, 19 Sep 2017 13:41:18 +0000 (14:41 +0100)]
tests: Explicitly unset LANGUAGE after setting LC_ALL

As a GNU extension, LANGUAGE takes precedence over LC_ALL for
gettext(3) whenever the locale is not C, causing tests that grep for
specific English strings to fail when run in non-English locales.
The upstream glibc proposal for C.UTF-8 would give C.UTF-8 the same
special case as C here, but the implementation in Debian does not
currently have this, so we have to unset LANGUAGE too.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #1188
Approved by: jlebon

8 years agotree-wide: Some glnx_fstatat_allow_noent() porting
Colin Walters [Fri, 15 Sep 2017 20:29:22 +0000 (16:29 -0400)]
tree-wide: Some glnx_fstatat_allow_noent() porting

The new API is definitely nicer.

Closes: #1180
Approved by: jlebon

8 years agolib/repo: Drop outdated FIXME comment from ostree-repo.h
Philip Withnall [Fri, 15 Sep 2017 15:03:36 +0000 (16:03 +0100)]
lib/repo: Drop outdated FIXME comment from ostree-repo.h

This was some incomplete planning from while the find_remotes() API was
being designed; now totally outdated.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1179
Approved by: cgwalters

8 years agolib/repo-finder-mount: Change the schema for finding repos on volumes
Philip Withnall [Fri, 15 Sep 2017 14:59:32 +0000 (15:59 +0100)]
lib/repo-finder-mount: Change the schema for finding repos on volumes

See issue #1174 for the rationale behind this. In summary:
 â€¢ It required two lists of collection–refs to be maintained: one in the
   repository, and one pointing to the repository.
 â€¢ It didn’t automatically work for live USBs of OSs based on OSTree
   (where there’s always a repository at /ostree/repo).
 â€¢ It was unnecessarily complex.

The new scheme allows a list of repositories to be searched, but without
needing a layer of indirection through their collection–refs. It adds
/ostree/repo and /.ostree/repo as well-known repository locations which
are always checked on a mounted volume (if they exist).

Update the unit tests accordingly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://github.com/ostreedev/ostree/issues/1174

Closes: #1179
Approved by: cgwalters

8 years agolib/repo: Add ostree_repo_equal() for comparing repos
Philip Withnall [Fri, 15 Sep 2017 14:26:22 +0000 (15:26 +0100)]
lib/repo: Add ostree_repo_equal() for comparing repos

This will compare their root directory inodes to see if they are the
same repository on disk. A convenience method for the users of the
public API who can’t access OstreeRepo.inode.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1179
Approved by: cgwalters

8 years agoci: Use distro-sync instead of upgrade
Colin Walters [Tue, 19 Sep 2017 13:46:17 +0000 (09:46 -0400)]
ci: Use distro-sync instead of upgrade

This should help ensure that if installing `glibc-devel` downgrades `glibc`
we'll run through our hackround for
<https://bugzilla.redhat.com/show_bug.cgi?id=1394862>.

Closes: #1190
Approved by: jlebon

8 years agobin/prune: Add --only-branch
Colin Walters [Fri, 1 Sep 2017 19:55:17 +0000 (15:55 -0400)]
bin/prune: Add --only-branch

In 5c940987e768523ef1411b65bcaad09fba6befef / #646 we
added `--retain-branch-depth`; this adds a symmetric
`--only-branch` for the case where a repo owner just
wants to prune a specific branch.

The implementation here is pretty straightforward; we
just walk all refs and inject the equivalent of
`--retain-branch-depth=$ref=-1` if they're *not* in
`--only-branch`.

Closes: https://github.com/ostreedev/ostree/issues/1115
Closes: #1127
Approved by: jlebon

8 years agotests/prune: Factor out a helper for counting commits in the repo
Colin Walters [Fri, 1 Sep 2017 20:24:31 +0000 (16:24 -0400)]
tests/prune: Factor out a helper for counting commits in the repo

We had lots of duplicates; prep for adding more tests.

Closes: #1127
Approved by: jlebon

8 years agoUpdate libglnx
Colin Walters [Tue, 12 Sep 2017 13:40:58 +0000 (09:40 -0400)]
Update libglnx

Update libglnx, which is mostly port the repo stagedir code
to the new tmpdir API.  This turned out to require some
libglnx changes to support de-allocating the tmpdir ref while
still maintaining the on-disk dir.

Update submodule: libglnx

Closes: #1172
Approved by: jlebon

8 years agobin/commit: Fix build failure when libarchive is not used
yceh [Mon, 18 Sep 2017 13:10:52 +0000 (13:10 +0000)]
bin/commit: Fix build failure when libarchive is not used

A `"}"` at line 641 is missing when `HAVE_LIBARCHIVE` is not defined
(even though probably few will use ostree without libarchive).

Closes: #1181
Approved by: jlebon

8 years agotest-help.sh: Skip trivial-httpd if enabled
Simon McVittie [Fri, 15 Sep 2017 15:05:48 +0000 (16:05 +0100)]
test-help.sh: Skip trivial-httpd if enabled

Because it runs a binary in ${libexecdir}, it will only work if
libostree was already installed, which makes the build-time test fail.
It also doesn't produce the output we expect: its usage mechanism
mentions "ostree-trivial-httpd", not "ostree trivial-httpd".

Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #1177
Approved by: jlebon

8 years agotests: Fix JavaScript tests with gjs 1.50.0
Simon McVittie [Fri, 15 Sep 2017 14:32:55 +0000 (15:32 +0100)]
tests: Fix JavaScript tests with gjs 1.50.0

In recent gjs, you can't declare a variable with "let" multiple times.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #1178
Approved by: cgwalters

8 years agolib/pull: Drop partial fetch code from libsoup backend
Colin Walters [Thu, 14 Sep 2017 19:10:54 +0000 (15:10 -0400)]
lib/pull: Drop partial fetch code from libsoup backend

Doing this in prep for libglnx tmpdir porting, but I think we should also do
this because the partial fetch code IMO was never fully baked; among other
things it was never integrated into the scheme we came up with for "boot id
sync" that we use for complete/staged objects.

There's a lot of complexity here that while we have some coverage for, I think
we need to refocus on the core functionality. The libcurl backend doesn't have
an equivalent to this today.

In particular for small objects, this is simply overly complex. The downside is
clearly for large objects like FAH's 61MB initramfs; not being able to resume
fetches of those is unfortunate.

In practice though, I think most people should be using deltas, and we need to
make sure deltas work for large objects anyways.

Further ultimately the peer-to-peer work should help a lot for people
with truly unreliable connections.

Closes: #1176
Approved by: jlebon

8 years agolib/checkout: Do UNION_FILES via atomic renameat()
Colin Walters [Wed, 13 Sep 2017 20:22:18 +0000 (16:22 -0400)]
lib/checkout: Do UNION_FILES via atomic renameat()

I was looking at fixing an `rpm-ostree livefs` bug where we need to replace
`/usr/lib/passwd`. It's obviously bad if that temporarily disappears ðŸ˜‰. My plan
is to do a subpath checkout of just `/usr/lib/{passwd,group}`.

Make this atomic (i.e. file always exists) by changing the logic to create a
temporary link in repo/tmp, then rename() it into place.

A bonus here is we kill one of the very few (only?) non-error-cleanup i.e.
"non-linear" `goto`s in the ostree codebase.

Closes: #1171
Approved by: jlebon

8 years agolib/repo: Port gpg signing function to new code style
Colin Walters [Tue, 12 Sep 2017 20:58:58 +0000 (16:58 -0400)]
lib/repo: Port gpg signing function to new code style

We already had all of the autocleanups ready for this.

Closes: #1164
Approved by: jlebon

8 years agobuild-sys: Post-release version bump
Jonathan Lebon [Thu, 14 Sep 2017 18:53:57 +0000 (18:53 +0000)]
build-sys: Post-release version bump

Closes: #1175
Approved by: cgwalters

8 years agoRelease 2017.11
Colin Walters [Thu, 14 Sep 2017 14:44:04 +0000 (10:44 -0400)]
Release 2017.11

Closes: #1173
Approved by: jlebon

8 years agotests: Port some bits of C to new style
Colin Walters [Wed, 13 Sep 2017 16:09:51 +0000 (12:09 -0400)]
tests: Port some bits of C to new style

Where we can; perhaps after updating libglnx we should use the
new test error macro?

Closes: #1169
Approved by: jlebon

8 years agolib/checkout: Rename disjoint union, change to merge identical files
Colin Walters [Fri, 8 Sep 2017 21:07:45 +0000 (17:07 -0400)]
lib/checkout: Rename disjoint union, change to merge identical files

It turns out that librpm automatically merges identical files between
distinct packages, and this occurs in practice with Fedora today between
`chkconfig` and `initscripts` for exmaple.

Since we added this for rpm-ostree, we basically want to do what librpm does,
let's change the semantics to do a merge.  While we're here rename
to `UNION_IDENTICAL`.

Closes: #1156
Approved by: jlebon

8 years agolib/repo: Port tmpdir locking func to new style
Colin Walters [Tue, 12 Sep 2017 14:31:39 +0000 (10:31 -0400)]
lib/repo: Port tmpdir locking func to new style

Prep for future work.

Closes: #1168
Approved by: jlebon

8 years agobuild-sys: Add -Werror=switch
Colin Walters [Wed, 13 Sep 2017 15:18:04 +0000 (11:18 -0400)]
build-sys: Add -Werror=switch

We use the "exhaustive enum" pattern (i.e. no `default:`) in some places so
we're forced to touch all users when adding cases.

Closes: #1167
Approved by: peterbaouoft

8 years agorepo: Ensure new config doesn't set remotes in separate file
Dan Nicholson [Mon, 11 Sep 2017 17:57:42 +0000 (12:57 -0500)]
repo: Ensure new config doesn't set remotes in separate file

If the new configuration passed to ostree_write_config () tries to
update options for a remote defined in a separate config file, return an
error. Without this, the full configuration would contain duplicate
remote specifications, which would raise an error the next time the repo
is opened.

Closes: #1159
Approved by: cgwalters

8 years agobin/remote: don't load repo on root command
Jonathan Lebon [Mon, 11 Sep 2017 21:06:30 +0000 (21:06 +0000)]
bin/remote: don't load repo on root command

Subcommands will demand a repo argument themselves. This allows one to
call `ostree remote` and get the "No subcommand" error rather than the
"Missing --repo" error.

Closes: #1126
Approved by: cgwalters

8 years agobin/admin: Don't load sysroot for root commands
Jonathan Lebon [Fri, 8 Sep 2017 19:40:59 +0000 (15:40 -0400)]
bin/admin: Don't load sysroot for root commands

There's no need to load the sysroot for root commands which have
subcommands, like `ostree admin` and `ostree admin instutil`. Otherwise,
even just calling them without arguments will cause a failure. The
subcommands will have the appropriate flags set as needed.

Closes: #1126
Approved by: cgwalters

8 years agobin/static-delta: Convert to new style and tweak output
Jonathan Lebon [Tue, 5 Sep 2017 18:27:20 +0000 (14:27 -0400)]
bin/static-delta: Convert to new style and tweak output

Convert the whole file to new style. Also tweak the help outputs to make
it similar enough to the other commands for tests to pass. Of course, we
should just centralize all subcommand handling the same way it was done
in rpm-ostree, though let's punt on that for now.

Closes: #1126
Approved by: cgwalters

8 years agobin/admin: Don't require root for instutil
Jonathan Lebon [Tue, 5 Sep 2017 18:27:20 +0000 (14:27 -0400)]
bin/admin: Don't require root for instutil

Otherwise, we can't even do `--help` on it. The subcommands all already
have the root flag set.

Closes: #1126
Approved by: cgwalters

8 years agotests/test-help.sh: Rework and strengthen checks
Jonathan Lebon [Tue, 5 Sep 2017 18:27:20 +0000 (14:27 -0400)]
tests/test-help.sh: Rework and strengthen checks

The `sed` expression wasn't actually matching the main output, so we
weren't recursing into the subcommands. Update the syntax to match the
current output and add a check so we don't miss that happening again.

Add a check that the help output is only printed once in all
circumstances. Also add a check for proper handling of non-existent
commands.

Closes: #1126
Approved by: cgwalters

8 years agobin/config: Tweak parameter string
Jonathan Lebon [Fri, 1 Sep 2017 19:52:13 +0000 (15:52 -0400)]
bin/config: Tweak parameter string

Make the parameter string more detailed.

Closes: #1126
Approved by: cgwalters

8 years agobin/main: Print usage when no command given
Jonathan Lebon [Fri, 1 Sep 2017 19:44:49 +0000 (15:44 -0400)]
bin/main: Print usage when no command given

Minor regression from https://github.com/ostreedev/ostree/pull/1106. We
want to print the usage text both when unknown commands are passed, as
well as when no commands are passed at all.

Closes: #1126
Approved by: cgwalters

8 years agolib/sysroot: Use direct g_mkdtemp() for overlay tmpdir
Colin Walters [Tue, 12 Sep 2017 14:21:17 +0000 (10:21 -0400)]
lib/sysroot: Use direct g_mkdtemp() for overlay tmpdir

The new libglnx `glnx_mkdtempat()` uses autocleanups, which
is inconvenient for this use case where we *don't* want autocleanups.
Since we don't need it to be fd-relative, just directly invoke
`g_mkdtemp_full()` which is fine for this use case.

Prep for updating libglnx.

Closes: #1161
Approved by: jlebon

8 years agoci: Fixate CentOS container image until rpm-md repos sync
Colin Walters [Tue, 12 Sep 2017 13:46:05 +0000 (09:46 -0400)]
ci: Fixate CentOS container image until rpm-md repos sync

Copy of https://github.com/projectatomic/rpm-ostree/pull/985

Closes: #1160
Approved by: jlebon

8 years agorepo: Add add-remotes-config-dir option
Dan Nicholson [Fri, 8 Sep 2017 15:18:10 +0000 (10:18 -0500)]
repo: Add add-remotes-config-dir option

This option allows a repo to explicitly opt out of adding new remotes in
a remotes configuration directory. This currently defaults to true for
system repos and false for non-system repos to maintain legacy behavior
that non-system repos don't add remotes in a configuration directory.
That would be problematic for flatpak, which specifies a remotes config
dir but adds remotes in ways that are incompatible with it.

So, what this really does is allow system repos to control whether they
want to add remotes in the config dir or not. That's important if your
flatpak repo is the system repo like at Endless.

Closes: #1134
Closes: #1155
Approved by: cgwalters

8 years agosysroot: Reload config after setting sysroot kind
Dan Nicholson [Fri, 8 Sep 2017 17:09:18 +0000 (12:09 -0500)]
sysroot: Reload config after setting sysroot kind

This allows any repo configuration defaults to be set based on whether
it's a system repo or not.

Closes: #1155
Approved by: cgwalters

8 years agolib/repo: Update outdated comment
Matthew Leeds [Sat, 9 Sep 2017 00:41:04 +0000 (17:41 -0700)]
lib/repo: Update outdated comment

Closes: #1157
Approved by: cgwalters

8 years agorofiles-fuse: Fix lchown() and hardlink verification for symlinks
Alexander Larsson [Wed, 6 Sep 2017 07:31:16 +0000 (09:31 +0200)]
rofiles-fuse: Fix lchown() and hardlink verification for symlinks

If you lchown("symlink") then we were incorrectly trying to chown the
symlink target, rather than the symlink itself. In particular, this cause
cp -a to fail for a broken symlink. Additionally, it was using the
symlink target when verifying writability, rather than the symlink
itself.

To fix this, we need pass AT_SYMLINK_NOFOLLOW in these cases.

In general, the kernel itself will always resolve any symlinks for us
before calling into the fuse backend, so we should really never do any
symlink following in the fuse fs itself. So, we pro-actively add
NOFOLLOW flags to a few other places:

 truncate:
      In reality this will never be hit, because
      the kernel will resolve symlinks before calling us.
 access:
      It seems the current fuse implementation never calls this
      (faccessat w/AT_SYMLINK_NOFOLLOW never reaches the fuse fs)
      but if this ever is implemented this is the correct behaviour.

We would ideally do `chmod` but this is not implemented on current kernels.
Because we're not multi-threaded, this is OK anyways.

Further, our write verification wasn't correctly handling the case of hardlinked
symlinks, which can occur for `bare` checkouts but *not* `bare-user` which the
tests were using. Change to `bare` mode to verify that.

Closes: #1137
Approved by: alexlarsson

8 years agolib/syslinux: Port to new code style
Colin Walters [Fri, 8 Sep 2017 13:31:03 +0000 (09:31 -0400)]
lib/syslinux: Port to new code style

There was only one tricky bit here around the ownership of the lines; I made use
of `g_steal_pointer()` to consistently track ownership, and converted to a `for`
loop while still preserving the loop logic around the last entry.

Closes: #1154
Approved by: jlebon

8 years agolib: Add a private helper to abort txns, use in sysroot cleanup
Colin Walters [Tue, 5 Sep 2017 19:43:04 +0000 (15:43 -0400)]
lib: Add a private helper to abort txns, use in sysroot cleanup

Steal some code from flatpak for this, which allows porting a few more things to
new style. I started on a public API version of this but was trying to roll some
other things into it and it snowballed. Let's do this version since it's easy
for now.

While here I changed things so that `generate_deployment_refs()` now just uses
`_set_ref_immediate()` rather than requring a txn.

Also, AFAICS there was no test coverage of `generate_deployment_refs()`; I tried
commenting it out and at least `admin-test.sh` passed. Add some coverage of this
- I verified that with this commenting out bits of that function cause the test
to fail.

Closes: #1132
Approved by: jlebon

8 years agolib/grub2: Port some to new code style
Colin Walters [Fri, 8 Sep 2017 01:46:10 +0000 (21:46 -0400)]
lib/grub2: Port some to new code style

I resisted trying to do anything invasive here like fd-relative porting as our
coverage is weak. But this was all straightforward porting to decl-after-stmt
style.

Closes: #1153
Approved by: jlebon

8 years agorepo: Fix non-system remotes-config-dir usage
Dan Nicholson [Thu, 7 Sep 2017 19:02:51 +0000 (14:02 -0500)]
repo: Fix non-system remotes-config-dir usage

Before commit e0346c1, a non-system repo could specify
remotes-config-dir and have remotes read from there. However, adding
remotes would only be done in the config dir for a system repo. Restore
that by respecting remotes-config-dir when no sysroot is found and
adding back the ostree_repo_is_system() check when adding remotes.

Closes: #1133
Closes: #1151
Approved by: cgwalters

8 years agouboot: add non-default deployments to uEnv.txt
Guy Shapiro [Tue, 5 Sep 2017 12:59:35 +0000 (15:59 +0300)]
uboot: add non-default deployments to uEnv.txt

Include non-default deployments in the uEnv.txt file imported by
U-Boot. All the configurations beside the defaults will have
numerical suffix E.G. "kernel_image2" or "bootargs2".
Those U-Boot environment variables may be used from interactive boot
prompt or from "altbootcmd" script.

Closes: #1138
Approved by: cgwalters

8 years agouboot: move system uEnv merge to new function, clean up
Guy Shapiro [Tue, 5 Sep 2017 09:03:52 +0000 (12:03 +0300)]
uboot: move system uEnv merge to new function, clean up

Split the code that merge the system uEnv to new function. While we're here,
clean up the logic to e.g. use `ot_openat_ignore_enoent()`.

Closes: #1138
Approved by: cgwalters

8 years agotree-wide: Add error prefixing for most remaining syscalls
Colin Walters [Thu, 7 Sep 2017 19:03:24 +0000 (15:03 -0400)]
tree-wide: Add error prefixing for most remaining syscalls

There were some important ones there like a random `syncfs()`. The remaining
users are mostly blocked on the "fstatat enoent" case, I'll wait to port those.

Closes: #1150
Approved by: jlebon

8 years agolib/sysroot: Use fd-relative acccess for bootversion cleanup
Colin Walters [Thu, 7 Sep 2017 16:11:55 +0000 (12:11 -0400)]
lib/sysroot: Use fd-relative acccess for bootversion cleanup

I noticed this was an easy change.

Closes: #1148
Approved by: peterbaouoft

8 years agolib/gpg: Provide the public key to the duplicate check
Robert McQueen [Thu, 3 Aug 2017 09:54:33 +0000 (10:54 +0100)]
lib/gpg: Provide the public key to the duplicate check

Add keys from the signing homedir to the GpgVerifier used to look
for duplicate signatures. This will allow signatures from subkeys
to be canonicalised and recognised as already signed despite the
differing key ID, avoiding duplicate signatures.

Closes: https://github.com/ostreedev/ostree/issues/608
Closes: #1092
Approved by: cgwalters

8 years agolib/gpg: Correct missing line prefix with bad signatures
Robert McQueen [Thu, 3 Aug 2017 09:23:39 +0000 (10:23 +0100)]
lib/gpg: Correct missing line prefix with bad signatures

In the case the signature time was bad, a line prefix was missing from the
result of `ostree_gpg_verify_result_describe_variant()`.

Closes: #1092
Approved by: cgwalters

8 years agolib/gpg: Add _FINGERPRINT_PRIMARY to OstreeGpgVerifyResult
Robert McQueen [Thu, 3 Aug 2017 09:00:42 +0000 (10:00 +0100)]
lib/gpg: Add _FINGERPRINT_PRIMARY to OstreeGpgVerifyResult

Revert the switch of _FINGERPRINT to giving the primary key ID
rather than the signing key ID, and instead add the primary
key ID as a new attribute which is available if the key is not
missing.

Closes: https://github.com/ostreedev/ostree/issues/608
Closes: #1092
Approved by: cgwalters

8 years agotests: Check "refs -c PREFIX" behavior
Matthew Leeds [Thu, 7 Sep 2017 18:19:34 +0000 (11:19 -0700)]
tests: Check "refs -c PREFIX" behavior

This commit adds tests to check the behavior of "refs -c PREFIX", where
prefix is interpreted as a collection ID.

Closes: #1149
Approved by: cgwalters

8 years agolib/commit: Add some error prefixing for txn commit/tmpdir
Colin Walters [Thu, 7 Sep 2017 02:08:55 +0000 (22:08 -0400)]
lib/commit: Add some error prefixing for txn commit/tmpdir

To help debug this: https://lists.projectatomic.io/projectatomic-archives/atomic-devel/2017-September/msg00001.html

Currently we just get: `error: Commit: unlinkat: Directory not empty`

Closes: #1147
Approved by: jlebon

8 years agolib/pull: A bit of new style porting
Colin Walters [Thu, 7 Sep 2017 01:44:09 +0000 (21:44 -0400)]
lib/pull: A bit of new style porting

A lof of the functions here are async and have nontrivial exits, but these ones
are all sync were straightforward ports.

Not prep for anything, just chipping away at porting.

Closes: #1146
Approved by: jlebon

8 years agolib/pull: Only look for cookie files for non-local remotes
Colin Walters [Thu, 7 Sep 2017 01:30:13 +0000 (21:30 -0400)]
lib/pull: Only look for cookie files for non-local remotes

Just noticed this while reading an strace.

Closes: https://github.com/ostreedev/ostree/issues/1139
Closes: #1145
Approved by: jlebon

8 years agolib/commit: Update docs/code style for ostree_repo_scan_hardlinks()
Colin Walters [Wed, 6 Sep 2017 21:11:27 +0000 (17:11 -0400)]
lib/commit: Update docs/code style for ostree_repo_scan_hardlinks()

Happened to notice this one `goto out` user, and decided to tweak the docs at
the same time.

Closes: #1144
Approved by: jlebon

8 years agotree-wide: Use helpers for unlinkat()
Colin Walters [Wed, 6 Sep 2017 15:37:02 +0000 (11:37 -0400)]
tree-wide: Use helpers for unlinkat()

We have `ot_ensure_unlinked_at()` for the "ignore ENOENT" case, and
`glnx_unlinkat()` otherwise. Port all in-tree callers to one or the other as
appropriate.

Just noticed an unprefixed error in the refs case and decided to do a tree-wide
check.

Closes: #1142
Approved by: jlebon

8 years agotests/rofiles-fuse: Add tests for chmod/chown
Colin Walters [Wed, 6 Sep 2017 14:39:43 +0000 (10:39 -0400)]
tests/rofiles-fuse: Add tests for chmod/chown

Prep for https://github.com/ostreedev/ostree/pull/1137 where
we were incorrectly handling `chown()` on symlinks.

Closes: #1141
Approved by: jlebon

8 years agolib/gpg: Port a few misc gpg functions to new style
Colin Walters [Wed, 6 Sep 2017 01:18:59 +0000 (21:18 -0400)]
lib/gpg: Port a few misc gpg functions to new style

I'd mostly been skipping the GPG functions due to lack of autoptr for a few
things, but I noticed these bits were straightforward.

Closes: #1136
Approved by: jlebon

8 years agolib/gpg: Use nicer helper for gpg error messages
Colin Walters [Wed, 6 Sep 2017 01:03:18 +0000 (21:03 -0400)]
lib/gpg: Use nicer helper for gpg error messages

The vast majority of invocations of `ot_gpgme_error_to_gio_error()` were paired
with `g_prefix_error()`; let's combine them for the same reason we do
`glnx_throw_errno_prefix()`. For the few cases that don't we might as well add
some prefix.

I also changed it to `return FALSE` in prep for more style porting.

Closes: #1135
Approved by: jlebon

8 years agolib/sysroot: A bit more new style porting
Colin Walters [Tue, 5 Sep 2017 19:24:07 +0000 (15:24 -0400)]
lib/sysroot: A bit more new style porting

A few things not done in the last pass; prep for `ostree_sysroot_new_at()` work.

Closes: #1131
Approved by: jlebon

8 years agobin/local-pull: Clarify docs, add more tests for corrupted local pulls
Colin Walters [Tue, 5 Sep 2017 19:01:12 +0000 (15:01 -0400)]
bin/local-pull: Clarify docs, add more tests for corrupted local pulls

I was reading the pull-local command docs and realized it was somewhat unclear
that `--untrusted` *only* applied to local repo pulls; in other words that we
always treat non-local pulls as untrusted.

Tweak the docstring, and add tests that verify this explicitly.

Closes: #1130
Approved by: jlebon

8 years agolib/repo: Add error prefixing during hardlink object import
Colin Walters [Tue, 5 Sep 2017 16:06:46 +0000 (12:06 -0400)]
lib/repo: Add error prefixing during hardlink object import

I happened to have a repo with a missing commit object, and got an unprefixed
error during a pull-local.

Closes: #1129
Approved by: jlebon

8 years agolib/repo: Add apidoc for repo properties
Colin Walters [Wed, 6 Sep 2017 14:24:56 +0000 (10:24 -0400)]
lib/repo: Add apidoc for repo properties

However, they weren't showing up in the output HTML and I have
no idea why; I looked at what we're doing and it looks close enough
to what's going on in `GDBusConnection` that I was using as a reference.
I'm not going to spend a lot of time to debug it right now.

Closes: #1140
Approved by: jlebon

8 years agoci: Hackaround Fedora rpm/libdb/glibc issue
Colin Walters [Wed, 6 Sep 2017 16:42:51 +0000 (12:42 -0400)]
ci: Hackaround Fedora rpm/libdb/glibc issue

Not sure I want to wait a few days for a new container, so let's
give this a shot now.

See https://bugzilla.redhat.com/show_bug.cgi?id=1483553

Closes: #1143
Approved by: jlebon

8 years agobin/admin: Check for booted sysroot for root-required commands
Colin Walters [Fri, 1 Sep 2017 19:03:02 +0000 (15:03 -0400)]
bin/admin: Check for booted sysroot for root-required commands

Drops a use of `ostree_sysroot_get_path()`, prep for `ostree_sysroot_new_at()`.

Closes: #1123
Approved by: jlebon

8 years agobin/admin: Do sysroot loading during argument parsing
Colin Walters [Fri, 1 Sep 2017 19:01:18 +0000 (15:01 -0400)]
bin/admin: Do sysroot loading during argument parsing

Followup from previous patch - we can now centralize the sysroot loading.
Besides the obvious cleanup value, this is also prep for dropping an
`ostree_sysroot_get_path()` user.

Closes: #1123
Approved by: jlebon

8 years agobin/admin: Change init-fs to stop loading a sysroot to init one
Colin Walters [Fri, 1 Sep 2017 18:57:53 +0000 (14:57 -0400)]
bin/admin: Change init-fs to stop loading a sysroot to init one

This is exactly analogous to the `ostree init` case where
we have `OSTREE_BUILTIN_FLAG_NO_REPO` to avoid trying to load
a repo when we're creating one.

Let's avoid the pointless sysroot for `init-fs`; among other
things this will then let us do `ostree_sysroot_load()` inside
the argument parsing, and drop it from every other user.

Closes: #1123
Approved by: jlebon

8 years agobin/admin: Check for booted deployment to see if we should reboot
Colin Walters [Fri, 1 Sep 2017 18:43:33 +0000 (14:43 -0400)]
bin/admin: Check for booted deployment to see if we should reboot

Rather than calling `ostree_sysroot_get_path()`, which I'd like to deprecate for
the same reason as `ostree_repo_get_path()`.

Closes: #1123
Approved by: jlebon

8 years agobin/admin: Port switch,upgrade to new style
Colin Walters [Fri, 1 Sep 2017 18:41:07 +0000 (14:41 -0400)]
bin/admin: Port switch,upgrade to new style

Was pretty easy.  Prep for future work.

Closes: #1123
Approved by: jlebon

8 years agobin/prune: Port to new style
Colin Walters [Fri, 1 Sep 2017 19:24:44 +0000 (15:24 -0400)]
bin/prune: Port to new style

No functional changes, all straightforward.  Prep for
https://github.com/ostreedev/ostree/issues/1115

Closes: #1124
Approved by: jlebon

8 years agotree-wide: Replace archive-z2 with archive
Colin Walters [Fri, 1 Sep 2017 20:15:33 +0000 (16:15 -0400)]
tree-wide: Replace archive-z2 with archive

In almost all places. There are just a few exceptions; one tricky bit for
example is that the repo config must still have `mode=archive-z2`, since
`archive` used to mean something else. (We could very likely just get rid of
that check, but eh, later).

I also added a test that one can still do `ostree repo init --mode=archive-z2`.

Closes: #1125
Approved by: jlebon

8 years agocheckout: add an extra checkout_overwrite mode
Ruixin [Thu, 31 Aug 2017 15:44:35 +0000 (15:44 +0000)]
checkout: add an extra checkout_overwrite mode

This is for issue projectatomic/rpm-ostree#365,
an extra option of overwrite mode is added to the checkout command
so that when there is "non-directory" file already exist
during checkout, the error will be handled.

Some tests are added for regression

Closes: #1116
Approved by: cgwalters

8 years agocommit: filter out selinux label before commit
Jonathan Lebon [Wed, 30 Aug 2017 19:20:31 +0000 (15:20 -0400)]
commit: filter out selinux label before commit

The new --selinux-policy added in [0] exposed a subtle issue in the way
we handle labeling during commit. The CI system in rpm-ostree hit this
when trying to make use of it[1].

Basically, because of the way we use a GVariant to represent xattrs, if
a file to be committed already has an SELinux label, the xattr object
ends up with *two* label entries. This of course throws off fsck later
on, since the checksum will have gone over both entries, even though the
on-disk file will only have a single label (in which the second entry
wins).

I confirmed that the `fsck` added in the installed test fails without
the rest of this patch.

[0] https://github.com/ostreedev/ostree/pull/1114
[1] https://github.com/projectatomic/rpm-ostree/pull/953

Closes: #1121
Approved by: cgwalters

8 years agotests: Make the deployment mutable in test-sysroot.js
Matthew Leeds [Wed, 30 Aug 2017 19:06:45 +0000 (12:06 -0700)]
tests: Make the deployment mutable in test-sysroot.js

We attempt to make deployments mutable in the test suite (as opposed to
immutable which is the default) to make it easier to chmod and clean up
the tmp files after each test. This is normally accomplished by setting
OSTREE_SYSROOT_DEBUG=mutable-deployments in libtest.sh, but that only
affects the environment variables for that bash instance, not the
process running gjs. So in test-sysroot.js OSTREE_SYSROOT_DEBUG wasn't
set when sysroot.deploy_tree() was called, which means the deployment
was made immutable which eventually causes the test to fail. This only
occurs when the test is run by the root user because for non-root users
_ostree_linuxfs_fd_alter_immutable_flag() would silently fail and the
deployment would be mutable.

This commit fixes this issue by setting the environment variable in
tests/test-sysroot.js.

Closes: #1122
Approved by: cgwalters

8 years agolibarchive: Add support for translating paths during commit
Colin Walters [Wed, 23 Aug 2017 01:52:24 +0000 (21:52 -0400)]
libarchive: Add support for translating paths during commit

For rpm-ostree, I want to move RPM files in `/boot` to `/usr/lib/ostree-boot`.
This is currently impossible without forking the libarchive code.  Supporting
this is pretty straightforward; we already had pathname translation in
the libarchive code, we just need to expose it as an option.

On the command line side, I chose to wrap this as a regexp. That should be good
enough for a lot of use cases; sophisticated users should as always be making
use of the API. Note that this required some new `#ifdef LIBARCHIVE` bits to use
the new API. Following previous patterns here, we use the new API only if a
relevant option is enabled, ensuring unit test coverage of both paths.

For the test cases, I ended up changing the accounting to avoid having to
multiply the test count.

Closes: #1105
Approved by: jlebon

8 years agoRemove shebang from bash completions
Simon McVittie [Tue, 29 Aug 2017 16:05:16 +0000 (17:05 +0100)]
Remove shebang from bash completions

bash completions are to be sourced. It makes little sense to
execute them.

Detected by Debian's Lintian tool, which warns about non-executable
files that appear to be #! scripts.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #1119
Approved by: cgwalters

8 years agotest-basic-user-only: Skip final step if no user xattrs
Simon McVittie [Tue, 29 Aug 2017 16:03:37 +0000 (17:03 +0100)]
test-basic-user-only: Skip final step if no user xattrs

We don't want to skip the entire test, because the whole point of
bare-user-only is that it works in the absence of xattrs; but we do
need to skip this last stage, which explicitly uses a bare-user
repository.

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #1120
Approved by: cgwalters

8 years agobasic-test: Skip explicit uses of bare-user if no user xattrs
Simon McVittie [Tue, 29 Aug 2017 16:02:43 +0000 (17:02 +0100)]
basic-test: Skip explicit uses of bare-user if no user xattrs

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #1120
Approved by: cgwalters

8 years agolibtest: Allow skipping single checks without user xattrs
Simon McVittie [Tue, 29 Aug 2017 16:02:18 +0000 (17:02 +0100)]
libtest: Allow skipping single checks without user xattrs

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #1120
Approved by: cgwalters

8 years agotest-pull-bareuser.sh: This test uses bare-user, hence needs xattrs
Simon McVittie [Tue, 29 Aug 2017 16:01:41 +0000 (17:01 +0100)]
test-pull-bareuser.sh: This test uses bare-user, hence needs xattrs

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #1120
Approved by: cgwalters

8 years agotest-libarchive-import: Skip if extended attributes are unsupported
Simon McVittie [Tue, 29 Aug 2017 15:46:19 +0000 (16:46 +0100)]
test-libarchive-import: Skip if extended attributes are unsupported

This is the case at build-time on some (all?) Debian autobuilders.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #1120
Approved by: cgwalters

8 years agolib/repo-refs: Fix typos in last commit
Matthew Leeds [Thu, 24 Aug 2017 21:56:48 +0000 (14:56 -0700)]
lib/repo-refs: Fix typos in last commit

This fixes a whitespace error and a mistake that made it into the last
commit, 7ed881baa, at the last minute.

Closes: #1112
Approved by: cgwalters