Commit Graph

455 Commits

Author SHA1 Message Date
Jonathan Lebon
914e79f414
Merge pull request #2706 from cgwalters/depmod-rs
Migrate `depmod` helper to core.rs
2021-03-29 16:32:40 -04:00
Colin Walters
4298fd4ddd rust: More usage of indoc
There's a lot more of this in the code, just decided to do a little
bit more in treefile.rs mostly.
2021-03-29 17:50:06 +00:00
Kelvin Fan
dedf2a2653
Merge pull request #2700 from cgwalters/indoc
rust: Use indoc crate
2021-03-29 13:18:43 -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
Colin Walters
fd69eeec5a bwrap: Add more docstrings
Trying to do this on general principle.
2021-03-29 14:45:35 +00:00
Colin Walters
a8f45b5848 bwrap: Clean up /sys ro binds
Less repetitive and a bit more documented this way.
2021-03-29 14:45:35 +00:00
Colin Walters
922e6847bc bwrap: Clean up capability additions
It's easier to read this way.
2021-03-29 14:45:35 +00:00
Colin Walters
8ba6348267 bwrap: Create a RoFilesMount struct
This cleans up the drop handling/ownership.
2021-03-29 14:45:35 +00:00
Colin Walters
fa81456cbf Rewrite bwrap code in Rust
I tried to do this incrementally but it snowballed.
2021-03-29 14:45:35 +00:00
Colin Walters
40dc281e5e bwrap: Initial Rust stub
This compiles and demonstrates moving a little bit of the bwrap
code to Rust.
2021-03-29 14:44:09 +00:00
Colin Walters
15842529dd rust: Use indoc crate
I came across this crate the other day randomly - yet *another*
dtolnay dependency.  We have a bunch of these inline multi-line
strings that are just much nicer to read this way.

I only converted this one use, if this merges I'll do more
over time.
2021-03-27 19:51:59 +00:00
Colin Walters
a7edfb6293 Add a helper API to detect running in systemd
Use it instead of detecting the journal; we *could* do that
by checking the `JOURNAL_STREAM` variable:
https://www.freedesktop.org/software/systemd/man/systemd.exec.html#%24JOURNAL_STREAM

