Commit Graph
8191 Commits
Author SHA1 Message Date
Mike Yuan 3a1fc3860f shared/wall: use loop_write_full 2023-09-07 20:32:45 +08:00
Mike Yuan e22c60a9d5 io-util: introduce loop_write_full that takes a timeout
Also drop do_poll as the use case is covered
by timeout.
2023-09-07 20:30:44 +08:00
Lennart Poettering ef65c0f6cc openssl-util: add common implementation of digest+sign 2023-09-06 18:34:21 +01:00
Thorsten Kukuk 53c0397b1d shared/wall: use logind if build without utmp support
If systemd is build without utmp support, use sd_get_sessions() in
utmp_wall() to get a list of logged in users with the corresponding tty.
2023-09-06 13:19:26 +01:00
Luca Boccassi ee6cf8eaf1 dissect: add 'f2fs' to allow-listed filesystems
f2fs is actively maintained upstream, and popular in certain device
categories (phones, embedded), so allow-list by default.

Fixes https://github.com/systemd/systemd/issues/29026
2023-09-05 21:38:29 +01:00
Jan Janssen 5169177fb0 ask-password: Use unicode for password echo 2023-09-05 12:54:51 +02:00
Luca Boccassi 626a9eba09 Merge pull request #28988 from keszybz/sd128-arbitrary-values
Add sd-id128 and systemd-id128 functionality to do "app specific" with any "base"
2023-09-03 14:05:32 +01:00
Luca Boccassi 4b246347ba Merge pull request #28963 from YHNdnzj/loginctl-table
loginctl: use vertical table for {user,session,seat}-status
2023-09-03 14:04:24 +01:00
Mike Yuan 62efc7629b format-table: use format_timestamp_relative_monotonic 2023-09-02 22:58:00 +08:00
Lennart Poettering c6c5d20de5 Revert "shutdown: do not umount recursively before MS_MOVE"
This reverts commit 6b219b74de.

This commit doesn't look right to me. We have to unmount everything
recursively *before* we MS_MOVE because the MS_MOVE will not get rid of
it for us, and we simply cannot access these mounts after the MS_MOVE is
complete anymore.

This is a fundamental difference between MS_MOVE and pivot_root(). The
latter repivots the entire mount table getting rid of anything outside
of the new root. MS_MOVE otoh just mounts a bunch of mount points to the
top, leaving in place whatever might be underneath it.

Thus, if we go through the MS_MOVE codepath we must unmount everything
explicitly before doing so because otherwise the mounts will be pinned
forever, but be entirely invisble to userspace.
2023-09-02 19:47:58 +08:00
Lennart Poettering 95648f9ed0 switch-root: when pivot_root() fails, but old root shall be mounted, do so
If pivot_root() fails, we'll fall back to switching root via MS_MOVE.
Unlike pivot_root() that won't place the old root fs anyway, but just
hide it. That's problematic during shutdown for example, since after all
we might still want to access it from the exitrd, to disassemble it
properly.

Hence let's make things somewhat systematic: regardless if pivot_root()
or MS_MOVE is used, always make the old root fs show up in the selected
new dir.
2023-09-02 19:47:58 +08:00
Lennart Poettering c2d62118f7 switch-root: rework SWITCH_ROOT_SKIP_RECURSIVE_RUN flag
Negative flags always raise eyebrows. Let's normalize
SWITCH_ROOT_SKIP_RECURSIVE_RUN to become SWITCH_ROOT_RECURSIVE_RUN, i.e.
make recursive behaviour opt-in, rather than opt-out. We only want it
for the initrd→host transition, and in all other cases we'd prefer to
avoid it.

This allows us to simplify some code. Also, normalize the mount point
table in switch_root() a bit, to be static const, and then just select
between two mount flag sets via SWITCH_ROOT_RECURSIVE_RUN, where the
mount flag without MS_BIND (i.e. zero) just means "skip this entry".

This does not actually change anything in behaviour, it's just
refactoring.

