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