Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce required permissions from /dev/tty0 to /dev/tty #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions inputdrivers/keyboard/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
}
Expand Down
10 changes: 5 additions & 5 deletions inputdrivers/linux_input/linux_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand All @@ -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" );
Expand Down Expand Up @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions systems/drmkms/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion systems/drmkms/vt.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <directfb.h>

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
Expand Down
8 changes: 4 additions & 4 deletions systems/fbdev/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion systems/fbdev/vt.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <directfb.h>

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
Expand Down
8 changes: 4 additions & 4 deletions systems/mesa/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion systems/mesa/vt.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <directfb.h>

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
Expand Down