Commit graph

67389 commits

Author SHA1 Message Date
Lennart Poettering 3bda3f17fa pidref: add structure that can reference a pid via both pidfd and pid_t
Let's start with the conversion of PID 1 to pidfds. Let's add a simple
structure with just two fields that can be used to maintain a reference
to arbitrary processes via both pid_t and pidfd.

This is an embeddable struct, to keep it in line with where we
previously used a pid_t directly to track a process.

Of course, since this might contain an fd on systems where we have pidfd
this structure has a proper lifecycle.

(Note that this is quite different from sd_event_add_child() event
source objects as that one is only for child processes and collects
process results, while this infra is much simpler and more generic and
can be used to reference any process, anywhere in the tree.)
2023-09-09 14:03:31 +02:00
Daan De Meyer 1e1441d796 mkosi: Allow configuring whether to do secure boot and pcrs from CLI 2023-09-09 10:42:07 +01:00
Michal Koutný 055665d596 dbus: Document org.freedesktop.systemd1.Service.MemoryAvailable property
The value is an optimistic estimate, make it clear in the docs.
2023-09-09 10:42:38 +02:00
Luca Boccassi 9aa642d4e9
Merge pull request #29127 from YHNdnzj/wall-followup
shared/wall: several cleanups
2023-09-09 01:30:51 +01:00
Luca Boccassi 2d17808200
Merge pull request #29116 from yuwata/network-sriov-debug
network/sr-iov: ignore EINVAL in reading dev_port sysfs attribute
2023-09-09 01:28:35 +01:00
Ronan Pigott 47f20650b7 zsh: busctl: fix flags parsing for properties
I'm not quite sure what the original intent of this line was, but it
doesn't work in the one call-site the "required" argument is actually
used. The "writable" flag was indexed as a scalar leaving only the
"e" to compare against.

Instead, let's just sort the parsed flags and compare the whole thing.
Also substitute "required" as a pattern, so that pattern based
comparisons may be supported.
2023-09-09 01:28:07 +01:00
Lennart Poettering 7b9da3861a Revert "tree-wide: Mount file descriptors via /proc/<pid>/fd" 2023-09-08 22:13:09 +01:00
Lennart Poettering 0df7d52576 serialize: add common deserialize_read_line() helper and use it everywhere
This introduces a common helper replacing three very similar uses.

Prompted by review of: #27890
2023-09-08 20:59:44 +01:00
Mike Yuan 7af442cf63
TODO: switch the default wall implementation to sd-login 2023-09-09 03:24:52 +08:00
Mike Yuan 560f15fc8f
shared/wall: fall back to logind if utmpx database doesn't exist 2023-09-09 03:22:25 +08:00
Mike Yuan 056aff96b9
shared/wall: several cleanups
Follow-up for 53c0397b1d

* Split do_wall into wall_utmp and wall_logind
* Don't pass unused arguments
* Add missing asserts
* Modernize error handling
* Don't do anything if neither utmp nor logind is enabled
2023-09-09 03:19:22 +08:00
Mike Yuan 8b2d219316
utmp-wtmp: remove unneeded include 2023-09-09 01:33:32 +08:00
Michal Koutný 8db929a1e2 cgroup: Estimate MemoryAvailable= when DefaultMemoryAccounting=no
Without memory accounting explicitly disabled, we may not obtain current
consumption from all units on the ancestry path.
Use a descendant value as lower bound estimate for ancestors if
ancestor's consumption cannot be directly queried.

This makes MemoryAvailable= an upper bound of available values.
2023-09-08 19:07:12 +02:00
Michal Koutný 727cea7652 cgroup: Refactor MemoryAvailable= evaluation
unit_get_memory_available() duplicates similar logic contained in
unit_get_memory_current(). Instead, it can call it for each unit it
needs data for.
Additionally, simplify the flow by treating all units from leaf to root
uniformly in one loop.

Functional change when a queried unit does not have MemoryAccounting=yes
(or cgroup_path), we will try getting an estimate from ancestors.
2023-09-08 19:07:12 +02:00
Michal Koutný 3565c709f5 cgroup: Fix MemoryAvailable= by considering physical memory
Currently, querying a unit's available memory would result in infinity
if there are no limits set on the unit or ancestors.
That undermines semantics implied by the name, so look at the physical
memory if the search propagates up to the -.slice.
This makes sense even in systemd user instances, limits of -.slice are
still looked at too.

Also change printed representation of infinite MemoryAvailable which
means we could not figure out a good estimate.
2023-09-08 19:05:52 +02:00
Mike Yuan 93f1da4556 conf-parser: parse main config first only if not symlinked to/as drop-in
Otherwise we'll skip parsing main config directly.

