Commit Graph

2119 Commits

Author SHA1 Message Date
Colin Walters
f8ab5c2669 importer: Remove rojig bits 2021-05-19 17:28:20 -04:00
Colin Walters
d40434db47 Add support for rpm-ostree deploy --ex-cliwrap=true
This is a better alternative to https://github.com/coreos/fedora-coreos-config/pull/830

Basically rather than trying to send this out to all FCOS users,
it's much saner to allow people to opt-in to it locally.

If we'd finished https://github.com/coreos/rpm-ostree/issues/2326
then this would be something as trivial as:
```
$ echo 'cliwrap: true' > /etc/rpm-ostree.d/cliwrap.yaml
$ rpm-ostree rebuild
```

Unfortunately that's not the world we live in, so a whole lot of
layers here need crossing to just propagate a boolean.  And it
interacts in a tricky way with our change detection code.

But, it works and will allow people to try this out.

Other fixed problems:

- Our `rpm --verify` wrapping was broken
- Dropping privileges clashed with the default directory being `/root`,
  so `chdir(/)` too
2021-05-19 14:42:18 -04:00
Colin Walters
79c3641166 daemon: If we can't figure out auth rule, use override
This is needed for `deploy --ex-cliwrap=true` which is kind
of like a local override.
2021-05-19 14:42:18 -04:00
Colin Walters
562e03f7c1 Remove large chunks of rojig code
The inevitable followup to https://github.com/coreos/rpm-ostree/pull/2278
that I was too cowardly to do at the time.  But it's time to admit
the 2 months or so of work on this was wasted.  We have too much
tech debt and this is a large chunk of C/C++ code that touches everything
in the codebase in a nontrivial way.

Bigger picture, I'm going to work on
https://github.com/coreos/fedora-coreos-tracker/issues/828
which will strongly orient rpm-ostree towards the container world instead.
We'll still obviously keep the rpm package world around, but only
as a secondary layer.  What rojig was trying to do in putting "images"
inside an RPM was conflating layers.  It would have had a lot of
benefits probably if we'd truly pushed it over the edge into completion,
but that didn't happen.  Let's focus on containers instead.

There's still a lot more rojig code to delete but this first patch removes
the bulk of it.  Touching everything that references e.g. `RPMOSTREE_REFSPEC_TYPE_ROJIG`
etc. can come as a 3rd phase.
2021-05-18 17:31:36 -04:00
Luca BRUNO
62f311ba9b
importer: align /var/lib/rpm handling
This reworks the special-case handling of `/var/lib/rpm`, in order
to make it uniform across codepaths and outside of auto-tmpfiles logic.
It prepares for further oxidation and auto-tmpfiles codepaths unification.
2021-05-18 12:36:45 +00:00
Jonathan Lebon
5d79fbf375
Merge pull request #2819 from jlebon/pr/skip-branch-validation
app/deploy: Add --skip-branch-check
2021-05-11 09:18:20 -04:00
Luca BRUNO
7c7d00421f libpriv/importer: move path-checking logic to Rust
This moves the path-checking logic to Rust.
Additionally it tweaks the /opt conditions to use absolute paths.
2021-05-10 19:49:18 -04:00
Rafael G. Ruiz
6d6ebd324d kargs: Simplify conditional statements
Follow-up for PR #2776
Simplify multiple if statements into one if  else statement

Signed-off-by: Rafael G. Ruiz <llerrak@hotmail.com>
2021-05-09 03:38:25 +02:00
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
Jonathan Lebon
57250d11ab
Merge pull request #2813 from kelvinfan001/pr/detect-inactive-driver
app/clientlib: Don't error if updates driver inactive
2021-05-07 17:12:42 -04:00
Kelvin Fan
86cf6ad479 app/clientlib: Don't error if update driver "stopped"
If updates driver is registered but "stopped", ignore driver (i.e.
do not error out during deploy, rebase, ugprade).

We define "stopped" to mean the driver's `ActiveState` is not in
the following states: "active", "activating", "reloading", "failed".
2021-05-07 18:41:45 +00: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