Commit Graph

33587 Commits

Author SHA1 Message Date
Lennart Poettering 8c4c2dfca9 update TODO 2018-05-24 17:02:23 +02:00
Lennart Poettering 44d565ed36 doc: add introductory docs for portable services 2018-05-24 17:01:57 +02:00
Lennart Poettering a8c42bb8f3 man: add man pages for the portable service stuff 2018-05-24 17:01:57 +02:00
Lennart Poettering 61d0578b07 add new portable service framework
This adds a small service "systemd-portabled" and a matching client
"portablectl", which implement the "portable service" concept.

The daemon implements the actual operations, is PolicyKit-enabled and is
activated on demand with exit-on-idle.

Both the daemon and the client are an optional build artifact, enabled
by default rhough.
2018-05-24 17:01:57 +02:00
Lennart Poettering 19017acb9f machined: move bus_reply_pair_array() into generic utilities
This way, we can reuse it in portabled.
2018-05-24 17:01:57 +02:00
Lennart Poettering 9b06c1e1ad machined: unify how we forward image method calls from manager to image object
Much like the previous commit, but for Image objects rather than Machine
objects.
2018-05-24 17:01:57 +02:00
Lennart Poettering eecf0181e1 machined: introduce a common function for redirecting machine method calls from manager to machine object
Let's shorten the code a bit, and unify how we forward executoin from
the machine functions that take a machine name as first argument to the
matching functions on the machine object.
2018-05-24 17:01:57 +02:00
Lennart Poettering ace9ab19ff machine-image: extend search path
This adds directories in /etc and /run to the search paths for OS
images. While it doesn't make much sense to actually place huge disk
images there, it's good enough for symlinks to those.

The main reason for supporting this is that this allows us to neatly
symlink portable image files located outside of the search path into the
search path when attaching them, so that attaching them also means they
are discoverable properly for all commands.
2018-05-24 17:01:57 +02:00
Lennart Poettering cf604fd40f machine-image: add 'discoverable' flag for images
This new flag indicates whether the image object was found in the search
paths using the usual algorithm, or was instantiated by path.

This is useful for code that wants to know whether an image may be
referenced by its shortened name or must be specified by its full name.
2018-05-24 17:01:57 +02:00
Lennart Poettering 9614bb06ef machine-image: add proper refcounting 2018-05-24 17:01:57 +02:00
Lennart Poettering 2ddf182baa machine-image: add APIs for converting arbitrary image paths into Image objects 2018-05-24 17:01:57 +02:00
Lennart Poettering 4c2e654b21 machine-image: fix a debug log message 2018-05-24 17:01:57 +02:00
Lennart Poettering 3a6ce860ac machine-image: rework error handling
Let's rework error handling a bit in image_find() and friends: when we
can't find an image, return -ENOENT rather than 0. That's better as
before we violated the usual rule in our codebase that return parameters
are initialized when the return value is >= 0 and otherwise not touched.

This also makes enumeration and validation a bit more strict: we'll only
accept ".raw" as suffix for regular files, and filter out this suffix
handling on directories/subvolumes, where it makes no sense.
2018-05-24 17:01:57 +02:00
Lennart Poettering 225219e504 machine-image: use pretty names if we already have them and validated them 2018-05-24 17:01:57 +02:00
Lennart Poettering 4756c94e5e machine-image: validate pretty names when auto-generating them 2018-05-24 17:01:57 +02:00
Lennart Poettering 1bf36bf9ef machine-image: fix duplicate detection when discovering images
We need to chop off the .raw suffix from the files we find before we can
test it against the hashmap. Hence do that.

And while we are at it, we can pass the pretty name into image_make(),
since we already have it properly formatted.
2018-05-24 17:01:57 +02:00
Lennart Poettering 5ef46e5f65 machine-image: introduce two different classes of images
This distuingishes two different classes of images, one for the purpose
of npsawn-like containers, i.e. "machines", and one for portable
services.

This distinction is mostly about search paths. We look for machine
images in /var/lib/machines and for portable images in
/var/lib/portables.
2018-05-24 17:01:57 +02:00
Lennart Poettering 3e36211be0 conf-files: beef up conf-files.[ch] a bit
This adds fozr new flags:

- If CONF_FILES_DIRECTORY is specified conf_file_list() and friends
  will look for directories only.

- Similar CONF_FILES_REGULAR means we'll look only for regular files.

