1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-01 05:47:04 +03:00

58589 Commits

Author SHA1 Message Date
Yu Watanabe
41fdc8ed32 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.

(cherry picked from commit b52031dbbcabe4b1e3016ba64d4a2822740188bc)
(cherry picked from commit 7aeb2a8d4ea660ad863e7b2c5432f64f903f1cd5)
2023-02-13 14:50:14 +00:00
Daan De Meyer
2a36784277 resolve: Skip creating stubs if missing CAP_NET_BIND_SERVICE
If we don't have CAP_NET_BIND_SERVICE, we won't be able to bind
the stub listener socket, so let's skip creating it and log a warning.

We do the same for the extra stubs if they're configured on privileged
ports.

(cherry picked from commit 0398c084efba664e44625d82f2be72e18c952678)
(cherry picked from commit ab877f7072728420e49d179bca310a698cf9994c)
2023-02-13 14:50:14 +00:00
Daan De Meyer
5037e0d27b nspawn: Drop CAP_NET_BIND_SERVICE when in userns but not in netns
If we're in a user namespace but not unsharing the network namespace,
we won't be able to bind any privileged ports even with
CAP_NET_BIND_SERVICE, so let's drop it from the retained capabilities
so services can condition themselves on that.

(cherry picked from commit 2642d22adc66771bd8bbb4187dc3de5472d04ad6)
(cherry picked from commit 3a49291f4b82e746294df1772e9ab7eb957a9771)
2023-02-13 14:50:14 +00:00
Nick Rosbrook
37df773b23 sd-netlink: add a test for rtnl_set_link_name()
Add a test that verifies a deleted alternative name is restored on error
in rtnl_set_link_name().

(cherry picked from commit b338a8bb402a3ab241a617e096b21ae6a7b7badf)
(cherry picked from commit 7299341bd1e114d2ef29539f4b0b5b5da9900120)
2023-02-13 14:50:14 +00:00
Nick Rosbrook
b7db01f20d udev: attempt device rename even if interface is up
Currently rename_netif() will not attempt to rename a device if it is
already up, because the kernel will return -EBUSY unless live renaming
is allowed on the device. This restriction will be removed in a future
kernel version [1].

To cover both cases, always attempt to rename the interface and return 0
if we get -EBUSY.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=bd039b5ea2a9

(cherry picked from commit 53584e7b61373c26635b906eb64e98fbd3fd3ba4)
(cherry picked from commit c6722b697530902968eb87fd5ac398184980ea3f)
2023-02-13 14:50:14 +00:00
Nick Rosbrook
a536073a62 sd-netlink: restore altname on error in rtnl_set_link_name
If a current alternative name is to be used to rename a network
interface, the alternative name must be removed first. If interface
renaming fails, restore the alternative name that was deleted if
necessary.

