Commit Graph

7964 Commits

Author SHA1 Message Date
Lennart Poettering
518c4f0488 ptyfwd: make sure pty_forward_free() follows our usual semantics regarding NULL 2023-12-20 15:49:59 +01:00
Lennart Poettering
e7d2b00e0d ptyfwd: reset colors when we exit the pty forwarding logic
Just in case there was still a color set, make sure to reset things.
2023-12-20 15:49:09 +01:00
Mike Yuan
2886cadc72 shared/install: use RET_GATHER more 2023-12-20 12:44:50 +08:00
Yu Watanabe
e2ceb696d6 Merge pull request #30493 from teknoraver/main
Add verbose output on unit start #5717
2023-12-20 13:42:59 +09:00
Lennart Poettering
1a424b0721 varlink: these two errors where added to the spec, we aren't squatting the namespace anymore
4443c57f1e
2023-12-20 12:22:05 +08:00
Daan De Meyer
a412a1b92a test: Skip various tests when /sys is not mounted
When running tests in a container, /sys might not be mounted, so
let's make sure we skip tests that depend on /sys in this case.
2023-12-19 16:38:57 +01:00
Matteo Croce
b408d46b83 systemctl: show success messages when showing transaction
Extend `--show-transaction` so it shows a success message when an unit
is successfully started.
2023-12-19 04:52:41 -08: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
Yu Watanabe
422d8905c0 find-esp: add debugging log about failure in parsing env variable
Addresses https://github.com/systemd/systemd/pull/30321#discussion_r1429716344.
2023-12-19 12:01:26 +01:00
Lukas Nykryn
3b2e7dc5a2 udev: allow/denylist for reading sysfs attributes when composing a NIC name
Users can currently pick specific versions of NIC naming, but that
does not guarantee that NIC names won't change after the kernel adds
a new sysfs attribute.

This patch allows for an allow/deny list of sysfs attributes
that could be used when composing the name.

These lists can be supplied as an hwdb entry in the form of
/etc/udev/hwdb.d/50-net-naming-allowlist.hwdb
net:naming:drvirtio_net
  ID_NET_NAME_ALLOW=0
  ID_NET_NAME_ALLOW_ACPI_INDEX=1
  ID_NET_NAME_ALLOW_ADDR_ASSIGN_TYPE=1
  ID_NET_NAME_ALLOW_ADDRESS=1
  ID_NET_NAME_ALLOW_ARI_ENABLED=1
  ID_NET_NAME_ALLOW_DEV_PORT=1
  ID_NET_NAME_ALLOW_FUNCTION_ID=1
  ID_NET_NAME_ALLOW_IFLINK=1
  ID_NET_NAME_ALLOW_INDEX=1
  ID_NET_NAME_ALLOW_LABEL=1
  ID_NET_NAME_ALLOW_PHYS_PORT_NAME=1
  ID_NET_NAME_ALLOW_TYPE=1
2023-12-19 19:15:52 +09:00
Lennart Poettering
f5fcf851b5 Merge pull request #30515 from poettering/dnslabelmax
extend most DNS label buffers by one
2023-12-18 15:12:27 +01:00
Lennart Poettering
a19e7f3101 Merge pull request #30321 from yuwata/find-esp
find-esp: gracefully handle btrfs RAID
2023-12-18 15:11:54 +01:00
Lennart Poettering
58982cf0cb creds-util: add helper for opening the credentials directory 2023-12-18 11:10:14 +01:00
Lennart Poettering
d393666403 specifier: use mempcpy() where we can 2023-12-18 10:28:03 +01:00
Lennart Poettering
fd7e988700 resolved: increase most label buffers to fit a trailing NUL byte
This is just paranoia. In all these cases we don't really care about the
trailing NUL byte. But if there's space for it dns_label_unescape() is
going to insert it, and that's a good safety strategy.

