Commit Graph

170 Commits

Author SHA1 Message Date
Yu Watanabe
3fc2a44043 include: move trivial kernel header wrappers to src/include/override/ 2025-07-11 13:05:46 +09: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
Lennart Poettering
51cc3825d1 tree-wide: use sd_bus_message_send() instead of sd_bus_send() wherever possible
Also, add a coccinelle script that patches this automatically.
2025-06-24 23:23:40 +09:00
Yu Watanabe
04fd0b9ff0 sysupdate: use path_is_safe()
path_is_safe(...) is an alias of path_is_valid_full(..., false).
2025-06-24 00:49:04 +09:00
Yu Watanabe
31a1e15ccb sd-bus: coding style cleanups
- replace `type *func()` -> `type* func()`,
- rename arguments for storing results,
- add several missing assertions.
2025-06-18 01:54:07 +09:00
Mike Yuan
718e7eb184 notify-recv: disable SO_PASSRIGHTS by default in notify_socket_prepare() 2025-06-17 13:16:43 +02: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
624d369868 discover-image: make image_discover() allocate hashmap when necessary 2025-06-11 22:45:08 +09:00
Luca Boccassi
5cfc9c34f4 sysupdate: change status once operation has completed
Otherwise after the service exits it will still show
"Installing 'foobar'" as the status, which is confusing
2025-05-29 15:44:31 +02:00
Daan De Meyer
5cf0b3b5bc sysupdate: Clean up includes
Split out of #37344.
2025-05-21 23:53:40 +09:00
Daan De Meyer
d86fead481 meson: Rework clang-tidy integration to be done via unit tests
Instead of using run-clang-tidy.py with its own scheduling, let's
just gather a list of source files ourselves and then use that to
add a unit test for each source file that runs clang-tidy on the
source file.

We also add a bit of logic to run clang-tidy on most header files
as well for extra coverage. This uncovered various header files that
were not standalone so this commit also includes fixes to make sure
the clang-tidy tests are all green.