(cherry picked from commit 4d600667f8af2985850b03a46357e068d3fb8570)
(cherry picked from commit 42d8817bd652731a25facebb4d6db7ee822774c2)
2023-02-13 14:50:14 +00:00
Nick Rosbrook
facb873e6f sd-netlink: do not swap old name and alternative name
Commit 434a348380 ("netlink: do not fail when new interface name is
already used as an alternative name") added logic to set the old
interface name as an alternative name, but only when the new name is
currently an alternative name. This is not the desired outcome in most
cases, and the important part of this commit was to delete the new name
from the list of alternative names if necessary.

(cherry picked from commit 080afbb57c4b2d592c5cf77ab10c6e0be74f0732)
(cherry picked from commit 3dc5b19f10916e15adb9071057fe877a958daea8)
2023-02-13 14:50:14 +00:00
Nick Rosbrook
ba896a6de0 udev/net: allow new link name as an altname before renaming happens
When configuring a link's alternative names, the link's new name to-be
is not allowed to be included because interface renaming will fail if
the new name is already present as an alternative name. However,
rtnl_set_link_name will delete the conflicting alternative name before
renaming the device, if necessary.

Allow the new link name to be set as an alternative name before the
device is renamed. This means that if the rename is later skipped (i.e.
because the link is already up), then the name can at least still be
present as an alternative name.

(cherry picked from commit d0b31efc1ab7f6826ad834cf6b9e371bf73776aa)
(cherry picked from commit 7918496dcf2d6c06a8cd8626c23d2a463343a9df)
2023-02-13 14:50:14 +00:00
Yu Watanabe
6fd3a1e581 nss-myhostname: do not return empty result with NSS_STATUS_SUCCESS
Fixes a bug introduced by db50d326a46beca3cc24b6354b6e1b3591902d45.

Fixes RHBZ#2167468 (https://bugzilla.redhat.com/show_bug.cgi?id=2167468).

(cherry picked from commit 1c3762937e9184c9abbc8d5541b4228841ccc24f)
(cherry picked from commit 5ce6c73f2db1b2bf9064f8b4344645c8ffdd84bd)
2023-02-13 14:50:14 +00:00
Yu Watanabe
2fcd5beebb nss-myhostname: fix inverted condition in
Fixes a bug introduced by db50d326a46beca3cc24b6354b6e1b3591902d45.

(cherry picked from commit a3b993ca3fb6fc0b837745c1ae82aca684951842)
(cherry picked from commit 7503626febb6fb9319ed6de4ef67011e8cd50572)
2023-02-13 14:50:14 +00:00
msizanoen1
64d7289214 unit: always return 1 in log_kill
This ensures that cg_kill_items returns the correct value to let the
manager know that a process was killed.

(cherry picked from commit 500cd2e83b8246fbf20d99db898039cfba746223)
(cherry picked from commit 86686e4292fed7ce150156439fbda690bac2ad68)
2023-02-13 14:50:14 +00:00
Ilya Leoshkevich
25cb55890e 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.

(cherry picked from commit 907046282c27ee2ced5e22abb80ed8df2e157baf)
(cherry picked from commit f62e7b470441643d07b23706ac943216a5cdfc97)
2023-02-13 14:50:14 +00:00
Yu Watanabe
0f967fba15 network: dhcp-server: do not create DHCPServer object when the DHCP server is running in relaying mode
Follow-up for c95df5879eeb2cec8bc8eec2cfa7e741e1d9469f.

Fixes #26196.

(cherry picked from commit 2cb1cabb412850e88eaf26feec663674e2c4f664)
(cherry picked from commit 318b6f60b8f91846331c2a4c65347c75b1203104)
2023-02-13 14:50:14 +00:00
Tuetuopay
ee6475d318 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")
(cherry picked from commit 1d84a3c7792a8910b05904937c703307ca19740f)
(cherry picked from commit b0f514ba567a1f6321f6b7f1ded038f8090c70f0)
2023-02-13 14:50:14 +00:00
Lennart Poettering
fa04709a3d resolvectl: don't filter loopback DNS server from global DNS server list
"resolvectl status" shows per-link DNS servers separately from global
ones. When querying the global list, it will contain both per-link and
global servers however. Thus, to not show duplicate info we filter all
entries that actually have a non-zero ifindex set (under the assumption
that that's a per-link server).

This doesn't work if people configured 127.0.0.1 as global server
though, as we'll add ifindex 1 to it since
6e32414a66ff8dbcef233981a7066684d903ee9f unconditionally even for global
servers.

Let's address that by excluding entries with ifindex 1 from suppression.
This is safe as resolved ignores loopback ifaces, hence never will have
per-link servers on ifindex 1.

Note that this splits up the "with_ifindex" parameter into a second
parameter "only_global", since they semantically do two different
things. One controls whether we shall expect/parse an ifindex dbus
field. The other controls whether we shall filter all ifindex values set
!= 0. These are effectively always used in conjunction hence making them
the same actually worked. However this is utterly confusing I think,
which as I guess is resulting in the confusion around #25796 (which
removes the whole check)

Replaces: #25796
(cherry picked from commit 889a1b9f4e799b31f1be06db74708aa8beb70829)
(cherry picked from commit b71ade8779002d7feb61a43bc8c2d8325b3d6750)
2023-02-13 14:50:14 +00:00
Lennart Poettering
87307bfdd1 resolvectl: fix type of ifindex D-Bus field, and make sure to initialize to zero in all code paths
(cherry picked from commit a5e6c8498ca375bafa865d5e46fa95e9313871ad)
(cherry picked from commit ed26f98f2f0559aee242836e71832a77a7000dbb)
2023-02-13 14:50:14 +00:00
msizanoen1
ca948c9601 udev: match device tags in rules using current device tags
This ensures that udev scripts using `TAG-="..."` and expecting later
udev rules to honor it will work properly. An use case is removing the
`uaccess` tag from a device without overriding the original file and
ensuring that `73-seat-uaccess.rules` won't run the uaccess builtin later.

(cherry picked from commit 310249903986957997b76bc52441cabb5843aad8)
(cherry picked from commit 7d4ea095d5e3e5aa87761c6c0f5f30287596dd75)
2023-02-13 14:50:14 +00:00
Lennart Poettering
b4e56b13a9 docs: remove /dev/tty* confusion
The text said /dev/tty* as a whole was the VT subsystem and that VT is
not supported in containers.

But that's not accurate as /dev/tty* will match /dev/tty too and that
one device node is special and is not related to VT: it always points to
the current process own controlling tty, regardless what that is.

hence, rewrite /dev/tty* as /dev/tty[0-9]*.

(cherry picked from commit 6ae5c39af1da5b0b6e49278e7a33158d49ec04a5)
(cherry picked from commit f3d620f5d2c26c546d9a5c410c3aa68329b74330)
2023-02-13 14:50:14 +00:00
Lennart Poettering
208153c32b units: pull in loop.ko and dm-mod.ko before repart
We want to make use of that when formatting file systems, hence let's
pull in these modules explicitly.

(This is necessary because we are an early boot service that might run
before systemd-tmpfiles-dev.service, which creates /dev/loop-control and
/dev/mapper/control.)

Alternatively we could just order ourselves after
systemd-tmpfiles-dev.service, but I think there's value in adding an
explicit minimal ordering here, since we know what we'll need.

Fixes: #25775
(cherry picked from commit ce7dcfd6b00b8099d1793d04bcfa9968ca4a0d96)
(cherry picked from commit 3856b97f8bcbde01b1e2ceb3b008513a2327d64d)
2023-02-13 14:50:14 +00:00
Lennart Poettering
923264e034 units: change modprobe@dm-mod.service → modprobe@dm_mod.service
Follow-up for 8f1359bf854e9683e4e0b89fd3a537e0d82d4b95

(cherry picked from commit 143a1f1039d992001d2f2f35b2e6ba07f8a52af7)
(cherry picked from commit 67467efd58b0b9814e92dfaa1edc21ebf2c830e7)
2023-02-13 14:50:14 +00:00
Yu Watanabe
60f297fa20 rules: add missing line continuation
Fixes a bug introduced by 953c928c24455744d5534679998d129b947a5e04.

Fixes #25811.

(cherry picked from commit de8409ac43f6e4596de4cecce8dbbb5f1f2a18b1)
(cherry picked from commit 856a02f33863db84a243225ed9ee11e4e5fc2edc)
2023-02-13 14:50:14 +00:00
Luca Boccassi
3402020d17 packit: use Fedora 37 spec/targets
F37 shipped with v251
v251.11
2023-01-27 09:46:47 +00:00
Daan De Meyer
0acf4d71e0 test-execute: Skip when /sys is read-only
The test depends on /sys being writable, so let's skip it when /sys
is read-only.

(cherry picked from commit 34b5977015a557840988e825ac116a7f09d0be75)
(cherry picked from commit 4dc37994e283d2e8af612519fd3fac195fc47e56)
2023-01-27 09:46:47 +00:00
Frantisek Sumsal
1fc632e151 partition: fix build with newer linux/btrfs.h uapi header
linux/btrfs.h needs  to be included after sys/mount.h, as since [0]
linux/btrfs.h includes linux/fs.h causing build errors:

```
In file included from /usr/include/linux/fs.h:19,
                 from ../src/basic/linux/btrfs.h:29,
                 from ../src/partition/growfs.c:6:
/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
   35 |   MS_RDONLY = 1,                /* Mount read-only.  */
      |   ^~~~~~~~~
[1222/2169] Compiling C object systemd-creds.p/src_creds_creds.c.o
ninja: build stopped: subcommand failed.
```

See: https://github.com/systemd/systemd/issues/8507

[0] a28135303a

(cherry picked from commit ed614f17fc9f3876b2178db949df42a2605f6895)
(cherry picked from commit 8f84df0da357128f1275933cd8aab4c5efad5767)
2023-01-27 09:46:47 +00:00
Frantisek Sumsal
4bc291c1d4 basic/linux: update linux uapi headers
IPPROTO_L2TP was moved from linux/l2tp.h to linux/in.h [0], so let's
reflect that change to fix build with newer kernels:

```
In file included from ../src/libsystemd/sd-netlink/netlink-types-genl.c:10:
../src/basic/linux/l2tp.h:16: error: "IPPROTO_L2TP" redefined [-Werror]
   16 | #define IPPROTO_L2TP            115
      |
In file included from ../src/libsystemd/sd-netlink/netlink-types-genl.c:3:
/usr/include/netinet/in.h:85: note: this is the location of the previous definition
   85 | #define IPPROTO_L2TP            IPPROTO_L2TP
      |
cc1: all warnings being treated as errors
```

When at it, update the rest of the headers we ship as well.

[0] 65b32f801b

(cherry picked from commit a95ff98ec40edad2825c824a186f44454120cf1f)
(cherry picked from commit 240513cecaeca035706a618161d0141a9f1267be)
2023-01-27 09:46:47 +00:00
Nick Rosbrook
7a7427db77 test: handle Debian's /etc/default/locale in testsuite-74.firstboot.sh
This handles a Debian-specific quirk where /etc/default/locale is used
instead of /etc/locale.conf. There is currently special handling for
this in testsuite-73.sh, so the quirk should be handled here too for
consistency.

(cherry picked from commit bb59fdc1e3a7119f3680d309147020fce9bf67b5)
(cherry picked from commit 9b42646b2292decd874c6efb4a9e21b11c8f3c7f)
2023-01-27 09:46:47 +00:00
Frantisek Sumsal
26fdfb0279 test: re-enable skipped systemd-firstboot --locale-messages= test
Since the original issue should be resolved by #25253.

(cherry picked from commit 59377dbef288bff2e9df1254f9cbccd3c7d726a5)
(cherry picked from commit ddc1898ebdd19b754f80f4c51450cda2039c57b7)
2023-01-27 09:46:47 +00:00
Nick Rosbrook
bd32bbebd5 test: make sure mount point exists in testsuite-64.sh
(cherry picked from commit 84e5b9225d12f8a1a7d414ef01f97fcd6881c14f)
(cherry picked from commit 07e4787106fb0a551f73d0a0ec4c6c8e7c958c7d)
2023-01-27 09:46:47 +00:00
Callum Farmer
eee571f159 boot: Use objcopy with arm64
Binutils 2.38 added support for efi-app-aarch64
Still use binary mode if we have an older objcopy
Add check for incompatible gnu-efi crt0 containing the header section
which gets added by objcopy and if used results in duplicate header
and subsequently a broken binary

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
(cherry picked from commit 9c100c4e709e1a063578cad1b6b3cdbf7de48610)
(cherry picked from commit 953e5fc093c731587de9cdadd054fdfff8d54d7a)
2023-01-27 09:46:47 +00:00
Luca Boccassi
ffa329c45c core: ensure init.scope is realized after drop-ins have been loaded
If we add a drop-in for init.scope (e.g.: to set some memory limit),
it will be loaded long after the cgroup has already been realized.
Do it again when creating the special unit.

(cherry picked from commit 020b2e41ea776cff73392da8084a0725b590d245)
(cherry picked from commit 786b7a7208cfb585b70659a8e3ac5180e85d0647)
2023-01-27 09:46:47 +00:00
Frantisek Sumsal
ba3029cfb4 test: bump the container spawn timeout to 60s
As 30s might be not enough on busy systems (and we already bumped the
reboot timeout from 30s to 60s for this reason).

(cherry picked from commit d932022ddfe021b1c49ffaf4d7dfe4093656f0c5)
(cherry picked from commit c2fef536d5d2f588c93159d7cf7cb83016dda2ef)
2023-01-27 09:46:47 +00:00
Frantisek Sumsal
f69dc64d38 test: bump the client-side timeout in sd-bus as well
Since c78d18215b D-Bus services now have 60s to start, but the client
side (sd-bus) still waits only for 25s before giving up:

```
[  226.196380] testsuite-71.sh[556]: + assert_in 'Static hostname: H' ''
[  226.332965] testsuite-71.sh[576]: + set +ex
[  226.332965] testsuite-71.sh[576]: FAIL: 'Static hostname: H' not found in:
[  228.910782] sh[577]: + systemctl poweroff --no-block
[  232.255584] hostnamectl[565]: Failed to query system properties: Connection timed out
[  236.827514] systemd[1]: end.service: Consumed 2.131s CPU time.
[  237.476969] dbus-daemon[566]: [system] Successfully activated service 'org.freedesktop.hostname1'
[  237.516308] systemd[1]: system-modprobe.slice: Consumed 1.533s CPU time.
[  237.794635] systemd[1]: testsuite-71.service: Main process exited, code=exited, status=1/FAILURE
[  237.818469] systemd[1]: testsuite-71.service: Failed with result 'exit-code'.
[  237.931415] systemd[1]: Failed to start testsuite-71.service.
[  238.000833] systemd[1]: testsuite-71.service: Consumed 5.651s CPU time.
[  238.181030] systemd[1]: Reached target testsuite.target.
```

Let's override the timeout in sd-bus as well to mitigate this.

Follow-up to c78d18215b3e5b0f0896ddb1d0d72c666b5e830b.

(cherry picked from commit e0cbb739113b9e2fbb67b27099430c351f03315c)
(cherry picked from commit e4ed752f2313c74b9d5ae3aeb947c150babe061a)
2023-01-27 09:46:47 +00:00
Yu Watanabe
96633df462 test-unit-name: fix fd leak
Fixes an issue reported at https://github.com/systemd/systemd/issues/22576#issuecomment-1396774385.

(cherry picked from commit 36f73b6c67afd9c826e612b751ea8f9249da7985)
(cherry picked from commit 728f0832575b9d2d35acb62d975a5f113012f584)
2023-01-27 09:46:47 +00:00
Yu Watanabe
e713ab8ea0 test-ndisc: fix memleak and fd leak
Fixes issues reported at #22576.

(cherry picked from commit 86d82cb8885afaac374225b945b2efc2a013cb7e)
(cherry picked from commit f6af7a4190d28715a858d8696f7fb89d42a0ead0)
2023-01-27 09:46:47 +00:00
Michal Koutný
fd260cb37e core: mount namespaces: Remove auxiliary bind mounts directory after unit termination
Unit that requires its own mount namespace creates a temporary directory
to implement dynamic bind mounts (org.freedesktop.systemd1.Manager.BindMountUnit).
However, this directory is never removed and they will accumulate for
each unique unit (e.g. templated units of systemd-coredump@).

Attach the auxiliary runtime directory existence to lifetime of other
"runtime" only per-unit directories.

(cherry picked from commit b9f976fb45635e09cd709dbedd0afb03d4b73c05)
(cherry picked from commit 80e8340ec49d0da3744cdf81f82202e13b0fad3b)
2023-01-27 09:46:47 +00:00
Frantisek Sumsal
539358c2c7 test: bump D-Bus service start timeout if we run without accel
The default (25s) doesn't seem to be enough in some cases (especially
in VMs without acceleration), causing spurious timeouts:

