]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c2f1db8f | 2 | #pragma once |
20263082 | 3 | |
20263082 | 4 | #include <stdbool.h> |
20263082 | 5 | |
cc377381 | 6 | #include "sd-bus.h" |
4f209af7 | 7 | #include "sd-device.h" |
07630cea LP |
8 | #include "sd-event.h" |
9 | ||
a2106925 | 10 | #include "conf-parser.h" |
20263082 | 11 | #include "hashmap.h" |
07630cea | 12 | #include "list.h" |
cc377381 | 13 | #include "set.h" |
ca78ad1d | 14 | #include "time-util.h" |
22c902fa | 15 | #include "user-record.h" |
20263082 | 16 | |
20263082 | 17 | typedef struct Manager Manager; |
20263082 | 18 | |
07630cea LP |
19 | #include "logind-action.h" |
20 | #include "logind-button.h" | |
90821c93 | 21 | #include "logind-device.h" |
f8e2fb7b | 22 | #include "logind-inhibit.h" |
20263082 LP |
23 | |
24 | struct Manager { | |
cc377381 LP |
25 | sd_event *event; |
26 | sd_bus *bus; | |
20263082 LP |
27 | |
28 | Hashmap *devices; | |
29 | Hashmap *seats; | |
30 | Hashmap *sessions; | |
238794b1 | 31 | Hashmap *sessions_by_leader; |
22c902fa | 32 | Hashmap *users; /* indexed by UID */ |
f8e2fb7b | 33 | Hashmap *inhibitors; |
069cfc85 | 34 | Hashmap *buttons; |
2a66c2a1 | 35 | Hashmap *brightness_writers; |
cc377381 | 36 | |
14c3baca LP |
37 | LIST_HEAD(Seat, seat_gc_queue); |
38 | LIST_HEAD(Session, session_gc_queue); | |
39 | LIST_HEAD(User, user_gc_queue); | |
40 | ||
eb968396 | 41 | sd_device_monitor *device_seat_monitor, *device_monitor, *device_vcsa_monitor, *device_button_monitor; |
30ed21ce | 42 | |
cc377381 | 43 | sd_event_source *console_active_event_source; |
20263082 | 44 | |
3d0ef5c7 LP |
45 | #if ENABLE_UTMP |
46 | sd_event_source *utmp_event_source; | |
47 | #endif | |
48 | ||
20263082 | 49 | int console_active_fd; |
20263082 | 50 | |
3f49d45a | 51 | unsigned n_autovts; |
20263082 | 52 | |
98a77df5 LP |
53 | unsigned reserve_vt; |
54 | int reserve_vt_fd; | |
55 | ||
92432fcc | 56 | Seat *seat0; |
20263082 | 57 | |
3f49d45a | 58 | char **kill_only_users, **kill_exclude_users; |
20263082 | 59 | bool kill_user_processes; |
98a28fef LP |
60 | |
61 | unsigned long session_counter; | |
f8e2fb7b | 62 | unsigned long inhibit_counter; |
1713813d | 63 | |
fb6becb4 LP |
64 | Hashmap *session_units; |
65 | Hashmap *user_units; | |
8c8c4351 | 66 | |
eecd1362 | 67 | usec_t inhibit_delay_max; |
9afe9efb | 68 | usec_t user_stop_delay; |
069cfc85 | 69 | |
314b4b0a LP |
70 | /* If an action is currently being executed or is delayed, |
71 | * this is != 0 and encodes what is being done */ | |
72 | InhibitWhat action_what; | |
73 | ||
74 | /* If a shutdown/suspend was delayed due to a inhibitor this | |
75 | contains the unit name we are supposed to start after the | |
76 | delay is over */ | |
77 | const char *action_unit; | |
78 | ||
79 | /* If a shutdown/suspend is currently executed, then this is | |
80 | * the job of it */ | |
81 | char *action_job; | |
c0f32805 | 82 | sd_event_source *inhibit_timeout_source; |
af9792ac | 83 | |
8aaa023a DM |
84 | char *scheduled_shutdown_type; |
85 | usec_t scheduled_shutdown_timeout; | |
86 | sd_event_source *scheduled_shutdown_timeout_source; | |
e2fa5721 DM |
87 | uid_t scheduled_shutdown_uid; |
88 | char *scheduled_shutdown_tty; | |
867c37f6 DM |
89 | sd_event_source *nologin_timeout_source; |
90 | bool unlink_nologin; | |
e2fa5721 DM |
91 | |
92 | char *wall_message; | |
93 | unsigned enable_wall_messages; | |
94 | sd_event_source *wall_message_timeout_source; | |
8aaa023a | 95 | |
1389f4b9 DM |
96 | bool shutdown_dry_run; |
97 | ||
cc377381 | 98 | sd_event_source *idle_action_event_source; |
23406ce5 LP |
99 | usec_t idle_action_usec; |
100 | usec_t idle_action_not_before_usec; | |
101 | HandleAction idle_action; | |
102 | ||
103 | HandleAction handle_power_key; | |
104 | HandleAction handle_suspend_key; | |
105 | HandleAction handle_hibernate_key; | |
106 | HandleAction handle_lid_switch; | |
e25937a3 | 107 | HandleAction handle_lid_switch_ep; |
3c56cab4 | 108 | HandleAction handle_lid_switch_docked; |
beaafb2e LP |
109 | |
110 | bool power_key_ignore_inhibited; | |
8e7fd6ad LP |
111 | bool suspend_key_ignore_inhibited; |
112 | bool hibernate_key_ignore_inhibited; | |
beaafb2e | 113 | bool lid_switch_ignore_inhibited; |
31b79c2b | 114 | |
66cdd0f2 LP |
115 | bool remove_ipc; |
116 | ||
cc377381 | 117 | Hashmap *polkit_registry; |
f9cd6be1 | 118 | |
9d10cbee | 119 | usec_t holdoff_timeout_usec; |
f9cd6be1 | 120 | sd_event_source *lid_switch_ignore_event_source; |
1c231f56 | 121 | |
a7b46b7d | 122 | uint64_t runtime_dir_size; |
cc1c85fb | 123 | uint64_t runtime_dir_inodes; |
183e0738 | 124 | uint64_t sessions_max; |
c5a11ae2 | 125 | uint64_t inhibitors_max; |
d4bd786d LP |
126 | |
127 | char **efi_boot_loader_entries; | |
128 | bool efi_boot_loader_entries_set; | |
af2697e8 LP |
129 | |
130 | char *efi_loader_entry_one_shot; | |
131 | struct stat efi_loader_entry_one_shot_stat; | |
20263082 LP |
132 | }; |
133 | ||
ae98d374 ZJS |
134 | void manager_reset_config(Manager *m); |
135 | int manager_parse_config_file(Manager *m); | |
136 | ||
f68d1485 ZJS |
137 | int manager_add_device(Manager *m, const char *sysfs, bool master, Device **ret_device); |
138 | int manager_add_button(Manager *m, const char *name, Button **ret_button); | |
139 | int manager_add_seat(Manager *m, const char *id, Seat **ret_seat); | |
140 | int manager_add_session(Manager *m, const char *id, Session **ret_session); | |
22c902fa | 141 | int manager_add_user(Manager *m, UserRecord *ur, User **ret_user); |
f68d1485 ZJS |
142 | int manager_add_user_by_name(Manager *m, const char *name, User **ret_user); |
143 | int manager_add_user_by_uid(Manager *m, uid_t uid, User **ret_user); | |
144 | int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **ret_inhibitor); | |
14c3baca | 145 | |
4f209af7 YW |
146 | int manager_process_seat_device(Manager *m, sd_device *d); |
147 | int manager_process_button_device(Manager *m, sd_device *d); | |
069cfc85 | 148 | |
14cb109d | 149 | int manager_spawn_autovt(Manager *m, unsigned vtnr); |
20263082 | 150 | |
405e0255 LP |
151 | bool manager_shall_kill(Manager *m, const char *user); |
152 | ||
a185c5aa LP |
153 | int manager_get_idle_hint(Manager *m, dual_timestamp *t); |
154 | ||
9444b1f2 | 155 | int manager_get_user_by_pid(Manager *m, pid_t pid, User **user); |
9b221b63 LP |
156 | int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session); |
157 | ||
9b9c23da | 158 | bool manager_is_lid_closed(Manager *m); |
602a41c2 | 159 | bool manager_is_docked_or_external_displays(Manager *m); |
e25937a3 SF |
160 | bool manager_is_on_external_power(void); |
161 | bool manager_all_buttons_ignored(Manager *m); | |
2d62c530 | 162 | |
3d0ef5c7 LP |
163 | int manager_read_utmp(Manager *m); |
164 | void manager_connect_utmp(Manager *m); | |
165 | void manager_reconnect_utmp(Manager *m); | |
166 | ||
f975e971 | 167 | /* gperf lookup function */ |
c9f7b4d3 | 168 | const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE length); |
e8b212fe | 169 | |
f9cd6be1 | 170 | int manager_set_lid_switch_ignore(Manager *m, usec_t until); |
1c231f56 | 171 | |
a2106925 LP |
172 | CONFIG_PARSER_PROTOTYPE(config_parse_n_autovts); |
173 | CONFIG_PARSER_PROTOTYPE(config_parse_tmpfs_size); | |
309a29df | 174 | |
e2fa5721 DM |
175 | int manager_setup_wall_message_timer(Manager *m); |
176 | bool logind_wall_tty_filter(const char *tty, void *userdata); | |
d4bd786d LP |
177 | |
178 | int manager_read_efi_boot_loader_entries(Manager *m); |