1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-14 16:58:22 +03:00

41769 Commits

Author SHA1 Message Date
Yu Watanabe
ff6db56a01 test-time-util: skip test for TIMESTAMP_DATE if the timestamp is too old
Follow-up for 64f3419ec1f56a93b6dd48137ca40c945fc06c59.

If the input timestamp is too old (say, 1min since 1970-01-01), then
parse_timestamp() may fail on a timezone with positive shift e.g.
JST (UTC+9). Moreover, even if parse_timestamp() succeeds, its result
'y' and 'usec_sub_unsigned(x, 2 * USEC_PER_DAY)' are both zero, and
the assertion will be triggered.

Fixes #26172.
2023-02-02 10:59:59 +01:00
Yu Watanabe
cf74e2e16f udev: make get_virtfn_info() provide physical PCI device
Fixes a bug introduced by 78463c6c4fdcb703bc0dc694c3ea77df3c5624e0.

Fixes #25545.
2023-02-01 23:41:48 +00:00
Luca Boccassi
5b5aaf9a91
Merge pull request #26180 from ddstreet/tpm2_cleanup
Add struct tpm2_handle and use _cleanup_ instead of goto
2023-02-01 23:40:52 +00:00
Luca Boccassi
9a101c5d4c
Merge pull request #26269 from keszybz/sysusers-empty-etc-and-improved-messages
sysusers: improve messages and autocreate /etc
2023-02-01 23:14:59 +00:00
Luca Boccassi
e5cf396181
Merge pull request #26287 from medhefgo/mkosi-auto-enroll
ci: Test with secure boot enabled under mkosi
2023-02-01 21:51:04 +00:00
Yu Watanabe
c4abc55890 locale: drop context_clear_x11()
It is used at only place, and mostly trivial.
No functional change, just refactoring.
2023-02-02 03:59:21 +09:00
Yu Watanabe
181ba13b23 locale: fix ENOENT handling for vconsole.conf or xorg.conf 2023-02-02 03:59:21 +09:00
Dan Streetman
16e16b8c7b tpm2: add Tpm2Handle with automatic cleanup
This allows using _cleanup_ with the handles, which then allows removing the
use of goto in all functions that use the handles.
2023-02-01 12:52:08 -05:00
Dan Streetman
23e9ccc24a tpm2: use Tpm2Context* instead of ESYS_CONTEXT*
This is needed for later patches that use Tpm2Handle, which requires access
to the Tpm2Context.
2023-02-01 12:51:17 -05:00
Dan Streetman
68d084cee5 tpm2: use ref counter for Tpm2Context
This will be used by Tpm2Handle instances, which is added in later patches.