[  174.297658] dbus-daemon[647]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.0' (uid=0 pid=645 comm="hostnamectl " label="kernel")
[  184.202313] systemd[1]: systemd-update-utmp-runlevel.service: Consumed 1.253s CPU time.
[  197.335422] systemd[1]: Started dbus.service.
[  199.211468] testsuite-71.sh[639]: + assert_in 'Static hostname: H' ''
[  199.347192] dbus-daemon[647]: [system] Failed to activate service 'org.freedesktop.hostname1': timed out (service_start_timeout=25000ms)
[  199.394879] testsuite-71.sh[657]: + set +ex
[  199.438918] testsuite-71.sh[657]: FAIL: 'Static hostname: H' not found in:
[  200.966006] systemd-logind[631]: Watching system buttons on /dev/input/event0 (Power Button)
[  201.008178] systemd-logind[631]: Watching system buttons on /dev/input/event1 (AT Translated Set 2 keyboard)
[  201.034106] systemd-logind[631]: New seat seat0.
[  201.238267] sh[658]: + systemctl poweroff --no-block
[  201.329890] systemd[1]: Starting systemd-hostnamed.service...
[  202.156622] systemd[1]: systemd-update-utmp-runlevel.service: Deactivated successfully.
[  204.818913] hostnamectl[645]: Failed to query system properties: Connection timed out
[  205.195583] systemd[1]: testsuite-71.service: Main process exited, code=exited, status=1/FAILURE
[  205.227237] systemd[1]: testsuite-71.service: Failed with result 'exit-code'.
[  205.712780] systemd[1]: Failed to start testsuite-71.service.

