Commit graph

2211 commits

Author SHA1 Message Date
David Rheinsberg
ebbedd1e89 linux: add proc_boot_id()
A new helper for the util.linux module which exposes the linux boot-id.
For security reasons, the boot-id is never exposed directly, but
instead only exposed through an application-id combined with the boot-id
via HMAC-SHA256.

Note that a raw kernel boot-id is always considered confidential, since
we never want an outside entity to deduce any information when they see
a boot-id used in protocol A and one in protocol B. It should not be
possible to tell whether both are from the same user and boot or not.
Hence, both should use their own boot-id namespace.
2022-12-06 09:48:38 +01:00
David Rheinsberg
aefaf21411 linux: add accessor for fcntl file locking ops
This adds a new accessor-function for the file-locking operations
through `fcntl(2)`. In particular, it adds the new function
`fcntl_flock()`, which wraps the `F_OFD_SETLK` command on `fcntl(2)`.

There were a few design considerations:

  * The name `fcntl_flock` comes from the `struct flock` structure that
    is the argument type of all file-locking syscalls. Furthermore, it
    mirrors what the `fcntl` module already provides as a wrapper for
    the classic file-locking syscall.

  * The wrapper only exposes very limited access to the file-locking
    commands. There already is `fcntl.fcntl()` and `fcntl.fcntl_flock()`
    in the standard library, which expose the classic file-locks.
    However, those are implemented in C, which gives much more freedom
    and access to architecture dependent types and functions.
    We do not have that freedom (see the in-code comments for the
    things to consider when exposing more fcntl-locking features).
    Hence, this only exposes a very limited set of functionality,
    exactly the parts we need in the objectstore rework.

  * We cannot use `fcntl.fcntl_flock()` from the standard library,
    because we really want the `OFD` version. OFD stands for
    `open-file-description`. These locks were introduced in 2014 to the
    linux kernel and mirror what the non-OFD locks do, but bind the
    locks to the file-description, rather than to a process. Therefore,
    closing a file-description will release all held locks on that
    file-description.
    This is so much more convenient to work with, and much less
    error-prone than the old-style locks. Hence, we really want these,
    even if it means that we have to introduce this new helper.

  * There is an open bug to add this to the python standard library:

        https://bugs.python.org/issue22367

    This is unresolved since 2014.

The implementation of the `fcntl_flock()` helper is straighforward and
should be easy to understand. However, the reasoning behind the design
decisions are not. Hence, the code contains a rather elaborate comment
explaining why it is done this way.

Lastly, this adds a small, but I think sufficient unit-test suite which
makes sure the API works as expected. It does not test for full
functionality of the underlying locking features, but that is not the
job of a wrapping layer, I think. But more tests can always be added.
2022-12-06 09:48:38 +01:00
SchutzBot
41851f7762 schutzfile: update manifest-db ref 2022-12-05 2022-12-05 14:47:46 +01:00
Thomas Lavocat
5112f72cbf mounts: use the options object for mountopts
This modification will allow a user to ask to mount the system as read
only for instance. Which would be super useful for image-info who is
progressively using more of OSbuild internals to mount partitions.
2022-11-30 14:21:10 +01:00
Thomas Lavocat
2e4d610633 ci: deactivate manifest test for rhel/centos9
A bug afflicts image-info on these distributions. We need to perform
modifications to the way image-info mounts the image to do its analyzis.
OSBuild needs some changes for that to happen:
- see https://github.com/osbuild/osbuild/pull/1182.
Since it will not be possible to land anything on OSBuild until
image-info is fixed, let's temporarily deactivate these two archs.
2022-11-29 11:49:51 +01:00
Thomas Lavocat
0a5e558604 ci: use the latest terraform to fix missing images
From OSBuild-composer:

cloud-cleaner deleted all our nightly and CS9 testing images, let's replace them.
2022-11-29 11:49:51 +01:00
schutzbot
5f1e2cf5aa Post release version bump
[skip ci]
2022-11-23 08:16:54 +00:00
Christian Kellner
fb54129317 devices/lvm2.lv: use new ensure_device_node helper
Use the new `DeviceService.ensure_device_node` helper; as a side
effect we won't fail if the device node already exists.
2022-11-22 18:28:38 +01:00
Christian Kellner
84fcf66596 devices/luks2: use new ensure_device_node helper
Use the new `DeviceService.ensure_device_node` helper; as a side
effect we won't fail if the device node already exists.
2022-11-22 18:28:38 +01:00
Christian Kellner
8abed7677f devices: new helper to ensure a device node exists
Add a new `ensure_device_node` helper function that will create
the specified device not, if it does not yet exist.
2022-11-22 18:28:38 +01:00
Christian Kellner
5219e96536 devices/loopback: tolerate existing device node
It is not an error if the device node already exist, which is e.g.
the case when we are using `/dev` of the host.
2022-11-22 18:28:38 +01:00
Christian Kellner
f8ca0cf4bc objectstore: direct path i/o for Object
The `Object.{read,write}` methods were introduced to implement
copy on write support. Calling `write` would trigger the copy,
if the object had a `base`. Additionally, a level of indirection
was introduced via bind mounts, which allowed to hide the actual
path of the object in the store and make sure that `read` really
returned a read-only path.
Support for copy-on-write was recently removed[1], and thus the
need for the `read` and `write` methods. We lose the benefits
of the indirection, but they are not really needed: the path to
the object is not really hidden since one can always use the
`resolve_ref` method to obtain the actual store object path.
The read only property of build trees is ensured via read only
bind mounts in the build root.
Instead of using `read` and `write`, `Object` now gained a new
`tree` property that is the path to the objects tree and also
is implementing `__fspath__` and so behaves like an `os.PathLike`
object and can thus transparently be used in many places, like
e.g. `os.path.join` or `pathlib.Path`.

[1] 5346025031
2022-11-21 17:26:53 +01:00
Christian Kellner
a25ae2b1d5 mounts/ostree.deployment: create private tree mount
Create a private mount point for the tree, so that later we can
move the `root` mount point. This is needed since "moving a mount
residing under a shared mount is invalid and unsupported.", see
`mount(8)`. Currently the `tree` is mounted via a private mount-
point since reading the tree is done via bind-mounts, but this
will change in subsequent commits; this prepares for it.
2022-11-21 17:26:53 +01:00
Christian Kellner
881b2bb5c9 mounts: convert paths to str during serialization
When creating the JSON data, call `os.fspath` on all paths, like
`root` and `devices.tree` to ensure they are strings; this allows
for tree to be an object that conforms to `os.PathLike`.
2022-11-21 17:26:53 +01:00
Christian Kellner
0a29694593 devices: convert tree to str during serialization
When creating the JSON data, call `os.fspath` on `tree` to ensure
it is a string; this allows for tree to be an object that conforms
to `os.PathLike`.
2022-11-21 17:26:53 +01:00
Christian Kellner
48a4419705 test/data: persist the journal for ostree images
Include the new journald config stage to configure journald to
persist the journal. This is needed since we don't create the
`/var/log/journal` directory that journald uses to switch the
default to persistent storage. But instead of creating that
directory, we explicitly configure journald via the new stage.
This is also what Fedora CoreOS does.
2022-11-16 17:51:56 +01:00
Christian Kellner
638d5b834d test/data: add 'rw' kernel flag to ostree image
A recent commit (8a7b6d3) fixed the ostree config stage and thus
we actually properly set the readonly flag for the deployment.
This broke the image since we did not specify the `rw` kernel flag
and as a consequence the ostree mounting code in the initrd broke.
2022-11-16 17:51:56 +01:00
Christian Kellner
74e1dea1f7 objectstore: remove context manager from Object
As `ObjectStore.object` is currently not used via a context
manager anywhere in the source, remove the code.
2022-11-16 11:09:44 +01:00
Christian Kellner
28b8252a04 objectstore: implicit clone based on object ids
If the object's id does not match with the one supplied for the
commit, we create a clone. Otherwise we store the tree.
The code path is arranged in a way that we always go through
`Object.store_tree` so we always call `Object.finalize` as a
prepration for the future, where we might actually do something
meaningful in the finalizer, like reset the *times or count the
tree size.
2022-11-16 11:09:44 +01:00
Christian Kellner
5346025031 objectstore: remove copy on write from object
Remove copy-on-write support from `objectstore.Object`. The main
reason for introducing copy-on-write was to save an additional
copy in the non DAG-pipeline model[1]. With the introduction of
the latter and the explicit `--export` option, we can achieve the
same result without the complexity of copy-on-write semantics.