The refcounting allows the context to be retained until all Tpm2Handles have
been cleaned up, and the initial ref is released, before cleaning the context.
2023-02-01 12:51:17 -05:00
Dan Streetman
bd860983a6 tpm2: rename struct tpm2_context to Tpm2Context
This aligns with systemd coding guidelines for struct naming
2023-02-01 12:51:17 -05:00
Dan Streetman
7bfe0a48d9 tpm2: rename tpm2 alg id<->string functions
The 'pcr_bank' functions operate on hash algs, and are not specific to the PCR
banks, while the 'primary_alg' functions operate on asymmetric algs, and are
not specific to primary keys.
2023-02-01 18:13:48 +01:00
Zbigniew Jędrzejewski-Szmek
92fc007902
Merge pull request #26219 from yuwata/localed-follow-ups
locale: check conversion before polkit
2023-02-01 17:18:35 +01:00
Jan Janssen
1e8e7f4463 boot: Add if-safe mode for secure boot enrollment 2023-02-01 16:52:28 +01:00
Lennart Poettering
951174e4fe test-journal-flush: minor modernizations
let's automatically destroy test dirs, instead of manually.
2023-02-01 15:25:44 +01:00
Lennart Poettering
74e795ee55 id128: introduce ERRNO_IS_MACHINE_ID_UNSET() helper macro 2023-02-01 15:25:30 +01:00
Robin Humble
19cfda9fc3
pid1: fix segv triggered by status query (#26279)
If any query makes it to the end of install_info_follow() then I think symlink_target is set to NULL.
If that is followed by -EXDEV from unit_file_load_or_readlink(), then that causes basename(NULL)
which segfaults pid 1.

This is triggered by eg. "systemctl status crond" in RHEL9 if

/etc/systemd/system/crond.service
  -> /ram/etc/systemd/system/crond.service
  -> /usr/lib/systemd/system/.crond.service.blah.blah
  -> /usr/lib/systemd/system/crond.service
2023-02-01 21:36:48 +09:00
Zbigniew Jędrzejewski-Szmek
e4c7b5f517 core: split system/user job timeouts and make them configurable
Config options are -Ddefault-timeout-sec= and -Ddefault-user-timeout-sec=.
Existing -Dupdate-helper-user-timeout= is renamed to -Dupdate-helper-user-timeout-sec=
for consistency. All three options take an integer value in seconds. The
renaming and type-change of the option is a small compat break, but it's just
at compile time and result in a clear error message. I also doubt that anyone was
actually using the option.

This commit separates the user manager timeouts, but keeps them unchanged at 90 s.
The timeout for the user manager is set to 4/3*user-timeout, which means that it
is still 120 s.

Fedora wants to experiment with lower timeouts, but doing this via a patch would
be annoying and more work than necessary. Let's make this easy to configure.
2023-02-01 11:52:29 +00:00
Zbigniew Jędrzejewski-Szmek
d173d5564f basic/user-util: create /etc from take_etc_passwd_lock
This allows sysusers to operate with --root that is an empty directory.
It may be useful to, for example, populate the user database before installing
anything else.

firstboot was already doing this, so drop the duplicated call there.
2023-02-01 11:38:35 +01:00
Zbigniew Jędrzejewski-Szmek
e5b30f7232 basic/user-util: convert prefix_roota→path_join and use _cleanup_ more 2023-02-01 11:38:35 +01:00
Zbigniew Jędrzejewski-Szmek
fddb524d8a basic: reword some comments
Without commas, the sentences can be hard to parse.
2023-02-01 11:38:35 +01:00
Zbigniew Jędrzejewski-Szmek
7519b880e7 sysusers: when comparing items, log debug the difference 2023-02-01 11:31:29 +01:00
Zbigniew Jędrzejewski-Szmek
9a87bdd7ed sysusers: add helper to create new Item 2023-02-01 11:30:26 +01:00
Zbigniew Jędrzejewski-Szmek
2584e16cb7
Merge pull request #26236 from medhefgo/meson-fixes
meson: Fixes
2023-02-01 10:05:36 +01:00
Lennart Poettering
0e8330262e journald: some minor modernizations 2023-02-01 09:25:57 +01:00
Lennart Poettering
2308cf7c9c journal: generate a clean message when we try to write to a journal file from a different host 2023-02-01 09:23:18 +01:00
Lennart Poettering
75bf2627b0 journal-file: refuse writing to journal files where the header size is different then expected
We keep adding fields to the header, and it's fine reading files with
different header sizes, as we check via the size if the fields we need
are included. However, let's be stricter when writing journal files than
when reading, and insist that the header structure in the file actually
matches our expectations. Refuse otherwise, so that a new file is
created after rotation that then matches our expectations.

This makes sure that mismatch in header size is treated exactly as
unknown "compatible" flags, which is our other mechanism to allow
extending the journal file format in a non-breaking way.
2023-02-01 09:20:18 +01:00
Rudi Heitbaum
1bb6ba08b1 glibc: Conditionally #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36
Co-authored-by: Frantisek Sumsal <frantisek@sumsal.cz>
2023-02-01 00:02:41 +00:00
Yu Watanabe
2cb1cabb41 network: dhcp-server: do not create DHCPServer object when the DHCP server is running in relaying mode
Follow-up for c95df5879eeb2cec8bc8eec2cfa7e741e1d9469f.

Fixes #26196.
2023-02-01 00:00:19 +00:00
Tuetuopay
1d84a3c779 network/dhcp4: accept local subnet routes from DHCP
RFC3442 specifies option 121 (Classless Static Routes) that allow a DHCP
server to push arbitrary routes to a client. It has a Local Subnet
Routes section expliciting the behavior of routes with a null (0.0.0.0)
gateway.

Such routes are to be installed on the interface with a Link scope, to
mark them as directly available on the link without any gateway.

Networkd currently drops those routes, which is against the RFC, as
Linux has proper support for such routes.

Fixes: 7f20627 ("network: dhcp4: ignore gateway in static routes if destination is link-local or in the same network")
2023-01-31 23:58:34 +00:00
Zbigniew Jędrzejewski-Szmek
5afdb4629a pid1,sysusers: drop unused SYNTHETIC_ERRNO
The only function of SYNTHETIC_ERRNO is to set the return value.
If we're ignoring the return value, it shouldn't be used.
2023-01-31 14:30:41 +01:00
Zbigniew Jędrzejewski-Szmek
616c53544f sysusers: drop counterproductive bitfield annotations
The usual story:
$ diff -u <(pahole build/systemd-sysusers.0) <(pahole build/systemd-sysusers)
 	/* size: 80, cachelines: 2, members: 15 */
-	/* sum members: 68, holes: 1, sum holes: 4 */
-	/* sum bitfield members: 5 bits (0 bytes) */
-	/* padding: 7 */
-	/* bit_padding: 3 bits */
+	/* sum members: 73, holes: 1, sum holes: 4 */
+	/* padding: 3 */
 	/* last cacheline: 16 bytes */

Effectively, because of padding, we were not saving anything. We're not putting
struct Item in arrays, but when allocating on the heap, we're going to round up to
normal alignment too.

The code becomes shorter (and quicker):
$ size build/systemd-sysusers{,.0}
   text	   data	    bss	    dec	    hex	filename
  79967	   2040	    264	  82271	  1415f	build/systemd-sysusers.0
  79726	   2040	    264	  82030	  1406e	build/systemd-sysusers

(In case you're wondering, I wrote this long commit message for a very simple
change on purpose: I want to deflate the bitfield cargo cult a bit.)
2023-01-31 13:47:17 +01:00
Ilya Leoshkevich
907046282c bpf: fix restrict_fs on s390x
Linux kernel's bpf-next contains BPF LSM support for s390x. systemd's
test-bpf-lsm currently fails with this kernel.

This is an endianness issue: in the restrict_fs bpf program,
magic_number has type unsigned long (64 bits on s390x), but magic_map
keys are uint32_t (32 bits). Accessing magic_map using 64-bit keys may
work by accident on little-endian systems, but fails hard on big-endian
ones.

Fix by casting magic_number to uint32_t.
2023-01-31 12:23:16 +01:00
Arsen Arsenović
181eea677d importd: Always specify file unpacked by tar
Despite popular belief, the default file extracted by GNU tar is not stdin.  It
is the value of the TAPE environment variable, falling back on a compile-time
constant.  On my system, the default value is /dev/full, which causes tar to
just spin forever due to --ignore-zeros.  Always specifying this flag is the
safe thing to do.

  ~$ tar --show-defaults
  --format=gnu -f/dev/full -b20 --quoting-style=escape
  --rmt-command=/usr/sbin/grmt

See also: ``(tar)defaults'', available via Info viewers, and in HTML form at:
https://www.gnu.org/s/tar/manual/html_node/defaults.html
2023-01-31 12:21:44 +01:00
Lennart Poettering
a444091840
Merge pull request #26249 from DaanDeMeyer/nspawn-uid-fix
nspawn: Make sure we create bind mount points as the correct UID/GID
2023-01-31 12:21:09 +01:00
Lennart Poettering
e9125200ac
Merge pull request #26245 from ldv-alt/tmpfiles-fixes
tmpfiles: fix specifier expansion in arguments of C and L lines
2023-01-30 17:14:03 +01:00
Luca Boccassi
0a5bd40a70
Merge pull request #25374 from yuwata/sleep-fixlets
sleep: several fixlets
2023-01-30 09:51:21 +00:00
Daan De Meyer
0a67965fa2 nspawn: Make sure we create bind mount points as the correct UID/GID
When using --private-users, we have to create bind mount points as
the user that will become root in the user namespace, so let's take
that into account.
2023-01-29 08:59:19 +01:00
Daan De Meyer
2312fd17cc mkdir-label: Add mkdir_parents_safe_label() 2023-01-28 15:11:29 +01:00
Yu Watanabe
b52031dbbc sd-dhcp-server: allow to send header only message
If we receive a header only message, and the server is running in relay
mode, then the assertion was triggered.

Fixes #26151.
2023-01-28 10:44:30 +00:00
Yu Watanabe
7bb322e982 locale: downgrade level of one more log message 2023-01-28 15:06:00 +09:00
Yu Watanabe
8669bbb565 locale: move logging from library-like functions to caller 2023-01-28 15:06:00 +09:00
Yu Watanabe
189cacabe9 locale: decouple vconsole_read_data() from x11_read_data()
Let's make library-functions simple and independent as possible as they
are. No functional change, just refactoring.
2023-01-28 15:05:55 +09:00
Yu Watanabe
f41338da6e locale: also check if converted keymap or friends is same as the current settings
Before this commit, if virtual console keymap is unchanged, localed just
returns without modifying anything. However, the X11 part may need updating.
So we should check for both and ensure they are unmodified.

Replaces #26190.
2023-01-28 14:54:50 +09:00
Yu Watanabe
71fa933b46 locale: sync two X11 contexts on update 2023-01-28 14:53:18 +09:00
Yu Watanabe
800f65f827 locale: always check input keyboard layout and friends earlier 2023-01-28 14:47:36 +09:00
Yu Watanabe
f59d83afaa locale: replace context_get_x11_context() with context_get_x11_context_safe()
Then, context_get_x11_context() always replies a valid X11 context.
No functional change, just refactoring.
2023-01-28 14:47:36 +09:00
Yu Watanabe
90005a4f0a locale: make vconsole_convert_to_x11() not update Context
This also makes x11_convert_to_vconsole() changed in the same way.
Then, their callers update Context if necessary.

No functional change, just preparation for later commits.
2023-01-28 14:47:36 +09:00
Yu Watanabe
ba4a886f2d locale: introduce VCContext and several helper functions for the struct
No functional changes, preparation for later commits.
2023-01-28 14:47:36 +09:00
Yu Watanabe
e0a720012d locale: add missing logs 2023-01-28 14:47:36 +09:00