(cherry picked from commit c78d18215b3e5b0f0896ddb1d0d72c666b5e830b)
(cherry picked from commit 17109481202856616f23ca477fe5999b376c495b)
2023-01-27 09:46:47 +00:00
Yu Watanabe
088d6c8521 sd-dhcp-client: gracefully handle invalid ether type client ID
Currently, sd-dhcp-server accepts spurious client IDs, then the leases
exposed by networkd may be invalid. Let's make networkctl gracefully
show such leases.

Fixes #25984.

(cherry picked from commit 841dfd3dc0dd370a21f190a5b7b870db1c95f7e6)
(cherry picked from commit a674a398e707a821e4148ace80cfdf68d2fd496f)
2023-01-27 09:46:47 +00:00
David Tardon
48251e428f mount: handle bind mount of file with non-existing target
When the target (Where=) of a mount does not exist, systemd tries to
create it. But previously, it'd always been created as a directory. That
doesn't work if one wants to bind-mount a file to a target that doesn't
exist.

Fixes: #17184
(cherry picked from commit 218cfe23354397ded28ac898f82b52724f48dae7)
(cherry picked from commit 25e30725d7d31d747a40a5c0ab387dc9f48f09e3)
2023-01-27 09:46:47 +00:00
Alberto Planas
cf62f6b727 creds-util: merge the TPM2 detection for initrd
This patch merge the TPM2 detection paths when we are inside and outside
an initrd.

