Skip to content

Commit 16597ac

Browse files
committed
logind: minor clean-ups
1 parent 5b74816 commit 16597ac

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/login/logind-session.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,17 +1049,21 @@ int session_prepare_vt(Session *s) {
10491049
}
10501050

10511051
void session_restore_vt(Session *s) {
1052+
1053+
static const struct vt_mode mode = {
1054+
.mode = VT_AUTO,
1055+
};
1056+
10521057
_cleanup_free_ char *utf8 = NULL;
1053-
int vt, kb = K_XLATE;
1054-
struct vt_mode mode = { 0 };
1058+
int vt, kb, old_fd;
10551059

10561060
/* We need to get a fresh handle to the virtual terminal,
10571061
* since the old file-descriptor is potentially in a hung-up
10581062
* state after the controlling process exited; we do a
10591063
* little dance to avoid having the terminal be available
10601064
* for reuse before we've cleaned it up.
10611065
*/
1062-
int old_fd = s->vtfd;
1066+
old_fd = s->vtfd;
10631067
s->vtfd = -1;
10641068

10651069
vt = session_open_vt(s);
@@ -1072,13 +1076,13 @@ void session_restore_vt(Session *s) {
10721076

10731077
if (read_one_line_file("/sys/module/vt/parameters/default_utf8", &utf8) >= 0 && *utf8 == '1')
10741078
kb = K_UNICODE;
1079+
else
1080+
kb = K_XLATE;
10751081

10761082
(void) ioctl(vt, KDSKBMODE, kb);
10771083

1078-
mode.mode = VT_AUTO;
10791084
(void) ioctl(vt, VT_SETMODE, &mode);
1080-
1081-
fchown(vt, 0, -1);
1085+
(void) fchown(vt, 0, (gid_t) -1);
10821086

10831087
s->vtfd = safe_close(s->vtfd);
10841088
}

0 commit comments

Comments
 (0)