Commit Graph
1477 Commits
Author SHA1 Message Date
Lennart Poettering e6ceea090a nspawn: add some debug logging for sd_notify() messages received by the container manager 2024-03-14 17:24:20 +01:00
Mike Yuan 4f49512695 extract-word: modernize extract_many_words 2024-03-03 19:01:00 +08:00
Lennart Poettering f4a63ce25f dissect-image: add flag for explicitly enabling userspace verity signature checking
let's make userspace verity signature checking optional. This adds a
dissection flag to enable the logic and patches through all our users to
enable it by default, thus effectively not changing anything from the
status quo ante. However, know we have a knob to turn this off in
certain scenarios.
2024-02-28 16:17:40 +01:00
Lennart Poettering 29eddf0ea4 nspawn: minor coding style tweaks to nspawn-register.c 2024-02-28 11:07:58 +01:00
Lennart Poettering b4679016f3 nspawn: hide ^] hint unless we are interactive mode
The hotkey only works in interactive mode hence don't mislead users
about it.
2024-02-26 11:55:11 +01:00
Lennart Poettering d4ece77f5e ptyfwd: optionally prefix window title with colored dot
in uid0/systemd-run/nspawn we already set a window title with a colorful
unicode dot indicating the changed privileges/execution context. This typically
gets overriden by the shell inside the environment however.

Let's tweak this a bit: when we see the window title OSC ANSI sequence
passing through, let's patch in the unicode dot as a prefix to the
title.

This is super pretty, since it makes sure root sessions via 0ad are
really easily recognizable as such, because the window title carries an
🔴 red dot as prefix then.
2024-02-23 21:15:25 +00:00
Lennart Poettering db7136ec73 signal-util: imply sentinel -1 in sigprocmask_many() + sigset_add_many() args list 2024-02-23 09:35:12 -08:00
Daan De Meyer 55c2350e85 Merge pull request #31320 from DaanDeMeyer/versioning
meson: Start adding devel and rc suffixes to the project version
2024-02-15 20:15:04 +01:00
Benjamin Franzke 614d09a37d nspawn: add support for owneridmap bind option
owneridmap bind option will map the target directory owner from inside the
container to the owner of the directory bound from the host filesystem.
This will ensure files and directories created in the container will be owned
by the directory owner of the host filesystem. All other users will remain
unmapped. Files to be written as other users in the container will not be
allowed.

Resolves: #27037
2024-02-15 11:49:54 +01:00
Daan De Meyer ea2a57bee3 meson: Start adding devel and rc suffixes to the project version
Let's make sure that versions generated by meson-vcs-tag.sh always
sort higher than official and stable releases. We achieve this by
immediately updating the meson version in meson.build after a new
release. To make sure this version always sorts lower than future
rcs, we suffix it with "~devel" which will sort lower than "~rcX".

The new release workflow is to update the version in meson.build
for each rc and the official release and to also update the version
number after a new release to the next development version.

The full version is exposed as PROJECT_VERSION_FULL and used where
it makes sense over PROJECT_VERSION.

We also switch to reading the version from a meson.version file in
the repo instead of hardcoding it in meson.build. This makes it
easier to access both inside and outside of the project.

The meson-vcs-tag.sh script is rewritten to query the version from
meson.version instead of passing it in via the command line. This
makes it easier to use outside of systemd since users don't have to
query the version themselves first.
2024-02-14 15:36:34 +01:00
Luca Boccassi 27af7c2b4c Merge pull request #31162 from poettering/tint-tweaks
ptyfwd: some tweaks to terminal handling
2024-02-12 16:47:09 +00:00
Sam Leonard d4a58877e4 nspawn: use parse_userns_uid_range 2024-02-12 09:46:01 +00:00
Lennart Poettering ab03434aa7 nspawn: set window title from container name
Let's update the window title with an ANSI sequence if we can. We'll
insert a blue dot, to match the blue tinting of the terminal screen,
indicating that we are in a container.
2024-02-09 18:27:01 +01:00
Sam Leonard 710dcce13f nspawn: add missing OOM check on gethostname_malloc() 2024-02-08 16:05:31 +01:00
Yu Watanabe 5ac0345329 nspawn: fix typo
Follow-up for f94025a136.
2024-02-08 11:36:08 +09:00
Luca Boccassi d50f58d641 Merge pull request #31210 from poettering/chdir-hardening
WorkingDirectory= hardening
2024-02-06 12:41:43 +00:00
Lennart Poettering 83d5dab4de nspawn: and also add comment, making clear chdir() should come late 2024-02-06 11:13:28 +01:00
Lennart Poettering f94025a136 nspawn: also refuse paths below API VFS in nspawn's --chdir= field 2024-02-06 11:13:28 +01:00
Mike Yuan b409aacb0a mountpoint-util: introduce path_is_mount_point_full 2024-02-06 15:09:28 +08:00
Ivan Shapovalov 00fcd79e65 nspawn: permit --ephemeral with --link-journal=try-* (treat as =no)
Common sense says that to "try" something means "to not fail if
something turns out not to be possible", thus do not make this
combination a hard error.

