*s = (Seat) {
.manager = m,
+ .id = strdup(id),
+ .state_file = path_join("/run/systemd/seats/", id),
};
-
- s->state_file = path_join("/run/systemd/seats", id);
- if (!s->state_file)
+ if (!s->id || !s->state_file)
return -ENOMEM;
- s->id = basename(s->state_file);
-
r = hashmap_put(m->seats, s->id, s);
if (r < 0)
return r;
free(s->positions);
free(s->state_file);
+ free(s->id);
return mfree(s);
}
*s = (Session) {
.manager = m,
+ .id = strdup(id),
+ .state_file = path_join("/run/systemd/sessions/", id),
.fifo_fd = -EBADF,
.vtfd = -EBADF,
.audit_id = AUDIT_SESSION_INVALID,
.tty_validity = _TTY_VALIDITY_INVALID,
.leader = PIDREF_NULL,
};
-
- s->state_file = path_join("/run/systemd/sessions", id);
- if (!s->state_file)
+ if (!s->id || !s->state_file)
return -ENOMEM;
- s->id = basename(s->state_file);
-
s->devices = hashmap_new(&devt_hash_ops);
if (!s->devices)
return -ENOMEM;
if (!s)
return NULL;
+ sd_event_source_unref(s->stop_on_idle_event_source);
+
if (s->in_gc_queue)
LIST_REMOVE(gc_queue, s->manager->session_gc_queue, s);
- s->timer_event_source = sd_event_source_unref(s->timer_event_source);
+ sd_event_source_unref(s->timer_event_source);
session_drop_controller(s);
/* Note that we remove neither the state file nor the fifo path here, since we want both to survive
* daemon restarts */
- free(s->state_file);
free(s->fifo_path);
-
- sd_event_source_unref(s->stop_on_idle_event_source);
+ free(s->state_file);
+ free(s->id);
return mfree(s);
}