But, really none of our code cares about this today;
anyone running `rpm-ostree compose tree` under e.g.
`systemd-run` can keep both pieces.
2021-03-26 14:29:53 +00:00
dependabot[bot]
c566e51c4a build(deps): bump cxx from 1.0.32 to 1.0.33
Bumps [cxx](https://github.com/dtolnay/cxx) from 1.0.32 to 1.0.33.
- [Release notes](https://github.com/dtolnay/cxx/releases)
- [Commits](https://github.com/dtolnay/cxx/compare/1.0.32...1.0.33)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-22 15:12:01 -04:00
dependabot[bot]
03ab3712ff build(deps): bump system-deps from 3.0.0 to 3.1.0
Bumps [system-deps](https://github.com/gdesmott/system-deps) from 3.0.0 to 3.1.0.
- [Release notes](https://github.com/gdesmott/system-deps/releases)
- [Commits](https://github.com/gdesmott/system-deps/compare/v3.0.0...v3.1.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-22 14:06:13 -04:00
dependabot[bot]
e15dba0fd8 build(deps): bump cxx-build from 1.0.32 to 1.0.33
Bumps [cxx-build](https://github.com/dtolnay/cxx) from 1.0.32 to 1.0.33.
- [Release notes](https://github.com/dtolnay/cxx/releases)
- [Commits](https://github.com/dtolnay/cxx/compare/1.0.32...1.0.33)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-22 12:58:12 -04:00
Jonathan Lebon
5d5f1d498d lockfile: Make packages optional
Now that `source-packages` is supported, we should allow a lockfile to
not specify a `packages` field at all. So make it optional.

We still require at least one of the two fields to be specified.
2021-03-22 12:57:49 -04:00
Jonathan Lebon
7979e250ee lockfile: Allow locking by source RPM EVR
Right now if we want to lock e.g. systemd, we need to specify every
subpackage of systemd that we use. This is a lot of duplication because
in the majority of cases, what we really mean is "lock at this build of
systemd".

Since RPMs bake in the source RPM they were built from, we can use this
to lock packages more succinctly. See the testcase and #2676 for
examples of how this looks.

Closes: https://github.com/coreos/rpm-ostree/issues/2676
2021-03-22 12:57:49 -04:00
Jonathan Lebon
4a9dc21d0e
Merge pull request #2679 from cgwalters/more-ostree-sys 2021-03-22 12:18:01 -04:00
Colin Walters
61e7d6a37f postprocess: Migrate mutate-os-release to Rust
Required binding a bit more of the bwrap bits.
2021-03-22 13:06:46 +00:00
Luca BRUNO
6905254344 passwd: optimize validation logic
This improves users/groups validation logic by avoiding spurious
allocations, and by optimizing lookups through an hashset.
2021-03-22 09:02:01 -04:00
Luca BRUNO
42d86d6895 libpriv/passwd: move pre-commit validation hooks to Rust
This moves the users/groups validation logic to Rust, taking care of
all the treefile check-passwd/check-groups knobs.
As all the passwd-handling logic has been ported to Rust, it also
drops the stale C source/headers/imports.
2021-03-22 09:02:01 -04:00
Colin Walters
8d30a82e0c rust/ostree-host: Add README.md and license files
In preparation for splitting to a new repo.
2021-03-19 18:13:35 +00:00
Colin Walters
41357a730a rust/ostree-host: Add SysrootExt trait
This currently just adds a reimplementation of a new API that's
already in C upstream, but the plan is to add more Rust-only APIs in
the future here.
2021-03-19 18:13:11 +00:00
Colin Walters
da9b64cd44 rust: Factor out an ostree-host crate
In preparation for publishing this to crates.io and moving
into e.g. github.com/ostreedev/ostree-host-rs

So that ostree upstream can move forward with more Rust on the
"top level".
2021-03-19 13:44:01 -04:00
Colin Walters
ae3c1bc9a7 compose: Move remove-files code to Rust
More oxidation.
2021-03-18 18:05:34 +00:00
Colin Walters
7f9129d67d compose: Move mutate-os-release string code to Rust
More classic C string manipulation which is much nicer in Rust
2021-03-18 18:05:34 +00:00
Colin Walters
5dafd7f75d treefile: Add an allow(dead_code)
I assume this will be used soon.
2021-03-17 21:21:09 +00:00
Colin Walters
27aa81beaf rust: Fix minor clippy warnings 2021-03-17 16:42:28 -04:00
Luca BRUNO
c5f2c58f58
rust/treefile: tweak check-passwd/check-groups data
This tweaks the data and types parsed from `check-passwd` and
`check-groups`, so that it can be more easily iterated and
consumed by passwd-handling logic.
2021-03-17 18:25:46 +00:00
Luca Bruno
b5d6b8266c
Merge pull request #2669 from cgwalters/more-postprocess-rs-2
More postprocess rs 2
2021-03-17 09:01:29 +00:00
Colin Walters
4c5bb4f216 Move units and default-target processing to Rust
More oxidation.
2021-03-16 23:44:55 +00:00
Colin Walters
ef931e20b0 rust/composepost: Cleanup Treefile import
This reads much more cleanly.
2021-03-16 23:28:27 +00:00
Colin Walters
9ee27a61ca postprocess: Move rpmdb symlink to Rust
More oxidation.
2021-03-16 23:20:02 +00:00
Timothée Ravier
d7851563f1 countme: Refuse to run as root
We do not need root privileges and should only be started via the system
service unit so avoid mistake by verifying that on startup.
2021-03-16 19:07:20 -04:00
Colin Walters
fad4ff66c3 postprocess: Use a single entrypoint to Rust
It's a bit silly to have a two bridged functions here; instead
have just a single one on the C++ side that calls multiple
on the Rust side.

Prep for moving more to Rust.
2021-03-16 22:19:53 +00:00
Colin Walters
6eb3caf9a9 Add Rust progress task wrapper
The manual `std::mem::drop()` bits are ugly; while we can do
function pointers from Rust to C++, let's just add the obvious
high level wrapper in Rust that accepts a `FnOnce()`.

Note in one instance we directly pass a function pointer which
is quite clean.
2021-03-16 14:54:26 +00:00
Colin Walters
531907af90 rust: Rename progress.rs to console_progress.rs
To clarify it's effectively only a backend for our higher
level output abstraction.
2021-03-16 14:50:30 +00:00
Jonathan Lebon
acc3aa1ac7
Merge pull request #2657 from cgwalters/live-tmpfiles
rust: Introduce systemd-run based isolation mod, use in live
2021-03-16 09:13:19 -04:00
Luca Bruno
35c31205a6
Merge pull request #2664 from cgwalters/postprocess-rs-more
Various postprocess oxidation patches
2021-03-16 08:47:11 +00:00
Colin Walters
f90124f363 composepost: Clean up imports
From review comments.
2021-03-15 22:24:23 +00:00
Colin Walters
9126831b8b rust: Introduce systemd-run based isolation mod, use in live
I was thinking about privilege separation today with
systemd units, and that led me to the problem of "lifecycle binding".
We really want e.g. `systemctl stop rpm-ostreed` to kill any
separate systemd units we're managing.

systemd already has a mechanism for this with `BindsTo=`.

And then I realized we weren't doing this for the systemd-tmpfiles
invocations in the `live.rs` code.

Generalize this into a small `isolation` module that fixes this
and several other things at the same time.  I'd like to build
on this to further improve our multi-process isolation story
later.
2021-03-15 21:06:13 +00:00
Luca BRUNO
efb50f5cc1 passwd: minor cleanups
This contains a couple of minor code cleanups, left over from previous
reviews.
2021-03-15 15:32:44 -04:00
Jonathan Lebon
c41adb0ad2
Merge pull request #2648 from cgwalters/deployment-status-cleanup
Move some small daemon layering lookup into Rust
2021-03-15 14:11:56 -04:00
Colin Walters
a0acdb596d Move writing /usr/share/rpm-ostree/treefile.json to Rust
More oxidation.  Also with a quick unit test now.
2021-03-15 13:18:57 +00:00
Colin Walters
9ad499ffd3 Move units/machineid-compat checking to treefile in Rust
More oxidation.
2021-03-15 13:18:57 +00:00
Colin Walters
3e856cb3be postprocess: Move treefile externals sanitycheck to Rust
This code really makes sense as a method on the treefile.

And when that's done, we no longer need to expose
`get_postprocess_script()` via cxx, so we can return a nicely
Rust native `Option<&mut File>`.
2021-03-15 13:18:57 +00:00
Colin Walters
62b47c64c6 postprocess: Move add-files handling to Rust
Port add-files handling to Rust.

Note that there's one very magical line of diff here worth calling out:
We dropped an interface from the cxxrs bridge, because both sides
are now Rust!  The treefile code can directly return an `&mut File` reference
instead of needing to pass the raw fd as `i32`.
2021-03-15 13:18:57 +00:00
Colin Walters
ac92456bdd postprocess: Move script execution to Rust
Continuing oxidation.
2021-03-15 13:18:57 +00:00
Colin Walters
1b3bdc243e Move high level bwrap postprocess interface to C++
A future patch will then expose this interface via cxxrs, allowing
us to port more of the postprocess.cxx code to Rust.
2021-03-15 13:18:57 +00:00
Luca Bruno
9deeeedc5d
Merge pull request #2660 from cgwalters/postprocess-rs-nsswitch
Oxidize postprocessing `altfiles` addition to `/etc/nsswitch.conf`
2021-03-15 08:32:05 +00:00