Follow-up for: b12d41a8bb
2023-09-02 19:47:57 +08:00
Zbigniew Jędrzejewski-Szmek aea3f594db various: use id128_from_string_not_null()
No functional change. In config_parse_address_generation_type() we would set
the output parameter and then say it's ignored, so it _looked_ like an error in
the code, but the variable was always initialized to SD_ID128_NULL anyway, so
the code was actually fine.
2023-09-02 14:16:25 +03:00
Yu Watanabe 1d4c874d3c Merge pull request #24570 from topimiettinen/nft-sets-v2
network: firewall integration with NFT sets
2023-09-01 20:13:39 +09:00
Lennart Poettering cb19bdaebf tpm2: whenever we measure, also write a tpm log record
Previously we only logged our measurements to the journal. This is not a
great solution though, since regular logs are subject to rotation, which
is something we really cannot have for measurements (as it means we can
never reproduce the PCR values from the data). Hence, let's maintain an
explicit log.

Ideally, we'd just use the TCG Canonical Event Log format 1:1
(https://trustedcomputinggroup.org/resource/canonical-event-log-format/).
However it's not a perfect fit fo us, for various reasons. But let's
follow it (in its JSON incantation) as closely at it makes sense, so
that it can easily be converted to the full format by programs consuming
it.

Code comments explain where we deviate from the TCG CEL-JSON, and what
to do about it when reading the data.
2023-08-30 12:59:34 +02:00
Luca Boccassi 8fcc700bd9 Merge pull request #28955 from poettering/generic-pe
unify two disparate PE executable parsers we currently have into one
2023-08-29 16:09:54 +01:00
Zbigniew Jędrzejewski-Szmek f1c0ad5279 shared/id128-print: fix indentation, reduce variable scope 2023-08-29 17:06:47 +03:00
Malte PollandPaul Meyer 4947de275a mkfs-util: propagate SOURCE_DATE_EPOCH to mcopy
Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
2023-08-29 14:58:44 +01:00
Lennart Poettering d8e2ba1b8e shared: remove now unused pe-header.h 2023-08-29 11:25:52 +02:00
Lennart Poettering 5c425807bf shared: port kernel-image.c over to new common PE parser 2023-08-29 11:25:52 +02:00
Lennart Poettering 8bc9d1aa9f shared: port bootspec.c over to new common PE parser 2023-08-29 11:25:52 +02:00
Lennart Poettering 0786b03969 shared: add common implementation of PE parser 2023-08-29 11:25:52 +02:00
Luca Boccassi cd4ed8579b Merge pull request #28948 from poettering/tpm2-duplicate-pcr-names
tpm2: unify tpm2 PCR symbolic identifiers
2023-08-28 17:43:10 +01:00
Luca Boccassi f154440980 Merge pull request #28916 from ddstreet/tpm2_pcr_value_post_merge
Tpm2 pcr value post merge
2023-08-28 17:42:48 +01:00
Zbigniew Jędrzejewski-Szmek 6f420b5f75 Merge pull request #28968 from DaanDeMeyer/rlimit
Limit rlim_max in rlimit_nofile_safe() to nr_open
2023-08-27 16:06:58 +02:00
Topi Miettinen 97f7fe97ab shared/firewall-util: promote failure to init ipv6 NAT to error 2023-08-26 21:37:51 +03:00
Topi Miettinen fc289dd0ad network: firewall integration with NFT sets
New directive `NFTSet=` provides a method for integrating network configuration
into firewall rules with NFT sets. The benefit of using this setting is that
static network configuration or dynamically obtained network addresses can be
used in firewall rules with the indirection of NFT set types. For example,
access could be granted for hosts in the local subnetwork only. Firewall rules
using IP address of an interface are also instantly updated when the network
configuration changes, for example via DHCP.

This option expects a whitespace separated list of NFT set definitions. Each
definition consists of a colon-separated tuple of source type (one of
"address", "prefix", or "ifindex"), NFT address family (one of "arp", "bridge",
"inet", "ip", "ip6", or "netdev"), table name and set name. The names of tables
and sets must conform to lexical restrictions of NFT table names. The type of
the element used in the NFT filter must match the type implied by the
directive ("address", "prefix" or "ifindex") and address type (IPv4 or IPv6)
as shown type implied by the directive ("address", "prefix" or "ifindex") and
address type (IPv4 or IPv6) must also match the set definition.

When an interface is configured with IP addresses, the addresses, subnetwork
masks or interface index will be appended to the NFT sets. The information will
be removed when the interface is deconfigured. systemd-networkd only inserts
elements to (or removes from) the sets, so the related NFT rules, tables and
sets must be prepared elsewhere in advance. Failures to manage the sets will be
ignored.

/etc/systemd/network/eth.network
```
[DHCPv4]
...
NFTSet=prefix:netdev:filter:eth_ipv4_prefix
```

Example NFT rules:
```
table netdev filter {
        set eth_ipv4_prefix {
                type ipv4_addr
                flags interval
        }
        chain eth_ingress {
                type filter hook ingress device "eth0" priority filter; policy drop;
                ip saddr != @eth_ipv4_prefix drop
                accept
        }
}
```
```
$ sudo nft list set netdev filter eth_ipv4_prefix
table netdev filter {
        set eth_ipv4_prefix {
                type ipv4_addr
                flags interval
                elements = { 10.0.0.0/24 }
        }
}
```
2023-08-26 21:37:09 +03:00
Daan De Meyer fbc6a75571 mkfs-util: Set FORK_REOPEN_LOG
We set FORK_CLOSE_ALL_FDS, so we should also set FORK_REOPEN_LOG to
reopen the log in the child process so we don't miss any logging
messages.
2023-08-25 14:25:33 +02:00
Dan Streetman 81e3d37211 tpm2: wrap (7) in UINT32_C() 2023-08-24 12:35:58 -04:00
Dan Streetman 26d8d71fa5 tpm2: add tpm2_pcr_values_has_(any|all)_values() functions 2023-08-24 12:35:58 -04:00
Dan Streetman 70cb382d36 tpm2: remove unnecessary void* cast 2023-08-24 12:35:58 -04:00
Dan Streetman ed35ac3155 tpm2: make logging level consistent at debug for some functions 2023-08-24 12:35:58 -04:00
Dan Streetman 3f4d5dfd65 tpm2: use switch() instead of if-else 2023-08-24 12:35:58 -04:00
Dan Streetman 6761e1355e tpm2: use table for openssl<->tpm2 ecc curve id mappings 2023-08-24 12:35:54 -04:00
Dan Streetman b030710295 openssl: use new(char, size) instead of malloc(size) 2023-08-24 12:33:26 -04:00
Dan Streetman 65fd657e0a tpm2: use memcpy_safe() instead of memcpy() 2023-08-24 12:33:26 -04:00
Dan Streetman ae2b38e463 tpm2: remove ret_ prefix from input/output params 2023-08-24 12:33:26 -04:00
Dan Streetman c6e5178220 tpm2: split TPM2_PCR_VALUE_MAKE() over multiple lines 2023-08-24 12:33:26 -04:00
Dan Streetman 85b6f299b2 tpm2: use strempty() 2023-08-24 12:33:26 -04:00
Dan Streetman 8e757259c3 tpm2: check pcr value hash != 0 before looking up hash algorithm name 2023-08-24 12:33:26 -04:00
Dan Streetman 495f2bf57c tpm2: simplify call to asprintf() 2023-08-24 12:33:26 -04:00
Dan Streetman 2b2ee3f265 tpm2: put !isempty() check inside previous !isempty() check 2023-08-24 12:33:26 -04:00
Dan Streetman 7001a7daf7 tpm2: use SIZE_MAX instead of strlen() for unhexmem() 2023-08-24 12:33:26 -04:00
Dan Streetman 193fd5730e tpm2: in tpm2_pcr_values_valid() use FOREACH_ARRAY() 2023-08-24 12:32:51 -04:00
Dan Streetman 064ac95d81 tpm2: in validator functions, return false instead of assert failure 2023-08-24 12:31:00 -04:00
Dan Streetman 3cd4145f34 tpm2: move cast from lhs to rhs in uint16_t/int comparison 2023-08-24 12:31:00 -04:00
Dan Streetman cc1a78d5c4 tpm2: lowercase TPM2_PCR_VALUE[S]_VALID functions
As these are not macros, they should be lowercase.
2023-08-24 12:31:00 -04:00
Dan Streetman 7354a7ccd4 tpm2: change *alg_to_* functions to use switch() 2023-08-24 12:31:00 -04:00
Lennart Poettering 6b0651df60 gpt: move basic header/partition structure of GPT into common code
This way we can use it at other places too, not just when dissecting
images.
2023-08-24 15:25:38 +02:00
Lennart Poettering e0e1f4f7a2 fundamental: rename tpm-pcr.h → tpm2-pcr.h
I always found it confusing that most of our TPM related definitions are
in tpm2-util.h, but the PCR names in tpm-pcr.h, without the "2". Let's
fix that and make this systematic, in particular as the definitions in
the file all start with TPM2_ already.

No code flow changes, just some renaming.
2023-08-24 13:40:37 +02:00