chiark / gitweb /
login: rename session_mute_vt() to session_prepare_vt()
[elogind.git] / src / login / logind-session.c
index 8c517f46a751ca044853676ba20e289f9129f72c..8e6f95e6cd5f38f2469b8c0a3f7cab8eedb71b6c 100644 (file)
@@ -682,7 +682,11 @@ void session_release(Session *s) {
                 return;
 
         if (!s->timer_event_source)
-                sd_event_add_monotonic(s->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + RELEASE_USEC, 0, release_timeout_callback, s);
+                sd_event_add_time(s->manager->event,
+                                  &s->timer_event_source,
+                                  CLOCK_MONOTONIC,
+                                  now(CLOCK_MONOTONIC) + RELEASE_USEC, 0,
+                                  release_timeout_callback, s);
 }
 
 bool session_is_active(Session *s) {
@@ -959,7 +963,7 @@ static int session_vt_fn(sd_event_source *source, const struct signalfd_siginfo
         return 0;
 }
 
-void session_mute_vt(Session *s) {
+void session_prepare_vt(Session *s) {
         int vt, r;
         struct vt_mode mode = { 0 };
         sigset_t mask;
@@ -968,6 +972,10 @@ void session_mute_vt(Session *s) {
         if (vt < 0)
                 return;
 
+        r = fchown(vt, s->user->uid, -1);
+        if (r < 0)
+                goto error;
+
         r = ioctl(vt, KDSKBMODE, K_OFF);
         if (r < 0)
                 goto error;
@@ -1022,6 +1030,8 @@ void session_restore_vt(Session *s) {
         mode.mode = VT_AUTO;
         ioctl(vt, VT_SETMODE, &mode);
 
+        fchown(vt, 0, -1);
+
         s->vtfd = safe_close(s->vtfd);
 }
 
@@ -1085,7 +1095,7 @@ int session_set_controller(Session *s, const char *sender, bool force) {
          * exits.
          * If logind crashes/restarts, we restore the controller during restart
          * or reset the VT in case it crashed/exited, too. */
-        session_mute_vt(s);
+        session_prepare_vt(s);
 
         return 0;
 }
@@ -1113,6 +1123,7 @@ static const char* const session_type_table[_SESSION_TYPE_MAX] = {
         [SESSION_TTY] = "tty",
         [SESSION_X11] = "x11",
         [SESSION_WAYLAND] = "wayland",
+        [SESSION_MIR] = "mir",
 };
 
 DEFINE_STRING_TABLE_LOOKUP(session_type, SessionType);