Commit Graph

41184 Commits

Author SHA1 Message Date
Lennart Poettering
1d8a8a7dee sysv-generator: port basename() → path_extract_filename() 2022-12-23 17:35:21 +01:00
Lennart Poettering
03469b770b shared: port various shared helpers basename() → path_extract_filename() 2022-12-23 17:35:21 +01:00
Lennart Poettering
7b2ffb593e repart/makefs: port over to path_extract_filename() 2022-12-23 15:04:19 +01:00
Lennart Poettering
7e763f9402 portable: port basename() → path_extract_filename() 2022-12-23 15:04:19 +01:00
Lennart Poettering
b36e39d2eb nspawn: port over basename() → path_extract_filename() 2022-12-23 15:04:19 +01:00
Lennart Poettering
451f0dba60 mount-tool: port over basename() → path_extract_filename() 2022-12-23 15:04:19 +01:00
Lennart Poettering
72d95a18c1 journalctl: port COMM= matching to path_extract_filename() 2022-12-23 15:04:19 +01:00
Lennart Poettering
83802e9abd dissect: remove one more use of basename()
And while we are at it, make use of path_extract_filename() return value
that indicates whether the path was suffixed with a slash.
2022-12-23 15:04:19 +01:00
Lennart Poettering
a99626c11a core: move some basename() use → path_extract_filename() 2022-12-23 15:04:19 +01:00
Lennart Poettering
0eb2f0a2fc tests: we don't actually use basename() anymore 2022-12-23 15:04:19 +01:00
Lennart Poettering
c96c9fc78e homed: move away from basename() 2022-12-23 15:04:19 +01:00
Jia Zhang
c2c38276cb measure: fix the failures of compare_reported_pcr_nr()
EFI_LOADER_VARIABLE() already applies to the stringify to construct the
path of EFI variable in efivars, so it is wrong to enclose the name of
EFI variable with the quotes. Otherwise, the following errors are
reported.

Reading EFI variable /sys/firmware/efi/efivars/StubFeatures-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f.
Reading EFI variable /sys/firmware/efi/efivars/"StubPcrKernelImage"-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f.
open("/sys/firmware/efi/efivars/"StubPcrKernelImage"-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f") failed: No such file or directory
Reading EFI variable /sys/firmware/efi/efivars/"StubPcrKernelParameters"-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f.
open("/sys/firmware/efi/efivars/"StubPcrKernelParameters"-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f") failed: No such file or directory
Reading EFI variable /sys/firmware/efi/efivars/"StubPcrInitRDSysExts"-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f.
open("/sys/firmware/efi/efivars/"StubPcrInitRDSysExts"-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f") failed: No such file or directory

Signed-off-by: Jia Zhang <zhang.jia@linux.alibaba.com>
2022-12-23 14:41:33 +01:00
Yu Watanabe
2b22355075 Merge pull request #25823 from poettering/dissect-diskseq
gpt-auto: reference dissected partitions to mount via diskseq block device symlinks
2022-12-23 22:11:59 +09:00
Yu Watanabe
26c45a6c1d tree-wide: have_effective_cap() may return negative errno 2022-12-23 22:11:00 +09:00
Yu Watanabe
d7301331e8 Merge pull request #25830 from yuwata/wait-online-unmanaged
wait-online: exit with success when all interfaces are ready or unmanaged
2022-12-23 22:10:38 +09:00
Lennart Poettering
71eaa9291d Merge pull request #25777 from PeterCxy/enroll-fido2
cryptenroll: Implement support for unlocking via FIDO2 tokens
2022-12-23 13:14:14 +01:00
Lennart Poettering
8716a76ce2 gpt-auto-generator: enable referencing partitions via diskseq symlinks 2022-12-23 12:44:57 +01:00
Lennart Poettering
1a81ddef00 dissect-image: optionally, reference dissected partition device nodes by diskseq
This is useful to make the dissection logic at boot a bit safer, as we
can reference device nodes by diskseq.

This locks down dissection a bit, since it makes it harder to swap out
the backing device between the time we dissected and validated it, until
we actually mounted it.

This is not complete though, as /bin/mount would have to verify the
diskseq after opening the diskseq symlink again.

