1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-12 13:18:14 +03:00
Commit Graph

62925 Commits

Author SHA1 Message Date
Yu Watanabe
752e92615d test-execute: add test for PrivateNetwork= with/without mount namespacing 2023-02-23 15:09:13 +09:00
Yu Watanabe
c2da3bf237 core/namespace: mount new sysfs when new network namespace is requested
Even when a mount namespace is created, previously host's sysfs is used,
especially with RootDirectory= or RootImage=, thus service processes can
still access the properties of the network interfaces in the main network
namespace through sysfs.

This makes, sysfs is remounted with the new network namespace tag, except
when PrivateMounts= is explicitly disabled. Hence, the properties of the
network interfaces in the main network namespace cannot be accessed by
service processes through sysfs.

Fixes #26422.
2023-02-23 15:09:13 +09:00
Yu Watanabe
277b269e25 core/namespace: introduce a new namespace mount mode PRIVATE_SYSFS
This is useful when a service running with a new network namespace.

The mount mode is not used yet, but will be used in a later commit.
2023-02-23 15:09:13 +09:00
Yu Watanabe
10028263fd core/namespace: rename SYSFS -> BIND_SYSFS
No functional change, just preparation for later commits.
2023-02-23 15:09:13 +09:00
Yu Watanabe
f63a2c4821 mount-util: introduce remount_sysfs()
This is useful when creating a new network namespace. Unlike procfs,
we need to remount sysfs, otherwise properties of the network interfaces
in the main network namespace are still accessible through the old sysfs,
e.g. /sys/class/net/eth0. All sub-mounts previously mounted on the sysfs
are moved onto the new sysfs mount.

The function will be used in later commits.
2023-02-23 15:09:13 +09:00
Yu Watanabe
2400212128 core/execute: make PrivateMounts= tristate
No functional change, just preparation for later commits.
2023-02-23 15:09:13 +09:00
Yu Watanabe
faac56d5d2 core/dbus-util: introduce bus_set_transient_tristate()
This will be used in later commits.
2023-02-23 15:09:13 +09:00
Yu Watanabe
ec1b4be82e bus-util: introduce bus_property_get_tristate()
This will be used in later commits.
2023-02-23 15:09:13 +09:00
Yu Watanabe
fde36d2581 core/execute: introduce exec_needs_ipc_namespace() helper function
This also fixes a missing condition in exec_runtime_make().
2023-02-23 15:09:13 +09:00
Yu Watanabe
fbbb9697b6 core/execute: introduce exec_needs_network_namespace() helper function 2023-02-23 15:09:13 +09:00
Yu Watanabe
06b3a2f6f0 core/namespace: drop unused field in NamespaceInfo 2023-02-23 15:09:13 +09:00
Yu Watanabe
dcef5e293f
Merge pull request #26555 from poettering/cleanup-array
add gcc cleanup attribute based logic to destroy arrays
2023-02-23 15:08:56 +09:00
Lennart Poettering
8c2d0d3af4 tree-wide: port various things over to CLEANUP_ARRAY() 2023-02-23 11:43:43 +09:00
Lennart Poettering
ff3f1464ec memory-util: add a concept for gcc cleanup attribute based array destruction 2023-02-23 11:43:43 +09:00
Yu Watanabe
63b1e67ed9 sd-event: fix error handling
Follow-up for 158fe190af.
2023-02-23 11:05:59 +09:00
Yu Watanabe
40c5d5d2a1 sd-event: fix use of uninitialized variable
Follow-up for 158fe190af.

Fixes CID#1505670.
2023-02-23 11:05:49 +09:00
Yu Watanabe
c7d941c527
Merge pull request #26557 from poettering/more-cap-utils
new helper for cap-list.[ch] + capability-util.[ch]
2023-02-23 10:44:53 +09:00
Yu Watanabe
2457a36d30
Merge pull request #26542 from medhefgo/boot-device-path
boot: Misc device path improvements
2023-02-23 10:26:40 +09:00
Yu Watanabe
6d2326e036 sd-event: always initialize sd_event.perturb
If the boot ID cannot be obtained, let's first fallback to the machine
ID, and if still cannot, then let's use 0.
Otherwise, no timer event source cannot be triggered.