The actual implementation ignores any --link-journal= setting when
--ephemeral is in effect, so the semantics are upheld.
2024-02-03 03:03:41 +09:00
Yu Watanabe a342d9e087 nspawn: resolve network interface names before moving to container network namespace
To escape a kernel issue fixed by
https://github.com/torvalds/linux/commit/8e15aee621618a3ee3abecaf1fd8c1428098b7ef,
let's resolve provided interface names earlier, and adjust the interface
name pairs with the result.

Fixes #31104.
2024-01-30 20:37:13 +09:00
Lennart Poettering 269f70de78 nspawn: fix separating empty lines in --help text
When I added the --background= switch I placed the empty line that was
supposed to separate the options from the next section before the switch
rather than after. Fix that.

To make issues like this harder to run into next time, let's move the \n
from the end of the preceeding line to the beginning of the section
title, since that's pretty much where they belong to.

Follow-up for: 3d8ba7b83f
2024-01-23 23:24:19 +00:00
Lennart Poettering 8bf3891e8e nspawn: tint the terminal bg blue if we are in a container
Let's give people a hint that they are not operating on the host.
2024-01-23 16:45:37 +01:00
Lennart Poettering 3d8ba7b83f nspawn: optionally tint the background color of a container 2024-01-23 16:45:37 +01:00
Lennart Poettering 75673cd8ae user-util: add get{pw,gr}{uid,gid,name}_malloc() helpers
These are wrappers around getpwuid_r() and friends, and will allocate the
right-sized buffer for this call.

We so far had multiple implementations of a buffer allocation loop
around getpwuid_r() and friends, and they all suck in some way. Let's
clean this up and add a common implementation, and use it everywhere.

Also, be more careful with error numbers, in particular systematically
turn ENOENT into ENOSRCH (the former is what is returned if /etc/passwd
is absent, which we want to consider identical to user not existing,
which is ENOSRCH). We so far did this at some invocations, but not all.

There are some invocations of getpwuid() left in the codebase. We really
should fix those too, and have a single unified implementation of the
logic, but those are not as trivial to convert, so left for another
time.
2024-01-22 17:55:07 +01:00
Lennart Poettering 1807baa931 nspawn,vmspawn: let's add some terminal magic to the welcome text
Let's grey the text out, and prefix it with a vertical grey bar, to make
clear this is output from the host, not the payload, and make it clearly
distinguishable from what follows.