See: https://github.com/util-linux/util-linux/issues/1786
2022-12-23 12:44:57 +01:00
Lennart Poettering
a559088671 dissect-image: simplify things by avoiding one string copy
We don't need the node in its original variable anymore, hence let's
just move it over instead of allocating a copy.
2022-12-23 12:42:37 +01:00
Lennart Poettering
13b99dccb7 import-creds: don't try to import VM creds in a container
If we run in a container we shouldn#t try to import creds passed in from
a VMM, as they are not for us, but for the VM itself.
2022-12-23 00:46:41 +01:00
Peter Cai
48765191d2 cryptenroll: Implement support for unlocking via FIDO2 tokens
This allows FIDO2 users to wipe out password slots and still be able to
enroll new key slots via systemd-cryptenroll. Note that when the user
wants to both unlock with a FIDO2 token and enroll a new FIDO2 token,
they cannot be set to automatic discovery. This is to safeguard against
confusion, because there will be multiple tokens connected to the system
when doing so -- and we require users to explicitly confirm which one to
use for unlocking and which one to use for enrollment.

Addresses #20230 for the FIDO2 case.
2022-12-22 17:33:25 -05:00
Luca Boccassi
21c8d750cd Merge pull request #25814 from DaanDeMeyer/ukify
ukify: Prefer using llvm-objcopy instead of objcopy
2022-12-22 22:19:05 +01:00
Peter Cai
52105bb487 cryptsetup-fido2: Remove plain mode parameters from acquire_fido2_key_auto()
`acquire_fido2_key_auto()` will not be used in PLAIN mode, and
parameters such as the salt will be acquired from the LUKS header.
Parameters intended for PLAIN mode are useless in
`acquire_fido2_key_auto()`.
2022-12-22 11:20:56 -05:00
Peter Cai
0a8e026e82 cryptsetup-fido2: Relocate to libsystemd-shared 2022-12-22 08:43:50 -05:00
Daan De Meyer
3fc1ae89e7 ukify: Validate that there are no overlapping sections
Let's make sure that after calling objcopy we have no overlapping
sections in the UKI
2022-12-22 12:21:11 +01:00
Daan De Meyer
789a642738 ukify: Prefer using llvm-objcopy instead of objcopy
llvm-objcopy works on stubs built for foreign architectures whereas
objcopy doesn't so let's prefer using llvm-objcopy instead of objcopy.

llvm-objcopy automatically sets the virtual address and doesn't provide
an option to set it manually so we only add --change-section-vma when
using objcopy

The default section flags differ between llvm-objcopy and objcopy
so we add a default for the section flags so we make sure all sections
are read-only data unless specified otherwise.
2022-12-22 12:20:24 +01:00
Daan De Meyer
22ad038ac6 ukify: Allow passing multiple directories to --tools 2022-12-22 12:19:55 +01:00
Luca Boccassi
27ce258c54 Merge pull request #25791 from keszybz/ukify-check-inputs
ukify: check inputs
2022-12-22 12:10:32 +01:00
Yu Watanabe
9c29d87bee macro: check existence of cleanup function before call it
The free function specified in the macro may be provided by a
dynamically loaded library.

Replaces #25781.
2022-12-22 10:59:26 +01:00
Lennart Poettering
80ce8580f5 dissect-image: let's lock down fstypes a bit
When we dissect images automatically, let's be a bit more conservative
with the file system types we are willing to mount: only mount common
file systems automatically.

Explicit mounts requested by admins should always be OK, but when we do
automatic mounts, let's not permit barely maintained, possibly legacy
file systems.

The list for now covers the four common writable and two common
read-only file systems. Sooner or later we might want to add more to the
list.

Also, it might make sense to eventually make this configurable via the
image dissection policy logic.
2022-12-22 10:30:35 +09:00
Yu Watanabe
ab3aed4a03 wait-online: exit with success when all interfaces are ready or unmanaged
Previously, when neither '--any' nor '--interface' options specified,
at least one of the interfaces must be in configured state.
This patch makes wait-online exit with success even if all interfaces
are in unmanaged state.

This may break backward compatibility in a rare situation. But in most
cases, this typically not change anything, as at least one interface
is managed by networkd.service when it is enabled.

This is mostly for making wait-online gracefully handle the case that
networkd.service and wait-online.service are enabled by mistake. In such
situation, all interfaces are typically not managed.

Fixes #25813.
2022-12-22 09:40:46 +09:00
Lennart Poettering
c6661401a7 creds: use empty_or_dash() where appropriate 2022-12-21 22:47:47 +01:00
Lennart Poettering
ef2409cbde string-util: rework empty_to_null() to not change "const" qualifier of input
This changes the definition from enpty_to_null() so that we are still
typesafe (i.e. only accept strings) but do not drop (or add) any const
to the returned string that wasn't also on the input.

