Commit Graph
5401 Commits
Author SHA1 Message Date
Lennart Poettering 85b55869bc tree-wide: port everything over to new sd-id128 compund literal bliss 2021-08-20 11:09:48 +02:00
Lennart Poettering dc131951b5 Merge pull request #18385 from kinvolk/mauricio/restrict-network-interfaces
Add RestrictNetworkInterfaces=
2021-08-20 03:41:11 +02:00
Daan De Meyer 6c35ea5ef0 udev: Add support for configuring nic coalescing settings
These are configured via the corresponding ethtool ioctl.
2021-08-20 00:32:28 +01:00
Lennart Poettering 7b58fcdd70 Merge pull request #19797 from oniko/systemd-fido2-pkcs11-plugins
Add support for remaining systemd fido2 and pkcs11 libcryptsetup plugins
2021-08-19 16:37:55 +02:00
Luca Boccassi 61a6aa21a5 Merge pull request #20471 from poettering/format-str-proc-fd
add FORMAT_PROC_FD_PATH() macro for generating /proc/self/fd/ paths on-the-fly
2021-08-19 14:05:22 +01:00
Ondrej Kozina 8186022c9d Add support for systemd-pkcs11 libcryptsetup plugin.
Add support for systemd-pkcs11 based LUKS2 device activation
via libcryptsetup plugin. This make the feature (pkcs11 sealed
LUKS2 keyslot passphrase) usable from both systemd utilities
and cryptsetup cli.

The feature is configured via -Dlibcryptsetup-plugins combo
with default value set to 'auto'. It get's enabled automatically
when cryptsetup 2.4.0 or later is installed in build system.
2021-08-19 13:58:10 +02:00
Ondrej Kozina 0ff605665a pkcs11-util: split pkcs11_token_login function
Future systemd-pkcs11 plugin requires unlock via single
call with supplied pin. To reduce needless code duplication
in plugin itself split original pkcs_11_token_login call in
two calls:

new pkcs11_token_login_by_pin and the former where loop
for retrying via PIN query callback remains.
2021-08-19 13:58:10 +02:00
Ondrej Kozina ed3d3af148 cryptsetup-pkcs11: move pkcs11_callback and data in shared utils.
To be used later by both (future) systemd-pkcs11 libcryptsetup
plugin and cryptsetup-pkcs11.
2021-08-19 13:58:10 +02:00
Yu Watanabe 7ff592a454 creds-util: fix possible divide-by-zero
input_size may be zero.

Fixes #20469.
2021-08-19 09:49:00 +02:00
Lennart Poettering ddb6eeafe2 tree-wide: port things over to FORMAT_PROC_FD_PATH() 2021-08-19 09:19:27 +02:00
Lennart Poettering 12a7f04a2b discover-image: pass the right fd to fd_getcrtime() 2021-08-19 09:18:45 +02:00
Mauricio Vásquez a59cb62cf2 core: add D-bus properties for RestrictNetworkInterfaces=
Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
2021-08-18 15:55:53 -05:00
Yu Watanabe 0d341eccef udev: make RxChannels= or friends also accept "max"
Follow-up for 406041b7de.

Also, this makes
- the settings accept an empty string,
- if the specified value is too large, also use the advertised maximum
  value.
