]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
login: Clean up includes
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 21 May 2025 12:17:11 +0000 (14:17 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 21 May 2025 16:09:28 +0000 (18:09 +0200)
Split out of #37344.

47 files changed:
src/login/inhibit.c
src/login/loginctl.c
src/login/logind-action.c
src/login/logind-action.h
src/login/logind-brightness.c
src/login/logind-brightness.h
src/login/logind-button.c
src/login/logind-button.h
src/login/logind-core.c
src/login/logind-dbus.c
src/login/logind-dbus.h
src/login/logind-device.c
src/login/logind-device.h
src/login/logind-forward.h [new file with mode: 0644]
src/login/logind-inhibit.c
src/login/logind-inhibit.h
src/login/logind-polkit.c
src/login/logind-polkit.h
src/login/logind-seat-dbus.c
src/login/logind-seat-dbus.h
src/login/logind-seat.c
src/login/logind-seat.h
src/login/logind-session-dbus.c
src/login/logind-session-dbus.h
src/login/logind-session-device.c
src/login/logind-session-device.h
src/login/logind-session.c
src/login/logind-session.h
src/login/logind-user-dbus.c
src/login/logind-user-dbus.h
src/login/logind-user.c
src/login/logind-user.h
src/login/logind-utmp.c
src/login/logind-utmp.h
src/login/logind-varlink.c
src/login/logind-varlink.h
src/login/logind-wall.c
src/login/logind.c
src/login/logind.h
src/login/pam_systemd.c
src/login/pam_systemd_loadkey.c
src/login/sysfs-show.c
src/login/sysfs-show.h
src/login/test-inhibit.c
src/login/test-login-shared.c
src/login/test-session-properties.c
src/login/user-runtime-dir.c

index df68eb7ef070fd0aa35a5affab345c7c771bca55..d97f206d2ab5115dc8ff7ff3efdb5454f9c59886 100644 (file)
@@ -3,7 +3,6 @@
 #include <fcntl.h>
 #include <getopt.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <unistd.h>
 
 #include "sd-bus.h"
 #include "bus-error.h"
 #include "bus-locator.h"
 #include "bus-util.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "format-table.h"
-#include "format-util.h"
 #include "log.h"
 #include "main-func.h"
 #include "pager.h"
 #include "polkit-agent.h"
 #include "pretty-print.h"
 #include "process-util.h"
+#include "runtime-scope.h"
 #include "signal-util.h"
+#include "string-util.h"
 #include "strv.h"
 #include "terminal-util.h"
 #include "user-util.h"
index bda69de076289cf3a14b7ea45ee77afa55bce7cb..1b82ce9238432654ab04083a434a0483bee733f6 100644 (file)
@@ -1,11 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <getopt.h>
 #include <locale.h>
 #include <unistd.h>
 
 #include "sd-bus.h"
+#include "sd-journal.h"
 
 #include "alloc-util.h"
 #include "build.h"
 #include "cgroup-show.h"
 #include "cgroup-util.h"
 #include "format-table.h"
+#include "format-util.h"
 #include "log.h"
 #include "logs-show.h"
-#include "macro.h"
 #include "main-func.h"
-#include "memory-util.h"
 #include "pager.h"
 #include "parse-argument.h"
 #include "parse-util.h"
 #include "polkit-agent.h"
 #include "pretty-print.h"
 #include "process-util.h"
-#include "rlimit-util.h"
-#include "signal-util.h"
+#include "runtime-scope.h"
 #include "string-table.h"
+#include "string-util.h"
 #include "strv.h"
 #include "sysfs-show.h"
 #include "terminal-util.h"
-#include "unit-name.h"
+#include "time-util.h"
 #include "user-util.h"
 #include "verbs.h"
 
index 9d1e392d7bcc07c42aabec5da9ea9358f837f90d..0ade0a77bbc88e2111d396721ad899ee8f6bfbe6 100644 (file)
@@ -2,15 +2,17 @@
 
 #include <unistd.h>
 
+#include "sd-bus.h"
 #include "sd-messages.h"
 
 #include "alloc-util.h"
 #include "bitfield.h"
 #include "bus-error.h"
 #include "bus-unit-util.h"
-#include "bus-util.h"
 #include "conf-parser.h"
+#include "extract-word.h"
 #include "format-util.h"
+#include "hashmap.h"
 #include "logind.h"
 #include "logind-action.h"
 #include "logind-dbus.h"
@@ -19,7 +21,6 @@
 #include "process-util.h"
 #include "special.h"
 #include "string-table.h"
-#include "terminal-util.h"
 #include "user-util.h"
 
 static const HandleActionData handle_action_data_table[_HANDLE_ACTION_MAX] = {
index e251701a8d2f85e0586b9f94088aff6fecdcec2c..9e2b562b5d336afed57b4f5e0806f23f4b37e84c 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "conf-parser.h"
+#include "logind-forward.h"
 #include "logind-inhibit.h"
 #include "sleep-config.h"
 
@@ -32,8 +32,6 @@ typedef enum HandleAction {
         _HANDLE_ACTION_INVALID = -EINVAL,
 } HandleAction;
 
-typedef struct HandleActionData HandleActionData;
-
 typedef enum HandleActionSleepMask {
         HANDLE_SLEEP_SUSPEND_MASK                = 1U << HANDLE_SUSPEND,
         HANDLE_SLEEP_HIBERNATE_MASK              = 1U << HANDLE_HIBERNATE,
@@ -55,7 +53,7 @@ static inline bool HANDLE_ACTION_IS_SLEEP(HandleAction a) {
         return a >= _HANDLE_ACTION_SLEEP_FIRST && a <= _HANDLE_ACTION_SLEEP_LAST;
 }
 
-struct HandleActionData {
+typedef struct HandleActionData {
         HandleAction handle;
         const char *target;
         InhibitWhat inhibit_what;
@@ -66,7 +64,7 @@ struct HandleActionData {
         const char* message_id;
         const char* message;
         const char* log_verb;
-};
+} HandleActionData;
 
 int handle_action_get_enabled_sleep_actions(HandleActionSleepMask mask, char ***ret);
 HandleAction handle_action_sleep_select(Manager *m);
index a51f2ab2496153338301eb87445f2bba78625d60..da6f424a1484b453dc37088f7aecdbd68f93ee82 100644 (file)
@@ -1,12 +1,18 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "sd-bus.h"
+#include "sd-device.h"
+#include "sd-event.h"
+
+#include "alloc-util.h"
 #include "bus-message-util.h"
-#include "bus-util.h"
 #include "device-util.h"
+#include "format-util.h"
 #include "hash-funcs.h"
 #include "logind.h"
 #include "logind-brightness.h"
 #include "process-util.h"
+#include "set.h"
 #include "stdio-util.h"
 
 /* Brightness and LED devices tend to be very slow to write to (often being I2C and such). Writes to the
index d0e8580032c9da8dfa4e3bdfcd41c57b3d6d80c0..02c991f273aa9c0eb905a27035a9bbe28960621c 100644 (file)
@@ -1,9 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-bus.h"
-#include "sd-device.h"
-
-typedef struct Manager Manager;
+#include "logind-forward.h"
 
 int manager_write_brightness(Manager *m, sd_device *device, uint32_t brightness, sd_bus_message *message);
index 29ee3e968ba93165ce0e8d995249d7b04c5dd0a4..285927a14d6256c1453378d77cff80acb2501be9 100644 (file)
@@ -1,16 +1,18 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
 #include <linux/input.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
 
+#include "sd-event.h"
 #include "sd-messages.h"
 
 #include "alloc-util.h"
 #include "async.h"
 #include "fd-util.h"
+#include "hashmap.h"
+#include "log.h"
 #include "logind.h"
 #include "logind-button.h"
 #include "logind-dbus.h"
index 4af54cb33d8ae3151a36f9fe283fc36d962fa0b3..aa48648752d67c86c56b045765497b417ca3de89 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-
-#include "sd-event.h"
-
-typedef struct Manager Manager;
+#include "logind-forward.h"
 
 typedef enum ButtonModifierMask {
         BUTTON_MODIFIER_NONE        = 0,
index 0208c74233998531308e261d9740e18d495d5fc0..6a1ddf9ddee8d3b44b465f10e9cb3a9a074bfb6f 100644 (file)
@@ -3,21 +3,21 @@
 #include <fcntl.h>
 #include <linux/vt.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 
+#include "sd-bus.h"
 #include "sd-device.h"
 
 #include "alloc-util.h"
 #include "battery-util.h"
 #include "bus-error.h"
 #include "bus-locator.h"
-#include "bus-util.h"
 #include "cgroup-util.h"
 #include "conf-parser.h"
 #include "device-util.h"
 #include "efi-loader.h"
 #include "errno-util.h"
 #include "fd-util.h"
+#include "hashmap.h"
 #include "limits-util.h"
 #include "logind.h"
 #include "logind-button.h"
@@ -25,9 +25,7 @@
 #include "logind-seat.h"
 #include "logind-session.h"
 #include "logind-user.h"
-#include "logind-utmp.h"
 #include "parse-util.h"
-#include "path-util.h"
 #include "process-util.h"
 #include "stdio-util.h"
 #include "strv.h"
index 19725aa21eb4170e3dbfe73d9f5b965d07eea579..ad7646ab4737b60d283dfee1140114ad9eb36fb0 100644 (file)
@@ -1,9 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
+#include <pwd.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include "sd-bus.h"
 #include "sd-device.h"
 #include "sd-messages.h"
 
@@ -15,6 +16,7 @@
 #include "bus-error.h"
 #include "bus-get-properties.h"
 #include "bus-locator.h"
+#include "bus-object.h"
 #include "bus-polkit.h"
 #include "bus-unit-util.h"
 #include "bus-util.h"
 #include "efivars.h"
 #include "env-file.h"
 #include "env-util.h"
+#include "errno-util.h"
 #include "escape.h"
 #include "event-util.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "format-util.h"
 #include "fs-util.h"
+#include "hashmap.h"
 #include "login-util.h"
+#include "logind-session.h"
 #include "logind.h"
 #include "logind-action.h"
 #include "logind-dbus.h"
 #include "logind-user-dbus.h"
 #include "logind-utmp.h"
 #include "mkdir-label.h"
+#include "os-util.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "process-util.h"
 #include "reboot-util.h"
-#include "selinux-util.h"
 #include "serialize.h"
 #include "signal-util.h"
 #include "sleep-config.h"
-#include "special.h"
 #include "stdio-util.h"
 #include "strv.h"
 #include "terminal-util.h"
 #include "tmpfile-util.h"
-#include "unit-name.h"
+#include "user-record.h"
 #include "user-util.h"
-#include "utmp-wtmp.h"
 #include "virt.h"
 #include "wall.h"
 
@@ -145,9 +148,9 @@ int manager_get_session_from_creds(
         assert(m);
         assert(ret);
 
-        if (SESSION_IS_SELF(name)) /* the caller's own session */
+        if (session_is_self(name)) /* the caller's own session */
                 return get_sender_session(m, message, false, error, ret);
-        if (SESSION_IS_AUTO(name)) /* The caller's own session if they have one, otherwise their user's display session */
+        if (session_is_auto(name)) /* The caller's own session if they have one, otherwise their user's display session */
                 return get_sender_session(m, message, true, error, ret);
 
         session = hashmap_get(m->sessions, name);
@@ -217,7 +220,7 @@ int manager_get_seat_from_creds(
         assert(m);
         assert(ret);
 
-        if (SEAT_IS_SELF(name) || SEAT_IS_AUTO(name)) {
+        if (seat_is_self(name) || seat_is_auto(name)) {
                 Session *session;
 
                 /* Use these special seat names as session names */
@@ -872,8 +875,8 @@ static int manager_choose_session_id(
                 } while (hashmap_contains(m->sessions, id));
 
         /* The generated names should not clash with 'auto' or 'self' */
-        assert(!SESSION_IS_SELF(id));
-        assert(!SESSION_IS_AUTO(id));
+        assert(!session_is_self(id));
+        assert(!session_is_auto(id));
 
         *ret_id = TAKE_PTR(id);
         return 0;
@@ -1792,7 +1795,7 @@ static int method_attach_device(sd_bus_message *message, void *userdata, sd_bus_
         if (!path_startswith(sysfs, "/sys"))
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path %s is not in /sys", sysfs);
 
-        if (SEAT_IS_SELF(seat) || SEAT_IS_AUTO(seat)) {
+        if (seat_is_self(seat) || seat_is_auto(seat)) {
                 Seat *found;
 
                 r = manager_get_seat_from_creds(m, message, seat, error, &found);
index 3b12ee860fb856198968b23d806984b9a7c47564..febc78aa4b52d99beea22eab51347abf7aab6721 100644 (file)
@@ -1,16 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-bus.h"
-
-#include "bus-object.h"
-#include "logind-session.h"
-#include "macro.h"
-
-typedef struct Manager Manager;
-typedef struct User User;
-typedef struct Seat Seat;
-typedef struct HandleActionData HandleActionData;
+#include "logind-forward.h"
 
 int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret);
 int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret);
index 4314790d97dd5e2c9dcf7e42faffef09e4d30333..5e7e8053d66db452a9dd2818826bd7cba43e23c7 100644 (file)
@@ -3,6 +3,7 @@
 #include <string.h>
 
 #include "alloc-util.h"
+#include "hashmap.h"
 #include "logind.h"
 #include "logind-device.h"
 #include "logind-seat.h"
index e6afe378a230e19dc62a0c3fda07f426815a9ca1..932bdeb3de79eaf452a15f728ef207838f505505 100644 (file)
@@ -2,14 +2,10 @@
 #pragma once
 
 #include "list.h"
+#include "logind-forward.h"
 #include "time-util.h"
 
-typedef struct Device Device;
-typedef struct Manager Manager;
-typedef struct Seat Seat;
-typedef struct SessionDevice SessionDevice;
-
-struct Device {
+typedef struct Device {
         Manager *manager;
 
         char *sysfs;
@@ -20,7 +16,7 @@ struct Device {
 
         LIST_FIELDS(Device, devices);
         LIST_HEAD(SessionDevice, session_devices);
-};
+} Device;
 
 Device* device_new(Manager *m, const char *sysfs, bool master);
 void device_free(Device *d);
diff --git a/src/login/logind-forward.h b/src/login/logind-forward.h
new file mode 100644 (file)
index 0000000..308749b
--- /dev/null
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "conf-parser-forward.h"    /* IWYU pragma: export */
+#include "forward.h"                /* IWYU pragma: export */
+
+typedef enum InhibitWhat InhibitWhat;
+typedef enum KillWhom KillWhom;
+typedef enum SessionType SessionType;
+typedef enum SessionClass SessionClass;
+
+typedef struct HandleActionData HandleActionData;
+typedef struct Device Device;
+typedef struct Manager Manager;
+typedef struct Seat Seat;
+typedef struct SessionDevice SessionDevice;
+typedef struct Session Session;
+typedef struct User User;
+typedef struct Inhibitor Inhibitor;
+typedef struct Button Button;
index e5070ff5738c1499919a89f87b321dc9cad4c122..7a79d81cad35562a0a172353c0d67ce65e492129 100644 (file)
@@ -1,27 +1,29 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <threads.h>
 #include <unistd.h>
 
+#include "sd-event.h"
+
 #include "alloc-util.h"
 #include "env-file.h"
-#include "errno-list.h"
 #include "errno-util.h"
 #include "escape.h"
+#include "extract-word.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "format-util.h"
 #include "fs-util.h"
+#include "hashmap.h"
 #include "io-util.h"
+#include "log.h"
+#include "logind-session.h"
 #include "logind.h"
 #include "logind-dbus.h"
 #include "logind-inhibit.h"
 #include "mkdir-label.h"
-#include "parse-util.h"
 #include "path-util.h"
 #include "string-table.h"
 #include "string-util.h"
index 1f115410f14afc3db3967a70c0ecff446dbab92b..f6d91364620d6975a5fea36bc2ec25c5ace9e085 100644 (file)
@@ -1,14 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-event.h"
-
+#include "logind-forward.h"
 #include "pidref.h"
 #include "time-util.h"
 
-typedef struct Inhibitor Inhibitor;
-typedef struct Manager Manager;
-
 typedef enum InhibitWhat {
         INHIBIT_SHUTDOWN             = 1 << 0,
         INHIBIT_SLEEP                = 1 << 1,
@@ -30,7 +26,7 @@ typedef enum InhibitMode {
         _INHIBIT_MODE_INVALID = -EINVAL,
 } InhibitMode;
 
-struct Inhibitor {
+typedef struct Inhibitor {
         Manager *manager;
 
         sd_event_source *event_source;
@@ -52,7 +48,7 @@ struct Inhibitor {
 
         char *fifo_path;
         int fifo_fd;
-};
+} Inhibitor;
 
 int inhibitor_new(Manager *m, const char* id, Inhibitor **ret);
 Inhibitor* inhibitor_free(Inhibitor *i);
index 1aa76e225d689f0c116229a2ee1f4abae97e0549..11dafa452d5bff4d98d5d18b58943c4d1facd1a9 100644 (file)
@@ -3,7 +3,6 @@
 #include "bus-polkit.h"
 #include "logind.h"
 #include "logind-polkit.h"
-#include "user-util.h"
 
 int check_polkit_chvt(sd_bus_message *message, Manager *manager, sd_bus_error *error) {
 #if ENABLE_POLKIT
index 7619ce2d90ffb162f3992142e70d2d6d8df4c30d..d0abab1605921856aa6bec1b566c10d5384351fd 100644 (file)
@@ -1,10 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-bus.h"
-
-#include "bus-object.h"
-
-typedef struct Manager Manager;
+#include "logind-forward.h"
 
 int check_polkit_chvt(sd_bus_message *message, Manager *manager, sd_bus_error *error);
index 4214d7cbde1dfd3531a20d2928ff58b50303aba3..e1f00e880c914a09006090235b930082fb6a461c 100644 (file)
@@ -1,13 +1,15 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
+#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 "hashmap.h"
+#include "logind-session.h"
 #include "logind.h"
 #include "logind-dbus.h"
 #include "logind-polkit.h"
@@ -15,6 +17,7 @@
 #include "logind-seat-dbus.h"
 #include "logind-session-dbus.h"
 #include "logind-user.h"
+#include "string-util.h"
 #include "strv.h"
 #include "user-util.h"
 
index 5b4e6846178285b51ac46e01d0b95cbf347edcc3..c6e17e338a8339db5ec1fa9c6ce3f99eb46de03a 100644 (file)
@@ -1,12 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-bus.h"
-
-#include "bus-object.h"
-#include "macro.h"
-
-typedef struct Seat Seat;
+#include "logind-forward.h"
 
 extern const BusObjectImplementation seat_object;
 
index fb52c5475e687c70559c6dcf8126784fd11c8641..e386e0756a85f64ad54527683820101d6e1cea51 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -14,7 +13,9 @@
 #include "fileio.h"
 #include "format-util.h"
 #include "fs-util.h"
+#include "hashmap.h"
 #include "id128-util.h"
+#include "log.h"
 #include "logind.h"
 #include "logind-device.h"
 #include "logind-seat.h"
 #include "logind-session-device.h"
 #include "logind-user.h"
 #include "mkdir-label.h"
-#include "parse-util.h"
 #include "path-util.h"
+#include "set.h"
 #include "stdio-util.h"
 #include "string-util.h"
 #include "terminal-util.h"
 #include "tmpfile-util.h"
+#include "user-record.h"
 
 int seat_new(Manager *m, const char *id, Seat **ret) {
         _cleanup_(seat_freep) Seat *s = NULL;
@@ -768,3 +770,11 @@ bool seat_name_is_valid(const char *name) {
 
         return true;
 }
+
+bool seat_is_self(const char *name) {
+        return isempty(name) || streq(name, "self");
+}
+
+bool seat_is_auto(const char *name) {
+        return streq_ptr(name, "auto");
+}
index c39136330325b7c24235c2760268bef1ea3a2eb7..323cbe546e23280285e3e0dc0a012ea950082334 100644 (file)
@@ -1,20 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-device.h"
-
 #include "list.h"
-#include "memory-util.h"
-#include "set.h"
-#include "string-util.h"
-#include "time-util.h"
-
-typedef struct Device Device;
-typedef struct Manager Manager;
-typedef struct Seat Seat;
-typedef struct Session Session;
+#include "logind-forward.h"
 
-struct Seat {
+typedef struct Seat {
         Manager *manager;
         char *id;
 
@@ -34,7 +24,7 @@ struct Seat {
         bool started:1;
 
         LIST_FIELDS(Seat, gc_queue);
-};
+} Seat;
 
 int seat_new(Manager *m, const char *id, Seat **ret);
 Seat* seat_free(Seat *s);
@@ -75,11 +65,5 @@ bool seat_may_gc(Seat *s, bool drop_not_started);
 void seat_add_to_gc_queue(Seat *s);
 
 bool seat_name_is_valid(const char *name);
-
-static inline bool SEAT_IS_SELF(const char *name) {
-        return isempty(name) || streq(name, "self");
-}
-
-static inline bool SEAT_IS_AUTO(const char *name) {
-        return streq_ptr(name, "auto");
-}
+bool seat_is_self(const char *name);
+bool seat_is_auto(const char *name);
index 50a965c5ff5ce782919f2466dfb0ca15c5e863be..0277f26fe58e3209fc3ec70ceb3412fab8eb010c 100644 (file)
@@ -1,18 +1,23 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <sys/eventfd.h>
 
+#include "sd-bus.h"
+#include "sd-device.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 "device-util.h"
 #include "devnum-util.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "format-util.h"
+#include "hashmap.h"
+#include "log.h"
 #include "logind.h"
 #include "logind-brightness.h"
 #include "logind-dbus.h"
 #include "logind-user-dbus.h"
 #include "path-util.h"
 #include "signal-util.h"
+#include "string-util.h"
 #include "strv.h"
 #include "terminal-util.h"
+#include "user-record.h"
 #include "user-util.h"
 
 static int property_get_user(
index 4ff45cb54f76042736570bf2cb73bea031a754a1..5b185ca6bdc270edbfa8564b8d851ac10aa50886 100644 (file)
@@ -1,13 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-bus.h"
-
-#include "bus-object.h"
-#include "macro.h"
-
-typedef struct Manager Manager;
-typedef struct Session Session;
+#include "logind-forward.h"
 
 extern const BusObjectImplementation session_object;
 
index 9e592740e8a7a1c313933d5c73d5a8e0171f4762..44efb56d22e365f58707dac09cf6b4f37e930a79 100644 (file)
@@ -5,16 +5,17 @@
 #include <linux/input.h>
 #include <string.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
+#include <sys/sysmacros.h>
 
-#include "sd-daemon.h"
+#include "sd-bus.h"
 #include "sd-device.h"
 
 #include "alloc-util.h"
-#include "bus-util.h"
 #include "daemon-util.h"
 #include "device-util.h"
+#include "errno-util.h"
 #include "fd-util.h"
+#include "hashmap.h"
 #include "logind.h"
 #include "logind-device.h"
 #include "logind-seat.h"
@@ -22,7 +23,7 @@
 #include "logind-session-dbus.h"
 #include "logind-session-device.h"
 #include "missing_drm.h"
-#include "parse-util.h"
+#include "string-util.h"
 
 enum SessionDeviceNotifications {
         SESSION_DEVICE_RESUME,
index 52cea0f74c9634b6899c6293bb5b5b852882aa59..0823bbaafb6d9cfd6deeb64f737d99069e2f49a8 100644 (file)
@@ -2,11 +2,7 @@
 #pragma once
 
 #include "list.h"
-#include "memory-util.h"
-
-typedef struct Device Device;
-typedef struct Session Session;
-typedef struct SessionDevice SessionDevice;
+#include "logind-forward.h"
 
 typedef enum DeviceType {
         DEVICE_TYPE_UNKNOWN,
@@ -15,7 +11,7 @@ typedef enum DeviceType {
         DEVICE_TYPE_HIDRAW,
 } DeviceType;
 
-struct SessionDevice {
+typedef struct SessionDevice {
         Session *session;
         Device *device;
 
@@ -27,7 +23,7 @@ struct SessionDevice {
         bool pushed_fd:1;
 
         LIST_FIELDS(struct SessionDevice, sd_by_device);
-};
+} SessionDevice;
 
 int session_device_new(Session *s, dev_t dev, bool open_device, SessionDevice **ret);
 SessionDevice *session_device_free(SessionDevice *sd);
index a540774ccaf0caf583ab1d7c6d6850ecf5f09c4d..72b61eaa669b931eb55108b6a665708b47acf2ad 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
 #include <linux/kd.h>
 #include <linux/vt.h>
@@ -9,7 +8,10 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include "sd-bus.h"
+#include "sd-event.h"
 #include "sd-messages.h"
+#include "sd-varlink.h"
 
 #include "alloc-util.h"
 #include "audit-util.h"
 #include "daemon-util.h"
 #include "devnum-util.h"
 #include "env-file.h"
+#include "errno-util.h"
 #include "escape.h"
+#include "extract-word.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "format-util.h"
 #include "fs-util.h"
-#include "io-util.h"
+#include "hashmap.h"
 #include "login-util.h"
 #include "logind.h"
 #include "logind-dbus.h"
 #include "process-util.h"
 #include "serialize.h"
 #include "string-table.h"
-#include "strv.h"
 #include "terminal-util.h"
 #include "tmpfile-util.h"
-#include "uid-classification.h"
+#include "user-record.h"
 #include "user-util.h"
 
 #define RELEASE_USEC (20*USEC_PER_SEC)
@@ -1613,6 +1616,14 @@ int session_send_create_reply(Session *s, const sd_bus_error *error) {
         return r;
 }
 
+bool session_is_self(const char *name) {
+        return isempty(name) || streq(name, "self");
+}
+
+bool session_is_auto(const char *name) {
+        return streq_ptr(name, "auto");
+}
+
 static const char* const session_state_table[_SESSION_STATE_MAX] = {
         [SESSION_OPENING] = "opening",
         [SESSION_ONLINE]  = "online",
index 923723479ccb3035cfe58ae97ea697dab49b4193..7dfbabf4813a2a6540d631a2587565d45a511c9b 100644 (file)
@@ -1,21 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-bus.h"
-#include "sd-event.h"
-#include "sd-varlink.h"
-
-#include "hashmap.h"
 #include "list.h"
+#include "logind-forward.h"
 #include "pidref.h"
-#include "string-util.h"
 #include "time-util.h"
 
-typedef struct Manager Manager;
-typedef struct Seat Seat;
-typedef struct Session Session;
-typedef struct User User;
-
 typedef enum SessionState {
         SESSION_OPENING,  /* Session scope is being created */
         SESSION_ONLINE,   /* Logged in */
@@ -106,7 +96,7 @@ typedef enum TTYValidity {
         _TTY_VALIDITY_INVALID = -EINVAL,
 } TTYValidity;
 
-struct Session {
+typedef struct Session {
         Manager *manager;
 
         char *id;
@@ -175,7 +165,7 @@ struct Session {
         LIST_FIELDS(Session, sessions_by_seat);
 
         LIST_FIELDS(Session, gc_queue);
-};
+} Session;
 
 int session_new(Manager *m, const char *id, Session **ret);
 Session* session_free(Session *s);
@@ -231,10 +221,5 @@ bool session_job_pending(Session *s);
 
 int session_send_create_reply(Session *s, const sd_bus_error *error);
 
-static inline bool SESSION_IS_SELF(const char *name) {
-        return isempty(name) || streq(name, "self");
-}
-
-static inline bool SESSION_IS_AUTO(const char *name) {
-        return streq_ptr(name, "auto");
-}
+bool session_is_self(const char *name);
+bool session_is_auto(const char *name);
index 34904d9b74a5471d5c8db69aea5af3ad08889ee7..600890230bbb49d345bfb2c469f4965a1833cf9a 100644 (file)
@@ -1,19 +1,23 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
+#include "sd-bus.h"
 
 #include "alloc-util.h"
 #include "bus-get-properties.h"
+#include "bus-object.h"
 #include "bus-polkit.h"
-#include "bus-util.h"
 #include "format-util.h"
+#include "hashmap.h"
 #include "logind.h"
 #include "logind-dbus.h"
+#include "logind-session.h"
 #include "logind-session-dbus.h"
 #include "logind-user.h"
 #include "logind-user-dbus.h"
 #include "signal-util.h"
+#include "string-util.h"
 #include "strv.h"
+#include "user-record.h"
 #include "user-util.h"
 
 static int property_get_uid(
index 867abc1799e630f58658fbb77e531f0270af4623..6e8482f9256dabad4e139df22f1a105b8acb3618 100644 (file)
@@ -1,12 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-bus.h"
-
-#include "bus-object.h"
-#include "macro.h"
-
-typedef struct User User;
+#include "logind-forward.h"
 
 extern const BusObjectImplementation user_object;
 
index d5795e2a7fce231db3e8a0fb29309682fe4cc361..876e2c438c8c8fd819dc8453bdeda5eb18279ec2 100644 (file)
@@ -1,24 +1,25 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <unistd.h>
+#include "sd-bus.h"
+#include "sd-event.h"
 
 #include "alloc-util.h"
 #include "bus-common-errors.h"
 #include "bus-error.h"
 #include "bus-locator.h"
 #include "bus-util.h"
-#include "cgroup-util.h"
 #include "clean-ipc.h"
 #include "env-file.h"
+#include "errno-util.h"
 #include "escape.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "format-util.h"
 #include "fs-util.h"
 #include "hashmap.h"
-#include "label-util.h"
 #include "limits-util.h"
+#include "logind-session.h"
 #include "logind.h"
 #include "logind-dbus.h"
 #include "logind-seat.h"
 #include "logind-user-dbus.h"
 #include "mkdir-label.h"
 #include "parse-util.h"
-#include "path-util.h"
 #include "percent-util.h"
-#include "rm-rf.h"
 #include "serialize.h"
 #include "special.h"
 #include "stdio-util.h"
 #include "string-table.h"
+#include "string-util.h"
 #include "strv.h"
 #include "tmpfile-util.h"
 #include "uid-classification.h"
 #include "unit-name.h"
+#include "user-record.h"
 #include "user-util.h"
 
 int user_new(Manager *m, UserRecord *ur, User **ret) {
index 88b5d06bdfa44b8cfc66394f4b36e2550cb777cc..f41b8888ea3edaea27eb6b350c2edd6771f42a2b 100644 (file)
@@ -1,15 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-event.h"
-
-#include "conf-parser.h"
+#include "forward.h"
 #include "list.h"
-#include "user-record.h"
-
-typedef struct Manager Manager;
-typedef struct Session Session;
-typedef struct User User;
+#include "logind-forward.h"
+#include "time-util.h"
 
 typedef enum UserState {
         USER_OFFLINE,    /* Not logged in at all */
@@ -29,7 +24,7 @@ typedef enum UserGCMode {
         _USER_GC_MODE_INVALID = -EINVAL,
 } UserGCMode;
 
-struct User {
+typedef struct User {
         Manager *manager;
 
         UserRecord *user_record;
@@ -66,7 +61,7 @@ struct User {
 
         LIST_HEAD(Session, sessions);
         LIST_FIELDS(User, gc_queue);
-};
+} User;
 
 int user_new(Manager *m, UserRecord *ur, User **ret);
 User *user_free(User *u);
index 228bcf97d11d1c2163a28e3991fc66f9b83eef53..8305ae743fa83f0ab578c1a02e55ce887d6b91cc 100644 (file)
@@ -1,5 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <sys/inotify.h>
+
+#include "sd-event.h"
+
 #include "log.h"
 #include "logind.h"
 #include "logind-session.h"
index 5309132c7780282d233f3ae380933c0dd5b092fb..955451b760439f85a1b3cb5a205b2d72bbee8fef 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct Manager Manager;
+#include "logind-forward.h"
 
 int manager_read_utmp(Manager *m);
 void manager_connect_utmp(Manager *m);
index 69a453483f4a995ddda01a2695c0901e4e1a01a4..79b53092a3fd96186e0574d9c4037293fd38058f 100644 (file)
@@ -1,17 +1,20 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "sd-bus.h"
+#include "sd-event.h"
 #include "alloc-util.h"
 #include "cgroup-util.h"
-#include "fd-util.h"
 #include "format-util.h"
+#include "hashmap.h"
 #include "json-util.h"
+#include "logind-session.h"
 #include "logind.h"
 #include "logind-dbus.h"
 #include "logind-seat.h"
-#include "logind-session-dbus.h"
 #include "logind-user.h"
 #include "logind-varlink.h"
 #include "terminal-util.h"
+#include "user-record.h"
 #include "user-util.h"
 #include "varlink-io.systemd.Login.h"
 #include "varlink-io.systemd.service.h"
@@ -78,9 +81,9 @@ static int manager_varlink_get_session_by_name(
 
         /* Resolves a session name to a session object. Supports resolving the special names "self" and "auto". */
 
-        if (SESSION_IS_SELF(name))
+        if (session_is_self(name))
                 return manager_varlink_get_session_by_peer(m, link, /* consult_display= */ false, ret);
-        if (SESSION_IS_AUTO(name))
+        if (session_is_auto(name))
                 return manager_varlink_get_session_by_peer(m, link, /* consult_display= */ true, ret);
 
         Session *session = hashmap_get(m->sessions, name);
index 3a8e43d9d9cb99e098358826fb5a49c7300f14e0..d99513d2103945fd6cddce377ca708bd883385d6 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "sd-bus.h"
-
-typedef struct Manager Manager;
-typedef struct Session Session;
+#include "logind-forward.h"
 
 int manager_varlink_init(Manager *m);
 void manager_varlink_done(Manager *m);
index 85d5d7c4a22ebf0518c320e8a1c3ee58ce5cdaa4..ac5e593d3f580e00d5a05be62f54aa105f7f6cf6 100644 (file)
@@ -1,22 +1,15 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <unistd.h>
+#include <stdio.h>
 
 #include "sd-messages.h"
 
 #include "alloc-util.h"
-#include "audit-util.h"
-#include "bus-common-errors.h"
-#include "bus-error.h"
-#include "bus-util.h"
 #include "event-util.h"
-#include "format-util.h"
+#include "log.h"
 #include "logind.h"
 #include "path-util.h"
-#include "special.h"
-#include "strv.h"
-#include "unit-name.h"
+#include "string-util.h"
 #include "user-util.h"
 #include "wall.h"
 
index 73f1e628daf7ded6d6134c539676884216969e85..65c8d9913d18adad3fe396c4181a5c800a8208c2 100644 (file)
@@ -1,46 +1,43 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
-#include <sys/types.h>
 #include <unistd.h>
 
+#include "sd-bus.h"
 #include "sd-daemon.h"
 #include "sd-device.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-polkit.h"
-#include "cgroup-util.h"
+#include "bus-object.h"
 #include "common-signal.h"
-#include "constants.h"
 #include "daemon-util.h"
 #include "device-util.h"
 #include "devnum-util.h"
 #include "dirent-util.h"
+#include "errno-util.h"
 #include "escape.h"
 #include "fd-util.h"
 #include "format-util.h"
 #include "fs-util.h"
+#include "hashmap.h"
+#include "label-util.h"
+#include "logind-session.h"
 #include "logind.h"
 #include "logind-button.h"
 #include "logind-dbus.h"
 #include "logind-device.h"
 #include "logind-seat.h"
-#include "logind-seat-dbus.h"
-#include "logind-session-dbus.h"
 #include "logind-session-device.h"
 #include "logind-user.h"
-#include "logind-user-dbus.h"
 #include "logind-utmp.h"
 #include "logind-varlink.h"
 #include "main-func.h"
 #include "mkdir-label.h"
 #include "parse-util.h"
 #include "process-util.h"
-#include "selinux-util.h"
 #include "service-util.h"
 #include "signal-util.h"
 #include "strv.h"
index 7ae30c5b63b1d5442e78b91ef58caadb91f99c39..c3119166476d45b416dfc6c992d790e7b2b565af 100644 (file)
@@ -1,28 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
 #include <sys/stat.h>
 
-#include "sd-bus.h"
-#include "sd-device.h"
-#include "sd-event.h"
-#include "sd-varlink.h"
-
 #include "calendarspec.h"
-#include "conf-parser.h"
-#include "hashmap.h"
 #include "list.h"
 #include "logind-action.h"
-#include "set.h"
-#include "time-util.h"
-#include "user-record.h"
-
-typedef struct Button Button;
-typedef struct Device Device;
-typedef struct Seat Seat;
-typedef struct Session Session;
-typedef struct User User;
+#include "logind-forward.h"
 
 typedef struct Manager {
         sd_event *event;
index d0533fc0e25ea51b0b20848fee48324e5497a7ac..eb8aaff251c200a057f42c1f784c6bfcbe907ae8 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <endian.h>
-#include <errno.h>
 #include <fcntl.h>
 #include <pwd.h>
 #include <security/_pam_macros.h>
 #include <security/pam_modules.h>
 #include <security/pam_modutil.h>
 #include <sys/file.h>
-#if HAVE_PIDFD_OPEN
-#include <sys/pidfd.h>
-#endif
+#include "time-util.h"
 #include <sys/stat.h>
 #include <sys/sysmacros.h>
-#include <sys/types.h>
 #include <unistd.h>
 
 #include "sd-bus.h"
 #include "sd-varlink.h"
 
 #include "alloc-util.h"
-#include "audit-util.h"
 #include "bus-common-errors.h"
 #include "bus-error.h"
 #include "bus-internal.h"
@@ -36,7 +31,6 @@
 #include "errno-util.h"
 #include "extract-word.h"
 #include "fd-util.h"
-#include "fileio.h"
 #include "format-util.h"
 #include "fs-util.h"
 #include "hostname-util.h"
 #include "json-util.h"
 #include "locale-util.h"
 #include "login-util.h"
-#include "macro.h"
-#include "missing_syscall.h"
 #include "osc-context.h"
 #include "pam-util.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "percent-util.h"
+#include "pidfd-util.h"
+#include "pidref.h"
 #include "process-util.h"
 #include "rlimit-util.h"
 #include "socket-util.h"
 #include "stdio-util.h"
+#include "string-util.h"
 #include "strv.h"
 #include "terminal-util.h"
 #include "tmpfile-util.h"
index cc20820851d72c135b5456cbaf77fb35f10c0c2c..b1a9aed234538707a3884511cc21b5be358f3dc1 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <security/_pam_macros.h>
 #include <security/pam_ext.h>
 #include <security/pam_misc.h>
@@ -8,8 +7,6 @@
 #include <security/pam_modutil.h>
 
 #include "keyring-util.h"
-#include "log.h"
-#include "macro.h"
 #include "missing_syscall.h"
 #include "nulstr-util.h"
 #include "pam-util.h"
index d1f105b1e37922eeab16e7f831d825fb3a74a89b..202041832c46dee1e8fdced82be25b139a58ed74 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-
 #include "sd-device.h"
 
 #include "alloc-util.h"
index 32ccbf3de4b3ff5168f0bea278c0a97b38c3d7cd..0864419877ecead636172348c24a2a2a46177504 100644 (file)
@@ -1,8 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <sys/types.h>
-
+#include "forward.h"
 #include "output-mode.h"
 
 int show_sysfs(const char *seat, const char *prefix, unsigned columns, OutputFlags flags);
index 9334ea532c576d56de382c26887eb447ea5e5d39..e6c0a03ffd54721d31fe6ee429ad54ceb84e977d 100644 (file)
@@ -6,9 +6,7 @@
 #include "sd-bus.h"
 
 #include "bus-locator.h"
-#include "bus-util.h"
 #include "fd-util.h"
-#include "macro.h"
 #include "tests.h"
 
 static int inhibit(sd_bus *bus, const char *what) {
index 17cd479dc914a7d6ef0811617532d34fa11c4624..45dc98d906ccd7b4d41e242a2bc795ccfbaa46c9 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "login-util.h"
-#include "macro.h"
 #include "tests.h"
 
 TEST(session_id_valid) {
index 00a0caaf5bbb7dd30040dd66f1c71524b56f047b..acb2d8022958ec8a02025eb92930ba9fa93d9611 100644 (file)
@@ -7,16 +7,15 @@
  */
 
 #include <fcntl.h>
-#include <sys/stat.h>
-#include <unistd.h>
+
+#include "sd-bus.h"
 
 #include "alloc-util.h"
+#include "argv-util.h"
 #include "bus-common-errors.h"
 #include "bus-locator.h"
-#include "path-util.h"
-#include "string-util.h"
-#include "terminal-util.h"
 #include "tests.h"
+#include "time-util.h"
 
 static const char *arg_tty = NULL;
 
index 63a0a166c0ac2707435f996489305a7e7f8cc435..77498081ea2db779c19dd9180a89dc71be7e6136 100644 (file)
@@ -1,14 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <stdint.h>
 #include <sys/mount.h>
 
 #include "sd-bus.h"
 
 #include "bus-error.h"
 #include "bus-locator.h"
-#include "dev-setup.h"
 #include "devnum-util.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "format-util.h"
 #include "fs-util.h"
@@ -24,7 +23,7 @@
 #include "path-util.h"
 #include "quota-util.h"
 #include "rm-rf.h"
-#include "selinux-util.h"
+#include "set.h"
 #include "smack-util.h"
 #include "stat-util.h"
 #include "stdio-util.h"