Commit Graph
62745 Commits
Author SHA1 Message Date
Luca Boccassi fb22861da1 manager: add GetMallocInfo() hidden/debug method
Return the output of malloc_info() via a file descriptor (in case it
gets large on a busy system). Useful to get live data about memory
usage when it is not possible to run under a profiler from the get-go.
Do not formally register the method, but add a 'hidden' interface
so that it cannot be seen by introspection or by looking at the
object.
2023-02-23 13:26:52 +00:00
Yu Watanabe 500ecfd513 Merge pull request #26535 from yuwata/systemctl-list-cleanups
systemctl-list: several cleanups
2023-02-23 21:38:13 +09:00
Yu Watanabe e47c426b5c Merge pull request #26560 from yuwata/journal-send-fix-memleak-and-cleanups
sd-journal: several fixlets and cleanups for sd_journal_send()
2023-02-23 21:37:20 +09:00
Yu Watanabe 4de2b47bde core/dbus-socket: check the socket path is absolute
In config_parse_socket_listen(), we have checked the path is absolute,
however we have not in the dbus method.
2023-02-23 21:34:16 +09:00
Lennart Poettering 638fd8ccb8 execute: pass ambient caps from PAM through to invoked service
If a PAM service sets some ambient caps, we should honour that, hence
query it, and merge it with our own ambient settings.

This needs to be done manually since otherwise dropping privs via
setresuid() will undo all such caps, and we need to manually tweak
things to keep them.
2023-02-23 12:53:09 +01:00
Zbigniew Jędrzejewski-Szmek 20b569a4c6 Merge pull request #26563 from dtardon/fd-init
Initialize fds with -EBADF + drop one unneeded initialization
2023-02-23 11:43:09 +01:00
Zbigniew Jędrzejewski-Szmek a34180a22f Merge pull request #26556 from keszybz/list-timers-optimize-left
Do not say " left" on every timer in LEFT column
2023-02-23 11:37:48 +01:00
Yu Watanabe 1b7b956a9b systemctl: cleanups for list-paths
- Rename struct path_info -> PathInfo,
- Drop struct path_infos,
- Use CLEANUP_ARRAY(),

No functional change, just refactoring.
2023-02-23 18:00:38 +09:00
Yu Watanabe 032b3f518c systemctl: cleanups for list-automounts
- Rename struct automount_info -> AutomountInfo,
- use CLEANUP_ARRAY(), and etc.

No functional change, just refactoring.
2023-02-23 18:00:38 +09:00
Yu Watanabe 0e351e9a27 systemctl: cleanups for list-timers
- Rename struct timer_info -> TimerInfo,
- use CLEANUP_ARRAY().

No functional change, just refactoring.
2023-02-23 18:00:38 +09:00
Yu Watanabe 1b87606639 systemctl: cleanups for list-sockets
- Rename struct socket_info -> SocketInfo.
- Drop own_triggered field, and always copy the triggered field.
- Use CLEANUP_ARRAY().

No functional changes, just refactoring.
2023-02-23 18:00:24 +09:00
David Tardon fabaf9ae25 bootctl: drop unneeded initialization 2023-02-23 09:50:26 +01:00
David Tardon 92651a7a2d tree-wide: initialize fds with -EBADF 2023-02-23 09:48:54 +01:00
Lennart Poettering f1e1614e10 Merge pull request #26458 from yuwata/core-network-namespace-remount-sysfs
core: remount sysfs when network and mount namespace are enabled
2023-02-23 09:44:06 +01:00
Yu Watanabe 1912f790fe sd-event: fix error handling
Follow-up for 6d2326e036.
2023-02-23 09:27:48 +01:00
Lennart Poettering ca06d8984f Merge pull request #26559 from yuwata/sd-event-memory-pressure-follow-ups
sd-event: follow-ups for memory pressure event source
2023-02-23 09:27:20 +01:00
Yu Watanabe f2ccc0d3e1 systemctl-list-units: drop unused return value 2023-02-23 15:13:05 +09:00
Yu Watanabe eef96911e1 systemctl-list-units: fix memleak on error 2023-02-23 15:13:05 +09:00
Yu Watanabe 5648ebaf40 sd-journal: fix memleak and freeing invalid pointers
This also makes
- use GREEDY_REALLOC() or GREEDY_REALLOC0(),
- use CLEANUP_ARRAY() macro.
2023-02-23 15:09:59 +09:00
Yu Watanabe de5cc016b5 io-util: drop double evaluation in IOVEC_INIT_STRING()
This also makes IOVEC_INIT_STRING() and IOVEC_MAKE_STRING() identical.
2023-02-23 15:09:59 +09:00
Yu Watanabe 65e7d565e4 io-util: introduce IOVEC_NULL 2023-02-23 15:09:59 +09:00
Lennart Poettering 253a83ea44 io-util: introduce iovec_array_free()
It will be used in later commits.
2023-02-23 15:09:59 +09:00
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