Debian Codegraph @

src/login/logind.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <sys/stat.h>
5
6 #include "calendarspec.h"
7 #include "list.h"
8 #include "logind-action.h"
9 #include "logind-forward.h"
10
11 typedef struct Manager {
12 sd_event *event;
13 sd_bus *bus;
14
15 Hashmap *devices;
16 Hashmap *seats;
17 Hashmap *sessions;
18 Hashmap *sessions_by_leader;
19 Hashmap *users; /* indexed by UID */
20 Hashmap *inhibitors;
21 Hashmap *buttons;
22 Hashmap *brightness_writers;
23
24 LIST_HEAD(Seat, seat_gc_queue);
25 LIST_HEAD(Session, session_gc_queue);
26 LIST_HEAD(User, user_gc_queue);
27
28 sd_device_monitor *device_seat_monitor;
29 sd_device_monitor *device_monitor;
30 sd_device_monitor *device_vcsa_monitor;
31 sd_device_monitor *device_button_monitor;
32 sd_device_monitor *device_uaccess_monitor;
33
34 sd_event_source *console_active_event_source;
35
36 #if ENABLE_UTMP
37 sd_event_source *utmp_event_source;
38 #endif
39
40 int console_active_fd;
41
42 unsigned n_autovts;
43
44 unsigned reserve_vt;
45 int reserve_vt_fd;
46
47 Seat *seat0;
48
49 char **kill_only_users, **kill_exclude_users;
50 bool kill_user_processes;
51
52 uint64_t session_counter;
53 uint64_t inhibit_counter;
54
55 Hashmap *session_units;
56 Hashmap *user_units;
57
58 usec_t inhibit_delay_max;
59 usec_t user_stop_delay;
60
61 /* If a shutdown/suspend was delayed due to an inhibitor this contains the action we are supposed to
62 * start after the delay is over */
63 const HandleActionData *delayed_action;
64
65 /* If a shutdown/suspend is currently executed, then this is the job of it */
66 char *action_job;
67 sd_event_source *inhibit_timeout_source;
68
69 HandleAction scheduled_shutdown_action;
70 usec_t scheduled_shutdown_timeout;
71 sd_event_source *scheduled_shutdown_timeout_source;
72 uid_t scheduled_shutdown_uid;
73 char *scheduled_shutdown_tty;
74 sd_event_source *nologin_timeout_source;
75 bool unlink_nologin;
76
77 char *wall_message;
78 bool wall_messages;
79 sd_event_source *wall_message_timeout_source;
80
81 bool shutdown_dry_run;
82
83 sd_event_source *idle_action_event_source;
84 usec_t idle_action_usec;
85 usec_t idle_action_not_before_usec;
86 HandleAction idle_action;
87 bool was_idle;
88
89 usec_t stop_idle_session_usec;
90
91 HandleActionSleepMask handle_action_sleep_mask;
92
93 HandleAction handle_power_key;
94 HandleAction handle_power_key_long_press;
95 HandleAction handle_reboot_key;
96 HandleAction handle_reboot_key_long_press;
97 HandleAction handle_suspend_key;
98 HandleAction handle_suspend_key_long_press;
99 HandleAction handle_hibernate_key;
100 HandleAction handle_hibernate_key_long_press;
101 HandleAction handle_secure_attention_key;
102
103 HandleAction handle_lid_switch;
104 HandleAction handle_lid_switch_ep;
105 HandleAction handle_lid_switch_docked;
106
107 bool power_key_ignore_inhibited;
108 bool suspend_key_ignore_inhibited;
109 bool hibernate_key_ignore_inhibited;
110 bool lid_switch_ignore_inhibited;
111 bool reboot_key_ignore_inhibited;
112
113 bool remove_ipc;
114
115 Hashmap *polkit_registry;
116
117 usec_t holdoff_timeout_usec;
118 sd_event_source *lid_switch_ignore_event_source;
119
120 sd_event_source *power_key_long_press_event_source;
121 sd_event_source *reboot_key_long_press_event_source;
122 sd_event_source *suspend_key_long_press_event_source;
123 sd_event_source *hibernate_key_long_press_event_source;
124
125 uint64_t runtime_dir_size;
126 uint64_t runtime_dir_inodes;
127 uint64_t sessions_max;
128 uint64_t inhibitors_max;
129
130 char **efi_boot_loader_entries;
131 bool efi_boot_loader_entries_set;
132
133 char *efi_loader_entry_one_shot;
134 struct stat efi_loader_entry_one_shot_stat;
135
136 CalendarSpec *maintenance_time;
137
138 dual_timestamp init_ts;
139
140 sd_varlink_server *varlink_server;
141 } Manager;
142
143 void manager_reset_config(Manager *m);
144 int manager_parse_config_file(Manager *m);
145
146 int manager_add_device(Manager *m, const char *sysfs, bool master, Device **ret_device);
147 int manager_add_button(Manager *m, const char *name, Button **ret_button);
148 int manager_add_seat(Manager *m, const char *id, Seat **ret_seat);
149 int manager_add_session(Manager *m, const char *id, Session **ret_session);
150 int manager_add_user(Manager *m, UserRecord *ur, User **ret_user);
151 int manager_add_user_by_name(Manager *m, const char *name, User **ret_user);
152 int manager_add_user_by_uid(Manager *m, uid_t uid, User **ret_user);
153 int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **ret_inhibitor);
154
155 int manager_process_seat_device(Manager *m, sd_device *d);
156 int manager_process_button_device(Manager *m, sd_device *d, Button **ret_button);
157
158 int manager_spawn_autovt(Manager *m, unsigned vtnr);
159
160 bool manager_shall_kill(Manager *m, const char *user);
161
162 bool manager_get_idle_hint(Manager *m, dual_timestamp *ret_timestamp);
163
164 int manager_get_user_by_pid(Manager *m, pid_t pid, User **ret);
165 int manager_get_session_by_pidref(Manager *m, const PidRef *pid, Session **ret);
166 int manager_get_session_by_leader(Manager *m, const PidRef *pid, Session **ret);
167
168 bool manager_is_lid_closed(Manager *m);
169 bool manager_is_docked_or_external_displays(Manager *m);
170 bool manager_is_on_external_power(void);
171 bool manager_all_buttons_ignored(Manager *m);
172
173 /* gperf lookup function */
174 const struct ConfigPerfItem* logind_gperf_lookup(const char *str, GPERF_LEN_TYPE length);
175
176 int manager_set_lid_switch_ignore(Manager *m, usec_t until);
177
178 CONFIG_PARSER_PROTOTYPE(config_parse_n_autovts);
179 CONFIG_PARSER_PROTOTYPE(config_parse_tmpfs_size);
180
181 int manager_setup_wall_message_timer(Manager *m);
182 bool logind_wall_tty_filter(const char *tty, bool is_local, void *userdata);
183
184 int manager_read_efi_boot_loader_entries(Manager *m);