[PATCH 3/6] linux: Don't muck about with tty permissions
Adam Jackson
ajax at redhat.com
Tue Aug 24 14:05:22 PDT 2010
This is not X's job.
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
hw/xfree86/os-support/linux/lnx_init.c | 62 --------------------------------
1 files changed, 0 insertions(+), 62 deletions(-)
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index a5bd4bb..0762dca 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -43,42 +43,10 @@ static Bool VTSwitch = TRUE;
static Bool ShareVTs = FALSE;
static int activeVT = -1;
-static int vtPermSave[4];
static char vtname[11];
static struct termios tty_attr; /* tty state to restore */
static int tty_mode; /* kbd mode to restore */
-static int
-saveVtPerms(void)
-{
- /* We need to use stat to get permissions. */
- struct stat svtp;
-
- /* Do them numerically ordered, hard coded tty0 first. */
- if (stat("/dev/tty0", &svtp) != 0)
- return 0;
- vtPermSave[0] = (int)svtp.st_uid;
- vtPermSave[1] = (int)svtp.st_gid;
-
- /* Now check the console we are dealing with. */
- if (stat(vtname, &svtp) != 0)
- return 0;
- vtPermSave[2] = (int)svtp.st_uid;
- vtPermSave[3] = (int)svtp.st_gid;
-
- return 1;
-}
-
-static void
-restoreVtPerms(void)
-{
- if (geteuid() == 0) {
- /* Set the terminal permissions back to before we started. */
- (void)chown("/dev/tty0", vtPermSave[0], vtPermSave[1]);
- (void)chown(vtname, vtPermSave[2], vtPermSave[3]);
- }
-}
-
static void *console_handler;
static void
@@ -173,34 +141,6 @@ xf86OpenConsole(void)
FatalError("xf86OpenConsole: Cannot open virtual console"
" %d (%s)\n", xf86Info.vtno, strerror(errno));
- if (!ShareVTs)
- {
- /*
- * Grab the vt ownership before we overwrite it.
- * Hard coded /dev/tty0 into this function as well for below.
- */
- if (!saveVtPerms())
- xf86Msg(X_WARNING,
- "xf86OpenConsole: Could not save ownership of VT\n");
-
- if (geteuid() == 0) {
- /* change ownership of the vt */
- if (chown(vtname, getuid(), getgid()) < 0)
- xf86Msg(X_WARNING,"xf86OpenConsole: chown %s failed: %s\n",
- vtname, strerror(errno));
-
- /*
- * the current VT device we're running on is not
- * "console", we want to grab all consoles too
- *
- * Why is this needed??
- */
- if (chown("/dev/tty0", getuid(), getgid()) < 0)
- xf86Msg(X_WARNING,"xf86OpenConsole: chown /dev/tty0 failed: %s\n",
- strerror(errno));
- }
- }
-
/*
* Linux doesn't switch to an active vt after the last close of a vt,
* so we do this ourselves by remembering which is active now.
@@ -349,8 +289,6 @@ xf86CloseConsole(void)
}
}
close(xf86Info.consoleFd); /* make the vt-manager happy */
-
- restoreVtPerms(); /* restore the permissions */
}
int
--
1.7.2.1
More information about the xorg-devel
mailing list