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