Replaces #27152
Replaces #28956:
chase() is an overkill for determining whether
two files are the same. We only need to check
if the inodes are the same.
2023-09-08 16:25:12 +02:00
Mike Yuan fc159b2fd9 repart,bootspec: use set_ensure_consume 2023-09-08 16:25:12 +02:00
Alvin Alvarado a05fa30f88 ukify/man: Look for a config file in systemd folders if not specified
If the user does not specify a config file to use, ukify will try looking for one at {/run,/etc,/usr/local/lib,/usr/lib}/systemd/ukify.conf in order and then use the first one found. Also made sure the --config input is a pathlib.Path by specifying its type in its CONFIG_ITEMS entry.
Big cheers to Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> for helping!
2023-09-08 16:21:28 +02:00
Lennart Poettering ea09a416ed core: introduce unit_defaults_init() common initialization helper
THis adds a helper for initializing UnitDefaults to our default values.
Previously we'd do that differently in two different locations. Let's
unify this in one, and apply the exact same settings at both as
defaults.
2023-09-08 15:25:05 +02:00
Lennart Poettering bfb27b06da manager: add manager_set_unit_defaults() call that sets all unit defaults in one go
No change in behaviour. Just some refactoring.
2023-09-08 15:25:05 +02:00
Lennart Poettering c9e120e06f manager: move various fields that declare unit defaults into a new structure UnitDefaults
This adds a new structure UnitDefaults which embedds the various default
settings for units we maintain. We so far maintained two sets of
variables for this, one in main.c as static variables and one in the
Manager structure. This moves them into a common structure.

This is most just search/replace, i.e. very dumb refactoring.

The fact that we now use a common structure for this allows us further
refactorings later.

Inspired by the discussions on #27890
2023-09-08 14:19:45 +02:00
Yu Watanabe b9962da63f network/sr-iov: move common parts to link_set_sr_iov_ifindices()
This also adds several debugging logs.
No functional change, just refactoring.
2023-09-08 20:09:15 +09:00
Yu Watanabe 4b12a8dd33 network/sr-iov: ignore -EINVAL in reading dev_port sysfs attribute
Fixes #27369.
2023-09-08 20:08:18 +09:00
Yu Watanabe 47f1ce1677 test-network: add testcase for [DHCPServer] ServerAddress= with null address 2023-09-08 20:03:40 +09:00
Yu Watanabe e443a88a9a man: update [DHCPServer] ServerAddress= 2023-09-08 20:03:40 +09:00
Yu Watanabe a0dfce0a3f network: allow to set null address for [DHCPServer] ServerAddress=
And refuse a link-local address.

With the previous commit, now ServerAddress= can take a null address,
but the config parser refused that. Let's allow that now.
2023-09-08 20:03:40 +09:00
Yu Watanabe 5459e11d39 network: find DHCP server address only on loading .network file
Previously, we periodically search suitable address for DHCP server,
1. when .network file is loaded,
2. when checking if we can configure sd_dhcp_server object,
3. when configuring sd_dhcp_server.

Especially, the step 2 may be triggered several times.

This makes, when .network file is loaded, find a corresponding Address
object, add a new Address object if not found, then save the found or
added Address object. So, it is not necessary to find address again on
configuring sd_dhcp_server object.
2023-09-08 20:03:40 +09:00
Yu Watanabe 26f8847102 network: call network_adjust_dhcp_server() from network_drop_invalid_addresses()
We need to find a suitable static address for the DHCP server.
So, all static addresses must be verified before network_adjust_dhcp_server()
is called. For safety, let's call it from network_drop_invalid_addresses().

No functional change, just refactoring and preparation for later
commits.
2023-09-08 20:03:40 +09:00
Mike Yuan b8f18c3089
Merge pull request #29123 from yuwata/conf-parser-cleanups-for-config-section
conf-parser: several cleanups and generalizations for ConfigSection
2023-09-08 18:11:12 +08:00
Luca Boccassi 30a0f7e310
Merge pull request #29121 from yuwata/network-drop-duplicated
network: drop duplicated checks and function calls
2023-09-08 10:42:08 +01:00
Lennart Poettering fea82394bc
Merge pull request #29071 from YHNdnzj/loop-write-full
io-util: introduce loop_write_full and use it where appropriate
2023-09-08 10:24:39 +02:00
Daan De Meyer 6ec74f916a mkosi: Drop arch workaround
archlinux-keyring was updated in Michel's PPA so let's drop the
workaround.
2023-09-08 09:20:46 +01:00
Yu Watanabe e63c6e9ffa conf-parser: introduce ordered_hashmap_by_section_find_unused_line() 2023-09-08 12:55:44 +09:00
Yu Watanabe d9171a230d conf-parser: check overflow in hashmap_find_free_section_line()
Also, this also renames the function, and makes it optionally takes
a filename.
2023-09-08 12:55:44 +09:00
Yu Watanabe 08ca764d0a conf-parser: modernize config_section_new()
- add assertions,
- rename argument to store result.
2023-09-08 12:55:44 +09:00
Yu Watanabe 7bf9e0d5f6 hashmap: introduce HASHMAP_BASE_FOREACH() and friend 2023-09-08 12:55:44 +09:00
Yu Watanabe f7f5028edc network: drop duplicated check
The same check is in network_adjust_dhcp_server().
2023-09-08 06:41:37 +09:00
Yu Watanabe 0ae8ff50ac network: drop duplicated address_set_broadcast()
It will be called later in link_request_address().
2023-09-08 06:41:37 +09:00
Frantisek Sumsal 3bf7d79637 ci: temporarily disable Packit's i386
As it currently crashes when extracting debuginfo due to [0] and hangs
until it's killed by the watchdog (which takes ~5 hours).

