chiark / gitweb /
logind: when generating session ids with a counter, retry if session is already allocated
[elogind.git] / src / logind.h
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
12   under the terms of the GNU General Public License as published by
13   the Free Software Foundation; either version 2 of the License, or
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
19   General Public License for more details.
20
21   You should have received a copy of the GNU General Public License
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"
31 #include "list.h"
32 #include "hashmap.h"
33 #include "cgroup-util.h"
34
35 /* TODO:
36  *
37  * recreate VTs when disallocated
38  * spawn user systemd
39  * direct client API
40  * subscribe to fd HUP
41  * D-Bus method: AttachDevice(seat, device);
42  * D-Bus method: PermitLinger(user, bool b);
43  * properly handle if two sessions with the same loginuid are attempted to be created
44  *
45  * non-local X11 server
46  * reboot/shutdown halt management
47  */
48
49 typedef struct Manager Manager;
50
51 #include "logind-device.h"
52 #include "logind-seat.h"
53 #include "logind-session.h"
54 #include "logind-user.h"
55
56 struct Manager {
57         DBusConnection *bus;
58
59         Hashmap *devices;
60         Hashmap *seats;
61         Hashmap *sessions;
62         Hashmap *users;
63
64         LIST_HEAD(Seat, seat_gc_queue);
65         LIST_HEAD(Session, session_gc_queue);
66         LIST_HEAD(User, user_gc_queue);
67
68         struct udev *udev;
69         struct udev_monitor *udev_monitor;
70
71         int udev_fd;
72         int console_active_fd;
73         int bus_fd;
74         int epoll_fd;
75
76         unsigned n_autovts;
77
78         Seat *vtconsole;
79
80         char *cgroup_path;
81         char **controllers;
82
83         char **kill_only_users, **kill_exclude_users;
84
85         bool kill_user_processes;
86
87         unsigned long session_counter;
88
89         Hashmap *cgroups;
90 };
91
92 Manager *manager_new(void);
93 void manager_free(Manager *m);
94
95 int manager_add_device(Manager *m, const char *sysfs, Device **_device);
96 int manager_add_seat(Manager *m, const char *id, Seat **_seat);
97 int manager_add_session(Manager *m, User *u, const char *id, Session **_session);
98 int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user);
99 int manager_add_user_by_name(Manager *m, const char *name, User **_user);
100 int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user);
101
102 int manager_process_device(Manager *m, struct udev_device *d);
103 int manager_dispatch_udev(Manager *m);
104 int manager_dispatch_console(Manager *m);
105
106 int manager_enumerate_devices(Manager *m);
107 int manager_enumerate_seats(Manager *m);
108 int manager_enumerate_sessions(Manager *m);
109 int manager_enumerate_users(Manager *m);
110
111 int manager_startup(Manager *m);
112 int manager_run(Manager *m);
113 int manager_spawn_autovt(Manager *m, int vtnr);
114
115 void manager_cgroup_notify_empty(Manager *m, const char *cgroup);
116
117 void manager_gc(Manager *m);
118
119 int manager_get_idle_hint(Manager *m, dual_timestamp *t);
120
121 bool x11_display_is_local(const char *display);
122
123 extern const DBusObjectPathVTable bus_manager_vtable;
124
125 DBusHandlerResult bus_message_filter(DBusConnection *c, DBusMessage *message, void *userdata);
126
127 int manager_send_changed(Manager *manager, const char *properties);
128
129 #endif