summaryrefslogtreecommitdiff
path: root/src/nspawn/nspawn-gperf.gperf
Commit message (Collapse)AuthorAgeFilesLines
* nspawn: container network interface namingThierry Martin2023-04-121-3/+3
| | | | | | | | systemd-nspawn now optionally supports colon-separated pair of host interface name and container interface name for --network-macvlan, --network-ipvlan and --network-interface options. Also supported in .nspawn configuration files (i.e Interface=, MACVLAN=, IPVLAN= parameters). man page changed for ntwk interface naming
* conf-parser: merge config_parse_string() and config_parse_safe_string()Yu Watanabe2022-03-101-61/+61
| | | | | This also makes unsafe strings escaped when logged. Otherwise, journalctl may not show the log message unless '--all' is specified.
* tree-wide: use config_parse_safe_string() at various placesLennart Poettering2022-02-091-1/+1
|
* nspawn: use three boolean fields from settings file when actually setLennart Poettering2021-11-091-3/+3
| | | | | | | | | | | | | | | Let's turn these three fields into tristates, so that we can distinguish whether they are not configured at all from explicitly turned off. Let#s then use this to ensure that we only copy the settings fields into our execution environment if they are actually configured. We already do this for some of the boolean settings, this adds it for the missing ones. The goal here is to ensure that an empty settings file used in --settings=override mode (i.e. the default mode used in the systemd-nspawn@.service unit) is truly a NOP.
* nspawn: add --suppress-sync=yes mode for turning sync() and friends into ↵Lennart Poettering2021-10-201-0/+1
| | | | | | | | | | | NOPs via seccomp This is supposed to be used by package/image builders such as mkosi to speed up building, since it allows us to suppress sync() inside a container. This does what Debian's eatmydata tool does, but for a container, and via seccomp (instead of LD_PRELOAD).
* nspawn: add new --bind-user= option for binding a host user into the containerLennart Poettering2021-05-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new option does three things for a host user specified via --bind-user=: 1. Bind mount the home directory from the host directory into /run/host/home/<username> 2. Install an additional user namepace UID/GID mapping mapping the host UID/GID of the host user to an unused one from the container in the range 60514…60577. 3. Synthesize a user/group record for the user/group under the same name as on the host, with minimized information, and the UID/GID set to the mapped UID/GID. This data is written to /run/host/userdb/ where nss-system will pick it up. This should make sharing users and home directories from host into the container pretty seamless, under some conditions: 1. User namespacing must be used. 2. The host UID/GID of the user/group cannot be in the range assigned to the container (kernel already refuses this, as this would mean two host UIDs/GIDs might end up being mapped to the same continer UID/GID. 3. There's a free UID/GID in the aforementioned range in the container, and the name of the user/group is not used in the container. 4. Container payload is new enough to include an nss-systemd version that picks up records from /run/host/userdb/
* nspawn: replace boolean --private-user-chown by enumLennart Poettering2021-05-071-1/+2
| | | | | | | | | | | | | | | | | | | | This replaces --private-user-chown by an enum value --private-user-ownership=off|chown. Changes otherwise very little. This is mostly preparation for a follow-up commit adding a new "map" mode, using kernel 5.12 UID mapping mounts. Note that this does alter codeflow a bit: the new enum already knows three different values instead of the old true/false pair. Besides "off" and "chown" it knows -EINVAL, i.e. whenever the value wsn't set explicitly. This value is changed to "off" or "chown" before use, thus retaining compat to the status quo before, except it won't override explicit configuration anymore. Thus, if you explicitly request --private-user=pick you can now combine it wiht an explicit --private-user-ownership=off if you like, which will give you a container that runs under its own UID set, but the files will be owned by the original image. Makes not much sense besids maybe debugging, but if requested explicitly I think it's OK to implement.
* tree-wide: add spdx header on all scripts and helpersZbigniew Jędrzejewski-Szmek2021-01-281-0/+1
| | | | | | Even though many of those scripts are very simple, it is easier to include the header than to try to say whether each of those files is trivial enough not to require one.
* systemd-nspawn: Allow setting ambient capability setTorsten Hilbrich2020-12-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | The old code was only able to pass the value 0 for the inheritable and ambient capability set when a non-root user was specified. However, sometimes it is useful to run a program in its own container with a user specification and some capabilities set. This is needed when the capabilities cannot be provided by file capabilities (because the file system is mounted with MS_NOSUID for additional security). This commit introduces the option --ambient-capability and the config file option AmbientCapability=. Both are used in a similar way to the existing Capability= setting. It changes the inheritable and ambient set (which is 0 by default). The code also checks that the settings for the bounding set (as defined by Capability= and DropCapability=) and the setting for the ambient set (as defined by AmbientCapability=) are compatible. Otherwise, the operation would fail in any way. Due to the current use of -1 to indicate no support for ambient capability set the special value "all" cannot be supported. Also, the setting of ambient capability is restricted to running a single program in the container payload.
* nspawn: add support for executing OCI runtime bundles with nspawnLennart Poettering2019-03-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a pretty large patch, and adds support for OCI runtime bundles to nspawn. A new switch --oci-bundle= is added that takes a path to an OCI bundle. The JSON file included therein is read similar to a .nspawn settings files, however with a different feature set. Implementation-wise this mostly extends the pre-existing Settings object to carry additional properties for OCI. However, OCI supports some concepts .nspawn files did not support yet, which this patch also adds: 1. Support for "masking" files and directories. This functionatly is now also available via the new --inaccesible= cmdline command, and Inaccessible= in .nspawn files. 2. Support for mounting arbitrary file systems. (not exposed through nspawn cmdline nor .nspawn files, because probably not a good idea) 3. Ability to configure the console settings for a container. This functionality is now also available on the nspawn cmdline in the new --console= switch (not added to .nspawn for now, as it is something specific to the invocation really, not a property of the container) 4. Console width/height configuration. Not exposed through .nspawn/cmdline, but this may be controlled through $COLUMNS and $LINES like in most other UNIX tools. 5. UID/GID configuration by raw numbers. (not exposed in .nspawn and on the cmdline, since containers likely have different user tables, and the existing --user= switch appears to be the better option) 6. OCI hook commands (no exposed in .nspawn/cmdline, as very specific to OCI) 7. Creation of additional devices nodes in /dev. Most likely not a good idea, hence not exposed in .nspawn/cmdline. There's already --bind= to achieve the same, which is the better alternative. 8. Explicit syscall filters. This is not a good idea, due to the skewed arch support, hence not exposed through .nspawn/cmdline. 9. Configuration of some sysctls on a whitelist. Questionnable, not supported in .nspawn/cmdline for now. 10. Configuration of all 5 types of capabilities. Not a useful concept, since the kernel will reduce the caps on execve() anyway. Not exposed through .nspawn/cmdline as this is not very useful hence. Note that this only implements the OCI runtime logic itself. It does not provide a runc-compatible command line tool. This is left for a later PR. Only with that in place tools such as "buildah" can use the OCI support in nspawn as drop-in replacement. Currently still missing is OCI hook support, but it's already parsed and everything, and should be easy to add. Other than that it's OCI is implemented pretty comprehensively. There's a list of incompatibilities in the nspawn-oci.c file. In a later PR I'd like to convert this into proper markdown and add it to the documentation directory.
* add ephemeral to nspawn-settings.Jiuyang liu2018-10-241-0/+1
|
* nspawn: similar to the previous patches, also make /etc/localtime handling ↵Lennart Poettering2018-05-221-0/+1
| | | | | | more configurable Fixes: #9009
* nspawn: make --link-journal= configurable through .nspawn files, tooLennart Poettering2018-05-221-0/+1
|
* nspawn: add greater control over how /etc/resolv.conf is handledLennart Poettering2018-05-221-0/+1
| | | | Fixes: #8014 #1781
* nspawn: add a new --cpu-affinity= switchLennart Poettering2018-05-171-0/+1
| | | | | | Similar as the other options added before, this is primarily useful to provide comprehensive OCI runtime compatbility, but might be useful otherwise, too.
* nspawn: add a new --oom-score-adjust= command line switchLennart Poettering2018-05-171-0/+1
| | | | | This is primarily useful in order to provide comprehensive OCI runtime compatibility with nspawn, but might have uses outside of it.
* nspawn: add a new --no-new-privileges= cmdline option to nspawnLennart Poettering2018-05-171-0/+1
| | | | | | | This simply controls the PR_SET_NO_NEW_PRIVS flag for the container. This too is primarily relevant to provide OCI runtime compaitiblity, but might have other uses too, in particular as it nicely complements the existing --capability= and --drop-capability= flags.
* nspawn: make the hostname of the container explicitly configurable with a ↵Lennart Poettering2018-05-171-0/+1
| | | | | | | | | | | | | | new --hostname= switch Previously, the container's hostname was exclusively initialized from the machine name configured with --machine=, i.e. the internal name and the external name used for and by the container was synchronized. This adds a new option --hostname= that optionally allows the internal name to deviate from the external name. This new option is mainly useful to ultimately implement the OCI runtime spec directly in nspawn, but it might be useful on its own for some other usecases too.
* nspawn: add new --rlimit= switch, and always set resource limits explicitly ↵Lennart Poettering2018-05-171-32/+48
| | | | | | | | | | | | | | | | | for our container payloads This ensures we set the various resource limits of our container explicitly on each invocation so that we inherit less from our callers into the payload. By default resource limits are now set to the same values Linux generally passes to the host PID 1, thus minimizing needless differences between host and container environments. The limits are now also configurable using a new --rlimit= switch. This is preparation for teaching nspawn native OCI runtime support as OCI permits setting resource limits for container payloads, and it hence probably makes sense if we do too.
* tree-wide: adjust fall through comments so that gcc is happyShawn Landden2017-11-201-0/+3
| | | | | | | | Distcc removes comments, making the comment silencing not work. I know there was a decision against a macro in commit ec251fe7d5bc24b5d38b0853bc5969f3a0ba06e2
* nspawn: implement configurable syscall whitelisting/blacklistingLennart Poettering2017-09-121-0/+1
| | | | | | | | | | | | | | | | | | | | | Now that we have ported nspawn's seccomp code to the generic code in seccomp-util, let's extend it to support whitelisting and blacklisting of specific additional syscalls. This uses similar syntax as PID1's support for system call filtering, but in contrast to that always implements a blacklist (and not a whitelist), as we prepopulate the filter with a blacklist, and the unit's system call filter logic does not come with anything prepopulated. (Later on we might actually want to invert the logic here, and whitelist rather than blacklist things, but at this point let's not do that. In case we switch this over later, the syscall add/remove logic of this commit should be compatible conceptually.) Fixes: #5163 Replaces: #5944
* nspawn: Add support for sysroot pivoting (#5258)Philip Withnall2017-02-081-0/+1
| | | | | | | | | Add a new --pivot-root argument to systemd-nspawn, which specifies a directory to pivot to / inside the container; while the original / is pivoted to another specified directory (if provided). This adds support for booting container images which may contain several bootable sysroots, as is common with OSTree disk images. When these disk images are booted on real hardware, ostree-prepare-root is run in conjunction with sysroot.mount in the initramfs to achieve the same results.
* nspawn: add ability to configure overlay mounts to .nspawn filesLennart Poettering2016-12-011-0/+2
| | | | Fixes: #4634
* nspawn: introduce --notify-ready=[no|yes] (#3474)Alessandro Puccetti2016-06-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This the patch implements a notificaiton mechanism from the init process in the container to systemd-nspawn. The switch --notify-ready=yes configures systemd-nspawn to wait the "READY=1" message from the init process in the container to send its own to systemd. --notify-ready=no is equivalent to the previous behavior before this patch, systemd-nspawn notifies systemd with a "READY=1" message when the container is created. This notificaiton mechanism uses socket file with path relative to the contanier "/run/systemd/nspawn/notify". The default values it --notify-ready=no. It is also possible to configure this mechanism from the .nspawn files using NotifyReady. This parameter takes the same options of the command line switch. Before this patch, systemd-nspawn notifies "ready" after the inner child was created, regardless the status of the service running inside it. Now, with --notify-ready=yes, systemd-nspawn notifies when the service is ready. This is really useful when there are dependencies between different contaniers. Fixes https://github.com/systemd/systemd/issues/1369 Based on the work from https://github.com/systemd/systemd/pull/3022 Testing: Boot a OS inside a container with systemd-nspawn. Note: modify the commands accordingly with your filesystem. 1. Create a filesystem where you can boot an OS. 2. sudo systemd-nspawn -D ${HOME}/distros/fedora-23/ sh 2.1. Create the unit file /etc/systemd/system/sleep.service inside the container (You can use the example below) 2.2. systemdctl enable sleep 2.3 exit 3. sudo systemd-run --service-type=notify --unit=notify-test ${HOME}/systemd/systemd-nspawn --notify-ready=yes -D ${HOME}/distros/fedora-23/ -b 4. In a different shell run "systemctl status notify-test" When using --notify-ready=yes the service status is "activating" for 20 seconds before being set to "active (running)". Instead, using --notify-ready=no the service status is marked "active (running)" quickly, without waiting for the 20 seconds. This patch was also test with --private-users=yes, you can test it just adding it at the end of the command at point 3. ------ sleep.service ------ [Unit] Description=sleep After=network.target [Service] Type=oneshot ExecStart=/bin/sleep 20 [Install] WantedBy=multi-user.target ------------ end ------------
* tree-wide: port more code to use ifname_valid()Lennart Poettering2016-05-091-1/+1
|
* nspawn: add new --network-zone= switch for automatically managed bridge devicesLennart Poettering2016-05-091-0/+1
| | | | | | | | | | | | | This adds a new concept of network "zones", which are little more than bridge devices that are automatically managed by nspawn: when the first container referencing a bridge is started, the bridge device is created, when the last container referencing it is removed the bridge device is removed again. Besides this logic --network-zone= is pretty much identical to --network-bridge=. The usecase for this is to make it easy to run multiple related containers (think MySQL in one and Apache in another) in a common, named virtual Ethernet broadcast zone, that only exists as long as one of them is running, and fully automatically managed otherwise.
* nspawn: allow configuration of user namespaces in .nspawn filesLennart Poettering2016-04-251-1/+3
| | | | | | In order to implement this we change the bool arg_userns into an enum UserNamespaceMode, which can take one of NO, PICK or FIXED, and replace the arg_uid_range_pick bool with it.
* nspawn: optionally run a stub init process as PID 1Lennart Poettering2016-02-031-1/+2
| | | | | | This adds a new switch --as-pid2, which allows running commands as PID 2, while a stub init process is run as PID 1. This is useful in order to run arbitrary commands in a container, as PID1's semantics are different from all other processes regarding reaping of unknown children or signal handling.
* nspawn: add new --chdir= switchLennart Poettering2016-02-031-0/+1
| | | | Fixes: #2192
* nspawn: add new --network-veth-extra= switch for defining additional veth linksLennart Poettering2015-11-121-21/+22
| | | | | | | | | | | The new switch operates like --network-veth, but may be specified multiple times (to define multiple link pairs) and allows flexible definition of the interface names. This is an independent reimplementation of #1678, but defines different semantics, keeping the behaviour completely independent of --network-veth. It also comes will full hook-up for .nspawn files, and the matching documentation.
* nspawn: add missing comma to gperf fileLennart Poettering2015-09-091-1/+1
|
* nspawn: remove nspawn.h, it's empty nowLennart Poettering2015-09-071-1/+0
|
* nspawn: split all port exposure code into nspawn-expose-port.[ch]Lennart Poettering2015-09-071-0/+1
|
* nspawn: add new .nspawn files for container settingsLennart Poettering2015-09-061-0/+38
.nspawn fiels are simple settings files that may accompany container images and directories and contain settings otherwise passed on the nspawn command line. This provides an efficient way to attach execution data directly to containers.