[0] https://bugzilla.redhat.com/show_bug.cgi?id=2237392
2023-09-07 22:22:56 +01:00
Lennart Poettering 4bba26aea6 tpm2-util: drop support for creating TPM2 trial sessions
This is unused these days, we instead calculate policy hashes ourselves
and do not need trial sessions for that anymore. Given how unreliable
they are in actual TPMs, we don't want to use them anyway, so I don't
think we ever want to readd this.

hence, let's drop this unused feature.
2023-09-07 20:41:54 +01:00
Jan Janssen b7801869d7 efi: Add some more paranoia asserts 2023-09-07 20:41:12 +01:00
Zbigniew Jędrzejewski-Szmek c63db5420c
Merge pull request #29036 from YHNdnzj/hibernate-resume-when-battery-low
hibernate-resume: split out the logic of finding hibernate location and support battery-check better
2023-09-07 17:34:27 +02:00
наб ef658a63f8 parse_timestamp: accept RFC3339-style timezone and %FT%R[:%S[.%N]]
We basically parsed the RFC3339 format already, except with a space:
      NOTE: ISO 8601 defines date and time separated by "T".
      Applications using this syntax may choose, for the sake of
      readability, to specify a full-date and full-time separated by
      (say) a space character.
so now we handle both
  2012-11-23 11:12:13.456
  2012-11-23T11:12:13.456
as equivalent.

Parse directly-suffixed Z and +05:30 timezones as well:
  2012-11-23T11:12:13.456Z
  2012-11-23T11:12:13.456+02:00
as they're both defined by RFC3339.

We do /not/ allow z or t; the RFC says
      NOTE: Per [ABNF] and ISO8601, the "T" and "Z" characters in this
      syntax may alternatively be lower case "t" or "z" respectively.

      This date/time format may be used in some environments or contexts
      that distinguish between the upper- and lower-case letters 'A'-'Z'
      and 'a'-'z' (e.g. XML).  Specifications that use this format in
      such environments MAY further limit the date/time syntax so that
      the letters 'T' and 'Z' used in the date/time syntax must always
      be upper case.  Applications that generate this format SHOULD use
      upper case letters.
We /are/ in a case-sensitive environment, neither are in wide-spread
use, and "z" poses an issue of whether "todayz" should be the same
as "todayZ" ("today UTC") or an error (it should be an error).

Fractional seconds are limited to six digits (they're nominally
   time-secfrac    = "." 1*DIGIT
), since we only support 1µs-resolution timestamps, and limit to six
digits in our other sub-second formats.

Parsing
  2012-11-23T11:12
is an extension two ways (no seconds, no timezone),
mirroring our "canonical" format.

Fixes #5194
2023-09-07 17:33:15 +02:00
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
Mike Yuan 89a1bb9012
units: order battery-check before hibernate-resume 2023-09-07 20:21:16 +08:00
Mike Yuan a628d933cc
hibernate-resume: split out the logic of finding hibernate location
Before this commit, the hibernate location logic only exists in
the generator. Also, we compare device nodes (devnode_same()) and
clear EFI variable HibernateLocation in the generator too. This is
not ideal though: when the generator gets to run, udev hasn't yet
started, so effectively devnode_same() always fails. Moreover, if
the boot process is interrupted by e.g. battery-check, the hibernate
information is lost.

Therefore, let's split out the logic of finding hibernate location.
The generator only does the initial validation of system info and
enables systemd-hibernate-resume.service, and when the service
actually runs we validate everything again, which includes comparing
the device nodes and clearing the EFI variable. This should make
things more robust, plus systems that don't utilize a systemd-enabled
initrd can use the exact same logic to resume using the EFI variable.
I.e., systemd-hibernate-resume can be used standalone.
2023-09-07 20:21:16 +08:00
Lennart Poettering 82b7bf8c1c
Merge pull request #28957 from yuwata/core-mount-set-dirty-on-umount
core/credential,mount: re-read /proc/self/mountinfo before invoking umount command
2023-09-07 11:54:52 +02:00
Christian Kirbach 8e2d9d40b3 po: Translated using Weblate (German)
Currently translated at 85.4% (194 of 227 strings)

Co-authored-by: Christian Kirbach <christian.kirbach@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/de/
Translation: systemd/main
2023-09-07 07:08:28 +09:00
Zbigniew Jędrzejewski-Szmek 1c5d54b2df test: use 'until' instead of 'while !'
In general, it's better to avoid a negation. And "!" is special, because it is
used for history expansion, i.e. the same command would behave differently if
pasted on the command line.

Inspired by 4a899c5a23.
2023-09-06 19:54:29 +01:00