[1] See commit 39213b7, part of 3b7c87d5..42a365d1 changeset.
2022-11-16 11:09:44 +01:00
Christian Kellner
afc82ee465 test/objectstore: always setup a fresh store
There is little use in sharing the store between test, quite to
opposite: all tests expect a clean store and some currently set
that up themselves. Create a fresh store for each test.
2022-11-16 11:09:44 +01:00
Christian Kellner
0a41742d27 test/objectstore: small check for clone on commit
Add a small test that checks we indeed copied the object by
verifying a file in the store has the same content after
committing but a different inode.
2022-11-16 11:09:44 +01:00
Christian Kellner
76d6bfa4e8 test/objectstore: use helper to assert contents 2022-11-16 11:09:44 +01:00
Christian Kellner
3e8d2c21dc pipeline: opt out of copy-on-write for objects
When committing an object to the store, clone it if the current
stage is not the latests stage, i.e. `todo` has still entries.
This is the second step of the removal of copy-on-write support
in `Object`.
2022-11-16 11:09:44 +01:00
Christian Kellner
daa2e1c3bb objectstore: option to clone object on commit
Add a new `clone` parameter to the `commit` method on `ObjectStore`
that when used will clone the object to the store instead of using
the `store_tree` method which moves the object and resets it. This
is the first step of removing copy-on-write support from `Object`.
2022-11-16 11:09:44 +01:00
Christian Kellner
1762048c1f objectstore: add clone method for object
Right now this is basically a clone(!) of `export` but this will
change in the future when we change the layout of how objects
are stored.
2022-11-16 11:09:44 +01:00
Christian Kellner
c3c06a1ebd objectstore: small comment fix
Just fix a typo, and start the comment with a capital letter.
2022-11-16 11:09:44 +01:00
schutzbot
0b870d88f0 schutzfile: Update snapshots to 20221115 2022-11-15 16:26:56 +01:00
Christian Kellner
a2e212bb26 stages/containers.storage: ability to specify a base file
In newer version of the container storage package the config file
moved from `/etc/containers` to `/usr/containers/`. The later is
not marked as config, so we don't want to change it.
The current containers code[1] will read _either_ a file in `usr`
or in `etc` depending on the existence of the latter. This we can
not just write the keys we want into a file in `/etc/containers`
without losing all other defaults set in the config file.
A new option `filebase` is therefore added, that when given will
be read and form the bases of the configuration data. Then data
from the target file (given via `filename`) will be merged into
and finally the actual configuration will be applied on top.

[1] 232bf398bd/types/options.go (L85)
2022-11-15 11:34:15 +01:00
Christian Kellner
b0ffe6c2b3 stages/containers.storage: allow setting options of empty sections
If the existing config does not have a section that is being set
by the stage it currently would crash since we assume that it
exists. Default to an empty dict in that case.
2022-11-15 11:34:15 +01:00
Christian Kellner
ed67839183 test/data: add rootfs to UKI
Create a squashfs image from the root file system and append it
to the existing initram fs. Passing `root=live:/rootfs.img`
is enough to use the existing dmsquash machiner in dracut.
2022-11-14 20:10:59 +01:00
Christian Kellner
053f027c67 test/data: add UKI test manifest
Example UKI manifest.
2022-11-14 20:10:59 +01:00
Christian Kellner
bca3fe62d5 test/data: add binutils to fedora-build-v2
Add binutils for `objcopy` needed to build UKIs.
2022-11-14 20:10:59 +01:00
Christian Kellner
9b9c989d7b stages: add stage to build unified kernel images
Add new `org.osbuild.uki` stage to build unified kernel images.
2022-11-14 20:10:59 +01:00
Christian Kellner
ecb24a8eb7 util: add module to parse PE32+ files
Add an new module with utility functions to inspect PE32+ files,
mainly listing the sections and their addresses and sizes.
Include a simple test to check that we can successfully parse the
EFI stub contained in systemd (systemd-udev package).
2022-11-14 20:10:59 +01:00
Antonio Murdaca
f34bee944b grub2.iso: add timeout option
add the ability to configure the grub timeout. Today it defealts to 1
minute and we can't configure it from osbuild-composer either (the
simplified-installer is mainly using this afaict and 1 min is just too
much).