Signed-off-by: Alberto Planas <aplanas@suse.com>
(cherry picked from commit e37dfcec528b43e203d198f978f9eaa87787c762)
(cherry picked from commit 78ffc39f9e626a32325e9565d65c6d8e8438f4f0)
2023-01-27 09:46:47 +00:00
Alberto Planas
febaf50a5f creds-util: do not try TPM2 if there is not support
During the credentials encryption, if systemd it is compiled with TPM2
support, it will try to use it depending on the key flags passed.

The current code only checks if the system has a functional TPM2 if the
case of the INITRD flag.

This patch do a similar check in the case that it is outside initrd (but
still automatic).

Signed-off-by: Alberto Planas <aplanas@suse.com>
(cherry picked from commit e653a194e490fae7d166f40762c334006d592051)
(cherry picked from commit 4f420958f92e27218405d1f52033885c6523ea70)
2023-01-27 09:46:47 +00:00
Alberto Planas
d7c8b1b709 creds-util: check for CAP_DAC_READ_SEARCH
In make_credential_host_secret, the credential.secret file is generated
first as a temporary anonymous file that is later instantiated with
linkat(2).  This system call requires CAP_DAC_READ_SEARCH capability
when the flag AT_EMPTY_PATH is used.

This patch check if the capability is effective, and if not uses the
alternative codepath for creating named temporary files.