- mention the range of the value in the man page.
2021-08-18 16:55:03 +02:00
Yu Watanabe bdbb61f69f tree-wide: fix typo 2021-08-18 13:36:14 +02:00
Daan De Meyer 406041b7de udev: Support "max" string for BufferSize options (#20458)
"max" indicates the hardware advertised maximum queue buffer size
should be used.

The max sizes can be checked by running `ethtool -g <dev>` (Preset maximums).
Since the buffer sizes can't be set to 0 by users, internally we use 0 to
indicate that the hardware advertised maximum should be used.
2021-08-18 15:59:13 +09:00
Luca Boccassi 9a4b883be2 extension-release: search for other files if expected name not found
In some cases image names are unpredictable - some orchestrators/deployment
tools like to mangle names to suit their internal formats. In these cases,
the requirement that the extension-release file matches exactly the image
name where it's contained cannot work.

Allow falling back to loading the first regular file which name starts with
'extension-release' located in /usr/lib/extension-release.d/ and tagged with
a user.extension-release.strict extended attribute with a true value, if the
one with the expected name cannot be found.
2021-08-17 13:04:44 +01:00
Lennart Poettering 7a6abbe937 env-util: add unsetenv_erase() helper
Let's unify how we remove secrets from the env block.
2021-08-17 13:17:44 +02:00
Lennart Poettering 235be6bcea shared: add generic helper tools for installing files/dir trees
This adds a bit of generic helper tools for installing files/dir trees.
"installing" is supposed to mean the final step when preparing a disk
image or directory tree, where the result is renamed to its final name.
It has some bells and whistles, as it is able to replace existing files
sanely, can fsync() things carefully and can mark things read-only in a
nice way.

This is supposed to be generic, unified code that can be used eventually
for any of our tools that prepare disk images/directory trees, including
importd, nspawn's --template= mechanism, the discover-image.c logic,
and more.
2021-08-17 10:08:48 +02:00
Yu Watanabe c2f2250e5c ethtool: make ethtool_set_features() return earlier when nothing is requested 2021-08-17 00:49:01 +09:00
Yu Watanabe 0db68800c7 ethtool: make the size of 'features' array static 2021-08-17 00:48:18 +09:00
Yu Watanabe 0995accdfd hostname: introduce gethostname_full() and use it in various gethostname() variants 2021-08-12 13:48:15 +09:00
Yu Watanabe ccdf235464 hostname: fix off-by-one issue in gethostname()
gethostname() returns null-terminated hostname.

Fixes #20309 and #20417.
2021-08-12 13:48:15 +09:00
Andrej Lajovic 23e026de25 shared/copy: add a new flag COPY_ALL_XATTRS
When the flag COPY_ALL_XATTRS is set, it causes the complete set of xattrs
to be copied. If the flag is unset, only xattrs from the "user" namespace
are copied.

Fixes #17178.
2021-08-11 17:48:10 +02:00
MertsA bbd239f67a Get rid of dangling setutxent()
utmp_wall() and utmp_put_dead_process() called setutxent() directly instead of the stub in utmp-wtmp.h and never called endutxent(). This would leave /run/utmp left open by PID 1 or journald. This can be reproduced by e.g. lsof /run/utmp and systemd-cat -p 0 echo test. For utmp_put_dead_process() it would only leave it open if it returned early before calling write_utmp_wtmp()
2021-08-11 09:40:10 +02:00
Luca Boccassi 788733428d Merge pull request #20368 from keszybz/drop-assert-not-reached-text
Drop the text argument from assert_not_reached()
2021-08-03 21:15:25 +01:00
Luca Boccassi 8954e89195 creds: assert that credential read from file fits in data struct
Coverity CID#1458114
2021-08-03 14:56:28 +01:00
Zbigniew Jędrzejewski-Szmek 04499a70fb Drop the text argument from assert_not_reached()
In general we almost never hit those asserts in production code, so users see
them very rarely, if ever. But either way, we just need something that users
can pass to the developers.

We have quite a few of those asserts, and some have fairly nice messages, but
many are like "WTF?" or "???" or "unexpected something". The error that is
printed includes the file location, and function name. In almost all functions
there's at most one assert, so the function name alone is enough to identify
the failure for a developer. So we don't get much extra from the message, and
we might just as well drop them.

Dropping them makes our code a tiny bit smaller, and most importantly, improves
development experience by making it easy to insert such an assert in the code
without thinking how to phrase the argument.
2021-08-03 10:05:10 +02:00
Egor Ignatov b10abe4bba time-set: adjust system clock if rtc is far in future 2021-08-02 20:33:01 +01:00
Luca Boccassi f121bd7818 Merge pull request #20352 from poettering/copy-tweaks
various tweaks to copy.c
2021-08-02 20:31:42 +01:00
David Seifert 2b6c0bb2a3 Use correct <poll.h> include
* `<sys/poll.h>` is not specified in POSIX
2021-08-02 17:31:32 +01:00
Lennart Poettering 28ba7e36d0 btrfs-util: expose COPY_SIGTERM for btrfs_snapshot() too 2021-08-02 17:24:23 +02:00
Lennart Poettering 1ac404cac0 copy: add COPY_SIGTERM, matching the existing COPY_SIGINT 2021-08-02 17:24:18 +02:00
Lennart Poettering 864e406256 copy: add COPY_SYNCFS flag
When copying large directory trees it should be a better idea to sync
the whole fs once when we are done instead of individually for each
file, hence add COPY_SYNCFS.

As opposed to COPY_FSYNC/COPY_FSYNC_FULL this only really applies to the
top-level directory, after completion of the whole copy.
2021-08-02 17:24:09 +02:00
Lennart Poettering 06a40b52d9 copy: optionally fsync() files after copying them
As a safety precaution it makes sense to fsync() files after copying
them, and maybe even the directories they are contained in. Let's add a
flag for these two cases.
2021-08-02 17:24:03 +02:00
Lennart Poettering 2f78204498 copy: tighten destination checks when copying files
let's make sure we only operate on regular files when copying files.

Also, make sure to copy file attributes only over if target is a regular
file (so that copying a file to /dev/null won't alter the access
mode/ownership of that device node...)
2021-08-02 17:23:58 +02:00
Lennart Poettering 5c9d961e79 copy: move to single clean-up path
(This might not look like a big improvement, but will shortly, when we
add fsync() support to the copy logic, at which point there are more
error paths we can unify that way.)

While we are at it, tweak a clean-up path: only unlink a copied file if
we are definitely the ones who created them, i.e. if O_EXCL is set.
2021-08-02 17:23:52 +02:00
Lennart Poettering 7d963260a1 Merge pull request #20172 from poettering/import-util-tweaks
Import-util: URL processing tweaks
2021-07-30 19:05:06 +02:00
Lennart Poettering 07697bfee6 tpm2-util: auto-detect supported PCR banks
Previously, we'd encode PCR policies strictly with the SHA256 PCR bank
set. However, as it appears not all hw implement those. Sad.

Let's add some minimal logic to auto-detect supported PCR banks: if
SHA256 is supported, use that. But if not, automatically fall back to
SHA1.

This then changes both the LUKS code, and the credentials code to
serialize the selected bank, along with the rest of the data in order to
make this robust.

This extends the LUK2 JSON metadata in a compatible way. The credentials
encryption format is modified in an incompatible way however, but given
that this is not part of any official release should be OK.

Fixes: #20134
2021-07-30 19:03:35 +02:00
Lennart Poettering 56ce4adafe import-util: tweak url patching helper
let's share some code between import_url_last_component() and
import_url_change_last_component(), and make sure we never eat up the
hostname component of the URL when parsing out the last component.

Let's also make import_url_change_last_component() more generic so that
we can also use it for append components to paths, instead of replacing
suffixes.
2021-07-30 16:23:20 +02:00
Lennart Poettering 1f0fb7d544 rm-rf: refactor rm_rf_children(), split out body of directory iteration loop
This splits out rm_rf_children_inner() as body of the loop. We can use
that to implement rm_rf_child() for deleting one specific entry in a
directory.
2021-07-30 16:14:37 +02:00
Lennart Poettering 7df660e456 seccomp: move sched_getaffinity() from @system-service to @default
See: https://github.com/systemd/systemd/pull/20191#issuecomment-881982739

In general, we shouldn't blanket move syscalls like this into @default,
given that glibc actually does have fallbacks, afaics. However, as
long as the syscalls are "read-only" and thus benign, I figure it's a
safe thing to do. But we should probably stick to a "if in doubt, don't"
rule, and put these syscalls in @system-service as default, but not into
@default.

I think in the real world @system-service is the sensible group people
should use, and not @default actually.
2021-07-27 17:14:06 +02:00
Lennart Poettering 67347f3740 seccomp: drop getrandom() from @system-service
It's included in @default now, since
14f4b1b568, and since @system-service
pulls that in we can drop it from @system-service.

Follow-up for #20191
2021-07-27 17:13:53 +02:00
Ondrej Kozina d1ae38d85a Add support for systemd-tpm2 libcryptsetup plugin.
Add support for systemd-tpm2 based LUKS2 device activation
via libcryptsetup plugin. This make the feature (tpm2 sealed
LUKS2 keyslot passphrase) usable from both systemd utilities
and cryptsetup cli.

The feature is configured via -Dlibcryptsetup-plugins combo
with default value set to 'auto'. It get's enabled automatically
when cryptsetup 2.4.0 or later is installed in build system.
2021-07-26 15:15:16 +02:00
Luca Boccassi 80362ec56f Merge pull request #20288 from keszybz/freeze-no-malloc
Don't call malloc from freeze which is called in a signal handler
2021-07-23 15:35:34 +01:00
Luca Boccassi f6f4ec7951 discover-image: mount as read-only when extracting metadata
We don't need to modify the image, and the loopback device is already set to read-only.
2021-07-23 14:07:58 +02:00
Cristian Rodríguez 14f4b1b568 malloc() uses getrandom now
glibc master uses getrandom in malloc since https://sourceware.org/git/?p=glibc.git;a=commit;h=fc859c304898a5ec72e0ba5269ed136ed0ea10e1  ,  getrandom should be in the default set so to avoid all non trivial programs to fallback to a PRNG.
2021-07-23 12:24:57 +02:00
Zbigniew Jędrzejewski-Szmek cbcf371abc Add variant of close_all_fds() that does not allocate and use it in freeze()
Even though it's just a fallback path, let's not be sloppy and allocate in
the crash handler.

> The deadlock happens because systemd crash in malloc() then in signal
> handler, it calls malloc() (close_all_fds()-> opendir()-> __alloc_dir())
> again. malloc() is not a signal-safe function, maybe we should re-think
> the logic here.

Fixes #20266.
2021-07-23 11:39:45 +02:00
Zbigniew Jędrzejewski-Szmek 45a68ed307 Move freeze() into shared/
Library code should not call freeze(), this is something that should
only be done by "application code", so moving it into shared/ is appropriate.

The fallback to call _exit() is dropped: let's trust that the infinite loop
is infinite.
2021-07-23 11:39:45 +02:00
Zbigniew Jędrzejewski-Szmek 3e24e8cd64 Move fork_agent() into shared/
Currently it's only used in two places in src/shared/, so the function was
already included just once in compiled code. But it seems appropriate to
move it there anyway, because library code should have no need to fork
agents, so it doesn't belong in basic/.
2021-07-23 11:39:45 +02:00
WANG Xuerui f15f2ab42e gpt: reformat for restoring vertical alignment 2021-07-20 17:32:59 +08:00