X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-session.c;h=8e6f95e6cd5f38f2469b8c0a3f7cab8eedb71b6c;hb=d9c67ea112724e271c39553d966eae612e272e34;hp=b4fd349f00cb7e4468d44227c18197adfee641d3;hpb=9541666b8d97f107335dd7e3cb93b4d2cfbf19c9;p=elogind.git diff --git a/src/login/logind-session.c b/src/login/logind-session.c index b4fd349f0..8e6f95e6c 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -963,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; @@ -972,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; @@ -1026,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); } @@ -1089,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; }