Let's also make the image name clickable (with new enough
shared-mime-info this should allow you to look into the image with
gnome-disk-utility or a similar tool.
2024-01-22 16:24:00 +01:00
Yu Watanabe 1c3e5b4210 nspawn-network: support passing wireless interface to container
Closes #7873.
2024-01-19 19:06:12 +09:00
Yu Watanabe 326214bfa8 nspawn-network: also check alternative names
If the requested new name for a network interface is already assigned as a
alternative name, then it is not necessary to and cannot rename the
interface.
2024-01-19 19:05:27 +09:00
Yu Watanabe 38475cac6f nspawn-network: split out move_network_interface_one()
This also changes to use sd_device to get some attributes.
So, on moving interfaces back to the parent, we need to populate sysfs
associated to the client netns.
That may look redundant and complicated, but it makes later change
easier, and hopefully faster.
2024-01-19 19:05:26 +09:00
Yu Watanabe cdd9988e43 nspawn-network: split out move_back_network_interfaces()
No functional change, just refactoring and preparation for later
commits.
2024-01-19 19:05:25 +09:00
Yu Watanabe d2881ef96e tree-wide: add short comments for namespace_open() and namespace_enter()
Also use -EBADF when unspecified.
2024-01-19 15:06:08 +09:00
Lennart Poettering e7f2eef411 Merge pull request #30973 from mrc0mmand/gcc14
Reorder arguments for calloc()-like functions, part #2
2024-01-18 09:16:40 +01:00
Lennart Poettering 69f3c61990 tree-wide: port over various pieces of code to strv_extend_many() 2024-01-17 11:32:11 +01:00
Frantisek Sumsal fdd84270df Reorder arguments for calloc()-like functions, part #2
To appease gcc-14's -Wcalloc-transposed-args check.

Follow-up for 2a9ab0974b.
2024-01-17 11:09:09 +01:00
Lennart Poettering 613fb4b601 nspawn: expose a dir in the container where it can bind AF_UNIX sockets that will appear on the host 2024-01-11 16:05:20 +01:00
Lennart Poettering d16d05d2d3 nspawn: drop empty #if/#endif section
Follow-up for adb29d588e
2024-01-09 16:06:30 +01:00
Mike Yuan bdd2036e81 hexdecoct: make unbase64mem and unhexmem always use SIZE_MAX 2024-01-09 03:59:15 +09:00
Lennart Poettering 6db53d20f5 nspawn: lock down access to notify socket a bit
On Linux only the "w" access bit is necessary to connect to an AF_UNIX
socket, hence let's only set that and nothing else, to limit exposure.

Just paranoia.
2024-01-06 11:21:00 +09:00
Lennart Poettering 9807ee19b0 Merge pull request #30791 from poettering/nspawn-restrict-run-host
nspawn: make some files we expose in /run/host/ in nspawn read-only via access mode
2024-01-05 22:37:29 +01:00
Lennart Poettering 32fa24582c nspawn: add new common make_run_host() helper
This new helper creates the /run/host/ top-level dir inside the
container.
2024-01-05 22:34:47 +01:00
Lennart Poettering 05794f5c48 nspawn: set read-only access mode on two /run/host/ files
The diectory is mounted read-only anyway, hence this doesn't do much,
but let's lock this down on every level we can.
2024-01-05 17:31:08 +01:00
Lennart Poettering 300a03bec3 nspawn: hook up --image=/--directory=/--template= with vpick logic 2024-01-03 18:38:46 +01:00
Yu Watanabe fe3fcb9492 Merge pull request #30633 from mrc0mmand/cocci-shenanigans
coccinelle: rework how we run the Coccinelle transformations
2023-12-26 05:45:58 +09:00
Frantisek Sumsal 34e2897f51 nspawn: log & return in a single statement 2023-12-25 18:26:59 +01:00
Yu Watanabe b3a9d980f3 tree-wide: drop space between variable and an increment/decrement 2023-12-25 01:56:40 +09:00
Mike Yuan dd9c8da865 various: clean up isatty() handling
As per https://github.com/systemd/systemd/pull/30547#discussion_r1434371627
2023-12-22 23:06:49 +08:00
Yu Watanabe 43127aebc7 tree-wide: use hashmap_isempty() and friends 2023-12-22 01:27:09 +09:00
Matteo Croce e22ad53d5c dbus-wait-for-jobs: change 'quiet' flag to enum
Change the 'quiet' flag to `bus_wait_for_jobs()` to an enum, so we can
select with more granularity the type of information logged.
2023-12-19 04:52:41 -08:00
Lennart Poettering e22ca70008 ether-addr-util: split out logic to mark MAC addresses as random 2023-12-19 11:48:05 +09:00
Mike Yuan bd546b9b48 machine-credential: introduce MachineCredentialContext
This allows more straightforward memory management and
the use of static destructor.

Requested (by me) in https://github.com/systemd/systemd/pull/30143#discussion_r1401980763
2023-12-14 08:50:44 +00:00