Commit Graph

554 Commits

Author SHA1 Message Date
Colin Walters b3ad113f78 Add "unconfigured-state" concept to origin files
Some operating systems may come with external tools for subscription
management that drive access to the content.  In that case, the origin
file may not be useful (for example, it could refer to an installer
ISO).

This patch will allow OS installers to inject that state, with a
useful error message, directing the system administrator to an
external tool.

See: https://github.com/projectatomic/rpm-ostree/issues/31

https://bugzilla.gnome.org/show_bug.cgi?id=737686
2014-10-03 14:03:55 -04:00
Colin Walters 63abc1b513 pull: Support full recursive mirrors of repositories with summary file
Now that we have a summary file, we can use it to allow a simple:

ostree pull --mirror

To download the latest commit on every branch.  Also, for a case I'm
dealing with there's only one branch, but I don't want mirror users to
have to hardcode it.

https://bugzilla.gnome.org/show_bug.cgi?id=737807
2014-10-03 13:56:40 -04:00
Colin Walters 7ab1fb2369 Add API to directly link() objects between repositories
And use it in pull-local.  As one might expect, this is blazingly fast
if they're on the same filesystem.

I'll be using this to "promote" builds between different repositories.
2014-10-01 23:20:35 -04:00
Colin Walters 1b8759a67e upgrader: Hold a ref to the origin
We unref it in _finalize, so we need to hold a ref.  I *thought*
this was the source of
https://github.com/projectatomic/rpm-ostree/issues/30

But apparently not =/
2014-09-30 11:02:14 -04:00
Owen W. Taylor 262cba09c0 ostree admin instutil set-kargs: make more flexible
Add command line arguments:
 --import-proc-cmdline: import values from /proc/cmdline
 --merge: import current values
 --replace=ARG=VALUE: replace value
 --append=ARG=VALUE: append a new argument

Extra command line arguments are treated like --append=, which
gives backwards compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=731051
2014-09-26 10:40:37 -04:00
Colin Walters 8f4ffa6950 deploy: Copy parent directories for modified config files
Previously, in the case where a parent directory of a modified config
file was removed, we would throw an exception.  This happens when
switching from a tree that has some software (e.g. firewalld), to one
that does not.

While it's nice to have this warning that your config file probably no
longer applies, there's no need to make it so...fatal.

It's particularly problematic that the only easy workaround is to
remove the config files from your current tree - which breaks
rollback.

The solution then is for for us to take ownership of the parent
directories too into the new /etc.  Admins can clean up these files
afterwards at any time.

https://bugzilla.gnome.org/show_bug.cgi?id=734293
2014-09-16 12:06:10 -04:00
Colin Walters b756a13a65 Extract opendirat() helper function into libotutil
We were duplicating the code to do an opendirat() in a few places.
2014-09-16 11:34:39 -04:00
Colin Walters dfeb27eca5 deploy: Remove legacy "current" symbolic links
Per comment, this was a temporary non-atomic hack, and it's time to
remove it.

https://bugzilla.gnome.org/show_bug.cgi?id=731051
2014-09-13 10:44:29 -04:00
Colin Walters 12e3ed83d3 deploy: Clean up leftover state before creating new directories
This fixes a regression introduced with https://git.gnome.org/browse/ostree/commit/?id=7baa600e237b326899de2899a9bc54a6b863943c

The original code in "ostree admin upgrade" had a comment:

 /* Here we perform cleanup of any leftover data from previous
  * partial failures. This avoids having to call gs_shutil_rm_rf()
  * at random points throughout the process. */

But since I deleted that initial cleanup call, we *do* need to do the
cleanup during the process run.  It turns out there are only a few
places this is necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=733030
2014-09-13 10:43:14 -04:00
Colin Walters 7b01bd2e43 deploy: Consistently use fd-relative API
While looking to fix a different bug here, I found the current
state of things where we had a mix of fd-relative API versus not
frustrating.

Change the code around to consistently use *at, and also add some more
tests.
2014-09-13 10:41:59 -04:00
Colin Walters a593078722 pull: Squash some uninitialized variable warnings 2014-09-08 13:43:12 -04:00
Colin Walters f8f5da219e Add repository "summary" file and metalink support
For Fedora and potentially other distributions which use globally
distributed mirrors, metalink is a popular solution to redirect
clients to a dynamic set of mirrors.

