diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 71238ac9c4..3a0d16a74f 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -1291,8 +1291,7 @@ int vt_restore(int fd) { }; int r, q = 0; - r = ioctl(fd, KDSETMODE, KD_TEXT); - if (r < 0) + if (ioctl(fd, KDSETMODE, KD_TEXT) < 0) q = log_debug_errno(errno, "Failed to set VT in text mode, ignoring: %m"); r = vt_reset_keyboard(fd); @@ -1302,18 +1301,17 @@ int vt_restore(int fd) { q = r; } - r = ioctl(fd, VT_SETMODE, &mode); - if (r < 0) { + if (ioctl(fd, VT_SETMODE, &mode) < 0) { log_debug_errno(errno, "Failed to set VT_AUTO mode, ignoring: %m"); if (q >= 0) q = -errno; } - r = fchown(fd, 0, (gid_t) -1); + r = fchmod_and_chown(fd, TTY_MODE, 0, (gid_t) -1); if (r < 0) { - log_debug_errno(errno, "Failed to chown VT, ignoring: %m"); + log_debug_errno(r, "Failed to chmod()/chown() VT, ignoring: %m"); if (q >= 0) - q = -errno; + q = r; } return q; diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h index 90adc14d17..87d09f8759 100644 --- a/src/basic/terminal-util.h +++ b/src/basic/terminal-util.h @@ -163,3 +163,6 @@ int vt_restore(int fd); int vt_release(int fd, bool restore_vt); void get_log_colors(int priority, const char **on, const char **off, const char **highlight); + +/* This assumes there is a 'tty' group */ +#define TTY_MODE 0620 diff --git a/src/core/execute.c b/src/core/execute.c index ab2a4de37a..640efac295 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -97,9 +97,6 @@ #define IDLE_TIMEOUT_USEC (5*USEC_PER_SEC) #define IDLE_TIMEOUT2_USEC (1*USEC_PER_SEC) -/* This assumes there is a 'tty' group */ -#define TTY_MODE 0620 - #define SNDBUF_SIZE (8*1024*1024) static int shift_fds(int fds[], size_t n_fds) {