- If CONF_FILES_BASENAME is specified the resulting list will contain
  only the basenames of all discovered files or directories, not the
  full paths.

- If CONF_FILES_FILTER_MASKED is specified the resulting list will have
  masked entries removed (i.e. those symlinked to /dev/null and
  suchlike)

These four flags are useful for discovering portable service profile
information.

While we are at it, also improve a couple of other things:

- More debug logging

- use path_hash_ops instead of string_hash_ops when putting together the
  path lists
2018-05-24 17:01:57 +02:00
Lennart Poettering c4054ddf79 fileio: make sure read_full_stream() works on memory-backed streams 2018-05-24 17:01:57 +02:00
Lennart Poettering 799b210267 path-lookup: add flag to optionally force checking split-usr unit dirs
When we look into a portable service image it might contain the unit
files in split-usr directories rather than merged-usr directories as on
the host. Hence, let#s add a flag that checking all dirs can be forced.
2018-05-24 17:01:57 +02:00
Lennart Poettering d6d9827687 install: export unit_file_lookup_state() 2018-05-24 17:01:57 +02:00
Lennart Poettering d58ad743f9 os-util: add helpers for finding /etc/os-release
Place this new helpers in a new source file os-util.[ch], and move the
existing and related call path_is_os_tree() to it as well.
2018-05-24 17:01:57 +02:00
Lennart Poettering 080dfda85a fileio: add parse_env_filev() that is like parse_env_file() but takes a va_list 2018-05-24 17:01:57 +02:00
Lennart Poettering 1a5a177eaf fileio: accept FILE* in addition to path in parse_env_file()
Most our other parsing functions do this, let's do this here too,
internally we accept that anyway. Also, the closely related
load_env_file() and load_env_file_pairs() also do this, so let's be
systematic.
2018-05-24 17:01:57 +02:00
Lennart Poettering e2047ba9ed process-util: add a new FORK_MOUNTNS_SLAVE flag for safe_fork()
We already have a flag for creating a new mount namespace for the child.
Let's add an extension to that: a new FORK_MOUNTNFS_SLAVE flag. When
used in combination will mark all mounts in the child namespace as
MS_SLAVE so that the child can freely mount or unmount stuff but it
won't leak into the parent.
2018-05-24 17:01:57 +02:00
Lennart Poettering 03bcb6d408 dissect: optionally, validate that the image we dissect is a valid OS image
We already do this kind of validation in nspawn when we operate on a
plain directory, let's also do this on raw images under the same
condition: that we are about too boot the image. Also, do this when we
are about to read OS metadata from it.
2018-05-24 17:01:57 +02:00
Lennart Poettering 4960ce43ff fd-util: add new helper call fd_duplicate_data_fd()
This call creates an fd from another fd containing the same data.
Specifically, repeated read() on the returned fd should return the same
data as the original fd. This call is useful when we want to copy data
out of disk images and suchlike, and want to be pass fds with the data
around without having to keep the disk image continously mounted.

The implementation tries to be somewhat smart and tries to prefer
memfds/pipes over files in /tmp or /var/tmp based on the size of the
data, but has appropropriate fallbacks in place.
2018-05-24 17:01:57 +02:00
Lennart Poettering cdc0f9be92
Merge pull request #8817 from yuwata/cleanup-nsflags
core: allow to specify RestrictNamespaces= multiple times
2018-05-24 16:49:13 +02:00
Susant Sahani cea79e6643 networkd: Support the ability to set MTU in [Route] sections
Add support to set the route MTU.

Closes #9047
2018-05-24 16:42:40 +02:00
Zbigniew Jędrzejewski-Szmek 45748f098e
Merge pull request #9020 from poettering/physical-memory-cgroupsv2
make sure physical_memory() groks cgroupsv2
2018-05-24 16:30:46 +02:00
Zbigniew Jędrzejewski-Szmek 17c1b9a93f
Merge pull request #9024 from poettering/nspawn-attrs-more
make even more nspawn concepts configurable
2018-05-24 16:27:27 +02:00
Zbigniew Jędrzejewski-Szmek 7cd92e2e9d
Merge pull request #9068 from poettering/nspawn-pty-deadlock
nspawn logging deadlock fix
2018-05-24 16:25:22 +02:00
Lennart Poettering a7b46b7d72 logind: let's change the type of the runtime directory size to uint64_t
Externally it's an uint64_t anyway, and internally we most just
initialize it to physical_memory() which returns uint64_t, hence there's
exactly zero value in using it as size_t internally. Hence, let's fix
that, and use uint64_t everywhere.
2018-05-24 12:14:48 +02:00
Lennart Poettering 0f578ea2ea util: add debug logging to system_tasks_max()
We should always do debug logging when we eat up error conditions. Let's
do so here too.
2018-05-24 12:14:48 +02:00
Lennart Poettering bd969ee6ef util: fix physical_memory() to work correctly on cgroupsv2
Let's look into the right cgroupsv2 attribute.

