Commit Graph
16 Commits
Author SHA1 Message Date
Luca Boccassi 78b40aea61 mountfsd: add support for mount options
RootImageOptions=/ExtensionImages=/MountImages= all support custom
mount options, but mountfsd does not support it. Add varlink
parameters to allow callers to specify mount options so that
those directives can work as expected.

Given the security implications of some mount options (e.g.: ACLs,
SELinux), require additional privileges to use custom mount options.
Pass the list of requested options to polkit details, so that the
policy can check the exact details if needed, for example to only
allow nosuid and reject the rest.
2026-01-07 00:47:52 +01:00
Lennart Poettering 46341769b7 mountfsd: optionally accept an access mode for the dir created by MakeDirectory()
So far we expected the client to access the access mode themselves, and
set a restrictive 0700 server-side.

However, in some scenarios it's handy if the inode is created
server-side already with the right mode, in particular when the client
doesn't do anything with the dir just yet, and just needs it to be there
with the right mode. If it has to adjust the mode client-side it might
otherwise need to fork something off, join the selected userns, adjust
the mode, and kill the child off again.
2025-12-21 07:04:42 +01:00
Lennart Poettering 030f239a19 varlink-idl: add infra to test our enum parsers against varlink IDL enums
In many cases we want to expose enums for which we have the usual
xyz_to_string()/xyz_from_string() via Varlink as enums. Let's add some
infra to test the tables against each other, to automatically detect
when they deviate.

In order to implement this properly, let's export/introduce clean
json_underscorefy()/json_dashify(), for dealing with the fact that our
enums usually use dash separates ames, but Varlink doesn't allow that.

(This does not add the test cases for all enum types we expose right
now, but only adds the general infra).
2025-11-04 11:46:17 +00:00
Luca Boccassi 674b4b4f96 mountfsd: add support for verity-protected bare filesystems
Add optional varlink parameters to pass in verity data/roothash/sig
2025-10-16 16:22:33 +01:00
Luca Boccassi a9b1e35a32 mountfsd: add boolean parameter to let callers enable verity sharing 2025-10-14 20:49:11 +01:00
Yu Watanabe b0f6d31f6f varlink: flag -> flags
Follow-up for 86fd19af14.
2025-09-19 20:21:22 +09:00
Lennart Poettering 86fd19af14 mountfsd: add recognizable error if we pass an fd with unexpected flags 2025-09-18 21:33:41 +02:00
Lennart Poettering de9e6428b5 mountfsd: include polkit allowInteractiveAuthorization field in IDL
Otherwise this option can never be actually used, as the IDL checker
will refuse any attempts to pass it.

Follow-up for: 0261fe571b
2025-08-19 11:48:14 +01:00
Lennart Poettering 0261fe571b mountfsd: add call for creating a foreign UID owned dir in dir owned by caller
In order to fully support unpriv containers placed in directories owned
by the foreign UID range, below some unpriv user $HOME, we need to away
to actually create these hierarchies in the first place.

Let's add a method call for that. It takes a dir fd, then validates that
its ownership matches the client's identity, and then creates a subdir,
chown()ing it to the foreign UID range. It then returns an fd to the
result.

The result could then be passed to MountDirectory() in order to get a
mount which can then be populated by some code running in a dynamic
userns.
2025-05-27 10:41:52 +02:00
Lennart Poettering 0ecfcc9790 mountfsd: also return suggested mount point paths for the returned partitions
When mounting a disk image we return a bunch of mount fds referencing
the various partitions in the disk, along with some metadata about them.
One key metadata field is the "designator" which is supposed to tell
clients what is what, and where to mount it.

Let's make this more explicit: let's also include the literal relative
path where each mount shall be placed, to simplify implementations of
clients that do not care about the concept of designators.
2025-03-11 18:20:31 +01:00
Lennart Poettering 00c17ad5cf mountfsd: complete varlink introspection comments 2025-03-11 18:20:31 +01:00
Yu Watanabe 3fa12d2cab mntfsd: fix typo
Follow-up for d6f8e1ae87.
2025-01-24 22:12:04 +09:00
Lennart Poettering d6f8e1ae87 mntfsd: add api to mount dirs for containers
systemd-mountfsd so far provided a MountImage() API call for mounting a
disk image and returning a set of mount fds. This complements the API
with a new MountDirectory() API call, that operates on a directory
instead of an image file. Now, what makes this interesting is that it
applies an idmapping from the foreign UID range to the provided target
userns – and in which case unpriveleged operation is allowed (well,
under some conditions: in particular the client must own a parent dir of
the provided path).

This allows container managers to run fully unprivileged from
directories – as long as those directories are owned by the foreign UID
range. Basic operation is like this:

1. acquire a transient userns from systemd-nsresourced with 64K users
2. ask systemd-mountfsd for an idmapped mount of the container dir
   matching that userns
3. join the userns and bind the mount fd as root.

Note that we have to drop various sandboxing knobs from the mountfsd
service file for this to work, since the kernel's security checks that
try to ensure than an obstructed /proc/ cannot be circumvented via
mounting a new procfs will otherwise prohibit mountfsd to duplicate the
mounts properly.
2025-01-23 21:48:02 +01:00
Lennart Poettering e47dbf5b4e polkit: introduce common macro for generating polkit allowInteractiveAuth varlink method call IDL field
We define the same field at many places, let's add a macro with it, that
also contains a suitable description comment.
2024-10-09 15:41:58 +02:00
Lennart Poettering 25ff515b39 sd-varlink: make our internal Varlink API public as sd-varlink.[ch]
It's time. sd-json was already done earlier in this cycle, let's now
make sd-varlink public too.

This is mostly just a search/replace job of epical proportions.

I left some functions internal (mostly IDL handling), and I turned some
static inline calls into regular calls.
2024-07-16 11:57:32 +02:00
Lennart Poettering 702a52f4b5 mountfsd: add new systemd-mountfsd component 2024-04-06 16:08:24 +02:00