Commit Graph

2109 Commits

Author SHA1 Message Date
Jonathan Lebon
7c1072f965 app/deploy: Add --skip-branch-check
In Fedora CoreOS, updates are driven by Zincati and we thus completely
trust the information it gives us. The branch validation rpm-ostree does
is thus not necessary. It's also harmful in the case where the node is
extremely out of date because it may not be able to GPG verify the
commit at the tip of the branch (because the GPG key isn't yet in the
tree).

See: https://github.com/coreos/fedora-coreos-tracker/issues/749
2021-05-07 17:45:09 -04:00
Timothée Ravier
c7bf08789d countme: Drop SELinux workaround/unpriv copy of rpm-ostree
The SELinux policy change has been merged and released upstream.

This reverts:
5d5ccf01 Install a temporary copy of rpm-ostree for unprivileged use
2021-05-07 08:41:22 -04:00
Rafael G. Ruiz
6246b990a9 kargs: Add CLI switch --unchanged-exit-77
The new switch will rise an exit code 77 if kernel args are unchanged

Closes: #1802

Signed-off-by: Rafael G. Ruiz <llerrak@hotmail.com>
2021-05-05 23:19:52 +02:00
Jonathan Lebon
ba7a72995b treefile: Add new repo-packages field for pinning packages to repos
This addresses the server compose side of
https://github.com/coreos/rpm-ostree/issues/2584.

One tricky bit is handling overrides across included treefiles (or
really, even within a single treefile): as usual, higher-level treefiles
should override lowel-level ones. Rust makes it pretty nice to handle.

For now this just supports a `repo` field, but one could imagine e.g.
`repos` (which takes an array of repoids instead), or e.g.
`exclude-repos`.

The actual core implementation otherwise is pretty straightforward.

This should help a lot in RHCOS where we currently use many `exclude=`
directives in repo files to get it to do what we want.

This is also kind of a requirement for modularity support because as
soon as rpm-ostree becomes modules-aware, modular filtering logic will
break composes which assume rpm-ostree treats modular and non-modular
packages the same.
2021-04-30 09:13:18 -04:00
Luca BRUNO
3b76a7eeef composepost: move rpmdb linking logic to Rust
This ports the rpmdb hardlinking logic which serves to maintain
a coherent single source of truth across tools.
2021-04-29 16:05:27 -04:00
Luca BRUNO
f1138dd134 composepost: move SELinux workaround logic to Rust
This ports the timestamp updating logic which serves as a workaround
for SELinux leaking host details.
2021-04-29 10:47:13 -04:00
Timothée Ravier
9ee8bbb6f7 daemon: Only update idle status every 10 seconds
This slightly reduces DBus traffic on nodes as we don't really need to
update systemd status more often than that.
2021-04-29 09:56:27 -04:00
Jonathan Lebon
2ed6e40cd2 core: Add comment about SERVER_BASE commits
This made me hesitate for a bit so add a comment about it to make it
clear. The RPMOSTREE_ASSEMBLE_TYPE_SERVER_BASE path was used by the `ex
container`, which was subsequently ripped out.
2021-04-29 09:52:02 -04:00
Jonathan Lebon
c095b97bf3 libpriv: Bridge print_treepkg_diff_from_sysroot_path()
This will be necessary for Rust-based client commands to be able to do
the regular "post-deployment package diff".
2021-04-29 09:52:02 -04:00
Jonathan Lebon
d465eeac68 rust/main: Pass CLI args to command entrypoints
The only entrypoint so far doesn't use it (`countme`), but a future new
entrypoint will.

Also mention that the commands should add themselves to the array in
libmain.cxx if applicable so it shows up in `--help`.
2021-04-29 09:52:02 -04:00
Jonathan Lebon
9348e44a55
Merge pull request #2782 from dustymabe/dusty-rpm-vercmp
lib/package: Fix rpm version comparison
2021-04-28 17:59:24 -04:00
Dusty Mabe
9e45eed598 lib/package: Fix rpm version comparison
`rpmvercmp()` doesn't properly compare full EVR. It needs to
be given the Version and Release separately in order to do
a comparison. For example `rpmVersionCompare()` first calls
`rpmvercmp()` to compare the Version and then checks the Release
in a second call to `rpmvercmp()`.

35739c2a22/lib/headerutil.c (L434-L440)

Let's just use `rpmverCmp()` instead, which can do the full
EVR comparison.

Fixes: https://github.com/coreos/rpm-ostree/issues/2668
2021-04-28 16:45:50 -04:00
Colin Walters
793d91d71b compose: Bump timeout for non-unified-core to 10s
The goal is to make this increasingly annoying until consumers port.
2021-04-28 15:32:57 -04:00
Jonathan Lebon
bb079a8f3c
Merge pull request #2713 from Razaloc/kargs1
kargs: add CLI switches --append-if-missing and --delete-if-present
2021-04-23 10:44:35 -04:00
Luca BRUNO
ad365df4b0 composepost: move rootfs symlinks creation to Rust
This ports the post-processing logic which creates symlinks for
several known state directories under /usr.
2021-04-22 13:11:52 -04:00
Rafael G. Ruiz
edd13e35cd kargs: add CLI switches --append-if-missing and --delete-if-present
These new switches will allow users/drivers to more easily make idempotent changes to kernel arguments.

