login: Remove circular header dependencies

This commit is contained in:
Daan De Meyer
2025-04-23 10:33:37 +02:00
parent d88dc9a5dd
commit 214c93c84c
35 changed files with 127 additions and 50 deletions
+1
View File
@@ -11,6 +11,7 @@
#include "bus-util.h"
#include "conf-parser.h"
#include "format-util.h"
#include "logind.h"
#include "logind-action.h"
#include "logind-dbus.h"
#include "logind-seat-dbus.h"
+2 -4
View File
@@ -2,6 +2,8 @@
#pragma once
#include "conf-parser.h"
#include "logind-inhibit.h"
#include "sleep-config.h"
typedef enum HandleAction {
HANDLE_IGNORE,
@@ -41,10 +43,6 @@ typedef enum HandleActionSleepMask {
#define HANDLE_ACTION_SLEEP_MASK_DEFAULT (HANDLE_SLEEP_SUSPEND_THEN_HIBERNATE_MASK|HANDLE_SLEEP_SUSPEND_MASK|HANDLE_SLEEP_HIBERNATE_MASK)
#include "logind-inhibit.h"
#include "logind.h"
#include "sleep-config.h"
static inline bool handle_action_valid(HandleAction a) {
return a >= 0 && a < _HANDLE_ACTION_MAX;
}
+1 -1
View File
@@ -4,6 +4,6 @@
#include "sd-bus.h"
#include "sd-device.h"
#include "logind.h"
typedef struct Manager Manager;
int manager_write_brightness(Manager *m, sd_device *device, uint32_t brightness, sd_bus_message *message);
+1
View File
@@ -11,6 +11,7 @@
#include "alloc-util.h"
#include "async.h"
#include "fd-util.h"
#include "logind.h"
#include "logind-button.h"
#include "logind-dbus.h"
#include "string-util.h"
+6 -4
View File
@@ -1,9 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct Button Button;
#include <stdbool.h>
#include "logind.h"
#include "sd-event.h"
typedef struct Manager Manager;
typedef enum ButtonModifierMask {
BUTTON_MODIFIER_NONE = 0,
@@ -19,7 +21,7 @@ typedef enum ButtonModifierMask {
#define BUTTON_MODIFIER_HAS_CTRL(modifier) (((modifier) & (BUTTON_MODIFIER_LEFT_CTRL|BUTTON_MODIFIER_RIGHT_CTRL)) != 0)
#define BUTTON_MODIFIER_HAS_ALT(modifier) (((modifier) & (BUTTON_MODIFIER_LEFT_ALT|BUTTON_MODIFIER_RIGHT_ALT)) != 0)
struct Button {
typedef struct Button {
Manager *manager;
sd_event_source *io_event_source;
@@ -33,7 +35,7 @@ struct Button {
bool lid_closed;
bool docked;
};
} Button;
Button* button_new(Manager *m, const char *name);
Button *button_free(Button *b);
+5
View File
@@ -20,6 +20,11 @@
#include "fd-util.h"
#include "limits-util.h"
#include "logind.h"
#include "logind-button.h"
#include "logind-device.h"
#include "logind-seat.h"
#include "logind-session.h"
#include "logind-user.h"
#include "logind-utmp.h"
#include "parse-util.h"
#include "path-util.h"
+3
View File
@@ -32,12 +32,15 @@
#include "fileio.h"
#include "format-util.h"
#include "fs-util.h"
#include "login-util.h"
#include "logind.h"
#include "logind-action.h"
#include "logind-dbus.h"
#include "logind-polkit.h"
#include "logind-seat.h"
#include "logind-seat-dbus.h"
#include "logind-session-dbus.h"
#include "logind-user.h"
#include "logind-user-dbus.h"
#include "logind-utmp.h"
#include "mkdir-label.h"
+6 -3
View File
@@ -4,10 +4,13 @@
#include "sd-bus.h"
#include "bus-object.h"
#include "logind-action.h"
#include "logind-session.h"
#include "logind-user.h"
#include "logind.h"
#include "macro.h"
typedef struct Manager Manager;
typedef struct User User;
typedef struct Seat Seat;
typedef struct HandleActionData HandleActionData;
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);
+3
View File
@@ -3,8 +3,11 @@
#include <string.h>
#include "alloc-util.h"
#include "logind.h"
#include "logind-device.h"
#include "logind-seat.h"
#include "logind-seat-dbus.h"
#include "logind-session-device.h"
Device* device_new(Manager *m, const char *sysfs, bool master) {
Device *d;
+6 -4
View File
@@ -1,11 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct Device Device;
#include "list.h"
#include "logind-seat.h"
#include "logind-session-device.h"
#include "time-util.h"
typedef struct Device Device;
typedef struct Manager Manager;
typedef struct Seat Seat;
typedef struct SessionDevice SessionDevice;
struct Device {
Manager *manager;
+1
View File
@@ -7,6 +7,7 @@ _Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
#include <stddef.h>
#include "conf-parser.h"
#include "logind.h"
#include "logind-user.h"
%}
struct ConfigPerfItem;
%null_strings
+1
View File
@@ -17,6 +17,7 @@
#include "format-util.h"
#include "fs-util.h"
#include "io-util.h"
#include "logind.h"
#include "logind-dbus.h"
#include "logind-inhibit.h"
#include "mkdir-label.h"
+4 -2
View File
@@ -1,9 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-event.h"
#include "pidref.h"
#include "time-util.h"
typedef struct Inhibitor Inhibitor;
typedef struct Manager Manager;
typedef enum InhibitWhat {
INHIBIT_SHUTDOWN = 1 << 0,
@@ -26,8 +30,6 @@ typedef enum InhibitMode {
_INHIBIT_MODE_INVALID = -EINVAL,
} InhibitMode;
#include "logind.h"
struct Inhibitor {
Manager *manager;
+1
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "bus-polkit.h"
#include "logind.h"
#include "logind-polkit.h"
#include "user-util.h"
+2 -1
View File
@@ -4,6 +4,7 @@
#include "sd-bus.h"
#include "bus-object.h"
#include "logind.h"
typedef struct Manager Manager;
int check_polkit_chvt(sd_bus_message *message, Manager *manager, sd_bus_error *error);
+1
View File
@@ -13,6 +13,7 @@
#include "logind-seat-dbus.h"
#include "logind-seat.h"
#include "logind-session-dbus.h"
#include "logind-user.h"
#include "logind.h"
#include "strv.h"
#include "user-util.h"
+3 -1
View File
@@ -4,7 +4,9 @@
#include "sd-bus.h"
#include "bus-object.h"
#include "logind-seat.h"
#include "macro.h"
typedef struct Seat Seat;
extern const BusObjectImplementation seat_object;
+5
View File
@@ -14,9 +14,14 @@
#include "fileio.h"
#include "format-util.h"
#include "fs-util.h"
#include "logind.h"
#include "logind-device.h"
#include "logind-seat-dbus.h"
#include "logind-seat.h"
#include "logind-session.h"
#include "logind-session-dbus.h"
#include "logind-session-device.h"
#include "logind-user.h"
#include "mkdir-label.h"
#include "parse-util.h"
#include "path-util.h"
+8 -3
View File
@@ -1,10 +1,15 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct Seat Seat;
#include "list.h"
#include "logind-session.h"
#include "memory-util.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;
struct Seat {
Manager *manager;
+2
View File
@@ -15,10 +15,12 @@
#include "logind-brightness.h"
#include "logind-dbus.h"
#include "logind-polkit.h"
#include "logind-seat.h"
#include "logind-seat-dbus.h"
#include "logind-session-dbus.h"
#include "logind-session-device.h"
#include "logind-session.h"
#include "logind-user.h"
#include "logind-user-dbus.h"
#include "logind.h"
#include "path-util.h"
+4 -1
View File
@@ -4,7 +4,10 @@
#include "sd-bus.h"
#include "bus-object.h"
#include "logind-session.h"
#include "macro.h"
typedef struct Manager Manager;
typedef struct Session Session;
extern const BusObjectImplementation session_object;
+4
View File
@@ -15,6 +15,10 @@
#include "daemon-util.h"
#include "device-util.h"
#include "fd-util.h"
#include "logind.h"
#include "logind-device.h"
#include "logind-seat.h"
#include "logind-session.h"
#include "logind-session-dbus.h"
#include "logind-session-device.h"
#include "missing_drm.h"
+7 -6
View File
@@ -1,18 +1,19 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef enum DeviceType DeviceType;
#include "list.h"
#include "memory-util.h"
typedef struct Device Device;
typedef struct Session Session;
typedef struct SessionDevice SessionDevice;
#include "list.h"
#include "logind.h"
enum DeviceType {
typedef enum DeviceType {
DEVICE_TYPE_UNKNOWN,
DEVICE_TYPE_DRM,
DEVICE_TYPE_EVDEV,
DEVICE_TYPE_HIDRAW,
};
} DeviceType;
struct SessionDevice {
Session *session;
+5
View File
@@ -24,10 +24,15 @@
#include "format-util.h"
#include "fs-util.h"
#include "io-util.h"
#include "login-util.h"
#include "logind.h"
#include "logind-dbus.h"
#include "logind-seat.h"
#include "logind-seat-dbus.h"
#include "logind-session-dbus.h"
#include "logind-session-device.h"
#include "logind-session.h"
#include "logind-user.h"
#include "logind-user-dbus.h"
#include "logind-varlink.h"
#include "mkdir-label.h"
+12 -6
View File
@@ -1,14 +1,20 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct Session Session;
typedef enum KillWhom KillWhom;
#include "sd-bus.h"
#include "sd-event.h"
#include "sd-varlink.h"
#include "hashmap.h"
#include "list.h"
#include "login-util.h"
#include "logind-user.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 */
@@ -85,12 +91,12 @@ typedef enum SessionType {
#define SESSION_TYPE_IS_GRAPHICAL(type) IN_SET(type, SESSION_X11, SESSION_WAYLAND, SESSION_MIR)
enum KillWhom {
typedef enum KillWhom {
KILL_LEADER,
KILL_ALL,
_KILL_WHOM_MAX,
_KILL_WHOM_INVALID = -EINVAL,
};
} KillWhom;
typedef enum TTYValidity {
TTY_FROM_PAM,
+4 -1
View File
@@ -3,7 +3,10 @@
#include "sd-bus.h"
#include "logind-user.h"
#include "bus-object.h"
#include "macro.h"
typedef struct User User;
extern const BusObjectImplementation user_object;
+2
View File
@@ -19,7 +19,9 @@
#include "hashmap.h"
#include "label-util.h"
#include "limits-util.h"
#include "logind.h"
#include "logind-dbus.h"
#include "logind-seat.h"
#include "logind-user-dbus.h"
#include "logind-user.h"
#include "mkdir-label.h"
+5 -2
View File
@@ -1,13 +1,16 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct User User;
#include "sd-event.h"
#include "conf-parser.h"
#include "list.h"
#include "logind.h"
#include "user-record.h"
typedef struct Manager Manager;
typedef struct Session Session;
typedef struct User User;
typedef enum UserState {
USER_OFFLINE, /* Not logged in at all */
USER_OPENING, /* Is logging in */
+3
View File
@@ -1,5 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "log.h"
#include "logind.h"
#include "logind-session.h"
#include "logind-utmp.h"
#include "path-util.h"
#include "process-util.h"
+1 -1
View File
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "logind.h"
typedef struct Manager Manager;
int manager_read_utmp(Manager *m);
void manager_connect_utmp(Manager *m);
+2
View File
@@ -6,7 +6,9 @@
#include "json-util.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-util.h"
+2 -2
View File
@@ -3,8 +3,8 @@
#include "sd-bus.h"
#include "logind.h"
#include "logind-session.h"
typedef struct Manager Manager;
typedef struct Session Session;
int manager_varlink_init(Manager *m);
void manager_varlink_done(Manager *m);
+5
View File
@@ -25,9 +25,14 @@
#include "format-util.h"
#include "fs-util.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"
+8 -8
View File
@@ -13,18 +13,18 @@
#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 Manager Manager;
typedef struct Button Button;
typedef struct Device Device;
typedef struct Seat Seat;
typedef struct Session Session;
typedef struct User User;
#include "logind-action.h"
#include "logind-button.h"
#include "logind-device.h"
#include "logind-inhibit.h"
struct Manager {
typedef struct Manager {
sd_event *event;
sd_bus *bus;
@@ -150,7 +150,7 @@ struct Manager {
dual_timestamp init_ts;
sd_varlink_server *varlink_server;
};
} Manager;
void manager_reset_config(Manager *m);
int manager_parse_config_file(Manager *m);
+1
View File
@@ -2,6 +2,7 @@
#include "logind-action.h"
#include "logind-session.h"
#include "logind-user.h"
#include "sleep-config.h"
#include "test-tables.h"
#include "tests.h"