xserver: Branch 'master'

Jesse Barnes jbarnes at kemper.freedesktop.org
Tue Aug 18 12:16:53 PDT 2009


 hw/xfree86/os-support/linux/lnx_init.c |   38 ++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 17 deletions(-)

New commits:
commit d225230148b3cdab3b32fce3abee26b818d4bab0
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Tue Aug 18 12:15:32 2009 -0700

    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 at virtuousgeek.org>

diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index a49086b..6403007 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));
+	    }
         }
 
 	/*


More information about the xorg-commit mailing list