In order to make metalink work though, it needs *one* file which can
be checksummed.  (Well, potentially we could explode all refs into the
metalink.xml, but that would be a lot more invasive, and a bit weird
as we'd end up checksumming the checksum file).

This commit adds a new command:

$ ostree summary -u

To regenerate the summary file.  Can only be run by one process at a
time.

After that's done, the metalink can be generated based on it, and the
client fetch code will parse and load it.

https://bugzilla.gnome.org/show_bug.cgi?id=729585
2014-09-03 13:21:52 -04:00
Colin Walters c08a4503ce fetcher: Close request body on error paths
Otherwise, we're potentially holding up subsequent requests.

I was hitting this when testing the metalink code, where we want to
continue doing more fetches after hitting a 404.

https://bugzilla.gnome.org/show_bug.cgi?id=729585
2014-08-27 14:00:31 -04:00
Anne LoVerso 6dfe99a283 pull: Fix use-after-free
The strchr() was pointing into a string we were freeing.
2014-08-21 13:57:31 -04:00
Anne LoVerso 3742c32945 repo-pull: Allow pulling only one directory
Changes the pull API to allow pulling only a single directory instead
of the whole deployment.  This option is utilized by the check-diff
option in rpm-ostree.

Add a new state directory to hold <checksum>.commitpartial files, so
we know that we've only downloaded partial state.
2014-08-20 15:09:32 -04:00
Colin Walters 6a55d2c32f sysroot: Add precondition that load() has been called for some API calls
We require the caller to invoke load() at the moment to do most
things.
2014-08-15 15:21:40 -04:00
Colin Walters b97a5f59df core: Support a per-remote "proxy" configuration option
We don't want to have to force people to set it in the environment.

https://bugzilla.gnome.org/show_bug.cgi?id=733734
2014-07-28 13:49:38 -04:00
James Antill 43bba232a0 Display bytes/second during pull
Add start time to the AsyncProgress object, use it in the common
progress.
2014-07-28 08:37:15 -04:00
James Antill 249da7aef2 pull: override max-conns-per-host to 8, for faster downloads
Modern web browsers are all converging on 6 or 8.  Let's match that.
2014-07-25 10:22:55 -04:00
Colin Walters d5e813c52c refs: Don't try searching for input strings that can't be objects
I noticed OSTree was a bit slower, did some investigation
and saw we were enumerating all objects for things like

$ ostree rev-parse blah

Since "blah" can never be an object (because of the 'l' and 'h'), just
return no matches.
2014-07-23 15:09:24 -04:00
Colin Walters cdaa9517af repofile: Avoid segfault if querying child in non-directory
The user might "ostree ls /usr/bin/bash/blah", which previously would
segfault.

A somewhat related future enhancement here would be for "ostree ls" to
follow symbolic links.

Reported-by: Dusty Mabe <dustymabe@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=733476
2014-07-21 07:58:07 -04:00
Colin Walters e392820541 core: Do enumerate ff/ objects as well
An embarassing off-by-one here.  I noticed we weren't pruning them.

https://bugzilla.gnome.org/show_bug.cgi?id=733458
2014-07-21 07:25:51 -04:00
Colin Walters 1834a71b1f core: Do enumerate content objects in archive-z2 repositories
Prune has worked fine on bare repositories for some time, but now that
I finally try to delete data on the server side, I notice we weren't
actually enumerating content objects =/

That caused them to not be pruned.

https://bugzilla.gnome.org/show_bug.cgi?id=733458
2014-07-21 07:25:51 -04:00
Colin Walters 72da2e0c36 core: Unify object deletion code with prune
The prune API duplicated logic to delete objects, and furthermore the
core API to delete an object didn't clean up detached metadata.

Fix the duplication by doing the obvious thing: prune should call
_delete.

https://bugzilla.gnome.org/show_bug.cgi?id=733452
2014-07-20 08:57:37 -04:00
Colin Walters 1dd4435936 Fix typo in previous commit 2014-07-18 15:49:40 -04:00
Anne LoVerso fd56952d6b ostree-repo-resolve-rev: Add function to accept a partial checksum
This patch adds a function that will parse a partial checksum when
resolving a refspec.  If the inputted refspec matches a truncated
existing checksum, it will return that checksum to be parsed.  If
multiple truncated checksums match the partial refspec, it is not
unique and will return false.  This addition is inspired by the same
functionality in Docker, which allows a user to reference a specific
commit without typing the entire checksum.

partial checksums: Add function to abstract comparison

This modifies the list_objects and list_objects_at functions
to take an additional argument for the string that a commit starts
with.  If this string arg is not null, it will only list commit
objects beginning with that string.  This allows for a new function
ostree_repo_list_commit_objects_starting_with to pass a partial string
and return a list of all matching commits.  This improves on the
previous strategy of listing refs because it will list all commit objects,
even ones in past history.  This update also includes bugfixes on
error handling and string comparison, and changes the output structure
of resolve_partial_checksum. The new strcuture will no longer return FALSE
without error.  Also, the hashtable foreach now uses iter.  Also
includes modified test file
2014-07-18 15:15:44 -04:00
James Antill 3645afc6d7 core: Use ostree_commit_get_parent in ostree_repo_resolve_rev 2014-07-18 10:10:06 -04:00
Colin Walters 772409e945 pull: Only set ca path if we actually have a setting for it
Otherwise, GTlsFileDatabase ends up accepting NULL for anchors, and
then we don't trust any CAs at all.

https://bugzilla.gnome.org/show_bug.cgi?id=726256
2014-07-01 08:53:39 -04:00
Colin Walters f60bac45fd core: add "tls-ca-path" option
Some organizations will want to use private Certificate Authorities to
serve content to their clients.  While it's possible to add the CA
to the system-wide CA store, that has two drawbacks:

1) Compromise of that cert means it can be used for other web traffic
2) All of ca-certificates is trusted

