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