Fixes #26549.
2023-02-23 10:11:45 +09:00
Lennart Poettering
a954b2492e execute: modernizations 2023-02-23 10:11:09 +09:00
Lennart Poettering
70f1280c83 tree-wide: use unlink_and_freep() moreover 2023-02-23 10:10:48 +09:00
Lennart Poettering
a649419aae capability-util: add new capability_get_ambient() helper 2023-02-22 23:45:40 +01:00
Lennart Poettering
66c1e440c7 cap-list: add capability_set_to_string_negative() 2023-02-22 23:45:40 +01:00
Lennart Poettering
8cf4674d86 cap-list: add capability_set_to_strv() 2023-02-22 23:45:40 +01:00
Zbigniew Jędrzejewski-Szmek
de2c4707c1 systemctl: make list-timers not say "left" in "LEFT" column
We would print:
NEXT                        LEFT          LAST                        PASSED        UNIT                           >
Wed 2023-02-22 23:55:00 CET 20min left    Wed 2023-02-22 23:25:00 CET 9min ago      pmlogger_check.timer           >
Wed 2023-02-22 23:55:10 CET 21min left    Wed 2023-02-22 23:25:16 CET 8min ago      pmlogger_farm_check.timer      >
Wed 2023-02-22 23:58:00 CET 23min left    Wed 2023-02-22 23:28:02 CET 6min ago      pmie_check.timer               >
Wed 2023-02-22 23:58:10 CET 24min left    Wed 2023-02-22 23:28:11 CET 5min ago      pmie_farm_check.timer          >
Thu 2023-02-23 00:00:00 CET 25min left    Wed 2023-02-22 00:00:10 CET 23h ago       logrotate.timer                >
Thu 2023-02-23 00:00:00 CET 25min left    Wed 2023-02-22 00:00:10 CET 23h ago       unbound-anchor.timer           >
Thu 2023-02-23 00:08:00 CET 33min left    Wed 2023-02-22 00:08:05 CET 23h ago       pmie_daily.timer               >
Thu 2023-02-23 00:10:00 CET 35min left    Wed 2023-02-22 00:10:03 CET 23h ago       pmlogger_daily.timer           >
Thu 2023-02-23 00:14:14 CET 40min left    Wed 2023-02-22 22:35:09 CET 58min ago     dnf-makecache.timer            >
Thu 2023-02-23 05:05:04 CET 5h 30min left Wed 2023-02-22 03:29:00 CET 20h ago       plocate-updatedb.timer         >
Thu 2023-02-23 11:34:34 CET 12h left      Wed 2023-02-22 11:34:33 CET 11h ago       systemd-tmpfiles-clean.timer   >
Sun 2023-02-26 01:00:00 CET 3 days left   Mon 2023-02-20 07:51:59 CET 2 days ago    raid-check.timer               >
Mon 2023-02-27 00:19:48 CET 4 days left   Mon 2023-02-20 07:51:59 CET 2 days ago    fstrim.timer                   >
Mon 2023-02-27 12:34:36 CET 4 days left   Tue 2023-02-21 08:22:14 CET 1 day 15h ago archlinux-keyring-wkd-sync.time>

The "left" part uses precious screen estate and is pretty much implied
by the column name. Drop it.
2023-02-22 23:43:33 +01:00
Zbigniew Jędrzejewski-Szmek
d5e6f36c7a shared/format-table: optionally print timestamps without "left"
This just adds the base functionality and some unit tests.
With TABLE_TIMESTAMP_RELATIVE we print "5s ago" and "5s left",
with the new TABLE_TIMESTAMP_LEFT, we print "5s ago" but "5s".
This is more useful for cases where we generally only want to
print timestamps in the future.
2023-02-22 23:43:33 +01:00
Frantisek Sumsal
a90d9ee162 sd-journal: fix build with older glibc
In older glibc (like 2.28 on CentOS Stream 8) there is no wrapper
for the gettid() syscall, so we need to provide our own.

../src/libsystemd/sd-journal/journal-send.c: In function ‘close_journal_fd’:
../src/libsystemd/sd-journal/journal-send.c:88:25: error: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Werror=implicit-function-declaration]
         if (getpid() != gettid())
                         ^~~~~~
                         getgid
../src/libsystemd/sd-journal/journal-send.c:88:25: warning: nested extern declaration of ‘gettid’ [-Wnested-externs]
cc1: some warnings being treated as errors

Follow-up to 50b35193ec.
2023-02-23 06:57:44 +09:00
Jan Janssen
10e27f768b boot: Take advantage of packed device paths
Now that device path types are marked as packed we can safely cast and
access them. If we ever take the address of a member, we would get a
compiler warning.
2023-02-22 21:56:26 +01:00
Jan Janssen
ea592abfc6 boot: Add GUID format helper macro 2023-02-22 21:56:20 +01:00
Jan Janssen
0b92662821 boot: Move more device path helpers to device-path-util.c
This also renames them to stay consistent with our naming style.
2023-02-22 21:54:11 +01:00
Jan Janssen
d755ac6214 boot: Remove some device path helper macros
In gnu-efi/EDK2 device paths are not marked as packed and instead the
Length field is split into 2 bytes. Accessing those requires these
helper macros as device paths may be unaligned.