Also, while we are at it, add debug logging for all error conditions we
eat up silently otherwise.
2018-05-24 12:14:48 +02:00
Yu Watanabe 6e2d744b2f doc: mention in NEWS that AF_INET{,6} are dropped from logind
Closes #9072.
2018-05-24 12:05:54 +02:00
Lennart Poettering 2ad98f977f
Merge pull request #9040 from yuwata/resolved-networkd-use-dynamic-user
Set DynamicUser= to resolved and networkd
2018-05-23 21:10:39 +02:00
Franck Bui 264afce098 install: "user" and "global" scopes are equivalent for user presets
Otherwise querying the preset status of a unit to the user instance gives
incorrect results since in this case the scope used by the manager is
UNIT_FILE_USER.
2018-05-23 21:08:27 +02:00
Lennart Poettering 97745ac601
Merge pull request #9039 from yuwata/fix-device-allow
core: support unit specifiers in IODeviceWeight= and friends
2018-05-23 21:07:22 +02:00
Zbigniew Jędrzejewski-Szmek 0341192035
Merge pull request #9067 from thedrow/patch-1
Enable ccache and mount it into the build/test container
2018-05-23 14:35:39 +02:00
Will Thompson da6c7806fd tmpfiles: fix documented constant for exit code 73
sysexits.h has:

    #define EX_CANTCREAT	73	/* can't create (user) output file */

EX_DATAERR is a copy-paste error from the previous sentence, which is
correct.
2018-05-22 18:35:34 +02:00
Zbigniew Jędrzejewski-Szmek 14d0afb94d
Merge pull request #9065 from poettering/fixup-tab-double-newline
tree-wide: fix some TABs and double newlines
2018-05-22 17:14:48 +02:00
Lennart Poettering 17cac366ae nspawn: make sure our container PID 1 keeps logging to the original stderr as long as possible
If we log to the pty that is configured as stdin/stdout/stderr of the
container too early we risk filling it up in full before we start
processing the pty from the parent process, resulting in deadlocks.
Let's hence keep a copy of the original tty we were started on before
setting up stdin/stdout/stderr, so that we can log to it, and keep using
it as long as we can.

Since the kernel's pty internal buffer is pretty small this actually
triggered deadlocks when we debug logged at lot from nspawn's child
processes, see: https://github.com/systemd/systemd/pull/9024#issuecomment-390403674

With this change we won't use the pty at all, only the actual payload we
start will, and hence we won't deadlock on it, ever.
2018-05-22 16:52:50 +02:00
Lennart Poettering 8ca082b49a nspawn: make use of log_set_open_when_needed() in nspawn too
Let's make use of log_set_open_when_needed() in nspawn too, i.e. at the
point where we close logging because we are about to rearrange fds,
let's automatically reopen the logging fds when we need them, the same
way as we do that in the service manager. This makes things simpler and
more robust.
2018-05-22 16:51:28 +02:00
Omer Katz 94153a7fd9
Install ccache in container. 2018-05-22 17:48:14 +03:00
Omer Katz 93727cf7b0
Enable ccache and mount it into the build/test container. 2018-05-22 17:45:19 +03:00
Lennart Poettering 72d711efa3 update TODO 2018-05-22 16:21:26 +02:00
Lennart Poettering f728ab1724 nspawn: let's rename _FORCE_ENUM_WIDTH → _SETTING_FORCE_ENUM_WIDTH
Just some preparation in case we need a similar hack in another enum one
day.
2018-05-22 16:21:26 +02:00
Lennart Poettering 1688841f46 nspawn: similar to the previous patches, also make /etc/localtime handling more configurable
Fixes: #9009
2018-05-22 16:21:26 +02:00
Lennart Poettering 63d1c29ffa nspawn: complain if people still use --share-system 2018-05-22 16:20:08 +02:00