Inspired by: 3196e2996f
2022-12-21 22:41:16 +01:00
Lennart Poettering
cf451f382a gpt-auto-generator: honour rootfstype= and rootflags= kernel cmdline option
Even if root= is not specified on the kernel cmdline, we should honour
the other rootXYZ= options.

Fixes: #8411
See: #17034
2022-12-21 22:15:02 +01:00
Antonio Alvarez Feijoo
09ed55c26d systemctl: fix typo 2022-12-21 19:34:25 +09:00
Jacek Migacz
8b23242989 resolve: fix enumerator name for DNS search domain 2022-12-20 19:02:18 +01:00
Lennart Poettering
5948d654fa Merge pull request #25789 from yuwata/EBADF
tree-wide: use -EBADF more
2022-12-20 19:01:54 +01:00
Zbigniew Jędrzejewski-Szmek
b764142565 Merge branch 'systemd-security/coredump-capabilities'
CVE-2022-4415: systemd: coredump not respecting fs.suid_dumpable kernel setting
Affects systemd >= 247 with libacl support enabled.

This is a merge of https://github.com/systemd/systemd-security/pull/12/.
I'm doing the merge locally because github doesn't support merging directly
from systemd/systemd-security to systemd/systemd.
2022-12-20 17:56:28 +01:00
Yu Watanabe
5bb1d7fbab tree-wide: use -EBADF more 2022-12-21 01:50:33 +09:00
Zbigniew Jędrzejewski-Szmek
095ff238d0 ukify: check early if inputs exist and are readable
It's much nicer for the user if we fail early instead of doing partial
processing if we cannot read some input. We can't do those checks immediately
from argparse.Parser.parse_args(), because we want to fully process the
commandline first. In particular, even with invalid args, if --help is
specified somewhere, we want to handle that. Thus, we need to delay the checks
after argparse.Parser.parse_args() returns.

Ukify didn't have type annotations on functions, but it probably should.
Jörg's suggested correction included them and we might just as well start here.
2022-12-20 16:10:36 +01:00
Mike Yuan
f206809b97 systemctl: new option --drop-in for specifying drop-in filename
Previously 'systemctl edit' would only operate on
'override.conf', but users may need more than that.
Thus the new option '--drop-in' is added to allow
users to specify the drop-in file name.

Closes #25767
2022-12-20 15:59:11 +01:00
Zbigniew Jędrzejewski-Szmek
33bdec184f ukify: catch error when loading foreign pe file
The autodetection code is supposed to throw ValueError when it
cannot figure out the version so that we fall back to the next method.
With the patch:
  Kernel version not specified, starting autodetection 😖.
  Real-Mode Kernel Header magic not found
  + readelf --notes vmlinuz/arm64/vmlinuz-6.0.9-300.fc37.aarch64
  readelf: vmlinuz/arm64/vmlinuz-6.0.9-300.fc37.aarch64: Error: Not an ELF file - it has the wrong magic bytes at the start
  Found uname version: 6.0.9-300.fc37.aarch64
2022-12-20 10:39:10 +01:00
Yu Watanabe
19ee48a6c2 tree-wide: introduce PIPE_EBADF macro 2022-12-20 11:12:58 +09:00
Yu Watanabe
f26c38edfa fuzz: sort headers 2022-12-20 11:12:58 +09:00
Yu Watanabe
57e7af551e Merge pull request #25786 from keszybz/ebadf
Use -EBADF for fd initialization
2022-12-20 10:02:10 +09:00
Yu Watanabe
8d8d4b092a Merge pull request #25787 from msekletar/rename-process-cap
units: allow systemd-userdbd to change process name
2022-12-20 09:58:47 +09:00
Michal Sekletar
03ee26168f argv-util: do proper permission check while when changing process name
Process renaming happens very seldomly so we are able to afford proper
permission check, i.e. actually check for CAP_SYS_RESOURCE capability
instead of euid.
2022-12-19 17:29:40 +01:00
Lennart Poettering
34eebf08fa Merge pull request #25783 from keszybz/trivial-cleanups
Trivial cleanups
2022-12-19 17:01:51 +01:00
Zbigniew Jędrzejewski-Szmek
e8d2cb0f34 basic/hashmap: add comment
Coverity complains that the check is suspicious. Add a comment to help
the reader.
2022-12-19 15:16:41 +01:00
Zbigniew Jędrzejewski-Szmek
a0e475ce6a efi: do not use 'r' as pointer name
'r' should only be used as in 'int r'.
2022-12-19 15:16:33 +01:00