Closes: https://github.com/coreos/rpm-ostree/issues/2709

Signed-off-by: Rafael G. Ruiz <llerrak@hotmail.com>
2021-04-22 17:17:49 +02:00
Colin Walters
a015fb345f Expose more from treefile via cxx-rs; adapt _install_langs to use it
We only honor `_install_langs` in the compose path, so move the
code to look at the treefile and move the string concatention to
Rust.
2021-04-19 19:59:06 -04:00
Colin Walters
f2bc1d86ef core: Split off a method to set the treespec
Since in the future we'll operate on a treefile, move the callers
still using treespecs to an explicit API.  This is also clearer
because about half the callers were passing `NULL` for this anyways.
2021-04-19 19:59:06 -04:00
Jonathan Lebon
2ad8543b3e
Merge pull request #2758 from cgwalters/treefile-validate-repos
compose: Move repos/lockfile-repos validation to Rust
2021-04-19 11:43:21 -04:00
Luca BRUNO
0d79b25a52 postprocess: move /var tmpfiles.d translation logic to Rust
This ports to Rust the auto-tmfiles.d translation logic which is
meant to consume a populated `/var` and to produce a matching
`rpm-ostree-1-autovar.conf` instead.
It also adds a unit-test covering most codepaths.
2021-04-19 07:39:58 -04:00
Colin Walters
324724da2c core: Remove cancellable/error from context creation APIs
A further cleanup, I noticed these functions never throw an
error, and we weren't consistently checking for one anyways.
2021-04-16 17:21:48 -04:00
Colin Walters
5845e3ab6a compose: Move repos/lockfile-repos validation to Rust
More prep for removing treespec.
2021-04-16 17:05:11 -04:00
Timothée Ravier
19e40a8708 countme: Force disable Count Me logic in DNF
Make sure that we do not use the internal Count Me logic in DNF in
rpm-ostree as we have our own external implementation that is aware of
the different behavior regarding repo handling.

See also the discussions in:
  - https://github.com/rpm-software-management/libdnf/issues/1174
  - https://github.com/rpm-software-management/libdnf/issues/1068
  - https://github.com/coreos/rpm-ostree/pull/2671

Also remove the corresponding note in the docs which not needed anymore.
2021-04-16 16:01:43 -04:00
Colin Walters
22a32a5757 core: Rename context_new_tree() to context_new_compose()
Makes the intention clearer.
2021-04-16 10:46:58 -04:00
Colin Walters
2b554dde64 core: Rename context_new_system() to context_new_client()
Makes the intention clearer.
2021-04-16 10:42:36 -04:00
Colin Walters
834328f963 Move ref parsing into core
We went through a lot of gyrations on this one.  It's only
relevant to server side composes, so having the core parse
the treefile for it directly just makes sense.
2021-04-14 18:24:42 -04:00
Colin Walters
53b4fc8c26 Read treefile directly for releasever
More draining of treespec to treefile.
2021-04-14 18:24:42 -04:00
Colin Walters
29b63cf270 compose: Remove unused helper functions
No longer needed.
2021-04-14 18:24:42 -04:00
Colin Walters
c792587645 Read treefile directly for selinux and recommends flags
Part of removing treespec in favor of treefile.
2021-04-14 18:24:42 -04:00
Colin Walters
69a79bc8e6 Read treefile directly for documentation flag
Part of removing treespec in favor of treefile.
2021-04-14 18:24:42 -04:00
Colin Walters
6321916436 compose: Pass treefile directly in rpmostree_context_new_tree()
Since the treefile is a requirement for server side composes,
pass the treefile directly there in the setup function.

Prep for dropping "treespec".
2021-04-14 18:24:42 -04:00
Stefan Berger
29440346f1 Support hardcoded user.ima to security.ima translation
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-04-12 21:16:46 -04:00
Colin Walters
92c79dc647 core: Fix the "is_system" variable
The intention here was to distinguish between server composes
and client side layering.  But that doesn't work today because
we we call`_new_system()`; probably a result of refactoring.
Doesn't matter too much because we only checked it to
throw an error if we failed to load the policy.

And now add a check for `is_system` instead of checking whether
a treefile is present.