Non-root users can now create per-user credentials with:

  export SYSTEMD_CREDENTIAL_SECRET=$HOME/.config/systemd/credential.secret
  systemd-creds setup

Signed-off-by: Alberto Planas <aplanas@suse.com>
(cherry picked from commit 1615578f2792fdeecaf65606861bd3db9eb949c3)
(cherry picked from commit 432ec5a654d5b8b123472ab64b29d9b5baf3cbf2)
2023-01-27 09:46:47 +00:00
Mike Yuan
ebe67b6e88 gpt-auto: harden ESP/XBOOTLDR mounts with "noexec,nosuid,nodev"
When these partitions are probed by gpt-auto,
they will always be hardened with such options.

See also: https://github.com/systemd/systemd/issues/25776#issuecomment-1364115711

Closes #25776

(cherry picked from commit d708293d436516823e0e4bfb02c54365820fd8c6)
(cherry picked from commit 49804cfb71d3a79f433096e4cfb5616980171336)
2023-01-27 09:46:47 +00:00
Yu Watanabe
abcd25b66e busctl: fix introspecting DBus properties
Follow-up for f2f7785d7a47ffa48ac929648794e1288509ddd8.

Fixes #26033.

(cherry picked from commit 2cbb171d20a07ec0a25296f167b0385de102d74e)
(cherry picked from commit 89e86ad8df4b87092264e49bcfba8053eb74822d)
2023-01-27 09:46:47 +00:00
Yu Watanabe
7ac8f1af5d network/l2tp: parse address or address type from correct string
Fixes a bug introduced by 8b49ee2dcda04f8147650f7d9fb93662caf3ea2e.

