Commit Graph
1660 Commits
Author SHA1 Message Date
Antonio Alvarez Feijoo 600bbac35f systemctl: remove unnecessary assignment 2025-07-16 21:03:10 +09:00
Luca Boccassi 7ebbe57ece Kill several SysV compat functionalities (v258) (#38178) 2025-07-15 01:21:13 +01:00
DaanDeMeyer e4691ebb49 fork-journal: Generalize to fork-notify
Most of the logic isn't journalctl specific, let's generalize a bit
so we can reuse this for other commands as well.
2025-07-14 15:07:48 +02:00
Yu Watanabe 8ba48d4bf8 core,initctl,systemctl: kill /dev/initctl support
This also kills support for controlling system state through
/sbin/init, initctl, and telinit.
2025-07-13 05:38:14 +09:00
Yu Watanabe af925f7eb3 systemctl: kill SysV compat 'runlevel' command 2025-07-13 05:38:13 +09:00
Yu Watanabe 5572fb18c0 systemctl/halt: drop support for calling in SysV init script
Traditionally, halt is called at the end of the init script on
reboot/shutdown. To support such usecase, previously we read the current
runlevel from utmp and set force flag on reboot/shutdown.

This drops the support for such the usecase.
Note, neither supported nor tested, but hopefully still the command can
be used in the end of the sysv init script by specifying -ff.
2025-07-13 05:38:13 +09:00
Yu Watanabe c17516a84a systemctl: move functions in systemctl-sysv-compat.[ch]
- parse_shutdown_time_spec() is used only by systemctl-compat-shutdown.c,
- talk_initctl() and action_to_runlevel() are used only by systemctl-compat-telinit.c,
- the exit code enum is widely used in systemctl, hence moved to systemctl-util.h.

No functional change, preparation for later changes.
2025-07-13 05:38:13 +09:00
Yu Watanabe 0939d5c360 reboot-util: merge with raw-reboot.h
The header raw-reboot.h is only used with reboot-util. Let's merge them.
2025-07-11 13:05:46 +09:00
Lennart Poettering 03b4a607f6 core: followups for the recent subgroup killing commits
This is a follow-up for 0f23564ad4 and
6b02854f50, as suggested here:

https://github.com/systemd/systemd/pull/37855#pullrequestreview-2997596953
2025-07-10 13:32:51 +09:00
Zbigniew Jędrzejewski-Szmek c179466616 Merge shared/exec-directory-util.? into basic/unit-def.?
Suggested in
https://github.com/systemd/systemd/pull/35892#discussion_r2180322856.

This is a tiny amount of code and does not warrant having a separate file
and spawning a separate instance of the compiler during the build.

Note: it took me a while to confirm that the contents of that table and
function don't end up in libsystemd.so. The issue is that they _are_ present in
it, unless LTO is used. We actually use link_whole[libbasic_static] for
libsystemd, so we end up with all that code there. LTO is needed to clean
that up.
2025-07-08 12:57:33 +02:00
Lennart Poettering 6b02854f50 systemctl: add --kill-subgroup= switch for killing subcgroup 2025-07-08 03:14:53 +02:00
Andres Beltran e8e274c8da Add quota support for systemctl 2025-07-07 17:31:05 +00:00
Lennart Poettering d03714e4e4 tree-wide: "human readable" → "human-readable"
Apparently, the spelling with a hyphen is better style in the English
language.

Suggested by: #36165
2025-07-07 11:21:25 +02:00
Yu Watanabe 4f18ff2e29 tree-wide: include unistd.h where necessary
We use symbols provided by unistd.h without including it. E.g.
open(), close(), read(), write(), access(), symlink(), unlink(), rmdir(),
fsync(), syncfs(), lseek(), ftruncate(), fchown(), dup2(), pipe2(),
getuid(), getgid(), gettid(), getppid(), pipe2(), execv(), _exit(),
environ, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO, F_OK, and their
friends and variants, so on.

Currently, unistd.h is indirectly included mainly in the following two paths:
- through missing_syscall.h, which is planned to covert to .c file.
- through signal.h -> bits/sigstksz.h, which is new since glibc-2.34.
  Note, signal.h is included by sd-eevent.h. So, many source files
  indirectly include unistd.h if newer glibc is used.

Currently, our baseline on glibc is 2.31. We need to support glibc older
than 2.34, but unfortunately, we do not have any CI environments with
such old glibc. CIFuzz uses glibc-2.31, but it builds only fuzzers, and
many files are even not compiled.
2025-06-30 09:19:15 +02:00
Yu Watanabe 296fe3d511 cpu-set-util: rename cpu_set_reset() -> cpu_set_done()
This also introduces cpu_set_done_and_replace().

No functional change, just refactoring.
2025-06-24 00:20:20 +09:00
Mike Yuan a59cc3860b tree-wide: check --machine= specification
Addresses https://github.com/systemd/systemd/pull/37741#discussion_r2128482378
2025-06-17 02:10:37 +02:00
Yu Watanabe 44875628ff systemctl: replace basename() with path_extract_filename() 2025-06-06 19:06:48 +09:00
A. Wilcox 6b783209a8 tree-wide: basename -> path_extract_filename 2025-06-06 19:06:48 +09:00
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