Since our own efi headers define device path structs as packed, we can
access these directly, making code much more readable.
2023-02-22 21:54:11 +01:00
Jan Janssen
e6d7dc9ada boot: Split out device path functions
No code changes aside from renaming path_replace_hd() and making its
parameter take any device path node type.
2023-02-22 21:54:11 +01:00
Jan Janssen
8e760b3fcd boot: Move disk_get_part_uuid into part-discovery.c
Thematically, they are similar and disk.c is awfully small to warrant
the separation.
2023-02-22 21:54:11 +01:00
Lennart Poettering
58a80840e6
Merge pull request #26540 from poettering/systemctl-list-tweaks
small tweaks to "systemctl list-automounts" + "systemctl list-timers" tabular output
2023-02-22 21:19:40 +01:00
Frantisek Sumsal
6299b6e5e6 test: add coverage for #24177
Original issue: https://bugzilla.redhat.com/show_bug.cgi?id=1985288
2023-02-23 04:52:46 +09:00
Daan De Meyer
b12525416b smack-util: Fix compilation error when smack is disabled 2023-02-22 20:48:02 +01:00
Lennart Poettering
976baf26d3 systemctl: read 64bit integers into uint64_t
usec_t is also a uint64_t internally, hence this doesn't actually change
anything. However, on the conceptual level, sd-bus expects a uint64_t
hence give it one.
2023-02-22 19:00:42 +01:00
Lennart Poettering
21ae8c17d4 systemctl: suppress timeout display if unset in list-automounts
If the timeout is zero it's not set, let's suppress the output then.
2023-02-22 19:00:42 +01:00
Lennart Poettering
f168919da8 systemctl: right-align left/passed columns in list-timers
Timespans are probably best right-aligned, in particular if they
systematically end in either " ago" or " left" because they are used as
"relative timestamps".
2023-02-22 18:59:15 +01:00
Daan De Meyer
ad36d31ea5 efi-string: Add startswith8()
startswith() from string-util-fundamental.h is defined for sd_char
which is char16_t, so let's add an implementation for char as well.
2023-02-22 16:55:07 +01:00
Daan De Meyer
bbef5a9617 efi-string: Fix strchr() null byte handling
strchr() should be able to search for the terminating null byte,
our implementation doesn't, let's fix that.
2023-02-22 16:55:07 +01:00
Lennart Poettering
921330af40
Merge pull request #26448 from poettering/sd-event-mempress
sd-event: add memory pressure event source
2023-02-22 16:23:59 +01:00
Mike Yuan
e774d3c9f1 systemctl: warn if units disabled in user scope are still enabled globally
Fixes #18271
2023-02-22 23:05:41 +09:00
Yu Watanabe
b59052be26 systemctl: show "Until:" field only for service and scope units
Only service and scope units have RuntimeMaxUSec bus property.
To suppress the "Until:" field for other unit types, the entry must be
initialized with USEC_INFINITY.

Fixes #26473.
2023-02-22 23:04:43 +09:00
Yu Watanabe
58fbf167d7
Merge pull request #26528 from keszybz/valgrind-simplification
Drop the -Dvalgrind configuration option
2023-02-22 23:04:12 +09:00
Daan De Meyer
97be742d95
Merge pull request #26500 from DaanDeMeyer/repart-mountpoints
repart: Several CopyFiles= improvements
2023-02-22 14:25:45 +01:00
Lennart Poettering
f8a32e679e man: document the new sd_event_add_memory_pressure() API 2023-02-22 13:16:34 +01:00
Lennart Poettering
b7dc40e663 test: add test for new memory pressure logic
it tests both real PSI stuff (if available) and fake pressure via
AF_UNIX and FIFO notification.
2023-02-22 13:14:36 +01:00
Lennart Poettering
158fe190af sd-event: add high-level sd_event_add_memory_pressure() event source
Typically, in reasonably complex programs we want to realease various
caches (such as glibc allocation caches) in case of memory pressure.
Let's add explicit infrastructure for that to sd-event, that can hook
Linux' Pressure Stall Information (PSI) logic with our event loop.

This adds sd_event_add_memory_pressure() as easy, one-step API to
install an even source that is called under memory pressure.

The parameters which file to watch (the per-cgroup PSI file, or the
system-wide file /proc/pressure/memory) can be configured via env vars.
The idea is that the service manager sooner or later gains controls for
setting this up correctly.

Alternatively to the PSI a similar logic is supported but instead of
waiting for POLLPRI on a procfs/cgroupfs fd we'll wait for POLLIN on
FIFO or AF_UNIX sockets. This is useful for testing, and possibly in
other environments, for example to hook up this protocol directly with
GNOME's low memory monitor.

By default this watches on the cgroup-local PSI so that we aren't
affected by pressure on cgroups we are not related to.
2023-02-22 13:09:42 +01:00
Daan De Meyer
4d8ff4e868 repart: Exclude APIVFS mountpoint directories
Also exclude APIVFS and temporary files directories from the copy
operation so that these files don't accidentally end up in images.
2023-02-22 12:44:39 +01:00