This is prep for converting the origin to a treefile and
using that as our standard format.
2021-04-10 14:21:52 +00:00
Luca Bruno
ff617e56eb
Merge pull request #2734 from stefanberger/stefanberger/fix_memory_leak
libpriv: Remove unnecessary builder causing memory leak
2021-04-09 13:09:16 +00:00
Luca Bruno
de7574f764
Merge pull request #2732 from cgwalters/postprocess-rs-more
Oxidize more of postprocess.cxx
2021-04-09 12:47:35 +00:00
Stefan Berger
c1a869666a libpriv: Remove unnecessary builder causing memory leak
Remove the unnecessary builder causing memory leaks like this one:

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7f60bd2fe3cf in __interceptor_malloc (/lib64/libasan.so.6+0xab3cf)
    #1 0x7f60bca6cbb8 in g_malloc (/lib64/libglib-2.0.so.0+0x5bbb8)
    #2 0x7f60bcaa54f2 in g_variant_type_copy (/lib64/libglib-2.0.so.0+0x944f2)
    #3 0x7f60bcaa3384 in g_variant_builder_init (/lib64/libglib-2.0.so.0+0x92384)
    #4 0x55e5bb3120d3 in filter_xattrs_cb src/libpriv/rpmostree-postprocess.cxx:1493
    #5 0x7f60bc89cb38  (/lib64/libostree-1.so.1+0x49b38)
    #6 0x7f60bc8a5e1a  (/lib64/libostree-1.so.1+0x52e1a)
    #7 0x7f60bc8a622b in ostree_repo_write_dfd_to_mtree (/lib64/libostree-1.so.1+0x5322b)
    #8 0x55e5bb307e6e in write_dfd_thread src/libpriv/rpmostree-postprocess.cxx:1551
    #9 0x7f60bca92401  (/lib64/libglib-2.0.so.0+0x81401)
    #10 0x7f60bc12d3f8 in start_thread (/lib64/libpthread.so.0+0x93f8)
    #11 0x7f60bc05ab52 in __GI___clone (/lib64/libc.so.6+0x101b52)

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-04-09 08:02:38 -04:00
Colin Walters
2407b9850f client: Provide more useful error if we're in a container
Let's make this more obvious - in particular today I ran
a command in the wrong terminal and the error made me pause
for a second.
2021-04-08 18:33:38 +00:00
Colin Walters
66c764fb38 Oxidize more of postprocess.cxx
Figuring out that we can't `fchmod()` on an `O_PATH` descriptor
took me a while =(

As part of that I discovered the `nix` crate grew a `Dir`
abstraction too.  But I think we still probably want to be using
https://docs.rs/cap-std/0.13.7/cap_std/fs/index.html
2021-04-08 16:33:47 +00:00
Colin Walters
46728cfd99 postprocess: Move more code into Rust
Previously we carefully ported functionality bit by bit here.
Now take the last step and move it all in to Rust.

A reason I didn't do this in one go before is around the
incredibly twisted handling of the `/etc` vs `/usr/etc`.

I think longer term we should aim to basically have all
of our code keep it as `/etc` up until the very end.  For
now we just do a rename dance around some of the add/remove
files code.
2021-04-07 11:32:40 +00:00
Colin Walters
86f9612395 composeutil: Clarify which dev failed to create 2021-04-07 11:32:08 +00:00
Jonathan Lebon
4624c3bdf8 app/db: Add db diff --advisories
This will be used by at least coreos-assembler to store in `meta.json`
so it's easy to tell new advisories that appeared in a given build.
2021-04-06 17:04:51 -04:00
Jonathan Lebon
136a3ea7e9 app/db: Add db list --advisories
This makes it easy to see the advisories stored in commit metadata.
2021-04-06 17:04:51 -04:00
Jonathan Lebon
427fe683a8 compose: Bake advisory information into commit metadata
There are a lot of use cases for this, notably:
- This allows us to display advisories without fetching updateinfo
  metadata in the pure OSTree case.
- It allows pipelines to fetch and display this information to
  sanity-check builds.
- It makes it much easier to fix the "intermediate CVEs" issue described
  in https://github.com/coreos/rpm-ostree/issues/1696#issuecomment-443861107.

This patch just adds the advisory information to the commit metadata.
There's follow-up work to make the client-side of rpm-ostree use this
data.

Also, remove the newly added metadata from the output of `rpm-ostree
status --json` for the same reason we remove the rpmdb. A follow-up
patch will teach `rpm-ostree db list/diff` to output advisories.

Closes: #1696
2021-04-06 17:04:51 -04:00
Luca BRUNO
d922f46bfd libpriv/json-parsing: remove dead code
This removes some JSON-handling helper methods which are not used
anymore. All the consumers have been moved to directly use the
treefile logic in Rust in the meanwhile.
2021-04-05 13:43:58 -04:00
Jonathan Lebon
b7a27e2328 app/clientlib: Support printing advisories without padding 2021-04-05 13:31:25 -04:00
Jonathan Lebon
4185178be7 app/clientlib: Make function for printing advisories public
We'll use this in a future patch.
2021-04-05 13:31:25 -04:00
Jonathan Lebon
6df0efb0c6 libpriv/util: Add g_variant_byteswap helpers
Will use these in a future patch.
2021-04-05 13:31:25 -04:00
Jonathan Lebon
4c5436e666 daemon: Move advisory GVariant generation to libpriv
Prep for future patch.
2021-04-05 13:31:25 -04:00
Ukpai Ugochi
695312fc43 Help text on error: Transaction in progress #2341
This is a feature request, to add help text to get new users unblocked.
2021-03-30 08:37:35 -04:00
Colin Walters
eba911c00a Migrate depmod helper to core.rs
Since it's called from both client and compose side, it should be
in core.  Migrate to Rust too.
2021-03-29 16:43:19 +00:00