summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-21 19:36:22 +0200
committerSven Eden <yamakuzure@gmx.net>2017-04-26 12:58:55 +0200
commit5382831207810d62db22b6c87f35f73ddfb30b23 (patch)
treed1615cc7f9e7f6ca0bb16f2707b0279b49498fb8 /src
parent8b89c78c709c597c8838095ff33845ffa7b1f268 (diff)
logind: minor clean-ups
Diffstat (limited to 'src')
-rw-r--r--src/login/logind-session.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index ca1ea5868..9cde4cc68 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -1154,9 +1154,13 @@ error:
}
void session_restore_vt(Session *s) {
+
+ static const struct vt_mode mode = {
+ .mode = VT_AUTO,
+ };
+
_cleanup_free_ char *utf8 = NULL;
- int vt, kb = K_XLATE;
- struct vt_mode mode = { 0 };
+ int vt, kb, old_fd;
/* We need to get a fresh handle to the virtual terminal,
* since the old file-descriptor is potentially in a hung-up
@@ -1164,7 +1168,7 @@ void session_restore_vt(Session *s) {
* little dance to avoid having the terminal be available
* for reuse before we've cleaned it up.
*/
- int old_fd = s->vtfd;
+ old_fd = s->vtfd;
s->vtfd = -1;
vt = session_open_vt(s);
@@ -1177,13 +1181,13 @@ void session_restore_vt(Session *s) {
if (read_one_line_file("/sys/module/vt/parameters/default_utf8", &utf8) >= 0 && *utf8 == '1')
kb = K_UNICODE;
+ else
+ kb = K_XLATE;
(void) ioctl(vt, KDSKBMODE, kb);
- mode.mode = VT_AUTO;
(void) ioctl(vt, VT_SETMODE, &mode);
-
- fchown(vt, 0, -1);
+ (void) fchown(vt, 0, (gid_t) -1);
s->vtfd = safe_close(s->vtfd);
}