aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-09-06 18:48:27 +0000
committermarha <marha@users.sourceforge.net>2009-09-06 18:48:27 +0000
commita915739887477b28d924ecc8417ee107d125bd6c (patch)
treec02f315476b61892d1fd89182e18943dce8d6277 /xorg-server/hw/xfree86/os-support/linux/lnx_init.c
parent6f25a23db1df27e992c34f6fd4c82e83c44fc2e2 (diff)
downloadvcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.gz
vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.bz2
vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.zip
Switched to xorg-server-1.6.99.900.tar.gz
Diffstat (limited to 'xorg-server/hw/xfree86/os-support/linux/lnx_init.c')
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_init.c85
1 files changed, 27 insertions, 58 deletions
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
index 7f408573a..5a6db8081 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
@@ -39,12 +39,6 @@
#include <sys/stat.h>
-#ifdef USE_DEV_FB
-extern char *getenv(const char *);
-#include <linux/fb.h>
-char *fb_dev_name;
-#endif
-
static Bool KeepTty = FALSE;
static int VTnum = -1;
static Bool VTSwitch = TRUE;
@@ -80,9 +74,11 @@ saveVtPerms(void)
static void
restoreVtPerms(void)
{
- /* Set the terminal permissions back to before we started. */
- chown("/dev/tty0", vtPermSave[0], vtPermSave[1]);
- chown(vtname, vtPermSave[2], vtPermSave[3]);
+ 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;
@@ -100,10 +96,6 @@ xf86OpenConsole(void)
struct vt_mode VT;
struct vt_stat vts;
MessageType from = X_PROBED;
-#ifdef USE_DEV_FB
- struct fb_var_screeninfo var;
- int fbfd;
-#endif
char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
@@ -150,22 +142,6 @@ xf86OpenConsole(void)
close(fd);
}
-#ifdef USE_DEV_FB
- if (!ShareVTs)
- {
- fb_dev_name=getenv("FRAMEBUFFER");
- if (!fb_dev_name)
- fb_dev_name="/dev/fb0current";
-
- if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0)
- FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
- fb_dev_name, strerror(errno));
-
- if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var) < 0)
- FatalError("xf86OpenConsole: Unable to get screen info %s\n",
- strerror(errno));
- }
-#endif
xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
if (!KeepTty) {
@@ -210,20 +186,22 @@ xf86OpenConsole(void)
xf86Msg(X_WARNING,
"xf86OpenConsole: Could not save ownership of VT\n");
- /* 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));
+ 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));
+ }
}
/*
@@ -308,19 +286,7 @@ xf86OpenConsole(void)
/* we really should have a InitOSInputDevices() function instead
* of Init?$#*&Device(). So I just place it here */
-
-#ifdef USE_DEV_FB
- /* copy info to new console */
- var.yoffset=0;
- var.xoffset=0;
- if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var))
- FatalError("Unable to set screen info\n");
- close(fbfd);
-#endif
- } else { /* ShareVTs */
- close(xf86Info.consoleFd);
}
- signal(SIGUSR2, xf86ReloadInputDevs);
} else { /* serverGeneration != 1 */
if (!ShareVTs && VTSwitch)
{
@@ -340,7 +306,7 @@ xf86OpenConsole(void)
}
void
-xf86CloseConsole()
+xf86CloseConsole(void)
{
struct vt_mode VT;
#if defined(DO_OS_FONTRESTORE)
@@ -348,7 +314,10 @@ xf86CloseConsole()
int vtno = -1;
#endif
- if (ShareVTs) return;
+ if (ShareVTs) {
+ close(xf86Info.consoleFd);
+ return;
+ }
if (console_handler) {
xf86RemoveGeneralHandler(console_handler);
@@ -447,7 +416,7 @@ xf86ProcessArgument(int argc, char *argv[], int i)
}
void
-xf86UseMsg()
+xf86UseMsg(void)
{
ErrorF("vtXX use the specified VT number\n");
ErrorF("-keeptty ");