Signed-off-by: Antonio Murdaca <antoniomurdaca@gmail.com>
2022-11-11 17:22:14 +01:00
Thomas Lavocat
9d1eb6cecc ci: add tags to AWS instances
The new terraform runners support an extended lists of tags to get a
greater precision on the stats we can extract from AWS cost center.
2022-11-10 20:09:26 +01:00
Antonio Murdaca
ea8261cad6 ignition: fix ignition_network_kcmdline
Signed-off-by: Antonio Murdaca <runcom@linux.com>
Signed-off-by: Antonio Murdaca <antoniomurdaca@gmail.com>
2022-11-09 12:02:07 +01:00
schutzbot
70bed2e984 Post release version bump
[skip ci]
2022-11-09 08:19:42 +00:00
Ygal Blum
6cdc27366b osbuild-mpp: recognize manifest without mediaType and with manifests fields as a list
According to the OCI Image Index specification the mediaType field is not mandatory
Assume that it is a list if mediaType is not set while manifests field is

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-11-08 11:25:25 +01:00
Christian Kellner
7729e6225e stages: add new cpio.out stage
New stage that will assemble a tree into a CPIO archive with the
help of the `cpio` command.
2022-11-03 17:26:43 +01:00
Christian Kellner
51b973f54d ci: update to containers/privdocker@552e30c
The privdocker action got update to node 16, since node 12 is
deprecated and support for it will be remove by summer 2023[1].

[1] https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
2022-11-03 12:59:52 +01:00
Simon de Vlieger
3421826d2f osbuild-dev: a new tool to help with manifests 2022-11-02 17:55:13 +01:00
Christian Kellner
58bafaad98 ci: upgrade to actions/checkout@v3
This uses the new node 16 version (see [1]), which is the future proof
version, since node 12 will be deprecated by summer 2023 (see [2]).

[1] upstream commits:
8f9e05e482
a12a3943b4

[2] https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
2022-11-02 00:14:57 +01:00
schutzbot
1ecc784386 schutzfile: Update snapshots to 20221028 2022-10-29 17:04:55 +02:00
Jan Macku
5a904f4c39 ci(lint): add shell linter - Differential ShellCheck
It performs differential ShellCheck scans and report results directly in pull request.

documentation: https://github.com/redhat-plumbers-in-action/differential-shellcheck

Co-authored-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-10-26 16:45:09 +02:00
schutzbot
9f92b81056 schutzfile: Update snapshots to 20221025 2022-10-26 15:19:17 +02:00
David Rheinsberg
8464e80143 stages/ostree.preptree: fix broken link
Fix the broken "adapting-existing" link in the ostree.preptree
introdutory comment.
2022-10-26 15:04:53 +02:00
Colin Walters
6a2c78b85f stages/ostree.preptree: Link to rpm-ostree code
This code was clearly influenced/copied from rpm-ostree,
since it's now duplicated let's cross-link to help ensure that
if someone wants to change this they hopefully consider changing
rpm-ostree too.
2022-10-26 15:04:53 +02:00
Irene Diez
24b116213c stages/firewall: change zones/sources handling
Signed-off-by: Irene Diez <idiez@redhat.com>
2022-10-26 12:07:21 +02:00