This patch allows a much stronger scenario where *only* the CAs in
tls-ca-path are used for verification from the given repository.

https://bugzilla.gnome.org/show_bug.cgi?id=726256
2014-06-27 13:16:47 -04:00
Colin Walters 5936740b95 [staticanalysis]: Fix some dead code
One was an unused variable, the other is actually dead because we
can't have mfile != NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=732020
2014-06-21 18:08:49 -04:00
Colin Walters 54079982d8 [staticanalysis]: Actually check errors on splice() of objects
We were using unsigned size when we should have been using signed,
this means we basically weren't checking for errors on write...ouch.

Luckily if we e.g. hit ENOSPC during a pull, the checksums wouldn't
match and we'd return an error anyways.  However when writing an
object, we'd end up silently ignoring it =/

https://bugzilla.gnome.org/show_bug.cgi?id=732020
2014-06-21 18:08:49 -04:00
Colin Walters 2dc0cea503 [staticanalysis]: Add assertion to pacify analyzer
This condition can't actually be hit, let's hint that's the case.

https://bugzilla.gnome.org/show_bug.cgi?id=732020
2014-06-21 18:08:49 -04:00
Colin Walters d7067975e7 [staticanalysis]: Fix two uses of uninitialized variables
https://bugzilla.gnome.org/show_bug.cgi?id=732020
2014-06-21 18:08:49 -04:00
Colin Walters 2265ccdeb3 libostree: Add ostree_repo_remote_add() API, port "ostree remote add"
At least one external tool is using the API, and wants to add a
remote, but all of the logic right now is in the tool.  Move it to the
library.

https://bugzilla.gnome.org/show_bug.cgi?id=731984
2014-06-20 15:36:46 -04:00
Colin Walters bb043b319f pull: Emit a better error if the remote isn't found
The generic GKeyFile error isn't quite informative enough here.

I hit this with the new compose process where we don't automatically
inject a configured remote into the generated disk images; we expect
people to add them.

https://bugzilla.gnome.org/show_bug.cgi?id=731346
2014-06-19 04:39:28 -04:00
James Antill d4d4cbda7a core: Fix g_file_get_uri/get_parse_name for non-root ostree files 2014-06-18 17:34:04 -04:00
Colin Walters 6a5e66b152 pull: Support --mirror option
There's several use cases for calling into ostree itself to do
mirroring, instead of using bare rsync.  For example, it's a bit more
efficient as it doesn't require syncing the objects/ directory.

