From 06b0afb4af23671362d94ab1fe7f38b6bf04e664 Mon Sep 17 00:00:00 2001 From: Marius van Voorden Date: Sat, 9 Jul 2022 12:53:39 +0200 Subject: [PATCH] Reduce required permissions from /dev/tty0 to /dev/tty --- inputdrivers/keyboard/keyboard.c | 6 +++--- inputdrivers/linux_input/linux_input.c | 10 +++++----- systems/drmkms/vt.c | 8 ++++---- systems/drmkms/vt.h | 2 +- systems/fbdev/vt.c | 8 ++++---- systems/fbdev/vt.h | 2 +- systems/mesa/vt.c | 8 ++++---- systems/mesa/vt.h | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/inputdrivers/keyboard/keyboard.c b/inputdrivers/keyboard/keyboard.c index 8d4dab7ba..11253ea91 100644 --- a/inputdrivers/keyboard/keyboard.c +++ b/inputdrivers/keyboard/keyboard.c @@ -345,7 +345,7 @@ driver_get_available( void ) return 0; } - fd = open( "/dev/tty0", O_RDWR | O_NOCTTY ); + fd = open( "/dev/tty", O_RDWR | O_NOCTTY ); if (fd < 0) return 0; @@ -389,9 +389,9 @@ driver_open_device( CoreInputDevice *device, } } else { - fd = open( "/dev/tty0", O_RDWR | O_NOCTTY ); + fd = open( "/dev/tty", O_RDWR | O_NOCTTY ); if (fd < 0) { - D_PERROR( "DirectFB/Keyboard: Could not open() /dev/tty0!\n" ); + D_PERROR( "DirectFB/Keyboard: Could not open() /dev/tty!\n" ); return DFB_INIT; } } diff --git a/inputdrivers/linux_input/linux_input.c b/inputdrivers/linux_input/linux_input.c index 7e9a6ad05..7da9a02bf 100644 --- a/inputdrivers/linux_input/linux_input.c +++ b/inputdrivers/linux_input/linux_input.c @@ -1266,7 +1266,7 @@ driver_get_available( void ) D_ASSERT( dfb_fbdev ); // Only allow USB keyboard and mouse support if the systems driver has - // the Virtual Terminal file ("/dev/tty0") open and available for use. + // the Virtual Terminal file ("/dev/tty") open and available for use. // FIXME: Additional logic needed for system drivers not similar to fbdev? if (!dfb_fbdev->vt || dfb_fbdev->vt->fd < 0) return 0; @@ -1466,7 +1466,7 @@ is_created( int index, void *data) * provider if the Virtual Terminal was opened for use by the systems driver. * * Note: The systems driver will open the Virtual Terminal file - * ("/dev/tty0") based on the directfbrc commands "vt" and "no-vt". + * ("/dev/tty") based on the directfbrc commands "vt" and "no-vt". */ static InputDriverCapability get_capability( void ) @@ -1483,7 +1483,7 @@ get_capability( void ) D_ASSERT( dfb_fbdev ); // Only allow USB keyboard and mouse support if the systems driver has - // the Virtual Terminal file ("/dev/tty0") open and available for use. + // the Virtual Terminal file ("/dev/tty") open and available for use. // FIXME: Additional logic needed for system drivers not similar to fbdev? if (!dfb_fbdev->vt || dfb_fbdev->vt->fd < 0) { D_DEBUG_AT( Debug_LinuxInput, " -> no VT\n" ); @@ -1865,10 +1865,10 @@ driver_open_device( CoreInputDevice *device, data->vt_fd = dup( dfb_fbdev->vt->fd ); } if (data->vt_fd < 0) - data->vt_fd = open( "/dev/tty0", O_RDWR | O_NOCTTY ); + data->vt_fd = open( "/dev/tty", O_RDWR | O_NOCTTY ); if (data->vt_fd < 0) - D_WARN( "no keymap support (requires /dev/tty0 - CONFIG_VT)" ); + D_WARN( "no keymap support (requires /dev/tty - CONFIG_VT)" ); } /* check if the device has LEDs */ diff --git a/systems/drmkms/vt.c b/systems/drmkms/vt.c index 188f0b69d..fab196e31 100644 --- a/systems/drmkms/vt.c +++ b/systems/drmkms/vt.c @@ -114,14 +114,14 @@ dfb_vt_initialize( void ) return D_OOM(); setsid(); - dfb_vt->fd0 = open( "/dev/tty0", O_RDONLY | O_NOCTTY ); + dfb_vt->fd0 = open( "/dev/tty", O_RDONLY | O_NOCTTY ); if (dfb_vt->fd0 < 0) { if (errno == ENOENT) { dfb_vt->fd0 = open( "/dev/vc/0", O_RDONLY | O_NOCTTY ); if (dfb_vt->fd0 < 0) { if (errno == ENOENT) { D_PERROR( "DirectFB/core/vt: Couldn't open " - "neither `/dev/tty0' nor `/dev/vc/0'!\n" ); + "neither `/dev/tty' nor `/dev/vc/0'!\n" ); } else { D_PERROR( "DirectFB/core/vt: " @@ -135,7 +135,7 @@ dfb_vt_initialize( void ) } } else { - D_PERROR( "DirectFB/core/vt: Error opening `/dev/tty0'!\n"); + D_PERROR( "DirectFB/core/vt: Error opening `/dev/tty'!\n"); D_FREE( dfb_vt ); dfb_vt = NULL; @@ -322,7 +322,7 @@ dfb_vt_shutdown( bool emergency ) if (close( dfb_vt->fd0 ) < 0) D_PERROR( "DirectFB/core/vt: Unable to " - "close file descriptor of tty0!\n" ); + "close file descriptor of tty!\n" ); D_FREE( dfb_vt ); dfb_vt = m_data->vt = NULL; diff --git a/systems/drmkms/vt.h b/systems/drmkms/vt.h index 1e2c65c32..f93601774 100644 --- a/systems/drmkms/vt.h +++ b/systems/drmkms/vt.h @@ -41,7 +41,7 @@ #include typedef struct { - int fd0; /* file descriptor of /dev/tty0 */ + int fd0; /* file descriptor of /dev/tty */ int fd; /* file descriptor of /dev/ttyN where N is the number of the allocated VT, may be equal to 'fd0' if VT allocation diff --git a/systems/fbdev/vt.c b/systems/fbdev/vt.c index e5cc7e183..f5b99c36e 100644 --- a/systems/fbdev/vt.c +++ b/systems/fbdev/vt.c @@ -117,14 +117,14 @@ dfb_vt_initialize( void ) return D_OOM(); setsid(); - dfb_vt->fd0 = open( "/dev/tty0", O_RDONLY | O_NOCTTY ); + dfb_vt->fd0 = open( "/dev/tty", O_RDONLY | O_NOCTTY ); if (dfb_vt->fd0 < 0) { if (errno == ENOENT) { dfb_vt->fd0 = open( "/dev/vc/0", O_RDONLY | O_NOCTTY ); if (dfb_vt->fd0 < 0) { if (errno == ENOENT) { D_PERROR( "DirectFB/core/vt: Couldn't open " - "neither `/dev/tty0' nor `/dev/vc/0'!\n" ); + "neither `/dev/tty' nor `/dev/vc/0'!\n" ); } else { D_PERROR( "DirectFB/core/vt: " @@ -138,7 +138,7 @@ dfb_vt_initialize( void ) } } else { - D_PERROR( "DirectFB/core/vt: Error opening `/dev/tty0'!\n"); + D_PERROR( "DirectFB/core/vt: Error opening `/dev/tty'!\n"); D_FREE( dfb_vt ); dfb_vt = NULL; @@ -326,7 +326,7 @@ dfb_vt_shutdown( bool emergency ) if (close( dfb_vt->fd0 ) < 0) D_PERROR( "DirectFB/core/vt: Unable to " - "close file descriptor of tty0!\n" ); + "close file descriptor of tty!\n" ); D_FREE( dfb_vt ); dfb_vt = dfb_fbdev->vt = NULL; diff --git a/systems/fbdev/vt.h b/systems/fbdev/vt.h index 1e2c65c32..f93601774 100644 --- a/systems/fbdev/vt.h +++ b/systems/fbdev/vt.h @@ -41,7 +41,7 @@ #include typedef struct { - int fd0; /* file descriptor of /dev/tty0 */ + int fd0; /* file descriptor of /dev/tty */ int fd; /* file descriptor of /dev/ttyN where N is the number of the allocated VT, may be equal to 'fd0' if VT allocation diff --git a/systems/mesa/vt.c b/systems/mesa/vt.c index ed70bd79a..13299006a 100644 --- a/systems/mesa/vt.c +++ b/systems/mesa/vt.c @@ -114,14 +114,14 @@ dfb_vt_initialize( void ) return D_OOM(); setsid(); - dfb_vt->fd0 = open( "/dev/tty0", O_RDONLY | O_NOCTTY ); + dfb_vt->fd0 = open( "/dev/tty", O_RDONLY | O_NOCTTY ); if (dfb_vt->fd0 < 0) { if (errno == ENOENT) { dfb_vt->fd0 = open( "/dev/vc/0", O_RDONLY | O_NOCTTY ); if (dfb_vt->fd0 < 0) { if (errno == ENOENT) { D_PERROR( "DirectFB/core/vt: Couldn't open " - "neither `/dev/tty0' nor `/dev/vc/0'!\n" ); + "neither `/dev/tty' nor `/dev/vc/0'!\n" ); } else { D_PERROR( "DirectFB/core/vt: " @@ -135,7 +135,7 @@ dfb_vt_initialize( void ) } } else { - D_PERROR( "DirectFB/core/vt: Error opening `/dev/tty0'!\n"); + D_PERROR( "DirectFB/core/vt: Error opening `/dev/tty'!\n"); D_FREE( dfb_vt ); dfb_vt = NULL; @@ -322,7 +322,7 @@ dfb_vt_shutdown( bool emergency ) if (close( dfb_vt->fd0 ) < 0) D_PERROR( "DirectFB/core/vt: Unable to " - "close file descriptor of tty0!\n" ); + "close file descriptor of tty!\n" ); D_FREE( dfb_vt ); dfb_vt = m_data->vt = NULL; diff --git a/systems/mesa/vt.h b/systems/mesa/vt.h index 1e2c65c32..f93601774 100644 --- a/systems/mesa/vt.h +++ b/systems/mesa/vt.h @@ -41,7 +41,7 @@ #include typedef struct { - int fd0; /* file descriptor of /dev/tty0 */ + int fd0; /* file descriptor of /dev/tty */ int fd; /* file descriptor of /dev/ttyN where N is the number of the allocated VT, may be equal to 'fd0' if VT allocation