From 90711654df84ccfb3b9dce5277d295b5d9f93335 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:59:25 +0200 Subject: [PATCH 01/15] user-record: Make sure UserStorage enum has the same name as its typedef --- src/shared/user-record.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/user-record.h b/src/shared/user-record.h index 32c8e38d04..fde03e5595 100644 --- a/src/shared/user-record.h +++ b/src/shared/user-record.h @@ -26,7 +26,7 @@ typedef enum UserDisposition { _USER_DISPOSITION_INVALID = -EINVAL, } UserDisposition; -typedef enum UserHomeStorage { +typedef enum UserStorage { USER_CLASSIC, USER_LUKS, USER_DIRECTORY, /* A directory, and a .identity file in it, which USER_CLASSIC lacks */ From 2a5559c2901ed595dc3193bdbabba27ff4561530 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:03:23 +0200 Subject: [PATCH 02/15] userdb: Clean up includes Split out of #37344. --- src/userdb/userdbctl.c | 9 ++++++--- src/userdb/userdbd-manager.c | 6 +++++- src/userdb/userdbd-manager.h | 11 +++-------- src/userdb/userdbd.c | 4 +++- src/userdb/userwork.c | 6 +++--- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c index db1743ee05..2d405197dc 100644 --- a/src/userdb/userdbctl.c +++ b/src/userdb/userdbctl.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include +#include +#include #include "alloc-util.h" #include "bitfield.h" @@ -9,22 +11,23 @@ #include "creds-util.h" #include "dirent-util.h" #include "errno-list.h" +#include "errno-util.h" #include "escape.h" #include "fd-util.h" #include "fileio.h" #include "format-table.h" #include "format-util.h" +#include "fs-util.h" #include "log.h" #include "main-func.h" -#include "mkdir-label.h" +#include "mkdir.h" #include "pager.h" #include "parse-argument.h" -#include "parse-util.h" #include "pretty-print.h" #include "recurse-dir.h" #include "socket-util.h" +#include "string-util.h" #include "strv.h" -#include "terminal-util.h" #include "uid-classification.h" #include "uid-range.h" #include "umask-util.h" diff --git a/src/userdb/userdbd-manager.c b/src/userdb/userdbd-manager.c index e30ec8ed75..48bd37ef50 100644 --- a/src/userdb/userdbd-manager.c +++ b/src/userdb/userdbd-manager.c @@ -1,14 +1,17 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include #include #include "sd-daemon.h" +#include "alloc-util.h" #include "build-path.h" #include "common-signal.h" #include "env-util.h" #include "event-util.h" #include "fd-util.h" +#include "format-util.h" #include "fs-util.h" #include "log.h" #include "mkdir.h" @@ -16,8 +19,9 @@ #include "set.h" #include "signal-util.h" #include "socket-util.h" -#include "stdio-util.h" +#include "string-util.h" #include "strv.h" +#include "time-util.h" #include "umask-util.h" #include "userdbd-manager.h" diff --git a/src/userdb/userdbd-manager.h b/src/userdb/userdbd-manager.h index c39f79d25c..40ff0ed121 100644 --- a/src/userdb/userdbd-manager.h +++ b/src/userdb/userdbd-manager.h @@ -1,18 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-bus.h" -#include "sd-event.h" - -typedef struct Manager Manager; - -#include "hashmap.h" +#include "forward.h" #include "ratelimit.h" #define USERDB_WORKERS_MIN 3 #define USERDB_WORKERS_MAX 4096 -struct Manager { +typedef struct Manager { sd_event *event; Set *workers_fixed; /* Workers 0…USERDB_WORKERS_MIN */ @@ -23,7 +18,7 @@ struct Manager { RateLimit worker_ratelimit; sd_event_source *deferred_start_worker_event_source; -}; +} Manager; int manager_new(Manager **ret); Manager* manager_free(Manager *m); diff --git a/src/userdb/userdbd.c b/src/userdb/userdbd.c index 64babef1c4..f3f4d516b6 100644 --- a/src/userdb/userdbd.c +++ b/src/userdb/userdbd.c @@ -1,7 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include #include -#include + +#include "sd-event.h" #include "daemon-util.h" #include "log.h" diff --git a/src/userdb/userwork.c b/src/userdb/userwork.c index 6ce5d57ef3..d1e296081c 100644 --- a/src/userdb/userwork.c +++ b/src/userdb/userwork.c @@ -6,6 +6,7 @@ #include "sd-daemon.h" #include "sd-varlink.h" +#include "alloc-util.h" #include "argv-util.h" #include "env-util.h" #include "errno-util.h" @@ -14,11 +15,10 @@ #include "io-util.h" #include "json-util.h" #include "main-func.h" -#include "process-util.h" -#include "strv.h" +#include "pidref.h" +#include "string-util.h" #include "time-util.h" #include "user-record.h" -#include "user-record-nss.h" #include "user-util.h" #include "userdb.h" #include "varlink-io.systemd.UserDatabase.h" From 6795ef350592343dee59271a7e294020d012e440 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:03:48 +0200 Subject: [PATCH 03/15] timedate: Clean up includes Split out of #37344. --- src/timedate/hwclock-util.c | 2 +- src/timedate/hwclock-util.h | 2 +- src/timedate/timedatectl.c | 5 ++++- src/timedate/timedated.c | 10 +++++----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/timedate/hwclock-util.c b/src/timedate/hwclock-util.c index 76a10f40b2..0a0045d2e0 100644 --- a/src/timedate/hwclock-util.c +++ b/src/timedate/hwclock-util.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include "errno-util.h" #include "fd-util.h" diff --git a/src/timedate/hwclock-util.h b/src/timedate/hwclock-util.h index 1503b5cf1f..ad24dad3a7 100644 --- a/src/timedate/hwclock-util.h +++ b/src/timedate/hwclock-util.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include "forward.h" int hwclock_get(struct tm *tm); int hwclock_set(const struct tm *tm); diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 02ee9c226e..78b4feaebe 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -3,10 +3,10 @@ #include #include #include -#include #include #include "sd-bus.h" +#include "sd-event.h" #include "alloc-util.h" #include "build.h" @@ -23,10 +23,13 @@ #include "parse-util.h" #include "polkit-agent.h" #include "pretty-print.h" +#include "runtime-scope.h" #include "sparse-endian.h" #include "string-table.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" +#include "time-util.h" #include "verbs.h" static PagerFlags arg_pager_flags = 0; diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 8d8495a6e2..40bba14a31 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -1,9 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include +#include #include #include -#include #include #include "sd-bus.h" @@ -25,25 +24,26 @@ #include "conf-files.h" #include "constants.h" #include "daemon-util.h" +#include "extract-word.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" #include "hashmap.h" #include "hwclock-util.h" +#include "label-util.h" #include "list.h" #include "log.h" #include "log-context.h" #include "main-func.h" #include "memory-util.h" #include "path-util.h" -#include "selinux-util.h" #include "service-util.h" -#include "signal-util.h" +#include "set.h" #include "string-util.h" #include "strv.h" +#include "time-util.h" #include "unit-def.h" #include "unit-name.h" -#include "user-util.h" #define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n" #define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n" From 546bba90978c6cc6316ca824ed32676fc1eec286 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:04:52 +0200 Subject: [PATCH 04/15] path: Clean up includes --- src/path/path.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/path/path.c b/src/path/path.c index 97685d2bd8..c725dd76fd 100644 --- a/src/path/path.c +++ b/src/path/path.c @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include -#include #include "sd-path.h" @@ -11,7 +9,6 @@ #include "build.h" #include "errno-util.h" #include "log.h" -#include "macro.h" #include "main-func.h" #include "pager.h" #include "pretty-print.h" From bfe1e8fc5e522a38a417be0e7d488a6695f1ff8b Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:11:19 +0200 Subject: [PATCH 05/15] busctl: Clean up includes Split out of #37344. --- src/busctl/busctl-introspect.c | 2 +- src/busctl/busctl-introspect.h | 3 +-- src/busctl/busctl.c | 9 ++++++--- src/busctl/test-busctl-introspect.c | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/busctl/busctl-introspect.c b/src/busctl/busctl-introspect.c index 92dca84b99..aa6f5cadf3 100644 --- a/src/busctl/busctl-introspect.c +++ b/src/busctl/busctl-introspect.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "sd-bus.h" +#include "sd-bus-vtable.h" #include "alloc-util.h" #include "busctl-introspect.h" diff --git a/src/busctl/busctl-introspect.h b/src/busctl/busctl-introspect.h index 720a0df79a..374ab53a19 100644 --- a/src/busctl/busctl-introspect.h +++ b/src/busctl/busctl-introspect.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include +#include "forward.h" typedef struct XMLIntrospectOps { int (*on_path)(const char *path, void *userdata); diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 8091a44705..8fe28ef015 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -1,29 +1,31 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include +#include #include "sd-bus.h" #include "sd-daemon.h" +#include "sd-event.h" #include "sd-json.h" #include "alloc-util.h" #include "bitfield.h" #include "build.h" #include "bus-dump.h" +#include "bus-error.h" #include "bus-internal.h" -#include "bus-message.h" #include "bus-signature.h" #include "bus-type.h" #include "bus-util.h" #include "busctl-introspect.h" #include "capsule-util.h" +#include "errno-util.h" #include "escape.h" #include "fd-util.h" #include "fdset.h" #include "fileio.h" #include "format-table.h" #include "glyph-util.h" -#include "json-util.h" #include "log.h" #include "logarithm.h" #include "main-func.h" @@ -36,9 +38,10 @@ #include "pretty-print.h" #include "runtime-scope.h" #include "set.h" -#include "sort-util.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" +#include "time-util.h" #include "user-util.h" #include "verbs.h" #include "version.h" diff --git a/src/busctl/test-busctl-introspect.c b/src/busctl/test-busctl-introspect.c index 859ca71435..9f68636033 100644 --- a/src/busctl/test-busctl-introspect.c +++ b/src/busctl/test-busctl-introspect.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "alloc-util.h" #include "busctl-introspect.h" #include "set.h" #include "strv.h" From 06b5f13db364c643b5762db1877e985b3172020c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:15:25 +0200 Subject: [PATCH 06/15] shutdown: Clean up includes Split out of #37344. --- src/shutdown/detach-dm.h | 2 +- src/shutdown/detach-loopback.h | 2 +- src/shutdown/detach-md.h | 2 +- src/shutdown/detach-swap.h | 3 +-- src/shutdown/shutdown.c | 6 ++++-- src/shutdown/test-umount.c | 2 -- src/shutdown/umount.c | 8 +++++--- src/shutdown/umount.h | 4 +--- 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/shutdown/detach-dm.h b/src/shutdown/detach-dm.h index b5f50a3bbf..0db81350e0 100644 --- a/src/shutdown/detach-dm.h +++ b/src/shutdown/detach-dm.h @@ -5,6 +5,6 @@ Copyright © 2010 ProFUSION embedded systems ***/ -#include +#include "forward.h" int dm_detach_all(bool *changed, bool last_try); diff --git a/src/shutdown/detach-loopback.h b/src/shutdown/detach-loopback.h index d6d73f31af..18cb2f6cfc 100644 --- a/src/shutdown/detach-loopback.h +++ b/src/shutdown/detach-loopback.h @@ -5,6 +5,6 @@ Copyright © 2010 ProFUSION embedded systems ***/ -#include +#include "forward.h" int loopback_detach_all(bool *changed, bool last_try); diff --git a/src/shutdown/detach-md.h b/src/shutdown/detach-md.h index 3784598208..8965a6ab65 100644 --- a/src/shutdown/detach-md.h +++ b/src/shutdown/detach-md.h @@ -5,6 +5,6 @@ Copyright © 2010 ProFUSION embedded systems ***/ -#include +#include "forward.h" int md_detach_all(bool *changed, bool last_try); diff --git a/src/shutdown/detach-swap.h b/src/shutdown/detach-swap.h index 1ebf5eb908..64e89076e7 100644 --- a/src/shutdown/detach-swap.h +++ b/src/shutdown/detach-swap.h @@ -5,8 +5,7 @@ Copyright © 2010 ProFUSION embedded systems ***/ -#include - +#include "forward.h" #include "list.h" int swapoff_all(bool *changed); diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c index 9c4eb4582d..7ab4deac5e 100644 --- a/src/shutdown/shutdown.c +++ b/src/shutdown/shutdown.c @@ -3,10 +3,8 @@ Copyright © 2010 ProFUSION embedded systems ***/ -#include #include #include -#include #include #include #include @@ -30,13 +28,16 @@ #include "detach-swap.h" #include "errno-util.h" #include "exec-util.h" +#include "extract-word.h" #include "fd-util.h" #include "fileio.h" +#include "format-util.h" #include "getopt-defs.h" #include "initrd-util.h" #include "killall.h" #include "log.h" #include "parse-util.h" +#include "pidref.h" #include "process-util.h" #include "reboot-util.h" #include "rlimit-util.h" @@ -46,6 +47,7 @@ #include "switch-root.h" #include "sysctl-util.h" #include "terminal-util.h" +#include "time-util.h" #include "umount.h" #include "virt.h" #include "watchdog.h" diff --git a/src/shutdown/test-umount.c b/src/shutdown/test-umount.c index 1de1fe8e11..c645b8e7b2 100644 --- a/src/shutdown/test-umount.c +++ b/src/shutdown/test-umount.c @@ -5,8 +5,6 @@ #include "errno-util.h" #include "fd-util.h" #include "log.h" -#include "path-util.h" -#include "string-util.h" #include "tests.h" #include "umount.h" diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c index 9b083d2492..2bb456e087 100644 --- a/src/shutdown/umount.c +++ b/src/shutdown/umount.c @@ -3,18 +3,18 @@ Copyright © 2010 ProFUSION embedded systems ***/ -#include #include #include #include -#include #include #include "alloc-util.h" #include "chase.h" #include "dirent-util.h" +#include "errno-util.h" #include "fd-util.h" #include "fileio.h" +#include "format-util.h" #include "fs-util.h" #include "fstab-util.h" #include "libmount-util.h" @@ -27,8 +27,10 @@ #include "process-util.h" #include "random-util.h" #include "signal-util.h" +#include "stat-util.h" +#include "string-util.h" +#include "time-util.h" #include "umount.h" -#include "user-util.h" #include "virt.h" static void mount_point_free(MountPoint **head, MountPoint *m) { diff --git a/src/shutdown/umount.h b/src/shutdown/umount.h index d18795c727..5fdaf76392 100644 --- a/src/shutdown/umount.h +++ b/src/shutdown/umount.h @@ -5,9 +5,7 @@ Copyright © 2010 ProFUSION embedded systems ***/ -#include -#include - +#include "forward.h" #include "list.h" int umount_all(bool *changed, bool last_try); From ca00c93962234735dab80d9953218ef0251c492c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:17:46 +0200 Subject: [PATCH 07/15] nss: Clean up includes Split out of #37344. --- src/nss-myhostname/nss-myhostname.c | 3 --- src/nss-mymachines/nss-mymachines.c | 7 +------ src/nss-resolve/nss-resolve.c | 5 +---- src/nss-systemd/nss-systemd.c | 4 ++-- src/nss-systemd/nss-systemd.h | 4 +--- src/nss-systemd/userdb-glue.c | 5 ++++- src/nss-systemd/userdb-glue.h | 2 +- 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c index a19a362896..b1a4cfebb8 100644 --- a/src/nss-myhostname/nss-myhostname.c +++ b/src/nss-myhostname/nss-myhostname.c @@ -1,17 +1,14 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include -#include #include "alloc-util.h" #include "errno-util.h" #include "hostname-setup.h" #include "hostname-util.h" #include "local-addresses.h" -#include "macro.h" #include "nss-util.h" #include "resolve-util.h" #include "signal-util.h" diff --git a/src/nss-mymachines/nss-mymachines.c b/src/nss-mymachines/nss-mymachines.c index c64e79bdff..2878ddc6b6 100644 --- a/src/nss-mymachines/nss-mymachines.c +++ b/src/nss-mymachines/nss-mymachines.c @@ -3,21 +3,16 @@ #include #include #include +#include #include "sd-bus.h" #include "sd-login.h" #include "alloc-util.h" -#include "bus-common-errors.h" #include "bus-locator.h" -#include "env-util.h" #include "errno-util.h" -#include "format-util.h" -#include "hostname-util.h" #include "in-addr-util.h" #include "log.h" -#include "macro.h" -#include "memory-util.h" #include "nss-util.h" #include "signal-util.h" #include "string-util.h" diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c index efcba2543d..3a660ca8b2 100644 --- a/src/nss-resolve/nss-resolve.c +++ b/src/nss-resolve/nss-resolve.c @@ -1,11 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include -#include -#include #include #include "sd-varlink.h" @@ -15,12 +12,12 @@ #include "glyph-util.h" #include "in-addr-util.h" #include "json-util.h" -#include "macro.h" #include "nss-util.h" #include "resolved-def.h" #include "signal-util.h" #include "string-util.h" #include "strv.h" +#include "time-util.h" static sd_json_dispatch_flags_t json_dispatch_flags = SD_JSON_ALLOW_EXTENSIONS; diff --git a/src/nss-systemd/nss-systemd.c b/src/nss-systemd/nss-systemd.c index 7b9908b89e..3c92cc2d00 100644 --- a/src/nss-systemd/nss-systemd.c +++ b/src/nss-systemd/nss-systemd.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include #include #include #include @@ -8,13 +9,12 @@ #include "alloc-util.h" #include "env-util.h" #include "errno-util.h" -#include "fd-util.h" #include "log.h" -#include "macro.h" #include "nss-systemd.h" #include "nss-util.h" #include "pthread-util.h" #include "signal-util.h" +#include "string-util.h" #include "strv.h" #include "user-record-nss.h" #include "user-util.h" diff --git a/src/nss-systemd/nss-systemd.h b/src/nss-systemd/nss-systemd.h index 2b46044e14..054bd40305 100644 --- a/src/nss-systemd/nss-systemd.h +++ b/src/nss-systemd/nss-systemd.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "assert-util.h" +#include "forward.h" int _nss_systemd_block(bool b); bool _nss_systemd_is_blocked(void); diff --git a/src/nss-systemd/userdb-glue.c b/src/nss-systemd/userdb-glue.c index c522c264bc..8e2d828be0 100644 --- a/src/nss-systemd/userdb-glue.c +++ b/src/nss-systemd/userdb-glue.c @@ -1,9 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include +#include + #include "env-util.h" -#include "fd-util.h" #include "nss-systemd.h" #include "strv.h" +#include "time-util.h" #include "user-record.h" #include "user-record-nss.h" #include "user-util.h" diff --git a/src/nss-systemd/userdb-glue.h b/src/nss-systemd/userdb-glue.h index ed4c5ec546..840329312d 100644 --- a/src/nss-systemd/userdb-glue.h +++ b/src/nss-systemd/userdb-glue.h @@ -4,8 +4,8 @@ #include #include #include -#include +#include "forward.h" #include "userdb.h" UserDBFlags nss_glue_userdb_flags(void); From e59fa61ba27ce1769eaee51e74547ed2c079a4dd Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:19:02 +0200 Subject: [PATCH 08/15] mountfsd: Clean up includes Split out of #37344. --- src/mountfsd/mountfsd-manager.c | 8 ++++++-- src/mountfsd/mountfsd-manager.h | 11 +++-------- src/mountfsd/mountfsd.c | 3 ++- src/mountfsd/mountwork.c | 15 +++++++++++++-- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/mountfsd/mountfsd-manager.c b/src/mountfsd/mountfsd-manager.c index 0d24e2d696..fdd98d7936 100644 --- a/src/mountfsd/mountfsd-manager.c +++ b/src/mountfsd/mountfsd-manager.c @@ -1,22 +1,26 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include #include #include "sd-daemon.h" +#include "alloc-util.h" #include "build-path.h" #include "common-signal.h" #include "env-util.h" #include "event-util.h" #include "fd-util.h" -#include "fs-util.h" +#include "format-util.h" #include "log.h" -#include "mkdir.h" #include "mountfsd-manager.h" #include "process-util.h" #include "set.h" #include "signal-util.h" #include "socket-util.h" #include "stdio-util.h" +#include "string-util.h" +#include "time-util.h" #include "umask-util.h" #define LISTEN_TIMEOUT_USEC (25 * USEC_PER_SEC) diff --git a/src/mountfsd/mountfsd-manager.h b/src/mountfsd/mountfsd-manager.h index 6bfbddcd17..06bd15f09a 100644 --- a/src/mountfsd/mountfsd-manager.h +++ b/src/mountfsd/mountfsd-manager.h @@ -1,18 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-bus.h" -#include "sd-event.h" - -typedef struct Manager Manager; - -#include "hashmap.h" +#include "forward.h" #include "ratelimit.h" #define MOUNTFS_WORKERS_MIN 3 #define MOUNTFS_WORKERS_MAX 4096 -struct Manager { +typedef struct Manager { sd_event *event; Set *workers_fixed; /* Workers 0…MOUNTFS_WORKERS_MIN */ @@ -21,7 +16,7 @@ struct Manager { int listen_fd; RateLimit worker_ratelimit; -}; +} Manager; int manager_new(Manager **ret); Manager* manager_free(Manager *m); diff --git a/src/mountfsd/mountfsd.c b/src/mountfsd/mountfsd.c index 87f4ab725a..6894c31b3f 100644 --- a/src/mountfsd/mountfsd.c +++ b/src/mountfsd/mountfsd.c @@ -1,7 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include + +#include "sd-event.h" #include "daemon-util.h" #include "log.h" diff --git a/src/mountfsd/mountwork.c b/src/mountfsd/mountwork.c index 8f24d2c3de..d932169e56 100644 --- a/src/mountfsd/mountwork.c +++ b/src/mountfsd/mountwork.c @@ -1,9 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include +#include +#include #include #include "sd-daemon.h" +#include "sd-event.h" #include "sd-varlink.h" #include "argv-util.h" @@ -14,20 +17,28 @@ #include "env-util.h" #include "errno-util.h" #include "fd-util.h" +#include "format-util.h" +#include "hashmap.h" +#include "image-policy.h" #include "io-util.h" #include "json-util.h" +#include "loop-util.h" #include "main-func.h" +#include "memory-util.h" #include "missing_syscall.h" #include "namespace-util.h" #include "nsresource.h" #include "nulstr-util.h" #include "os-util.h" -#include "process-util.h" +#include "path-util.h" +#include "pidref.h" #include "stat-util.h" #include "string-table.h" +#include "string-util.h" +#include "strv.h" +#include "time-util.h" #include "uid-classification.h" #include "uid-range.h" -#include "user-util.h" #include "varlink-io.systemd.MountFileSystem.h" #include "varlink-util.h" From 25fef10b339ac63c5fe2005a1c148f6e5529879c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:23:31 +0200 Subject: [PATCH 09/15] userns-restrict: Move HAVE_VMLINUX check into functions Let's do these checks like we try to do them elsewhere, in the function, not outside. This avoids having to declare the function arguments twice and keeps the logic for each function together instead of spread out across the file. --- src/nsresourced/userns-restrict.c | 46 ++++++++++++++----------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/nsresourced/userns-restrict.c b/src/nsresourced/userns-restrict.c index cb48ffbe79..e464731e70 100644 --- a/src/nsresourced/userns-restrict.c +++ b/src/nsresourced/userns-restrict.c @@ -1,10 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "log.h" -#include "userns-restrict.h" - -#if HAVE_VMLINUX_H - #include #include @@ -12,12 +7,14 @@ #include "bpf-link.h" #include "fd-util.h" #include "fs-util.h" +#include "log.h" #include "lsm-util.h" #include "mkdir.h" #include "mount-util.h" #include "mountpoint-util.h" #include "namespace-util.h" #include "path-util.h" +#include "userns-restrict.h" #define USERNS_MAX (16U*1024U) #define MOUNTS_MAX 4096U @@ -26,10 +23,14 @@ #define MAP_LINK_PREFIX "/sys/fs/bpf/systemd/userns-restrict/maps" struct userns_restrict_bpf *userns_restrict_bpf_free(struct userns_restrict_bpf *obj) { +#if HAVE_VMLINUX_H (void) userns_restrict_bpf__destroy(obj); /* this call is fine with NULL */ +#endif return NULL; + } +#if HAVE_VMLINUX_H static int make_inner_hash_map(void) { int fd; @@ -45,11 +46,13 @@ static int make_inner_hash_map(void) { return fd; } +#endif int userns_restrict_install( bool pin, struct userns_restrict_bpf **ret) { +#if HAVE_VMLINUX_H _cleanup_(userns_restrict_bpf_freep) struct userns_restrict_bpf *obj = NULL; _cleanup_close_ int dummy_mnt_id_hash_fd = -EBADF; int r; @@ -176,6 +179,9 @@ int userns_restrict_install( *ret = TAKE_PTR(obj); return 0; +#else + return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "User Namespace Restriction BPF support disabled."); +#endif } int userns_restrict_put_by_inode( @@ -185,6 +191,7 @@ int userns_restrict_put_by_inode( const int mount_fds[], size_t n_mount_fds) { +#if HAVE_VMLINUX_H _cleanup_close_ int inner_map_fd = -EBADF; _cleanup_free_ int *mnt_ids = NULL; uint64_t ino = userns_inode; @@ -268,6 +275,9 @@ int userns_restrict_put_by_inode( } return 0; +#else + return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "User Namespace Restriction BPF support disabled."); +#endif } int userns_restrict_put_by_fd( @@ -277,6 +287,7 @@ int userns_restrict_put_by_fd( const int mount_fds[], size_t n_mount_fds) { +#if HAVE_VMLINUX_H struct stat st; int r; @@ -299,12 +310,16 @@ int userns_restrict_put_by_fd( replace, mount_fds, n_mount_fds); +#else + return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "User Namespace Restriction BPF support disabled."); +#endif } int userns_restrict_reset_by_inode( struct userns_restrict_bpf *obj, uint64_t ino) { +#if HAVE_VMLINUX_H int r, outer_map_fd; unsigned u; @@ -325,26 +340,7 @@ int userns_restrict_reset_by_inode( return log_debug_errno(r, "Failed to remove entry for inode %" PRIu64 " from outer map: %m", ino); return 0; -} - #else -int userns_restrict_install(bool pin, struct userns_restrict_bpf **ret) { return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "User Namespace Restriction BPF support disabled."); -} - -struct userns_restrict_bpf *userns_restrict_bpf_free(struct userns_restrict_bpf *obj) { - return NULL; -} - -int userns_restrict_put_by_fd(struct userns_restrict_bpf *obj, int userns_fd, bool replace, const int mount_fds[], size_t n_mount_fds) { - return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "User Namespace Restriction BPF support disabled."); -} - -int userns_restrict_put_by_inode(struct userns_restrict_bpf *obj, uint64_t userns_inode, bool replace, const int mount_fds[], size_t n_mount_fds) { - return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "User Namespace Restriction BPF support disabled."); -} - -int userns_restrict_reset_by_inode(struct userns_restrict_bpf *obj, uint64_t userns_inode) { - return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "User Namespace Restriction BPF support disabled."); -} #endif +} From a1e519910ba3254ef085268b2d3f520def9029b6 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:26:24 +0200 Subject: [PATCH 10/15] nsresourced: Clean up includes Split out of #37344. --- src/nsresourced/nsresourced-manager.c | 5 ++++- src/nsresourced/nsresourced-manager.h | 11 +++-------- src/nsresourced/nsresourced.c | 4 +++- src/nsresourced/nsresourcework.c | 15 ++++++++++----- src/nsresourced/test-userns-restrict.c | 3 ++- src/nsresourced/userns-registry.c | 4 ++++ src/nsresourced/userns-registry.h | 2 +- src/nsresourced/userns-restrict.c | 3 ++- src/nsresourced/userns-restrict.h | 5 +---- 9 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/nsresourced/nsresourced-manager.c b/src/nsresourced/nsresourced-manager.c index ee52f09f84..ab3086ad76 100644 --- a/src/nsresourced/nsresourced-manager.c +++ b/src/nsresourced/nsresourced-manager.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include #include #include @@ -14,6 +15,7 @@ #include "env-util.h" #include "event-util.h" #include "fd-util.h" +#include "format-util.h" #include "fs-util.h" #include "log.h" #include "mkdir.h" @@ -24,9 +26,10 @@ #include "set.h" #include "signal-util.h" #include "socket-util.h" -#include "stat-util.h" #include "stdio-util.h" +#include "string-util.h" #include "strv.h" +#include "time-util.h" #include "umask-util.h" #include "unaligned.h" #include "user-util.h" diff --git a/src/nsresourced/nsresourced-manager.h b/src/nsresourced/nsresourced-manager.h index 5ecf378a60..ce8d8c690a 100644 --- a/src/nsresourced/nsresourced-manager.h +++ b/src/nsresourced/nsresourced-manager.h @@ -1,18 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-bus.h" -#include "sd-event.h" - -typedef struct Manager Manager; - -#include "hashmap.h" +#include "forward.h" #include "ratelimit.h" #define NSRESOURCE_WORKERS_MIN 5 #define NSRESOURCE_WORKERS_MAX 4096 -struct Manager { +typedef struct Manager { sd_event *event; Set *workers_fixed; /* Workers 0…NSRESOURCE_WORKERS_MIN */ @@ -31,7 +26,7 @@ struct Manager { #endif int registry_fd; -}; +} Manager; int manager_new(Manager **ret); Manager* manager_free(Manager *m); diff --git a/src/nsresourced/nsresourced.c b/src/nsresourced/nsresourced.c index ff84f766cd..455ee70705 100644 --- a/src/nsresourced/nsresourced.c +++ b/src/nsresourced/nsresourced.c @@ -1,7 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include #include -#include + +#include "sd-event.h" #include "daemon-util.h" #include "log.h" diff --git a/src/nsresourced/nsresourcework.c b/src/nsresourced/nsresourcework.c index b1c6dd86f9..e283593bf7 100644 --- a/src/nsresourced/nsresourcework.c +++ b/src/nsresourced/nsresourcework.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -12,36 +13,40 @@ #include #include "sd-daemon.h" +#include "sd-event.h" #include "sd-netlink.h" #include "sd-varlink.h" #include "argv-util.h" #include "bus-polkit.h" #include "env-util.h" +#include "errno-util.h" +#include "ether-addr-util.h" #include "fd-util.h" #include "fileio.h" -#include "fs-util.h" -#include "group-record.h" +#include "format-util.h" +#include "hashmap.h" #include "io-util.h" #include "json-util.h" -#include "lock-util.h" #include "main-func.h" #include "missing_magic.h" +#include "missing_sched.h" #include "missing_syscall.h" -#include "mount-util.h" #include "mountpoint-util.h" #include "namespace-util.h" #include "netlink-util.h" +#include "pidref.h" #include "process-util.h" #include "random-util.h" +#include "siphash24.h" #include "socket-util.h" #include "stat-util.h" +#include "string-util.h" #include "strv.h" #include "time-util.h" #include "uid-classification.h" #include "uid-range.h" #include "user-record.h" -#include "user-record-nss.h" #include "user-util.h" #include "userdb.h" #include "userns-registry.h" diff --git a/src/nsresourced/test-userns-restrict.c b/src/nsresourced/test-userns-restrict.c index 0aff1c87fb..61d4cd64bc 100644 --- a/src/nsresourced/test-userns-restrict.c +++ b/src/nsresourced/test-userns-restrict.c @@ -2,12 +2,13 @@ #include #include +#include #include "errno-util.h" #include "fd-util.h" #include "log.h" #include "main-func.h" -#include "missing_syscall.h" +#include "missing_sched.h" #include "namespace-util.h" #include "process-util.h" #include "rm-rf.h" diff --git a/src/nsresourced/userns-registry.c b/src/nsresourced/userns-registry.c index be314231ae..464bbee55a 100644 --- a/src/nsresourced/userns-registry.c +++ b/src/nsresourced/userns-registry.c @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #include "sd-json.h" #include "sd-netlink.h" @@ -15,6 +17,8 @@ #include "path-util.h" #include "recurse-dir.h" #include "rm-rf.h" +#include "stat-util.h" +#include "string-util.h" #include "strv.h" #include "user-util.h" #include "userns-registry.h" diff --git a/src/nsresourced/userns-registry.h b/src/nsresourced/userns-registry.h index e25b402e88..c1e7c9f1f5 100644 --- a/src/nsresourced/userns-registry.h +++ b/src/nsresourced/userns-registry.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "memory-util.h" +#include "forward.h" #define USER_NAMESPACE_CGROUPS_DELEGATE_MAX 16U #define USER_NAMESPACE_NETIFS_DELEGATE_MAX 16U diff --git a/src/nsresourced/userns-restrict.c b/src/nsresourced/userns-restrict.c index e464731e70..e082dce243 100644 --- a/src/nsresourced/userns-restrict.c +++ b/src/nsresourced/userns-restrict.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include #include #include @@ -10,10 +11,10 @@ #include "log.h" #include "lsm-util.h" #include "mkdir.h" -#include "mount-util.h" #include "mountpoint-util.h" #include "namespace-util.h" #include "path-util.h" +#include "string-util.h" #include "userns-restrict.h" #define USERNS_MAX (16U*1024U) diff --git a/src/nsresourced/userns-restrict.h b/src/nsresourced/userns-restrict.h index 92c8c9f211..d9c0f611ef 100644 --- a/src/nsresourced/userns-restrict.h +++ b/src/nsresourced/userns-restrict.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "macro.h" -#include "memory-util.h" +#include "forward.h" #if HAVE_VMLINUX_H #include "bpf/userns_restrict/userns-restrict-skel.h" From a7dad604d7377896d343f9e96e631ab52a5690ab Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:26:58 +0200 Subject: [PATCH 11/15] locale: Clean up includes Split out of #37344. --- src/locale/localectl.c | 8 +++----- src/locale/localed-util.c | 7 ++++--- src/locale/localed-util.h | 4 +--- src/locale/localed.c | 13 ++++--------- src/locale/test-localed-util.c | 2 ++ src/locale/xkbcommon-util.c | 2 -- src/locale/xkbcommon-util.h | 1 + 7 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 54e2ee597c..451bd19e08 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include #include "sd-bus.h" @@ -20,12 +19,11 @@ #include "pager.h" #include "polkit-agent.h" #include "pretty-print.h" -#include "proc-cmdline.h" -#include "set.h" +#include "runtime-scope.h" +#include "string-util.h" #include "strv.h" -#include "terminal-util.h" +#include "time-util.h" #include "verbs.h" -#include "virt.h" /* Enough time for locale-gen to finish server-side (in case it is in use) */ #define LOCALE_SLOW_BUS_CALL_TIMEOUT_USEC (2*USEC_PER_MINUTE) diff --git a/src/locale/localed-util.c b/src/locale/localed-util.c index 067d094020..9e990443e4 100644 --- a/src/locale/localed-util.c +++ b/src/locale/localed-util.c @@ -1,19 +1,20 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include #include +#include "sd-bus.h" + #include "alloc-util.h" #include "copy.h" #include "env-file.h" #include "env-file-label.h" -#include "env-util.h" #include "errno-util.h" #include "extract-word.h" #include "fd-util.h" #include "fileio.h" +#include "fs-util.h" +#include "hashmap.h" #include "kbd-util.h" #include "localed-util.h" #include "log.h" diff --git a/src/locale/localed-util.h b/src/locale/localed-util.h index a5bd78a4f7..888313b001 100644 --- a/src/locale/localed-util.h +++ b/src/locale/localed-util.h @@ -4,9 +4,7 @@ #include #include -#include "sd-bus.h" - -#include "hashmap.h" +#include "forward.h" #include "locale-setup.h" #include "vconsole-util.h" diff --git a/src/locale/localed.c b/src/locale/localed.c index 24ec6263e5..4a62e063b1 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -1,34 +1,29 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include #include #include "sd-bus.h" +#include "sd-event.h" #include "alloc-util.h" #include "bus-error.h" #include "bus-locator.h" #include "bus-log-control-api.h" -#include "bus-message.h" #include "bus-polkit.h" #include "bus-unit-util.h" #include "bus-util.h" #include "constants.h" #include "daemon-util.h" -#include "kbd-util.h" +#include "hashmap.h" +#include "label-util.h" #include "localed-util.h" #include "log.h" -#include "macro.h" #include "main-func.h" -#include "path-util.h" -#include "selinux-util.h" #include "service-util.h" -#include "signal-util.h" #include "string-util.h" #include "strv.h" -#include "user-util.h" +#include "time-util.h" static int vconsole_reload(sd_bus *bus) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; diff --git a/src/locale/test-localed-util.c b/src/locale/test-localed-util.c index d6221edbaf..92fe7b0421 100644 --- a/src/locale/test-localed-util.c +++ b/src/locale/test-localed-util.c @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #include "alloc-util.h" #include "localed-util.h" #include "log.h" diff --git a/src/locale/xkbcommon-util.c b/src/locale/xkbcommon-util.c index 8d0de9b431..edced7492d 100644 --- a/src/locale/xkbcommon-util.c +++ b/src/locale/xkbcommon-util.c @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "alloc-util.h" #include "dlfcn-util.h" #include "log.h" -#include "macro.h" #include "string-util.h" #include "xkbcommon-util.h" diff --git a/src/locale/xkbcommon-util.h b/src/locale/xkbcommon-util.h index 6149ce392d..7d4071fd79 100644 --- a/src/locale/xkbcommon-util.h +++ b/src/locale/xkbcommon-util.h @@ -2,6 +2,7 @@ #pragma once #include "dlfcn-util.h" +#include "forward.h" #if HAVE_XKBCOMMON #include From 2bb89066daf3590f2a5a1bc8eabcfd3e92dfffc0 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:28:54 +0200 Subject: [PATCH 12/15] integritysetup: Clean up includes Split out of #37344. --- src/integritysetup/integrity-util.c | 8 ++++++-- src/integritysetup/integrity-util.h | 5 +---- src/integritysetup/integritysetup-generator.c | 9 +-------- src/integritysetup/integritysetup.c | 7 +------ 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/integritysetup/integrity-util.c b/src/integritysetup/integrity-util.c index 754f3bf332..f421487805 100644 --- a/src/integritysetup/integrity-util.c +++ b/src/integritysetup/integrity-util.c @@ -1,10 +1,14 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "alloc-util.h" +#include "cryptsetup-util.h" #include "extract-word.h" -#include "fileio.h" #include "integrity-util.h" #include "log.h" -#include "path-util.h" #include "percent-util.h" +#include "string-util.h" +#include "strv.h" +#include "time-util.h" static int supported_integrity_algorithm(char *user_supplied) { if (!STR_IN_SET(user_supplied, "crc32", "crc32c", "xxhash64", "sha1", "sha256", "hmac-sha256")) diff --git a/src/integritysetup/integrity-util.h b/src/integritysetup/integrity-util.h index 359d2556a4..edc3ceac5f 100644 --- a/src/integritysetup/integrity-util.h +++ b/src/integritysetup/integrity-util.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "cryptsetup-util.h" -#include "time-util.h" +#include "forward.h" int parse_integrity_options( const char *options, diff --git a/src/integritysetup/integritysetup-generator.c b/src/integritysetup/integritysetup-generator.c index 7b0863d958..60f26b5ddc 100644 --- a/src/integritysetup/integritysetup-generator.c +++ b/src/integritysetup/integritysetup-generator.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include #include #include #include @@ -11,14 +9,9 @@ #include "fileio.h" #include "fstab-util.h" #include "generator.h" -#include "hexdecoct.h" -#include "id128-util.h" #include "integrity-util.h" -#include "main-func.h" -#include "mkdir.h" -#include "parse-util.h" +#include "log.h" #include "path-util.h" -#include "proc-cmdline.h" #include "specifier.h" #include "string-util.h" #include "unit-name.h" diff --git a/src/integritysetup/integritysetup.c b/src/integritysetup/integritysetup.c index ece8c3c1a8..b643a48e11 100644 --- a/src/integritysetup/integritysetup.c +++ b/src/integritysetup/integritysetup.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include @@ -8,17 +7,13 @@ #include "argv-util.h" #include "cryptsetup-util.h" #include "fileio.h" -#include "hexdecoct.h" #include "integrity-util.h" #include "log.h" #include "main-func.h" -#include "memory-util.h" -#include "parse-util.h" #include "path-util.h" #include "pretty-print.h" -#include "process-util.h" #include "string-util.h" -#include "terminal-util.h" +#include "time-util.h" #include "verbs.h" static uint32_t arg_activate_flags; From 8b4a4e996c62a2b74c41972d968707e1f44bb8b8 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:31:07 +0200 Subject: [PATCH 13/15] hibernate-resume: Clean up includes Split out of #37344. --- src/hibernate-resume/hibernate-resume-config.c | 1 + src/hibernate-resume/hibernate-resume-config.h | 5 +---- src/hibernate-resume/hibernate-resume-generator.c | 2 -- src/hibernate-resume/hibernate-resume.c | 2 -- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/hibernate-resume/hibernate-resume-config.c b/src/hibernate-resume/hibernate-resume-config.c index 3289fcd521..c30bfb73e1 100644 --- a/src/hibernate-resume/hibernate-resume-config.c +++ b/src/hibernate-resume/hibernate-resume-config.c @@ -7,6 +7,7 @@ #include "efivars.h" #include "fstab-util.h" #include "hibernate-resume-config.h" +#include "log.h" #include "os-util.h" #include "parse-util.h" #include "path-util.h" diff --git a/src/hibernate-resume/hibernate-resume-config.h b/src/hibernate-resume/hibernate-resume-config.h index 4bf4af6386..55f344a9e6 100644 --- a/src/hibernate-resume/hibernate-resume-config.h +++ b/src/hibernate-resume/hibernate-resume-config.h @@ -1,12 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - #include "sd-id128.h" -#include "macro.h" -#include "memory-util.h" +#include "forward.h" typedef struct KernelHibernateLocation KernelHibernateLocation; diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index 8d268a4805..07f6b89f6d 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -9,8 +9,6 @@ #include "hibernate-resume-config.h" #include "initrd-util.h" #include "log.h" -#include "main-func.h" -#include "parse-util.h" #include "proc-cmdline.h" #include "special.h" #include "static-destruct.h" diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c index 781b2faf77..e16bf825c9 100644 --- a/src/hibernate-resume/hibernate-resume.c +++ b/src/hibernate-resume/hibernate-resume.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include @@ -15,7 +14,6 @@ #include "parse-util.h" #include "pretty-print.h" #include "static-destruct.h" -#include "terminal-util.h" static HibernateInfo arg_info = {}; static bool arg_clear = false; From b06adfb06c947e2de110e9bc5516c230294c2355 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:32:00 +0200 Subject: [PATCH 14/15] coredump: Clean up includes Split out of #37344. --- src/coredump/coredump-vacuum.c | 2 -- src/coredump/coredump-vacuum.h | 3 +-- src/coredump/coredump.c | 9 ++++----- src/coredump/coredumpctl.c | 10 +++++++--- src/coredump/test-coredump-vacuum.c | 2 -- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/coredump/coredump-vacuum.c b/src/coredump/coredump-vacuum.c index e4c5e00ead..f3e2403822 100644 --- a/src/coredump/coredump-vacuum.c +++ b/src/coredump/coredump-vacuum.c @@ -2,7 +2,6 @@ #include #include -#include #include #include "alloc-util.h" @@ -12,7 +11,6 @@ #include "fs-util.h" #include "hashmap.h" #include "log.h" -#include "macro.h" #include "memory-util.h" #include "stat-util.h" #include "string-util.h" diff --git a/src/coredump/coredump-vacuum.h b/src/coredump/coredump-vacuum.h index 8ad5bafc15..1a2d648111 100644 --- a/src/coredump/coredump-vacuum.h +++ b/src/coredump/coredump-vacuum.h @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include +#include "forward.h" int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use); diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 2090dbc343..b8ba77e6ae 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include @@ -9,6 +8,7 @@ #include #include +#include "sd-bus.h" #include "sd-daemon.h" #include "sd-journal.h" #include "sd-json.h" @@ -27,24 +27,25 @@ #include "coredump-vacuum.h" #include "dirent-util.h" #include "elf-util.h" +#include "errno-util.h" #include "escape.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" +#include "io-util.h" #include "iovec-util.h" #include "journal-importer.h" #include "journal-send.h" #include "json-util.h" #include "log.h" -#include "macro.h" #include "main-func.h" #include "memory-util.h" #include "memstream-util.h" -#include "missing_syscall.h" #include "mkdir-label.h" #include "namespace-util.h" #include "parse-util.h" #include "path-util.h" +#include "pidref.h" #include "process-util.h" #include "signal-util.h" #include "socket-util.h" @@ -52,8 +53,6 @@ #include "stat-util.h" #include "string-table.h" #include "string-util.h" -#include "strv.h" -#include "sync-util.h" #include "tmpfile-util.h" #include "uid-classification.h" #include "user-util.h" diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index f44fc706b2..5dbd7cfa8d 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include "sd-bus.h" @@ -18,11 +20,13 @@ #include "bus-util.h" #include "chase.h" #include "compress.h" -#include "constants.h" #include "dissect-image.h" +#include "errno-util.h" #include "escape.h" +#include "extract-word.h" #include "fd-util.h" #include "format-table.h" +#include "format-util.h" #include "fs-util.h" #include "glob-util.h" #include "image-policy.h" @@ -31,7 +35,7 @@ #include "json-util.h" #include "log.h" #include "logs-show.h" -#include "macro.h" +#include "loop-util.h" #include "main-func.h" #include "mount-util.h" #include "pager.h" @@ -40,11 +44,11 @@ #include "path-util.h" #include "pretty-print.h" #include "process-util.h" -#include "rlimit-util.h" #include "signal-util.h" #include "string-util.h" #include "strv.h" #include "terminal-util.h" +#include "time-util.h" #include "tmpfile-util.h" #include "user-util.h" #include "verbs.h" diff --git a/src/coredump/test-coredump-vacuum.c b/src/coredump/test-coredump-vacuum.c index 27f8330950..454f044384 100644 --- a/src/coredump/test-coredump-vacuum.c +++ b/src/coredump/test-coredump-vacuum.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - #include "coredump-vacuum.h" #include "tests.h" From 3e0f1aff945b1456eb62207c32bcf3e99f840a0c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 23:35:14 +0200 Subject: [PATCH 15/15] portable: Clean up includes Split out of #37344. --- src/portable/portable.c | 11 ++++++----- src/portable/portable.h | 6 +----- src/portable/portablectl.c | 7 +------ src/portable/portabled-bus.c | 7 +++++-- src/portable/portabled-bus.h | 4 ++-- src/portable/portabled-forward.h | 8 ++++++++ src/portable/portabled-image-bus.c | 9 ++++++--- src/portable/portabled-image-bus.h | 6 ++---- src/portable/portabled-image.c | 5 ++++- src/portable/portabled-image.h | 7 +------ src/portable/portabled-operation.c | 5 +++++ src/portable/portabled-operation.h | 13 +++---------- src/portable/portabled.c | 8 ++++---- src/portable/portabled.h | 6 +----- 14 files changed, 49 insertions(+), 53 deletions(-) create mode 100644 src/portable/portabled-forward.h diff --git a/src/portable/portable.c b/src/portable/portable.c index 763f283bb4..75e32abcce 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -2,6 +2,7 @@ #include +#include "sd-bus.h" #include "sd-messages.h" #include "bus-common-errors.h" @@ -9,7 +10,6 @@ #include "bus-locator.h" #include "chase.h" #include "conf-files.h" -#include "constants.h" #include "copy.h" #include "data-fd-util.h" #include "dirent-util.h" @@ -17,19 +17,20 @@ #include "dissect-image.h" #include "env-file.h" #include "env-util.h" -#include "errno-list.h" +#include "errno-util.h" #include "escape.h" #include "extension-util.h" +#include "extract-word.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" +#include "glyph-util.h" #include "install.h" #include "iovec-util.h" -#include "locale-util.h" #include "log-context.h" +#include "log.h" #include "loop-util.h" #include "mkdir.h" -#include "nulstr-util.h" #include "os-util.h" #include "path-lookup.h" #include "portable.h" @@ -44,7 +45,7 @@ #include "string-table.h" #include "strv.h" #include "tmpfile-util.h" -#include "user-util.h" +#include "unit-name.h" #include "vpick.h" /* Markers used in the first line of our 20-portable.conf unit file drop-in to determine, that a) the unit file was diff --git a/src/portable/portable.h b/src/portable/portable.h index 03977159f0..c0ce30f72d 100644 --- a/src/portable/portable.h +++ b/src/portable/portable.h @@ -1,13 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-bus.h" - #include "dissect-image.h" -#include "hashmap.h" -#include "macro.h" +#include "forward.h" #include "runtime-scope.h" -#include "set.h" #include "string-util.h" typedef struct PortableMetadata { diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 6624f36299..ab49cf6edf 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include "sd-bus.h" @@ -12,18 +11,15 @@ #include "bus-unit-util.h" #include "bus-wait-for-jobs.h" #include "chase.h" -#include "constants.h" -#include "dirent-util.h" #include "env-file.h" #include "fd-util.h" #include "fileio.h" #include "format-table.h" #include "fs-util.h" -#include "locale-util.h" +#include "install.h" #include "main-func.h" #include "os-util.h" #include "pager.h" -#include "parse-argument.h" #include "parse-util.h" #include "path-util.h" #include "polkit-agent.h" @@ -31,7 +27,6 @@ #include "pretty-print.h" #include "string-util.h" #include "strv.h" -#include "terminal-util.h" #include "verbs.h" static PagerFlags arg_pager_flags = 0; diff --git a/src/portable/portabled-bus.c b/src/portable/portabled-bus.c index f313ce37ca..e347db5c0d 100644 --- a/src/portable/portabled-bus.c +++ b/src/portable/portabled-bus.c @@ -1,20 +1,23 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "sd-bus.h" + #include "alloc-util.h" #include "btrfs-util.h" -#include "bus-common-errors.h" +#include "bus-error.h" #include "bus-object.h" #include "bus-polkit.h" #include "discover-image.h" #include "fd-util.h" +#include "hashmap.h" #include "io-util.h" +#include "log.h" #include "portable.h" #include "portabled.h" #include "portabled-bus.h" #include "portabled-image.h" #include "portabled-image-bus.h" #include "strv.h" -#include "user-util.h" static int property_get_pool_path( sd_bus *bus, diff --git a/src/portable/portabled-bus.h b/src/portable/portabled-bus.h index c216c3aa75..b95ce5c647 100644 --- a/src/portable/portabled-bus.h +++ b/src/portable/portabled-bus.h @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-bus.h" +#include "sd-bus-vtable.h" -typedef struct PortableChange PortableChange; +#include "portabled-forward.h" extern const sd_bus_vtable manager_vtable[]; diff --git a/src/portable/portabled-forward.h b/src/portable/portabled-forward.h new file mode 100644 index 0000000000..c4529f07fa --- /dev/null +++ b/src/portable/portabled-forward.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include "forward.h" // IWYU pragma: export + +typedef struct Manager Manager; +typedef struct Operation Operation; +typedef struct PortableChange PortableChange; diff --git a/src/portable/portabled-image-bus.c b/src/portable/portabled-image-bus.c index 6a35262e6d..021035ab85 100644 --- a/src/portable/portabled-image-bus.c +++ b/src/portable/portabled-image-bus.c @@ -2,29 +2,32 @@ #include #include -#include #include +#include "sd-bus.h" + #include "alloc-util.h" #include "bus-common-errors.h" #include "bus-get-properties.h" -#include "bus-label.h" #include "bus-object.h" #include "bus-polkit.h" #include "bus-util.h" #include "discover-image.h" #include "fd-util.h" #include "fileio.h" +#include "hashmap.h" +#include "image-policy.h" #include "io-util.h" #include "os-util.h" +#include "path-util.h" #include "portable.h" #include "portabled.h" #include "portabled-bus.h" #include "portabled-image.h" #include "portabled-image-bus.h" +#include "portabled-operation.h" #include "process-util.h" #include "strv.h" -#include "user-util.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, image_type, ImageType); diff --git a/src/portable/portabled-image-bus.h b/src/portable/portabled-image-bus.h index d37c244315..5784d3ab15 100644 --- a/src/portable/portabled-image-bus.h +++ b/src/portable/portabled-image-bus.h @@ -1,12 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-bus.h" +#include "sd-bus-vtable.h" #include "bus-object.h" -#include "discover-image.h" - -typedef struct Manager Manager; +#include "portabled-forward.h" int bus_image_common_get_os_release(Manager *m, sd_bus_message *message, const char *name_or_path, Image *image, sd_bus_error *error); int bus_image_common_get_metadata(Manager *m, sd_bus_message *message, const char *name_or_path, Image *image, sd_bus_error *error); diff --git a/src/portable/portabled-image.c b/src/portable/portabled-image.c index f14d1a69ef..961ca4588a 100644 --- a/src/portable/portabled-image.c +++ b/src/portable/portabled-image.c @@ -1,6 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "portable.h" +#include "sd-event.h" + +#include "discover-image.h" +#include "hashmap.h" #include "portabled.h" #include "portabled-image.h" diff --git a/src/portable/portabled-image.h b/src/portable/portabled-image.h index 424694b3fd..ababa411a8 100644 --- a/src/portable/portabled-image.h +++ b/src/portable/portabled-image.h @@ -1,12 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-bus.h" - -#include "discover-image.h" -#include "hashmap.h" - -typedef struct Manager Manager; +#include "portabled-forward.h" Image *manager_image_cache_get(Manager *m, const char *name_or_path); diff --git a/src/portable/portabled-operation.c b/src/portable/portabled-operation.c index 0e4a6e4629..236904c728 100644 --- a/src/portable/portabled-operation.c +++ b/src/portable/portabled-operation.c @@ -1,9 +1,14 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include #include +#include "sd-bus.h" +#include "sd-event.h" + #include "alloc-util.h" #include "fd-util.h" +#include "format-util.h" #include "log.h" #include "portabled.h" #include "portabled-operation.h" diff --git a/src/portable/portabled-operation.h b/src/portable/portabled-operation.h index efbadc4620..7d3210a3f3 100644 --- a/src/portable/portabled-operation.h +++ b/src/portable/portabled-operation.h @@ -1,19 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "sd-bus.h" -#include "sd-event.h" - #include "list.h" - -typedef struct Manager Manager; -typedef struct Operation Operation; +#include "portabled-forward.h" #define OPERATIONS_MAX 64 -struct Operation { +typedef struct Operation { Manager *manager; pid_t pid; sd_bus_message *message; @@ -22,7 +15,7 @@ struct Operation { sd_event_source *event_source; int (*done)(Operation *o, int ret, sd_bus_error *error); LIST_FIELDS(Operation, operations); -}; +} Operation; int operation_new(Manager *manager, pid_t child, sd_bus_message *message, int errno_fd, Operation **ret); Operation *operation_free(Operation *o); diff --git a/src/portable/portabled.c b/src/portable/portabled.c index ddc9935a7d..b9c880992d 100644 --- a/src/portable/portabled.c +++ b/src/portable/portabled.c @@ -1,24 +1,24 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include #include "sd-bus.h" +#include "sd-event.h" #include "alloc-util.h" #include "bus-log-control-api.h" -#include "bus-polkit.h" #include "bus-util.h" #include "common-signal.h" #include "constants.h" #include "daemon-util.h" +#include "hashmap.h" +#include "log.h" #include "main-func.h" #include "portabled.h" -#include "portabled-bus.h" #include "portabled-image-bus.h" -#include "process-util.h" #include "service-util.h" #include "signal-util.h" +#include "time-util.h" static Manager* manager_unref(Manager *m); DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_unref); diff --git a/src/portable/portabled.h b/src/portable/portabled.h index 418c1040da..c7ce247955 100644 --- a/src/portable/portabled.h +++ b/src/portable/portabled.h @@ -1,13 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-bus.h" -#include "sd-event.h" - #include "bus-object.h" -#include "hashmap.h" #include "list.h" -#include "portabled-operation.h" +#include "portabled-forward.h" #include "runtime-scope.h" typedef struct Manager {