https://bugzilla.gnome.org/show_bug.cgi?id=728351
2014-06-16 17:14:13 -04:00
Colin Walters e31daf448a libostree: Silently ignore EPERM when setting EXT2_IMMUTABLE_FL
In the case of running ostree as non-root on a regular filesystem (not
tmpfs which doesn't support immutable), we should just silently do
nothing if we encounter EPERM.  Cache the result to avoid spam in
strace.

https://bugzilla.gnome.org/show_bug.cgi?id=728006
2014-06-09 14:44:17 -04:00
Colin Walters 24c64d6b4f libostree: Make OstreeFetcher explicitly private
Per previous commit.  We're not attempting to export an HTTP to
clients, the high level API is ostree_repo_pull().

https://bugzilla.gnome.org/show_bug.cgi?id=731369
2014-06-09 14:04:53 -04:00
Colin Walters 4ce93db595 libostree: Make OstreeTlsCertInteraction explicitly private
Similar to previous commit, this should be private.

https://bugzilla.gnome.org/show_bug.cgi?id=731369
2014-06-09 14:04:53 -04:00
Colin Walters 9f734494ff libostree: Make OstreeLibarchiveInputStream explicitly private
We weren't installing the headers, but at the moment all symbols
starting with ostree_ were being exported.  Fix that by prefixing
non-static symbols with '_'.

https://bugzilla.gnome.org/show_bug.cgi?id=731369
2014-06-09 14:04:53 -04:00
Colin Walters 51bf1fab0f repo: Support fsync=false configuration
See rationale in the updated docs.  Basically developer use cases as
well as UPS-backed servers.
2014-06-05 17:35:50 -04:00
Vadim Rutkovsky ef00572999 Honor disable_fsync during checkout also
Finally, fsync to ensure all entries are on disk, unless disabled.
 We support disabling this for cases like server-side buildroot
 construction where we don't need to be robust against power loss
2014-06-04 16:14:46 +02:00
Colin Walters b4d21e9406 deploy: Set the immutable bit on the deployment root
This prevents people from creating new directories there and expecting
them to be persisted.  The OSTree model has all local state to be in
/etc and /var.

This introduces a compile-time dependency on libe2fsprogs.

We're only doing this for the root directory at the moment.

https://bugzilla.gnome.org/show_bug.cgi?id=728006
2014-06-03 13:41:48 -04:00
Colin Walters 47610b45c2 Limit metadata to 10 MiB
If fetching GPG-signed commits over plain HTTP, a MitM attacker can
fill up the drive of targets by simply returning an enormous stream
for the commit object.

Related to this, an attacker can also cause OSTree to perform large
memory allocations by returning enormous GVariants in the metadata.

This helps close that attack by limiting all metadata objects to 10
MiB, so the initial fetch will be truncated.

But now the attack is only slightly more difficult as the attacker
will have to return a correctly formed commit object, then return a
large stream of < 10 MiB dirmeta/dirtree objects.

https://bugzilla.gnome.org/show_bug.cgi?id=725921
2014-05-27 14:15:27 -04:00
Colin Walters 6002356747 fetcher: Unref pending result when completing
Otherwise we were just leaking it.

https://bugzilla.gnome.org/show_bug.cgi?id=725921
2014-05-27 12:01:14 -04:00
Colin Walters f1ccaa581e repo: Don't require a txn for writing
The current "transaction" symlink was introduced to fix issues with
interrupted pulls; normally we assume that if we have a metadata
object, we also have all objects to which it refers.

There used to be a "summary" which had all the available refs, but I
deleted it because it wasn't really used, and was still racy despite
the transaction bits.

We still want the pull process to use the transaction link, so don't
delete the APIs, just relax the restriction on object writing, and
introduce a new ostree_repo_set_ref_immediate().
2014-05-26 18:49:17 -04:00
Colin Walters a4d01976bb repo: Only load /etc/ostree/remotes.d for system repo
They shouldn't be loaded for random test/personal repositories.  Doing
so triggers another bug in that we return them from
ostree_repo_get_config() when then causes clients to write them out
permanently to disk with ostree_repo_write_config().  This caused test
suite failures.
2014-05-26 18:38:35 -04:00
Colin Walters 62c2a204c9 trivial: commit: Fix docstring typos 2014-05-26 17:57:36 -04:00
Colin Walters 78726244a0 deploy: Convert remaining g_print() to systemd journal messages
These bits should be logged more sanely.
2014-05-24 13:19:29 -04:00