We can also use this in a later commit to run clang-include-cleaner
on each source file in the same way.
2025-05-20 10:29:59 +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
Daan De Meyer
7305347221 discover-image: Move some logic to the implementation file
This will allow removing the string-util.h and path-util.h includes
as part of #37344.
2025-05-14 19:55:56 +02:00
Lennart Poettering
0da0b3f81d notify-recv: optionally return event source from notify_socket_prepare() 2025-05-13 14:42:33 +02:00
Daan De Meyer
5f142e01d0 strv: Move STRV_FOREACH() to strv-fundamental.h 2025-05-09 11:33:33 +02:00
Daan De Meyer
decad4826d static-destruct: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer
b78d73fa22 conf-parser: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer
e548ca38b9 device-util: 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
fda652117e fs-util: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer
e4a08721c3 string-util: Remove utf8.h and alloc-util.h includes 2025-05-06 13:27:54 +02:00
Yu Watanabe
8d7f05abc8 cleanup: bugprone argument issues (#37346)
Follow up from https://github.com/systemd/systemd/pull/37281
2025-05-06 18:56:07 +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
Jelle van der Waa
866a662abe treewide: correct argument comments for sd_notifyf 2025-05-05 19:35:39 +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
cf108818b3 sysupdate: Remove circular header includes 2025-04-23 10:33:37 +02:00
Daan De Meyer
8aa304d313 shared: Remove circular dependency between image-policy.h and dissect-image.h
ImagePolicy can just be a forward declaration in dissect-image.h.
2025-04-23 09:53:43 +02:00
Daan De Meyer
93a1f7921a basic: Stop including log.h in macro.h
Now that the necessary functions from log.h have been moved to macro.h,
we can stop including log.h in macro.h. This requires modifying source
files all over the tree to include log.h instead.
2025-04-18 14:19:15 +02:00
Daan De Meyer
03e17cbe6e basic: Move assertion specific functions to assert-util.h
Various functions in log.h are only used by asserts, and there's
enough assertion related stuff in macro.h to justify a separate header
which also makes it easier to avoid circular dependencies.

Let's introduce assert-util.h and an accompanying fundamental header
and move all the assertion related stuff over there. PROJECT_FILE is
moved over to macro.h.
2025-04-18 13:59:06 +02:00
Yu Watanabe
4c42fc6aa8 sysupdated: use notify_socket_prepare()
This also make it use autobind notify socket.
2025-04-01 03:58:38 +09:00
Yu Watanabe
0ffddd23f4 sysupdate-transfer: use notify_socket_prepare() 2025-04-01 03:58:38 +09:00
Yu Watanabe
66936ba5fa sysupdate-transfer: fix potential memleak 2025-04-01 03:58:38 +09: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
bc0763551f sysext,sysupdate: resolve incompatibilities (#36617)
Fixes #24562.
Fixes #34445.
Replaces #36311.
2025-03-06 14:05:35 +01:00
Yu Watanabe
5c9feb2d6e tree-wide: drop unnecessary break in default branch 2025-03-06 11:42:20 +01:00
Lennart Poettering
de4144cfc3 sysupdate: don't get confused by sysext on /usr/
Fixes: #24562
2025-03-06 10:27:55 +01:00
Thorsten Kukuk
54cd851bd9 sysupdate: fix features and vaccum if all features are disabled
If all transfer definitions are features and disabled, a wrong error
is reported that there are no transfer definitions.
This breaks the features and vaccum verb, as they work on disabled
features, too.
2025-03-06 00:53:27 +09:00
Mike Yuan
74cd56d31b notify-recv: several followups
Follow-up for 7f6af95dab

- Allocate internal buf on the stack, memdup() only at the end.
  This ensures we're able to handle OOM gracefully, i.e.
  return -EAGAIN on OOM while still emptying socket buffer.
- Do not treat empty notify message as error.
- Raise log level since all callers log loudly anyway.
2025-02-26 13:02:23 +01:00
Lennart Poettering
cc19df7c76 sysupdated: port to notify_recv() 2025-02-20 18:11:31 +01:00
Lennart Poettering
ee26ad44d7 sysupdate: port to notify_recv() 2025-02-20 18:11:31 +01:00
Nick Rosbrook
5dc89b327f tree-wide: remove some spurious newlines
Specifically, remove double newlines, and newlines before '}'.
2025-01-29 16:17:46 +00:00
Yu Watanabe
d7306348b2 tree-wide: insert a space at the end of comments 2025-01-25 05:24:23 +09:00
Lennart Poettering
1c0ade2e1f discover-image: introduce per-user image directories
We nowadays support unprivileged invocation of systemd-nspawn +
systemd-vmspawn, but there was no support for discovering suitable disk
images (i.e. no per-user counterpart of /var/lib/machines). Add this
now, and hook it up everywhere.

Instead of hardcoding machined's, importd's, portabled's, sysupdated's
image discovery to RUNTIME_SCOPE_SYSTEM I introduced a field that make
the scope variable, even if this field is always initialized to
RUNTIME_SCOPE_SYSTEM for now. I think these four services should
eventually be updated to support a per-user concept too, this is
preparation for that, even though it doesn't outright add support for
this.

This is for the largest part not user visible, except for in nspawn,
vmspawn and the dissect tool. For the latter I added a pair of
--user/--system switches to select the discovery scope.
2024-12-20 18:04:01 +01:00
Matthias Lisin
1462736c7e sysupdate: fix args order of formatted error 2024-12-19 12:39:31 +01:00
Abderrahim Kitouni
912ef24b66 sysupdate: fix typo in DBus config 2024-12-07 11:33:29 +00:00
Yu Watanabe
d9d784ebe0 sysupdate: add missing full stop to the polkit message
Follow-up for e55e7a5a61.
2024-11-28 18:13:51 +09:00
Abderrahim Kitouni
0ae6f4843e updatectl: fix DBus method signature for SetFeatureEnabled
The signature was changed to 'sit' in sysupdated during review, but updatectl
kept using 'sbt'
2024-11-26 22:03:41 +09:00
Adrian Vovk
a509603b2e sysupdated: Make sure targets we skip are skipped
We'd log that we're skipping the target, but it would never actually get
removed from the manager's list. Thus, we'd advertise targets that don't
actually exist to clients.

In the original version of the sysupdated PR, this was handled by
removing the target from the manager's list in target_free, and using a
_cleanup_ attribute to free the target when skipping. However, this
changed at some point during review. So, this commit takes the
alternative approach
2024-11-06 15:44:10 -05:00
Zbigniew Jędrzejewski-Szmek
243b63d8a6 meson: add separate option for sysupdated, disable in release builds
This commit introduces a build-time option to enable/disable sysupdated
separately from sysupdate. 'auto' translated to enabled by default in
developer builds.
2024-10-31 21:08:08 +00:00