summaryrefslogtreecommitdiff
path: root/hw/xfree86/os-support/linux/lnx_init.c
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2009-08-18 12:15:32 -0700
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-08-18 12:15:32 -0700
commitd225230148b3cdab3b32fce3abee26b818d4bab0 (patch)
tree7d92479ab90c25f478826ab153e9b0217b715d46 /hw/xfree86/os-support/linux/lnx_init.c
parent41884b8f4dfe4d931c64a6046adfefcc2b7646c2 (diff)
xfree86/linux: don't change VT perms unless we're running as root
In non-setuid root installations, we shouldn't try to adjust VT/tty ownership. It will fail, and shouldn't be necessary anyway (since startup scripts or PAM should be handling perms for us in that case). Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'hw/xfree86/os-support/linux/lnx_init.c')
-rw-r--r--hw/xfree86/os-support/linux/lnx_init.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index a49086b37..64030072f 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -74,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;
@@ -184,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));
+ }
}
/*