]>
Commit | Line | Data |
---|---|---|
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> | |
25 | #include <inttypes.h> | |
26 | #include <dbus/dbus.h> | |
27 | #include <libudev.h> | |
28 | ||
29 | #include "util.h" | |
d7832d2c | 30 | #include "audit.h" |
20263082 LP |
31 | #include "list.h" |
32 | #include "hashmap.h" | |
33 | #include "cgroup-util.h" | |
34 | ||
20263082 | 35 | typedef struct Manager Manager; |
20263082 | 36 | |
90821c93 LP |
37 | #include "logind-device.h" |
38 | #include "logind-seat.h" | |
39 | #include "logind-session.h" | |
40 | #include "logind-user.h" | |
f8e2fb7b | 41 | #include "logind-inhibit.h" |
069cfc85 | 42 | #include "logind-button.h" |
20263082 LP |
43 | |
44 | struct Manager { | |
45 | DBusConnection *bus; | |
46 | ||
47 | Hashmap *devices; | |
48 | Hashmap *seats; | |
49 | Hashmap *sessions; | |
50 | Hashmap *users; | |
f8e2fb7b | 51 | Hashmap *inhibitors; |
069cfc85 | 52 | Hashmap *buttons; |
20263082 | 53 | |
14c3baca LP |
54 | LIST_HEAD(Seat, seat_gc_queue); |
55 | LIST_HEAD(Session, session_gc_queue); | |
56 | LIST_HEAD(User, user_gc_queue); | |
57 | ||
20263082 | 58 | struct udev *udev; |
069cfc85 | 59 | struct udev_monitor *udev_seat_monitor, *udev_vcsa_monitor, *udev_button_monitor; |
30ed21ce LP |
60 | |
61 | int udev_seat_fd; | |
62 | int udev_vcsa_fd; | |
069cfc85 | 63 | int udev_button_fd; |
20263082 | 64 | |
20263082 LP |
65 | int console_active_fd; |
66 | int bus_fd; | |
67 | int epoll_fd; | |
68 | ||
3f49d45a | 69 | unsigned n_autovts; |
20263082 | 70 | |
98a77df5 LP |
71 | unsigned reserve_vt; |
72 | int reserve_vt_fd; | |
73 | ||
20263082 LP |
74 | Seat *vtconsole; |
75 | ||
76 | char *cgroup_path; | |
193197e8 | 77 | char **controllers, **reset_controllers; |
20263082 | 78 | |
3f49d45a | 79 | char **kill_only_users, **kill_exclude_users; |
20263082 LP |
80 | |
81 | bool kill_user_processes; | |
98a28fef LP |
82 | |
83 | unsigned long session_counter; | |
f8e2fb7b | 84 | unsigned long inhibit_counter; |
1713813d | 85 | |
8c8c4351 LP |
86 | Hashmap *session_cgroups; |
87 | Hashmap *user_cgroups; | |
88 | ||
f8e2fb7b LP |
89 | Hashmap *session_fds; |
90 | Hashmap *inhibitor_fds; | |
069cfc85 | 91 | Hashmap *button_fds; |
eecd1362 LP |
92 | |
93 | /* If a shutdown was delayed due to a inhibitor this contains | |
94 | the unit name we are supposed to start after the delay is | |
95 | over */ | |
d889a206 LP |
96 | const char *delayed_unit; |
97 | InhibitWhat delayed_what; | |
98 | usec_t delayed_timestamp; | |
eecd1362 LP |
99 | |
100 | usec_t inhibit_delay_max; | |
069cfc85 LP |
101 | |
102 | HandleButton handle_power_key; | |
103 | HandleButton handle_sleep_key; | |
104 | HandleButton handle_lid_switch; | |
31b79c2b LP |
105 | }; |
106 | ||
107 | enum { | |
30ed21ce LP |
108 | FD_SEAT_UDEV, |
109 | FD_VCSA_UDEV, | |
069cfc85 | 110 | FD_BUTTON_UDEV, |
31b79c2b LP |
111 | FD_CONSOLE, |
112 | FD_BUS, | |
069cfc85 | 113 | FD_OTHER_BASE |
20263082 LP |
114 | }; |
115 | ||
20263082 LP |
116 | Manager *manager_new(void); |
117 | void manager_free(Manager *m); | |
14c3baca | 118 | |
20263082 | 119 | int manager_add_device(Manager *m, const char *sysfs, Device **_device); |
069cfc85 | 120 | int manager_add_button(Manager *m, const char *name, Button **_button); |
20263082 LP |
121 | int manager_add_seat(Manager *m, const char *id, Seat **_seat); |
122 | int manager_add_session(Manager *m, User *u, const char *id, Session **_session); | |
123 | int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user); | |
124 | int manager_add_user_by_name(Manager *m, const char *name, User **_user); | |
125 | int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user); | |
f8e2fb7b | 126 | int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **_inhibitor); |
14c3baca | 127 | |
30ed21ce | 128 | int manager_process_seat_device(Manager *m, struct udev_device *d); |
069cfc85 LP |
129 | int manager_process_button_device(Manager *m, struct udev_device *d); |
130 | ||
30ed21ce LP |
131 | int manager_dispatch_seat_udev(Manager *m); |
132 | int manager_dispatch_vcsa_udev(Manager *m); | |
069cfc85 | 133 | int manager_dispatch_button_udev(Manager *m); |
20263082 | 134 | int manager_dispatch_console(Manager *m); |
14c3baca | 135 | |
20263082 | 136 | int manager_enumerate_devices(Manager *m); |
069cfc85 | 137 | int manager_enumerate_buttons(Manager *m); |
20263082 LP |
138 | int manager_enumerate_seats(Manager *m); |
139 | int manager_enumerate_sessions(Manager *m); | |
140 | int manager_enumerate_users(Manager *m); | |
f8e2fb7b | 141 | int manager_enumerate_inhibitors(Manager *m); |
14c3baca | 142 | |
20263082 LP |
143 | int manager_startup(Manager *m); |
144 | int manager_run(Manager *m); | |
145 | int manager_spawn_autovt(Manager *m, int vtnr); | |
146 | ||
1713813d LP |
147 | void manager_cgroup_notify_empty(Manager *m, const char *cgroup); |
148 | ||
4a4b033f | 149 | void manager_gc(Manager *m, bool drop_not_started); |
14c3baca | 150 | |
a185c5aa LP |
151 | int manager_get_idle_hint(Manager *m, dual_timestamp *t); |
152 | ||
8c8c4351 | 153 | int manager_get_user_by_cgroup(Manager *m, const char *cgroup, User **user); |
9b221b63 LP |
154 | int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **session); |
155 | int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session); | |
156 | ||
3f49d45a LP |
157 | extern const DBusObjectPathVTable bus_manager_vtable; |
158 | ||
1713813d LP |
159 | DBusHandlerResult bus_message_filter(DBusConnection *c, DBusMessage *message, void *userdata); |
160 | ||
069cfc85 LP |
161 | int bus_manager_shutdown_or_sleep_now_or_later(Manager *m, const char *unit_name, InhibitWhat w, DBusError *error); |
162 | ||
9418f147 LP |
163 | int manager_send_changed(Manager *manager, const char *properties); |
164 | ||
d889a206 | 165 | int manager_dispatch_delayed(Manager *manager); |
eecd1362 | 166 | |
f975e971 LP |
167 | /* gperf lookup function */ |
168 | const struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned length); |