Commit Graph
1642 Commits
Author SHA1 Message Date
Daan De Meyer 0ee78fc96e tree-wide: Clean up more includes 2025-05-26 11:16:40 +02:00
Daan De Meyer 1e35e81b2c tree-wide: Clean up includes
Preparation for cleaning up includes in src/shared.
2025-05-22 21:10:15 +02:00
Daan De Meyer 0bbd8e18ed systemctl: Clean up includes
Split out of #37344.
2025-05-21 23:59:03 +09:00
Daan De Meyer 8b5ce49591 basic: Include time-util.h in constants.h
constants.h defines a bunch of constants that use macros from
time-util.h, so add the needed include. To avoid cyclic dependencies,
we move the HAS_FEATURE_MEMORY_SANITIZER and HAS_FEATURE_ADDRESS_SANITIZER
logic to macro.h and get rid of the constants.h include there.

The rest of this commit is adding missing constants.h includes where
needed due to it being removed from macro.h.
2025-05-21 10:49:42 +02:00
Daan De Meyer a583b34416 meson: Extract more objects instead of compiling multiple times
Also, let's deflatten the lists of sources in preparation for the
next commit at the same time.

In systemctl, we split out systemctl-main.c to make sure the definition
of main() is in a separate object which allows us to extract the systemctl.c
object and link it in the fuzzer target without getting a multiple definition
error when linking.
2025-05-20 10:29:58 +02:00
Mike Yuan 5fde5c0399 systemctl-show: drop BlockIO* property formatter 2025-05-15 02:19:15 +02:00
Mike Yuan b86b1ca22f fork-journal: use char* const* for strv input param
This is compatible with char** and is what I originally
asked for in
https://github.com/systemd/systemd/pull/36858#discussion_r2086792739
Someone needs to read better ;-)
2025-05-13 23:01:23 +02:00
Yu Watanabe 5884fafcd7 systemctl: make systemctl clean --what= values more discoverable (#37418) 2025-05-14 02:16:47 +09:00
Jörg Behrmann 68b6289a9e systemct: show all in output of systemctl clean --what=help 2025-05-13 17:21:02 +02:00
Jörg Behrmann 028de7292d man, systemctl: document --what=help 2025-05-13 17:19:39 +02:00
Lennart Poettering c8aff47a9c systemctl: add --verbose mode 2025-05-13 15:39:57 +02:00
Daan De Meyer b78d73fa22 conf-parser: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer 6553db6063 strv: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer c94f6ab1bf string-table: Move more implementation logic into functions
Let's move some more implementation logic into functions. We keep
the logic that requires the macro in the macro and move the rest into
functions.

While we're at it, let's also make the parameter declarations of
all the string table macros less clausthrophobic.
2025-05-06 10:14:24 +02:00
Daan De Meyer 76d62b63ef main-func: Reduce transitive includes
Let's move some logic from _DEFINE_MAIN_FUNCTION() and other places
in main-func.h into functions that we implement in main-func.c to
allow moving some included headers from the header to the .c file.
2025-05-06 10:07:27 +02:00
Daan De Meyer 1cf40697e3 tree-wide: Sort includes
This was done by running a locally built clang-format with
https://github.com/llvm/llvm-project/pull/137617 and
https://github.com/llvm/llvm-project/pull/137840 applied on all .c
and .h files.
2025-04-30 09:30:51 +02:00
Daan De Meyer 401a22bfc1 tree-wide: Make sure all headers are standalone
Let's make sure all of our headers include everything they require.
2025-04-23 10:33:38 +02:00
Lennart Poettering 9ca16f6f18 pid1: add a concurrency limit to slice units
Fixes: #35862
2025-04-22 18:53:51 +02:00
Yu Watanabe 5793a39dd8 core,systemctl: unit_file_find_fragment() provides names with string_hash_ops_free
names are assigned with set_put_strdup(), hence string_hash_ops_free is
used and we can use set_free() rather than set_free_free().
2025-04-13 09:49:40 +09:00
Yu Watanabe b457af42e5 Log message improvements (#35237)
Various improvements to log messages. Inspired by
https://bugzilla.redhat.com/show_bug.cgi?id=2327296.
2025-03-31 21:23:23 +09:00
Zbigniew Jędrzejewski-Szmek fdfa9fd8ab various: handle the positive condition after strv_skip() first 2025-03-27 12:04:37 +01:00
Nick Rosbrook bc3a11097f login: add polkit example rules for allowing root to ignore inhibitors
The semantics of strong inhibitors require that POLKIT_ALWAYS_QUERY
always be set when checking if we can allow blocking inhibitors to be
ignored on shutdown, reboot, etc. With the default polkit rules and
policy, users may experience a situation where users in the sudo group
are authorized to run:

 systemctl reboot --check-inhibitors=no

but the root user is not authorized. Instead, the following error is
given:

 Call to Reboot failed: Interactive authentication required.

While this is correct according to the semantics of strong inhibitors,
it is confusing. To help the situation, provide example polkit rules
that allow root to perform these actions.

Finally, when root receives SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED
when calling e.g. systemctl reboot, print a message explaining that this
is due to the current polkit policy, and point to the new example rule.

Related: https://github.com/systemd/systemd/issues/36786
2025-03-25 16:15:34 -04:00
Zbigniew Jędrzejewski-Szmek 75d51d77da basic/glyph-util: introduce optional_glyph() to wrap emoji_enabled() 2025-03-15 14:40:52 +01:00
Zbigniew Jędrzejewski-Szmek 1ae9b0cfa8 basic/glyph-util: rename "special glyph" to just "glyph"
Admittedly, some of our glyphs _are_ special, e.g. "O=" for SPECIAL_GLYPH_TOUCH ;)
But we don't need this in the name. The very long names make some invocations
very wordy, e.g. special_glyph(SPECIAL_GLYPH_SLIGHTLY_UNHAPPY_SMILEY).
Also, I want to add GLYPH_SPACE, which is not special at all.
2025-03-15 14:40:39 +01:00
Lennart Poettering 98b7c5e2f2 basic: move gethostname_full() from basic/hostname-util.c → shared/hostname-setup.c
In one of the next commits we'd like to introduce a concept of
optionally hashing the hostname from the machine ID. For that we we need
to optionally back gethostname_full() by code involving sd-id128, hence
let's move it from src/basic/ to src/shared/, since only there we are
allowed to use our public APIs.
2025-03-11 17:54:44 +01:00
Yu Watanabe c0cc01de8a meson: use install_symlink() where applicable
Now our baseline of meson is 0.62, hence install_symlink() can be used.

Note, install_symlink() implies install_emptydir() for specified
install_dir. Hence, this also drops several unnecessary
install_emptydir() calls.

Note, the function currently does not support 'relative' and 'force' flags,
so several 'ln -frsT' inline calls cannot be replaced.
2025-03-10 02:41:40 +09:00
Yu Watanabe 5c9feb2d6e tree-wide: drop unnecessary break in default branch 2025-03-06 11:42:20 +01:00
Daan De Meyer daa2547e31 Add a few more bypass environment variables
When we're building ParticleOS images, we don't want the package
manager (or mkosi) to run systemd-sysusers, systemd-tmpfiles or
systemctl preset so let's add a few more bypass environment
variables that we can set to have execution of these skipped like
we already have $SYSTEMD_HWDB_UPDATE_BYPASS and $KERNEL_INSTALL_BYPASS.
2025-03-01 16:22:53 +01:00
Vyacheslav Yurkov b1e5a7aa3f meson: add install tag for systemctl
Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>
2025-02-04 09:56:33 +01:00
Yu Watanabe 08570f2841 systemctl: fix memleak
Fixes a bug introduced by adb6cd9be2.

Fixes #36178.
2025-01-26 21:04:11 +00:00
Mike Yuan e3d37628aa shared/bus-util: move bus_message_hash_ops to bus-message-util 2025-01-13 16:24:44 +01:00
Yu Watanabe 66f379b63d systemctl: certainly ignore ENOENT in checking inhibitors
Fixes a bug caused by 804874d26a.

Follow-up for 084f361b50 and
a1417e5563.

Note, ERRNO_IS_NEG_DISCONNECT() includes ENONET rather than ENOENT...
So, ENOENT needs to be handled explicitly.

Fixes #35757 and #35806.
2025-01-02 14:15:09 +00:00
Yu Watanabe 084f361b50 systemctl: also ignore ENOENT in checking inhibitors
Fixes a bug caused by 804874d26a.
Follow-up for a1417e5563.
Fixes #35757.
2024-12-28 12:00:22 +00:00
Yu Watanabe b58b00e4c3 systemctl-edit: ignore ENOENT from unit_is_masked()
If a specified unit does not exist, then it is definitely not masked.

Fixes #35632.
2024-12-17 13:19:35 +09:00
Yu Watanabe c577fe65f3 systemctl: downgrade log level of ECONNREFUSED from system dbus.service
To suppress log message when 'systemctl poweroff' or friends invoked in
rescue shell, which does not have dbus.service.
2024-12-11 18:08:26 +09:00
Lennart Poettering 9cbd4f9b61 systemctl: use correct runtime scope 2024-12-09 14:16:37 +00:00
Yu Watanabe a1417e5563 systemctl: skip checking inhibitors when dbus.service is not running
Fixes a bug introduced by 804874d26a.

Fixes #35416.
2024-12-01 14:00:55 +09:00
Lennart Poettering 54646b1ca9 systemctl: grey out tasks limit the same way we grey out the fd store limit in the output
"systemctl status systemd-logind" otherwise looks a bit weird, since the
tasks and the fdstore lines are so close to each other but formatted
quite differently when it comes to coloring.
2024-11-19 10:11:49 +01:00
Mike Yuan 249bb7f894 systemctl: don't fall back to immediate shutdown silently if we cannot schedule one
The previous behavior of systemctl --when= seems absurd, i.e.
if we fail to schedule shutdown in the future it's performed
immediately. Let's instead hard fail, which also removes the need
of specializing on certain errnos (preparation for later commits).
2024-10-31 15:45:40 +01:00
Mike Yuan 5aa48b6de1 systemctl: use the retval of must_be_root() 2024-10-31 15:32:32 +01:00
Zbigniew Jędrzejewski-Szmek 99996d5f5e Merge pull request #34245 from bluca/logind_drop_weak_delay_inhibitor
logind: drop new delay-weak inhibitor
2024-10-29 17:13:11 +01:00
Daan De Meyer 61808636a7 Merge pull request #34679 from DaanDeMeyer/bus-log
Various logging improvements
2024-10-09 11:42:26 +02:00
Daan De Meyer d8a77d55e6 bus-util: Log more information when connecting to a bus socket fails
Let's log about which bus we're trying to connect to and what transport
we're using to do it.
2024-10-09 10:27:53 +02:00
Yu Watanabe 483ab07534 systemctl: separate memory usage with comma
Just for readability.

Before:
$ build/systemctl status -n 0 systemd-networkd.service | grep Memory:
     Memory: 4.7M (peak: 14.3M swap: 1M swap peak: 1.1M)

After:
$ build/systemctl status -n 0 systemd-networkd.service | grep Memory:
     Memory: 4.7M (peak: 14.3M, swap: 1M, swap peak: 1.1M)
2024-10-09 05:36:11 +09:00
Lennart Poettering ac42b151f8 Merge pull request #34556 from ryantimwilson/extra-fds
Add ExtraFileDescriptor property to StartTransientUnit dbus API
2024-10-08 13:26:59 +02:00
Ryan Wilson 3543456f84 Add ExtraFileDescriptor property to StartTransientUnit dbus API
This adds the ExtraFileDescriptor property to StartTransient dbus API
with format "a(hs)" - array of (file descriptor, name) pairs. The FD
will be passed to the unit via sd_notify like Socket and OpenFile.

systemctl show also shows ExtraFileDescriptorName for these transient
units. We only show the name passed to dbus as the FD numbers will
change once passed over the unix socket and are duplicated, so its
confusing to display the numbers.

We do not add this functionality for systemd-run or general systemd
service units as it is not useful for general systemd services.
Arguably, it could be useful for systemd-run in bash scripts but we
prefer to be cautious and not expose the API yet.

Fixes: #34396
2024-10-07 09:01:48 -07:00
Yu Watanabe f769518c9a tree-wide: drop doubled empty lines 2024-10-07 09:51:37 +02:00
Mike Yuan a48c1699eb Merge pull request #34564 from YHNdnzj/systemctl-status-job-id
systemctl: also show job id in status output
2024-09-30 17:39:19 +02:00
Zbigniew Jędrzejewski-Szmek 8dc40c25a4 shared: adjust whitespace and formatting 2024-09-27 20:19:58 +02:00
Zbigniew Jędrzejewski-Szmek 69c751c61c systemctl: fix printing of RootImageOptions
The type is a(ss), so a custom printer is required.

Fixes https://github.com/systemd/systemd/issues/33967.
2024-09-27 20:19:58 +02:00