]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/login/logind.h
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / login / logind.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
c2f1db8f 2#pragma once
20263082
LP
3
4/***
5 This file is part of systemd.
6
7 Copyright 2011 Lennart Poettering
20263082
LP
8***/
9
10#include <stdbool.h>
20263082 11
07630cea 12#include "libudev.h"
cc377381 13#include "sd-bus.h"
07630cea
LP
14#include "sd-event.h"
15
20263082 16#include "hashmap.h"
07630cea 17#include "list.h"
cc377381 18#include "set.h"
20263082 19
20263082 20typedef struct Manager Manager;
20263082 21
07630cea
LP
22#include "logind-action.h"
23#include "logind-button.h"
90821c93 24#include "logind-device.h"
f8e2fb7b 25#include "logind-inhibit.h"
20263082
LP
26
27struct Manager {
cc377381
LP
28 sd_event *event;
29 sd_bus *bus;
20263082
LP
30
31 Hashmap *devices;
32 Hashmap *seats;
33 Hashmap *sessions;
34 Hashmap *users;
f8e2fb7b 35 Hashmap *inhibitors;
069cfc85 36 Hashmap *buttons;
cc377381 37
14c3baca
LP
38 LIST_HEAD(Seat, seat_gc_queue);
39 LIST_HEAD(Session, session_gc_queue);
40 LIST_HEAD(User, user_gc_queue);
41
20263082 42 struct udev *udev;
718d006a 43 struct udev_monitor *udev_seat_monitor, *udev_device_monitor, *udev_vcsa_monitor, *udev_button_monitor;
30ed21ce 44
cc377381
LP
45 sd_event_source *console_active_event_source;
46 sd_event_source *udev_seat_event_source;
47 sd_event_source *udev_device_event_source;
48 sd_event_source *udev_vcsa_event_source;
49 sd_event_source *udev_button_event_source;
20263082 50
20263082 51 int console_active_fd;
20263082 52
3f49d45a 53 unsigned n_autovts;
20263082 54
98a77df5
LP
55 unsigned reserve_vt;
56 int reserve_vt_fd;
57
92432fcc 58 Seat *seat0;
20263082 59
3f49d45a 60 char **kill_only_users, **kill_exclude_users;
20263082 61 bool kill_user_processes;
98a28fef
LP
62
63 unsigned long session_counter;
f8e2fb7b 64 unsigned long inhibit_counter;
1713813d 65
fb6becb4
LP
66 Hashmap *session_units;
67 Hashmap *user_units;
8c8c4351 68
eecd1362 69 usec_t inhibit_delay_max;
069cfc85 70
314b4b0a
LP
71 /* If an action is currently being executed or is delayed,
72 * this is != 0 and encodes what is being done */
73 InhibitWhat action_what;
74
75 /* If a shutdown/suspend was delayed due to a inhibitor this
76 contains the unit name we are supposed to start after the
77 delay is over */
78 const char *action_unit;
79
80 /* If a shutdown/suspend is currently executed, then this is
81 * the job of it */
82 char *action_job;
c0f32805 83 sd_event_source *inhibit_timeout_source;
af9792ac 84
8aaa023a
DM
85 char *scheduled_shutdown_type;
86 usec_t scheduled_shutdown_timeout;
87 sd_event_source *scheduled_shutdown_timeout_source;
e2fa5721
DM
88 uid_t scheduled_shutdown_uid;
89 char *scheduled_shutdown_tty;
867c37f6
DM
90 sd_event_source *nologin_timeout_source;
91 bool unlink_nologin;
e2fa5721
DM
92
93 char *wall_message;
94 unsigned enable_wall_messages;
95 sd_event_source *wall_message_timeout_source;
8aaa023a 96
1389f4b9
DM
97 bool shutdown_dry_run;
98
cc377381 99 sd_event_source *idle_action_event_source;
23406ce5
LP
100 usec_t idle_action_usec;
101 usec_t idle_action_not_before_usec;
102 HandleAction idle_action;
103
104 HandleAction handle_power_key;
105 HandleAction handle_suspend_key;
106 HandleAction handle_hibernate_key;
107 HandleAction handle_lid_switch;
e25937a3 108 HandleAction handle_lid_switch_ep;
3c56cab4 109 HandleAction handle_lid_switch_docked;
beaafb2e
LP
110
111 bool power_key_ignore_inhibited;
8e7fd6ad
LP
112 bool suspend_key_ignore_inhibited;
113 bool hibernate_key_ignore_inhibited;
beaafb2e 114 bool lid_switch_ignore_inhibited;
31b79c2b 115
66cdd0f2
LP
116 bool remove_ipc;
117
cc377381 118 Hashmap *polkit_registry;
f9cd6be1 119
9d10cbee 120 usec_t holdoff_timeout_usec;
f9cd6be1 121 sd_event_source *lid_switch_ignore_event_source;
1c231f56
LP
122
123 size_t runtime_dir_size;
90558f31 124 uint64_t user_tasks_max;
183e0738 125 uint64_t sessions_max;
c5a11ae2 126 uint64_t inhibitors_max;
20263082
LP
127};
128
718d006a 129int manager_add_device(Manager *m, const char *sysfs, bool master, Device **_device);
069cfc85 130int manager_add_button(Manager *m, const char *name, Button **_button);
20263082 131int manager_add_seat(Manager *m, const char *id, Seat **_seat);
9444b1f2 132int manager_add_session(Manager *m, const char *id, Session **_session);
20263082
LP
133int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user);
134int manager_add_user_by_name(Manager *m, const char *name, User **_user);
135int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user);
f8e2fb7b 136int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **_inhibitor);
14c3baca 137
30ed21ce 138int manager_process_seat_device(Manager *m, struct udev_device *d);
069cfc85
LP
139int manager_process_button_device(Manager *m, struct udev_device *d);
140
92bd5ff3 141int manager_spawn_autovt(Manager *m, unsigned int vtnr);
20263082 142
405e0255
LP
143bool manager_shall_kill(Manager *m, const char *user);
144
a185c5aa
LP
145int manager_get_idle_hint(Manager *m, dual_timestamp *t);
146
9444b1f2 147int manager_get_user_by_pid(Manager *m, pid_t pid, User **user);
9b221b63
LP
148int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session);
149
602a41c2 150bool manager_is_docked_or_external_displays(Manager *m);
e25937a3
SF
151bool manager_is_on_external_power(void);
152bool manager_all_buttons_ignored(Manager *m);
2d62c530 153
cc377381 154extern const sd_bus_vtable manager_vtable[];
3f49d45a 155
19070062
LP
156int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error);
157int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error);
158int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error);
159int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error);
160int match_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error);
1713813d 161
cc377381 162int bus_manager_shutdown_or_sleep_now_or_later(Manager *m, const char *unit_name, InhibitWhat w, sd_bus_error *error);
069cfc85 163
cc377381 164int manager_send_changed(Manager *manager, const char *property, ...) _sentinel_;
9418f147 165
90558f31
LP
166int manager_start_slice(Manager *manager, const char *slice, const char *description, const char *after, const char *after2, uint64_t tasks_max, sd_bus_error *error, char **job);
167int manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, const char *after, const char *after2, uint64_t tasks_max, sd_bus_error *error, char **job);
cc377381
LP
168int manager_start_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
169int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
5f41d1f1 170int manager_abandon_scope(Manager *manager, const char *scope, sd_bus_error *error);
cc377381 171int manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo, sd_bus_error *error);
fb6becb4 172int manager_unit_is_active(Manager *manager, const char *unit);
cc377381 173int manager_job_is_active(Manager *manager, const char *path);
fb6becb4 174
f975e971 175/* gperf lookup function */
c9f7b4d3 176const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
e8b212fe 177
f9cd6be1 178int manager_set_lid_switch_ignore(Manager *m, usec_t until);
1c231f56 179
c29b65f7 180int config_parse_n_autovts(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
1c231f56 181int config_parse_tmpfs_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
c06eec15 182int config_parse_user_tasks_max(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
309a29df
LP
183
184int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret);
185int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret);
186int manager_get_seat_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Seat **ret);
e2fa5721
DM
187
188int manager_setup_wall_message_timer(Manager *m);
189bool logind_wall_tty_filter(const char *tty, void *userdata);
418b22b8
DM
190
191int manager_dispatch_delayed(Manager *manager, bool timeout);