]>
Commit | Line | Data |
---|---|---|
20263082 LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | #ifndef foologindhfoo | |
4 | #define foologindhfoo | |
5 | ||
6 | /*** | |
7 | This file is part of systemd. | |
8 | ||
9 | Copyright 2011 Lennart Poettering | |
10 | ||
11 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
12 | under the terms of the GNU Lesser General Public License as published by |
13 | the Free Software Foundation; either version 2.1 of the License, or | |
20263082 LP |
14 | (at your option) any later version. |
15 | ||
16 | systemd is distributed in the hope that it will be useful, but | |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 19 | Lesser General Public License for more details. |
20263082 | 20 | |
5430f7f2 | 21 | You should have received a copy of the GNU Lesser General Public License |
20263082 LP |
22 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
23 | ***/ | |
24 | ||
25 | #include <stdbool.h> | |
26 | #include <inttypes.h> | |
27 | #include <dbus/dbus.h> | |
28 | #include <libudev.h> | |
29 | ||
30 | #include "util.h" | |
d7832d2c | 31 | #include "audit.h" |
20263082 LP |
32 | #include "list.h" |
33 | #include "hashmap.h" | |
34 | #include "cgroup-util.h" | |
35 | ||
20263082 | 36 | typedef struct Manager Manager; |
20263082 | 37 | |
90821c93 LP |
38 | #include "logind-device.h" |
39 | #include "logind-seat.h" | |
40 | #include "logind-session.h" | |
41 | #include "logind-user.h" | |
f8e2fb7b | 42 | #include "logind-inhibit.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; |
20263082 | 52 | |
14c3baca LP |
53 | LIST_HEAD(Seat, seat_gc_queue); |
54 | LIST_HEAD(Session, session_gc_queue); | |
55 | LIST_HEAD(User, user_gc_queue); | |
56 | ||
20263082 | 57 | struct udev *udev; |
30ed21ce LP |
58 | struct udev_monitor *udev_seat_monitor, *udev_vcsa_monitor; |
59 | ||
60 | int udev_seat_fd; | |
61 | int udev_vcsa_fd; | |
20263082 | 62 | |
20263082 LP |
63 | int console_active_fd; |
64 | int bus_fd; | |
65 | int epoll_fd; | |
66 | ||
3f49d45a | 67 | unsigned n_autovts; |
20263082 LP |
68 | |
69 | Seat *vtconsole; | |
70 | ||
71 | char *cgroup_path; | |
193197e8 | 72 | char **controllers, **reset_controllers; |
20263082 | 73 | |
3f49d45a | 74 | char **kill_only_users, **kill_exclude_users; |
20263082 LP |
75 | |
76 | bool kill_user_processes; | |
98a28fef LP |
77 | |
78 | unsigned long session_counter; | |
f8e2fb7b | 79 | unsigned long inhibit_counter; |
1713813d LP |
80 | |
81 | Hashmap *cgroups; | |
f8e2fb7b LP |
82 | Hashmap *session_fds; |
83 | Hashmap *inhibitor_fds; | |
eecd1362 LP |
84 | |
85 | /* If a shutdown was delayed due to a inhibitor this contains | |
86 | the unit name we are supposed to start after the delay is | |
87 | over */ | |
88 | const char *delayed_shutdown; | |
89 | usec_t delayed_shutdown_timestamp; | |
90 | ||
91 | usec_t inhibit_delay_max; | |
31b79c2b LP |
92 | }; |
93 | ||
94 | enum { | |
30ed21ce LP |
95 | FD_SEAT_UDEV, |
96 | FD_VCSA_UDEV, | |
31b79c2b LP |
97 | FD_CONSOLE, |
98 | FD_BUS, | |
932e3ee7 | 99 | FD_FIFO_BASE |
20263082 LP |
100 | }; |
101 | ||
20263082 LP |
102 | Manager *manager_new(void); |
103 | void manager_free(Manager *m); | |
14c3baca | 104 | |
20263082 LP |
105 | int manager_add_device(Manager *m, const char *sysfs, Device **_device); |
106 | int manager_add_seat(Manager *m, const char *id, Seat **_seat); | |
107 | int manager_add_session(Manager *m, User *u, const char *id, Session **_session); | |
108 | int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user); | |
109 | int manager_add_user_by_name(Manager *m, const char *name, User **_user); | |
110 | int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user); | |
f8e2fb7b | 111 | int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **_inhibitor); |
14c3baca | 112 | |
30ed21ce LP |
113 | int manager_process_seat_device(Manager *m, struct udev_device *d); |
114 | int manager_dispatch_seat_udev(Manager *m); | |
115 | int manager_dispatch_vcsa_udev(Manager *m); | |
20263082 | 116 | int manager_dispatch_console(Manager *m); |
14c3baca | 117 | |
20263082 LP |
118 | int manager_enumerate_devices(Manager *m); |
119 | int manager_enumerate_seats(Manager *m); | |
120 | int manager_enumerate_sessions(Manager *m); | |
121 | int manager_enumerate_users(Manager *m); | |
f8e2fb7b | 122 | int manager_enumerate_inhibitors(Manager *m); |
14c3baca | 123 | |
20263082 LP |
124 | int manager_startup(Manager *m); |
125 | int manager_run(Manager *m); | |
126 | int manager_spawn_autovt(Manager *m, int vtnr); | |
127 | ||
1713813d LP |
128 | void manager_cgroup_notify_empty(Manager *m, const char *cgroup); |
129 | ||
4a4b033f | 130 | void manager_gc(Manager *m, bool drop_not_started); |
14c3baca | 131 | |
a185c5aa LP |
132 | int manager_get_idle_hint(Manager *m, dual_timestamp *t); |
133 | ||
9b221b63 LP |
134 | int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **session); |
135 | int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session); | |
136 | ||
3f49d45a LP |
137 | extern const DBusObjectPathVTable bus_manager_vtable; |
138 | ||
1713813d LP |
139 | DBusHandlerResult bus_message_filter(DBusConnection *c, DBusMessage *message, void *userdata); |
140 | ||
9418f147 LP |
141 | int manager_send_changed(Manager *manager, const char *properties); |
142 | ||
eecd1362 LP |
143 | int manager_dispatch_delayed_shutdown(Manager *manager); |
144 | ||
f975e971 LP |
145 | /* gperf lookup function */ |
146 | const struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned length); | |
147 | ||
20263082 | 148 | #endif |