Fixes #26011.

(cherry picked from commit bf4a5ac804d85a1e8df8226e8595219aa6fdafae)
(cherry picked from commit 33e6d133819c8b4b9468a16caf222ceb6ef39437)
2023-01-27 09:46:47 +00:00
Yu Watanabe
5f4042eea6 network/l2tp: fix error code in log message
(cherry picked from commit 4da53043a618b557f3c0c8ccef81c537c4ad1e18)
(cherry picked from commit b215afc58df8867dc82110f7064b1a2139793f28)
2023-01-27 09:46:47 +00:00
Frantisek Sumsal
4768110a2e import: use CURLOPT_PROTOCOLS_STR with libcurl >= 7.85.0
CURLOPT_PROTOCOLS [0] was deprecated in libcurl 7.85.0 with
CURLOPT_PROTOCOLS_STR [1] as a replacement, causing build warnings/errors:

../build/src/import/curl-util.c: In function ‘curl_glue_make’:
../build/src/import/curl-util.c:255:9: error: ‘CURLOPT_PROTOCOLS’ is deprecated: since 7.85.0. Use CURLOPT_PROTOCOLS_STR [-Werror=deprecated-declarations]
  255 |         if (curl_easy_setopt(c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_FILE) != CURLE_OK)
      |         ^~
In file included from ../build/src/import/curl-util.h:4,
                 from ../build/src/import/curl-util.c:6:
