}
s->id = file_name_from_path(s->state_file);
+ s->manager = m;
if (hashmap_put(m->seats, s->id, s) < 0) {
- free(s->id);
+ free(s->state_file);
free(s);
return NULL;
}
- s->manager = m;
-
return s;
}
void seat_free(Seat *s) {
assert(s);
+ if (s->in_gc_queue)
+ LIST_REMOVE(Seat, gc_queue, s->manager->seat_gc_queue, s);
+
while (s->sessions)
session_free(s->sessions);
hashmap_remove(s->manager->seats, s->id);
- free(s->state_file);
+ if (s->state_file) {
+ unlink(s->state_file);
+ free(s->state_file);
+ }
+
free(s);
}
int seat_save(Seat *s) {
- FILE *f;
int r;
+ FILE *f;
+ char *temp_path;
assert(s);
r = safe_mkdir("/run/systemd/seat", 0755, 0, 0);
if (r < 0)
- return r;
+ goto finish;
+
+ r = fopen_temporary(s->state_file, &f, &temp_path);
+ if (r < 0)
+ goto finish;
- f = fopen(s->state_file, "we");
- if (!f)
- return -errno;
+ fchmod(fileno(f), 0644);
fprintf(f,
+ "# This is private data. Do not parse.\n"
"IS_VTCONSOLE=%i\n",
s->manager->vtconsole == s);
if (s->sessions) {
Session *i;
- fputs("OTHER_UIDS=", f);
+ fputs("OTHER=", f);
LIST_FOREACH(sessions_by_seat, i, s->sessions) {
- assert(i->user);
+ if (i == s->active)
+ continue;
+
+ fprintf(f,
+ "%s%c",
+ i->id,
+ i->sessions_by_seat_next ? ' ' : '\n');
+ }
+ fputs("OTHER_UIDS=", f);
+ LIST_FOREACH(sessions_by_seat, i, s->sessions) {
if (i == s->active)
continue;
fprintf(f,
- "%s%lu",
- i == s->sessions ? "" : " ",
- (unsigned long) i->user->uid);
+ "%lu%c",
+ (unsigned long) i->user->uid,
+ i->sessions_by_seat_next ? ' ' : '\n');
}
}
fflush(f);
- if (ferror(f)) {
+
+ if (ferror(f) || rename(temp_path, s->state_file) < 0) {
r = -errno;
unlink(s->state_file);
+ unlink(temp_path);
}
fclose(f);
+ free(temp_path);
+
+finish:
+ if (r < 0)
+ log_error("Failed to save seat data for %s: %s", s->id, strerror(-r));
+
return r;
}
return r;
}
-int seat_preallocate_vts(Seat *s) {
+static int seat_preallocate_vts(Seat *s) {
int i, r = 0;
assert(s);
int q;
q = vt_allocate(i);
- if (r >= 0 && q < 0)
+ if (q < 0) {
+ log_error("Failed to preallocate VT %i: %s", i, strerror(-q));
r = q;
+ }
}
return r;
}
int seat_active_vt_changed(Seat *s, int vtnr) {
- Session *i;
- Session *old_active;
+ Session *i, *new_active = NULL, *old_active;
assert(s);
assert(vtnr >= 1);
- assert(s->manager->vtconsole == s);
- old_active = s->active;
- s->active = NULL;
+ if (s->manager->vtconsole != s)
+ return -EINVAL;
+
+ log_debug("VT changed to %i", vtnr);
LIST_FOREACH(sessions_by_seat, i, s->sessions)
if (i->vtnr == vtnr) {
- s->active = i;
+ new_active = i;
break;
}
- if (old_active == s->active)
+ if (new_active == s->active)
return 0;
+ old_active = s->active;
+ s->active = new_active;
+
seat_apply_acls(s, old_active);
manager_spawn_autovt(s->manager, vtnr);
return 0;
}
+int seat_read_active_vt(Seat *s) {
+ char t[64];
+ ssize_t k;
+ int r, vtnr;
+
+ assert(s);
+
+ if (s->manager->vtconsole != s)
+ return 0;
+
+ lseek(s->manager->console_active_fd, SEEK_SET, 0);
+
+ k = read(s->manager->console_active_fd, t, sizeof(t)-1);
+ if (k <= 0) {
+ log_error("Failed to read current console: %s", k < 0 ? strerror(-errno) : "EOF");
+ return k < 0 ? -errno : -EIO;
+ }
+
+ t[k] = 0;
+ truncate_nl(t);
+
+ if (!startswith(t, "tty")) {
+ log_error("Hm, /sys/class/tty/tty0/active is badly formatted.");
+ return -EIO;
+ }
+
+ r = safe_atoi(t+3, &vtnr);
+ if (r < 0) {
+ log_error("Failed to parse VT number %s", t+3);
+ return r;
+ }
+
+ if (vtnr <= 0) {
+ log_error("VT number invalid: %s", t+3);
+ return -EIO;
+ }
+
+ return seat_active_vt_changed(s, vtnr);
+}
+
+int seat_start(Seat *s) {
+ assert(s);
+
+ /* Initialize VT magic stuff */
+ seat_preallocate_vts(s);
+
+ /* Read current VT */
+ seat_read_active_vt(s);
+
+ /* Save seat data */
+ seat_save(s);
+
+ return 0;
+}
+
int seat_stop(Seat *s) {
Session *session;
- int r = 0;
+ int r = 0, k;
assert(s);
LIST_FOREACH(sessions_by_seat, session, s->sessions) {
- int k;
-
k = session_stop(session);
if (k < 0)
r = k;
}
+ seat_save(s);
+ seat_add_to_gc_queue(s);
+
return r;
}
+
+int seat_check_gc(Seat *s) {
+ assert(s);
+
+ if (s->manager->vtconsole == s)
+ return 1;
+
+ return !!s->devices;
+}
+
+void seat_add_to_gc_queue(Seat *s) {
+ assert(s);
+
+ if (s->in_gc_queue)
+ return;
+
+ LIST_PREPEND(Seat, gc_queue, s->manager->seat_gc_queue, s);
+ s->in_gc_queue = true;
+}
Session *active;
LIST_HEAD(Session, sessions);
+
+ bool in_gc_queue:1;
+
+ LIST_FIELDS(Seat, gc_queue);
};
Seat *seat_new(Manager *m, const char *id);
void seat_free(Seat *s);
-int seat_preallocate_vts(Seat *s);
-int seat_active_vt_changed(Seat *s, int vtnr);
-int seat_apply_acls(Seat *s, Session *old_active);
-int seat_stop(Seat *s);
+
int seat_save(Seat *s);
int seat_load(Seat *s);
+int seat_apply_acls(Seat *s, Session *old_active);
+int seat_active_vt_changed(Seat *s, int vtnr);
+int seat_read_active_vt(Seat *s);
+
+int seat_start(Seat *s);
+int seat_stop(Seat *s);
+
+int seat_check_gc(Seat *s);
+void seat_add_to_gc_queue(Seat *s);
+
#endif
assert(m);
assert(id);
- s = new(Session, 1);
+ s = new0(Session, 1);
if (!s)
return NULL;
s->pipe_fd = -1;
s->user = u;
- dual_timestamp_get(&s->timestamp);
+ LIST_PREPEND(Session, sessions_by_user, u->sessions, s);
return s;
}
void session_free(Session *s) {
assert(s);
+ if (s->in_gc_queue)
+ LIST_REMOVE(Session, gc_queue, s->manager->session_gc_queue, s);
+
if (s->user) {
LIST_REMOVE(Session, sessions_by_user, s->user->sessions, s);
hashmap_remove(s->manager->sessions, s->id);
- free(s->state_file);
+ if (s->state_file) {
+ unlink(s->state_file);
+ free(s->state_file);
+ }
+
free(s);
}
int session_save(Session *s) {
FILE *f;
int r = 0;
+ char *temp_path;
assert(s);
r = safe_mkdir("/run/systemd/session", 0755, 0, 0);
if (r < 0)
- return r;
+ goto finish;
- f = fopen(s->state_file, "we");
- if (!f)
- return -errno;
+ r = fopen_temporary(s->state_file, &f, &temp_path);
+ if (r < 0)
+ goto finish;
assert(s->user);
+ fchmod(fileno(f), 0644);
+
fprintf(f,
"# This is private data. Do not parse.\n"
"UID=%lu\n"
(unsigned long long) s->audit_id);
fflush(f);
- if (ferror(f)) {
+
+ if (ferror(f) || rename(temp_path, s->state_file) < 0) {
r = -errno;
unlink(s->state_file);
+ unlink(temp_path);
}
fclose(f);
+ free(temp_path);
+
+finish:
+ if (r < 0)
+ log_error("Failed to save session data for %s: %s", s->id, strerror(-r));
+
return r;
}
old_active = s->seat->active;
s->seat->active = s;
- seat_apply_acls(s->seat, old_active);
- manager_spawn_autovt(s->manager, s->vtnr);
-
- return 0;
+ return seat_apply_acls(s->seat, old_active);
}
bool x11_display_is_local(const char *display) {
assert(s);
assert(s->user);
- /* Create user first */
- r = user_start(s->user);
- if (r < 0)
- return r;
-
/* Create cgroup */
r = session_create_cgroup(s);
if (r < 0)
/* Create X11 symlink */
session_link_x11_socket(s);
+
+ /* Save session data */
+ session_save(s);
+
+ dual_timestamp_get(&s->timestamp);
+
return 0;
}
/* Remove X11 symlink */
session_unlink_x11_socket(s);
+ session_save(s);
+
return r;
}
if (r < 0)
return r;
- if (r <= 0)
+ if (r == 0)
return 1;
}
return 0;
}
+void session_add_to_gc_queue(Session *s) {
+ assert(s);
+
+ if (s->in_gc_queue)
+ return;
+
+ LIST_PREPEND(Session, gc_queue, s->manager->session_gc_queue, s);
+ s->in_gc_queue = true;
+}
+
static const char* const session_type_table[_SESSION_TYPE_MAX] = {
[SESSION_TERMINAL] = "terminal",
[SESSION_X11] = "x11"
char *cgroup_path;
char **controllers, **reset_controllers;
- bool kill_processes;
+ bool kill_processes:1;
+ bool in_gc_queue:1;
LIST_FIELDS(Session, sessions_by_user);
LIST_FIELDS(Session, sessions_by_seat);
+
+ LIST_FIELDS(Session, gc_queue);
};
Session *session_new(Manager *m, User *u, const char *id);
void session_free(Session *s);
+int session_check_gc(Session *s);
+void session_add_to_gc_queue(Session *s);
int session_activate(Session *s);
bool session_is_active(Session *s);
-int session_check_gc(Session *s);
int session_start(Session *s);
int session_stop(Session *s);
int session_save(Session *s);
assert(m);
assert(name);
- u = new(User, 1);
+ u = new0(User, 1);
if (!u)
return NULL;
void user_free(User *u) {
assert(u);
+ if (u->in_gc_queue)
+ LIST_REMOVE(User, gc_queue, u->manager->user_gc_queue, u);
+
while (u->sessions)
session_free(u->sessions);
hashmap_remove(u->manager->users, ULONG_TO_PTR((unsigned long) u->uid));
free(u->name);
- free(u->state_file);
+
+ if (u->state_file) {
+ unlink(u->state_file);
+ free(u->state_file);
+ }
+
free(u);
}
int user_save(User *u) {
FILE *f;
int r;
+ char *temp_path;
assert(u);
assert(u->state_file);
r = safe_mkdir("/run/systemd/user", 0755, 0, 0);
if (r < 0)
- return r;
+ goto finish;
- f = fopen(u->state_file, "we");
- if (!f)
- return -errno;
+ r = fopen_temporary(u->state_file, &f, &temp_path);
+ if (r < 0)
+ goto finish;
+
+ fchmod(fileno(f), 0644);
fprintf(f,
+ "# This is private data. Do not parse.\n"
"NAME=%s\n"
"STATE=%s\n",
u->name,
u->display->id);
fflush(f);
- if (ferror(f)) {
+
+ if (ferror(f) || rename(temp_path, u->state_file) < 0) {
r = -errno;
unlink(u->state_file);
+ unlink(temp_path);
}
fclose(f);
+ free(temp_path);
+
+finish:
+ if (r < 0)
+ log_error("Failed to save user data for %s: %s", u->name, strerror(-r));
+
return r;
}
if (r < 0)
return r;
+ /* Save new user data */
+ user_save(u);
+
dual_timestamp_get(&u->timestamp);
return 0;
return 0;
}
+void user_add_to_gc_queue(User *u) {
+ assert(u);
+
+ if (u->in_gc_queue)
+ return;
+
+ LIST_PREPEND(User, gc_queue, u->manager->user_gc_queue, u);
+ u->in_gc_queue = true;
+}
+
UserState user_get_state(User *u) {
Session *i;
dual_timestamp timestamp;
+ bool in_gc_queue:1;
+
LIST_HEAD(Session, sessions);
+ LIST_FIELDS(User, gc_queue);
};
User* user_new(Manager *m, uid_t uid, gid_t gid, const char *name);
void user_free(User *u);
+int user_check_gc(User *u);
+void user_add_to_gc_queue(User *u);
int user_start(User *u);
int user_stop(User *u);
-int user_check_gc(User *u);
UserState user_get_state(User *u);
int user_save(User *u);
int user_load(User *u);
int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user) {
User *u;
- int r;
assert(m);
assert(name);
if (!u)
return -ENOMEM;
- r = user_start(u);
- if (r < 0) {
- user_stop(u);
- user_free(u);
- } else {
- if (_user)
- *_user = u;
- }
+ if (_user)
+ *_user = u;
- return r;
+ return 0;
}
int manager_add_user_by_name(Manager *m, const char *name, User **_user) {
}
int manager_process_device(Manager *m, struct udev_device *d) {
- const char *sn;
- Seat *seat;
Device *device;
int r;
assert(m);
- sn = udev_device_get_property_value(d, "SEAT");
- if (!sn)
- sn = "seat0";
+ if (streq_ptr(udev_device_get_action(d), "remove")) {
- r = manager_add_device(m, udev_device_get_syspath(d), &device);
- if (r < 0)
- return r;
+ device = hashmap_get(m->devices, udev_device_get_syspath(d));
+ if (!device)
+ return 0;
- r = manager_add_seat(m, sn, &seat);
- if (r < 0)
- return r;
+ seat_add_to_gc_queue(device->seat);
+ device_free(device);
+
+ } else {
+ const char *sn;
+ Seat *seat;
+
+ sn = udev_device_get_property_value(d, "SEAT");
+ if (!sn)
+ sn = "seat0";
+
+ if (!startswith(sn, "seat"))
+ return -EINVAL;
+
+ r = manager_add_device(m, udev_device_get_syspath(d), &device);
+ if (r < 0)
+ return r;
+
+ r = manager_add_seat(m, sn, &seat);
+ if (r < 0) {
+ if (!device->seat)
+ device_free(device);
+
+ return r;
+ }
+
+ device_attach(device, seat);
+ }
- device_attach(device, seat);
return 0;
}
int manager_enumerate_devices(Manager *m) {
struct udev_list_entry *item = NULL, *first = NULL;
struct udev_enumerate *e;
- int r = -ENOMEM;
+ int r;
assert(m);
* necessary */
e = udev_enumerate_new(m->udev);
- if (!e)
+ if (!e) {
+ r = -ENOMEM;
goto finish;
+ }
- if (udev_enumerate_add_match_subsystem(e, "graphics") < 0)
+ r = udev_enumerate_add_match_subsystem(e, "graphics");
+ if (r < 0)
goto finish;
- if (udev_enumerate_add_match_tag(e, "seat") < 0)
+ r = udev_enumerate_add_match_tag(e, "seat");
+ if (r < 0)
goto finish;
- if (udev_enumerate_scan_devices(e) < 0)
+ r = udev_enumerate_scan_devices(e);
+ if (r < 0)
goto finish;
first = udev_enumerate_get_list_entry(e);
int k;
d = udev_device_new_from_syspath(m->udev, udev_list_entry_get_name(item));
- if (!d)
+ if (!d) {
+ r = -ENOMEM;
goto finish;
+ }
k = manager_process_device(m, d);
udev_device_unref(d);
if (!dirent_is_file(de))
continue;
+ if (!startswith(de->d_name, "seat"))
+ continue;
+
s = hashmap_get(m->seats, de->d_name);
if (!s) {
unlinkat(dirfd(d), de->d_name, 0);
while ((r = cg_read_subgroup(d, &name)) > 0) {
User *user;
+ int k;
+
+ k = manager_add_user_by_name(m, name, &user);
+ if (k < 0) {
+ free(name);
+ r = k;
+ continue;
+ }
+
+ user_add_to_gc_queue(user);
+
+ if (!user->cgroup_path)
+ if (asprintf(&user->cgroup_path, "%s/%s", m->cgroup_path, name) < 0) {
+ r = -ENOMEM;
+ free(name);
+ break;
+ }
- r = manager_add_user_by_name(m, name, &user);
free(name);
+ }
+
+ closedir(d);
+
+ return r;
+}
- if (r < 0)
- break;
- if (user->cgroup_path)
+static int manager_enumerate_linger_users(Manager *m) {
+ DIR *d;
+ struct dirent *de;
+ int r = 0;
+
+ d = opendir("/var/lib/systemd/linger");
+ if (!d) {
+ if (errno == ENOENT)
+ return 0;
+
+ log_error("Failed to open /var/lib/systemd/linger/: %m");
+ return -errno;
+ }
+
+ while ((de = readdir(d))) {
+ int k;
+
+ if (!dirent_is_file(de))
continue;
- if (asprintf(&user->cgroup_path, "%s/%s", m->cgroup_path, name) < 0) {
- r = -ENOMEM;
- break;
+ k = manager_add_user_by_name(m, de->d_name, NULL);
+ if (k < 0) {
+ log_notice("Couldn't add lingering user %s: %s", de->d_name, strerror(-k));
+ r = k;
}
}
- if (d)
- closedir(d);
+ closedir(d);
return r;
}
int manager_enumerate_users(Manager *m) {
DIR *d;
struct dirent *de;
- int r;
+ int r, k;
assert(m);
+ /* First, enumerate user cgroups */
r = manager_enumerate_users_from_cgroup(m);
+ /* Second, add lingering users on top */
+ k = manager_enumerate_linger_users(m);
+ if (k < 0)
+ r = k;
+
+ /* Third, read in user data stored on disk */
d = opendir("/run/systemd/users");
if (!d) {
if (errno == ENOENT)
while ((de = readdir(d))) {
unsigned long ul;
User *u;
- int k;
if (!dirent_is_file(de))
continue;
char *name;
int k;
+ if (!u->cgroup_path)
+ continue;
+
k = cg_enumerate_subgroups(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, &d);
if (k < 0) {
if (k == -ENOENT)
Session *session;
k = manager_add_session(m, u, name, &session);
- free(name);
-
- if (k < 0)
+ if (k < 0) {
+ free(name);
break;
+ }
- if (session->cgroup_path)
- continue;
+ session_add_to_gc_queue(session);
- if (asprintf(&session->cgroup_path, "%s/%s", u->cgroup_path, name) < 0) {
- k = -ENOMEM;
- break;
- }
+ if (!session->cgroup_path)
+ if (asprintf(&session->cgroup_path, "%s/%s", u->cgroup_path, name) < 0) {
+ k = -ENOMEM;
+ free(name);
+ break;
+ }
+
+ free(name);
}
closedir(d);
assert(m);
+ /* First enumerate session cgroups */
r = manager_enumerate_sessions_from_cgroup(m);
+ /* Second, read in session data stored on disk */
d = opendir("/run/systemd/sessions");
if (!d) {
if (errno == ENOENT)
return r;
}
-int manager_start_linger_users(Manager *m) {
- DIR *d;
- struct dirent *de;
- int r = 0;
-
- d = opendir("/var/lib/systemd/linger");
- if (!d) {
- if (errno == ENOENT)
- return 0;
-
- log_error("Failed to open /var/lib/systemd/linger/: %m");
- return -errno;
- }
-
- while ((de = readdir(d))) {
- int k;
-
- if (!dirent_is_file(de))
- continue;
-
- k = manager_add_user_by_name(m, de->d_name, NULL);
- if (k < 0) {
- log_notice("Couldn't add lingering user %s: %s", de->d_name, strerror(-k));
- r = k;
- }
- }
-
- closedir(d);
-
- return r;
-}
-
int manager_dispatch_udev(Manager *m) {
struct udev_device *d;
int r;
}
int manager_dispatch_console(Manager *m) {
- char t[64];
- ssize_t k;
- int r, vtnr;
-
assert(m);
- lseek(m->console_active_fd, SEEK_SET, 0);
-
- k = read(m->console_active_fd, t, sizeof(t)-1);
- if (k <= 0) {
- log_error("Failed to read current console: %s", k < 0 ? strerror(-errno) : "EOF");
- return k < 0 ? -errno : -EIO;
- }
-
- t[k] = 0;
- if (!startswith(t, "tty")) {
- log_error("Hm, /sys/class/tty/tty0/active is badly formatted.");
- return -EIO;
- }
-
- r = safe_atoi(t+3, &vtnr);
- if (r < 0) {
- log_error("Failed to parse VT number %s", t+3);
- return r;
- }
-
- if (vtnr <= 0) {
- log_error("VT number invalid: %s", t+3);
- return -EIO;
- }
-
if (m->vtconsole)
- seat_active_vt_changed(m->vtconsole, vtnr);
+ seat_read_active_vt(m->vtconsole);
return 0;
}
}
zero(ev);
- ev.events = EPOLLIN;
+ ev.events = 0;
ev.data.u32 = FD_CONSOLE;
if (epoll_ctl(m->epoll_fd, EPOLL_CTL_ADD, m->console_active_fd, &ev) < 0)
static int manager_connect_udev(Manager *m) {
struct epoll_event ev;
+ int r;
assert(m);
assert(!m->udev_monitor);
if (!m->udev_monitor)
return -ENOMEM;
- udev_monitor_filter_add_match_tag(m->udev_monitor, "seat");
+ r = udev_monitor_filter_add_match_tag(m->udev_monitor, "seat");
+ if (r < 0)
+ return r;
- if (udev_monitor_filter_add_match_subsystem_devtype(m->udev_monitor, "graphics", NULL) < 0)
- return -ENOMEM;
+ r = udev_monitor_filter_add_match_subsystem_devtype(m->udev_monitor, "graphics", NULL);
+ if (r < 0)
+ return r;
- if (udev_monitor_enable_receiving(m->udev_monitor) < 0)
- return -ENOMEM;
+ r = udev_monitor_enable_receiving(m->udev_monitor);
+ if (r < 0)
+ return r;
m->udev_fd = udev_monitor_get_fd(m->udev_monitor);
return 0;
}
+void manager_gc(Manager *m) {
+ Seat *seat;
+ Session *session;
+ User *user;
+
+ assert(m);
+
+ while ((seat = m->seat_gc_queue)) {
+ LIST_REMOVE(Seat, gc_queue, m->seat_gc_queue, seat);
+ seat->in_gc_queue = false;
+
+ if (seat_check_gc(seat) == 0) {
+ seat_stop(seat);
+ seat_free(seat);
+ }
+ }
+
+ while ((session = m->session_gc_queue)) {
+ LIST_REMOVE(Session, gc_queue, m->session_gc_queue, session);
+ session->in_gc_queue = false;
+
+ if (session_check_gc(session) == 0) {
+ session_stop(session);
+ session_free(session);
+ }
+ }
+
+ while ((user = m->user_gc_queue)) {
+ LIST_REMOVE(User, gc_queue, m->user_gc_queue, user);
+ user->in_gc_queue = false;
+
+ if (user_check_gc(user) == 0) {
+ user_stop(user);
+ user_free(user);
+ }
+ }
+}
+
int manager_startup(Manager *m) {
int r;
+ Seat *seat;
+ Session *session;
+ User *user;
+ Iterator i;
assert(m);
assert(m->epoll_fd <= 0);
if (r < 0)
return r;
+ /* Instantiate magic seat 0 */
+ r = manager_add_seat(m, "seat0", &m->vtconsole);
+ if (r < 0)
+ return r;
+
/* Deserialize state */
manager_enumerate_devices(m);
manager_enumerate_seats(m);
manager_enumerate_users(m);
manager_enumerate_sessions(m);
- /* Spawn lingering users */
- manager_start_linger_users(m);
+ /* Get rid of objects that are no longer used */
+ manager_gc(m);
+
+ /* And start everything */
+ HASHMAP_FOREACH(seat, m->seats, i)
+ seat_start(seat);
+
+ HASHMAP_FOREACH(user, m->users, i)
+ user_start(user);
+
+ HASHMAP_FOREACH(session, m->sessions, i)
+ session_start(session);
return 0;
}
struct epoll_event event;
int n;
+ manager_gc(m);
+
if (dbus_connection_dispatch(m->bus) != DBUS_DISPATCH_COMPLETE)
continue;
Hashmap *sessions;
Hashmap *users;
+ LIST_HEAD(Seat, seat_gc_queue);
+ LIST_HEAD(Session, session_gc_queue);
+ LIST_HEAD(User, user_gc_queue);
+
struct udev *udev;
struct udev_monitor *udev_monitor;
Manager *manager_new(void);
void manager_free(Manager *m);
+
int manager_add_device(Manager *m, const char *sysfs, Device **_device);
int manager_add_seat(Manager *m, const char *id, Seat **_seat);
int manager_add_session(Manager *m, User *u, const char *id, Session **_session);
int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user);
int manager_add_user_by_name(Manager *m, const char *name, User **_user);
int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user);
+
int manager_process_device(Manager *m, struct udev_device *d);
int manager_dispatch_udev(Manager *m);
int manager_dispatch_console(Manager *m);
+
int manager_enumerate_devices(Manager *m);
int manager_enumerate_seats(Manager *m);
int manager_enumerate_sessions(Manager *m);
int manager_enumerate_users(Manager *m);
-int manager_start_one_linger_user(Manager *m, const char *user);
-int manager_start_linger_users(Manager *m);
+
int manager_startup(Manager *m);
int manager_run(Manager *m);
int manager_spawn_autovt(Manager *m, int vtnr);
+void manager_gc(Manager *m);
+
bool x11_display_is_local(const char *display);
#endif
--- /dev/null
+<?xml version="1.0"?> <!--*-nxml-*-->
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
+<!--
+ This file is part of systemd.
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+-->
+
+<busconfig>
+
+ <policy user="root">
+ <allow own="org.freedesktop.login1"/>
+ <allow send_destination="org.freedesktop.login1"/>
+ <allow receive_sender="org.freedesktop.login1"/>
+ </policy>
+
+ <policy context="default">
+ <allow own="org.freedesktop.login1"/>
+ <allow send_destination="org.freedesktop.login1"/>
+ <allow receive_sender="org.freedesktop.login1"/>
+ </policy>
+
+</busconfig>