This is a follow-up to c29c3adefa8cd859f8cb87d9ad62f3d77b7cd102 which
fixed an actual bug, unlike this commit, which is just paranoia.
2023-12-18 10:27:27 +01:00
Daan De Meyer
3d11b46bf7 Add $SYSTEMD_HWDB_UPDATE_BYPASS (#30463)
Same as $KERNEL_INSTALL_BYPASS, but for hwdb. This will speed up
cross architecture image builds in mkosi as I can disable package
managers from running the costly hwdb update stuff in qemu user
mode and run it myself with a native systemd-hwdb with --root=.
2023-12-14 18:57: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
Daan De Meyer
9ce4dad81f Merge pull request #30467 from poettering/loop-block-tweaks
various tweaks to block device ioctls, and loop device mgmt
2023-12-14 09:38:17 +01:00
Lennart Poettering
bb59b92256 mount-util: make sure mount_switch_root() works as clean NOP when '/' is specified as target 2023-12-14 13:13:45 +09:00
Lennart Poettering
51778dea0d dissect-image: also store the image size in DissectedImage
That way we can easily access it the same way regardless if we operate
on a block device or on a regular file.
2023-12-13 17:35:22 +01:00
Lennart Poettering
6bc201343f loop-util: remember if we created the LoopDevice
Let's store in a bool whether a LoopDevice object was created via
loop_device_open() or loop_device_make().
2023-12-13 17:35:22 +01:00
Lennart Poettering
c961a8c605 loop-util: also store the device size in LoopDevice
That makes the field easily accessible, just as the sector size.
2023-12-13 17:35:22 +01:00
Lennart Poettering
01db9c85cf blockdev-util: add new helper blockdev_get_device_size()
This function is just a wrapper around the BLKGETSIZE64. Which is a
pretty simple ioctl. The only reason to wrap it, is that the headers we
need to call it are a bit messy (as "linux/fs.h" is incompatible with
certain glibc headers). Hence add the simple helper that wraps it and
allows us to do the header mess needed in one file only.

It's also nicely symmetric to blockdev_get_sector_size().
2023-12-13 17:35:22 +01:00
Luca Boccassi
b896058883 Merge pull request #30450 from poettering/cgroups-delegate-attr-update
cgroup: bring list of delegated cgroup attributes up-to-date with cur…
2023-12-13 13:50:41 +00:00
Lennart Poettering
2c70a81de6 cgroup: bring list of delegated cgroup attributes up-to-date with current kernels
THis brings the list of attributes to delegate to managers of subcgroups
to the state of kernel 6.6.

We probably should unify this list, and maybe generate it automatically
from /sys/kernel/cgroup/delegate, but let's do that another time.
2023-12-13 09:58:45 +01:00
Lennart Poettering
f2ad89248b varlink: improve compat with varlink C reference implementation
The reference implementation seems to set the 'parameters' field for
method calls to 'null' if nothing is specified on its command line. We
so far only could deal if the parameters field was unset or set to the
empty object. Let's also accept the 'null' type.
2023-12-13 09:39:10 +01:00
Yu Watanabe
997ba18af1 find-esp: do not skip fstype check even when --root= or --image= is specified
The check was introduced by 63105f33ed,
but there is no reason to skip the check even in such cases.
2023-12-13 14:19:28 +09:00
Yu Watanabe
9bbd3c699c find-esp: introduce verify_esp_flags_init() helper function
And split VERIFY_ESP_RELAX_CHECKS into two.

No functional change, just refactoring.
2023-12-13 14:19:28 +09:00
Yu Watanabe
5c831ddec8 find-esp: do not fail when /boot on btrfs RAID on searching ESP or xbootldr
When /boot or friends is on btrfs RAID, btrfs_get_block_device_at() will
succeed with 0 and provide zero devnum. Then,
- if we are previleged, devname_from_devnum() maps the devnum to
  /run/systemd/inaccessible/blk, and the subsequent verification by blkid
  will fail,
- if we are unprevileged, sd_device_new_from_devnum() will fail.

This makes
- when find_esp() or find_xbootldr() is called without any paths, that
  is, called with the searching mode, then returns -ENOKEY, which should
  be handled gracefully by the caller,
- when they are called with an input path, then they provide the proper
  error message and suggestion.

Fixes RHBZ#2251262 (https://bugzilla.redhat.com/show_bug.cgi?id=2251262).
2023-12-13 14:19:28 +09:00
Yu Watanabe
740539835a Merge pull request #30453 from poettering/dissect-fixes
dissect-image: various fixes
2023-12-13 14:15:05 +09:00
David Tardon
38e1035bef openssl-util: avoid freeing invalid pointer 2023-12-13 07:28:30 +08:00
Lennart Poettering
3f8229fbb0 dissect-image: move comment to right place
The image name is extracted from the image path originally passed in,
i.e. not the contents of the image. And the image UUID is directly
retrieved from the partition table, hence also not from the contents.
Let's hence move the comment to separate out the stuff extract from the
file systems (and thus only available when mounting/with privs/with
block devices) from the data available without any of that.
2023-12-12 16:20:10 +01:00
Lennart Poettering
8d5e61db43 dissect-image: fix fd leak in dissected_image_acquire_metadata()
We have to go through the "finish" label to properly close all pipes in
the error path, so that we don't leak them.
2023-12-12 16:19:50 +01:00
Lennart Poettering
a8e8bcfb7d dissect-image: don't try to validate an extension release file with no image name
Otherwise we might validate the OS release file instead…
2023-12-12 16:19:31 +01:00
Lennart Poettering
29b4db7ede dissect-image: handle 'continue' event in metadata acquisition uniformly
Let's jump to the same label in all cases, that closes the associated
pipe, systematically.
2023-12-12 16:19:21 +01:00
Lennart Poettering
3ee413e632 dissect-image: path[] is now defined for all metadata fields
There's no point in handling a case that never can happen.
2023-12-12 16:19:05 +01:00
ksaleem
9fb2a61830 bootctl: fix case-sensitive comparisons in reporting bootloader entries
Fixes #30159
2023-12-11 10:51:56 +00:00
Mike Yuan
8ad973ed99 hibernate-util: de-duplicate clear_efi_hibernate_location 2023-12-10 14:08:46 +09:00
Yu Watanabe
2b2f192a0e Merge pull request #30362 from mrc0mmand/cat-highlight-directives
shared: highlight directives when dumping configs
2023-12-09 18:54:46 +09:00
Frantisek Sumsal
fe6e0cfa19 install: don't translate unit instances to paths when reenabling them
For unit instances install_info_discover() returns path to the template,
which then generates confusing errors when passed to
do_unit_file_enable():

~# build/systemctl --root=/tmp/systemctl-test.N9ysbz reenable templ1@two.service
Unit name: templ1@two.service; p: /etc/systemd/system/templ1@.service
Removed "/tmp/systemctl-test.N9ysbz/etc/systemd/system/services.target.wants/templ1@two.service".
Failed to reenable templ1@.service, destination unit services.target is a non-template unit.

This can also be seen with a different reproducer using getty@.service
and a simple bind mount to / - there's no error this time, but it tries
to create a symlink for the default instance (from DefaultInstance=tty1),
which is also incorrect:

~# SYSTEMD_LOG_LEVEL=debug systemctl --root /mnt/bindroot/ reenable getty@test.service
Symlink /mnt/bindroot/etc/systemd/system/getty.target.wants/getty@tty1.service → /usr/lib/systemd/system/getty@.service already exists

Follow-up to: 29a7c59abb
Resolves: #24740
2023-12-08 11:20:12 +09:00
Mike Yuan
513412a69c various: don't log synthetic EIO for fwrite
Follow-up for f9568765d4
2023-12-08 10:49:08 +09:00
Frantisek Sumsal
22b0b7bfbf shared: highlight directives when dumping configs
We already highlight sections and "de-highlight" comments, so let's add
the last piece of the puzzle and highlight the configuration directives
to visually distinguish them from the values.

Closes: #13416
2023-12-07 15:35:54 +01:00
Daan De Meyer
b952663cd1 gpt-auto-generator: Pass cryptsetup credentials to cryptsetup
cryptsetup reads a bunch of credentials now but we don't pass import
those in any service units yet. Let's pass through all cryptsetup
prefixed credentials to the systemd-cryptsetup@root instance.
2023-12-06 23:37:32 +01:00
Zbigniew Jędrzejewski-Szmek
d50bf46f19 Merge pull request #30322 from YHNdnzj/hibernate-improvements
A few improvements for hibernate-util/hibernate-resume
2023-12-06 22:29:43 +01:00
Zbigniew Jędrzejewski-Szmek
34f4fcb59f Merge pull request #30302 from keszybz/systemd-edit-stdin
systemctl edit --stdin
2023-12-06 22:28:02 +01:00
Lennart Poettering
4482ea0c24 Merge pull request #30271 from YHNdnzj/executor-cloexec
fdset,core/executor: ocloexecification ™️
2023-12-06 22:26:40 +01:00
Lennart Poettering
cbc51d0cf4 Merge pull request #30101 from poettering/underline-rework
systemctl: "list-units" table tweaks
2023-12-06 22:13:12 +01:00
Lennart Poettering
4d56442755 recurse-dir: add new readdir_all_at() helper
This new helper combines open() with readdir_all() to simplify a few
callers.
2023-12-06 22:12:48 +01:00
Lennart Poettering
dc7a49ed25 Merge pull request #30183 from poettering/nlcr
NL → CRNL conversion fixes when logging at the same time as ptyfwd runs
2023-12-06 22:12:17 +01:00
Mike Yuan
374c29fc88 shared/killall: correctly warn about rootfs daemon's root
Follow-up for 9e615117da

We'll typically send signals to all remaining processes in the following
cases:

1. pid1 (in initrd) when transitioning from initrd to sysroot: SIGTERM
2. pid1 (in sysroot) before transitioning back to initrd (exitrd): SIGTERM + SIGKILL
3. systemd-shutdown (in exitrd): SIGTERM + SIGKILL

'warn_rootfs' is set to true only when we're not in initrd and we're
sending SIGKILL, which means the second case. So, we want to emit the
warning when the root of the storage daemon IS the same as that of pid1,
rather than the other way around.

The condition is spuriously reversed in the offending commit.
2023-12-06 22:03:35 +01:00