/usr/include/curl/curl.h:1749:3: note: declared here
 1749 |   CURLOPTDEPRECATED(CURLOPT_PROTOCOLS, CURLOPTTYPE_LONG, 181,
      |   ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Since there's no grace period between the two symbols, let's resort
to a light if-def-ery to resolve this.

[0] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS.html
[1] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS_STR.html

(cherry picked from commit e61a4c0b7c79eabbe4eb50ff2e663734fde769f0)
(cherry picked from commit 14f573175aa6a026c03fd09dea5952f3755b799a)
2023-01-27 09:46:47 +00:00
Frantisek Sumsal
c2be553868 import: use CURLINFO_SCHEME instead of CURLINFO_PROTOCOL
CURLINFO_PROTOCOL has been deprecated in curl 7.85.0 causing compilation
warnings/errors:

../build/src/import/pull-job.c: In function ‘pull_job_curl_on_finished’:
../build/src/import/pull-job.c:142:9: error: ‘CURLINFO_PROTOCOL’ is deprecated: since 7.85.0. Use CURLINFO_SCHEME [-Werror=deprecated-declarations]
  142 |         code = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
      |         ^~~~
In file included from ../build/src/import/curl-util.h:4,
                 from ../build/src/import/pull-job.h:6,
                 from ../build/src/import/pull-common.h:7,
                 from ../build/src/import/pull-job.c:16:
/usr/include/curl/curl.h:2896:3: note: declared here
 2896 |   CURLINFO_PROTOCOL    CURL_DEPRECATED(7.85.0, "Use CURLINFO_SCHEME")
      |   ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Since both CURLINFO_SCHEME and CURLINFO_PROTOCOL were introduced in
the same curl version (7.52.0 [0][1]) we don't have to worry about
backwards compatibility.

[0] https://curl.se/libcurl/c/CURLINFO_SCHEME.html
[1] https://curl.se/libcurl/c/CURLINFO_PROTOCOL.html

(cherry picked from commit 2285c462ebb0b5d9a7043719a4f0d684a5dc37c2)
(cherry picked from commit 4ab37502b35c76441b7be656b67ef53024af8a9f)
2023-01-27 09:46:47 +00:00
Lennart Poettering
d8b4ac7a17 nspawn: guard acl_free() with a NULL check
Inspired by #25957 there's one other place where we don't guard
acl_free() calls with a NULL check.

Fix that.

(cherry picked from commit 34680637e838415204850f77c93ca6ca219abaf1)
(cherry picked from commit 4dabf90526d4573144a51bdd87c1203b25265b33)
2023-01-27 09:46:47 +00:00
Sam James
455193605d tmpfiles: avoid null free() for acl attributes
When built with ACL support, we might be processing a tmpfiles
entry where there's no cause for us to call parse_acls_from_arg,
then we get to the end of parse_line without having ever populated
i.{acl_access, acl_default}.

Then we pass a null pointer into acl_free().

From UBSAN w/ GCC 13.0.0_pre20230101:
```
$ systemd-tmpfiles --clean
/var/tmp/portage/sys-apps/acl-2.3.1-r1/work/acl-2.3.1/libacl/acl_free.c:44:14: runtime error: applying non-zero offset 18446744073709551608 to null pointer
    #0 0x7f65d868b482 in acl_free /var/tmp/portage/sys-apps/acl-2.3.1-r1/work/acl-2.3.1/libacl/acl_free.c:44
    #1 0x55fe7e592249 in item_free_contents ../systemd-9999/src/tmpfiles/tmpfiles.c:2855
    #2 0x55fe7e5a347a in parse_line ../systemd-9999/src/tmpfiles/tmpfiles.c:3158
    #3 0x55fe7e5a347a in read_config_file ../systemd-9999/src/tmpfiles/tmpfiles.c:3897
    #4 0x55fe7e590c61 in read_config_files ../systemd-9999/src/tmpfiles/tmpfiles.c:3985
    #5 0x55fe7e590c61 in run ../systemd-9999/src/tmpfiles/tmpfiles.c:4157
    #6 0x55fe7e590c61 in main ../systemd-9999/src/tmpfiles/tmpfiles.c:4218
    #7 0x7f65d7ebe289  (/usr/lib64/libc.so.6+0x23289)
    #8 0x7f65d7ebe344 in __libc_start_main (/usr/lib64/libc.so.6+0x23344)
    #9 0x55fe7e591900 in _start (/usr/bin/systemd-tmpfiles+0x11900)
```

(cherry picked from commit 9f804ab04d566ff745849e1c4ced680a0447cf76)
(cherry picked from commit a11a949c43def70ec5d3f57f561884c3f652603e)
2023-01-27 09:46:47 +00:00
Lennart Poettering
5fe49d0fb8 sd-event: don't mistake USEC_INFINITY passed in for overflow
Let's pass USEC_INFINITY from sd_event_source_set_time_relative() to
sd_event_source_set_time() instead of raising EOVERFLOW.

We should raise EOVERFLOW only if your addition fails, but not if the
input already is USEC_INFINITY, since it's an entirely valid operation
to have an infinite time-out, and we should support that.

(cherry picked from commit ef8591951aefccb668201f24aa481aa6cda834da)
(cherry picked from commit 9769d84fe51573b4f2d5cb8f76664e886c7daf88)
2023-01-27 09:46:47 +00:00