]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Only try and switch VTs when running as root
authorRobert Ancell <robert.ancell@canonical.com>
Thu, 14 Jul 2011 01:32:26 +0000 (11:32 +1000)
committerRobert Ancell <robert.ancell@canonical.com>
Thu, 14 Jul 2011 01:32:26 +0000 (11:32 +1000)
src/vt.c

index 40a2a67e37756d5e1b218d3fcd71b0714859eabb..e9f24c13926ac21bd5836d193bfcb6b112c812c1 100644 (file)
--- a/src/vt.c
+++ b/src/vt.c
@@ -28,7 +28,12 @@ static GList *used_vts = NULL;
 static gint
 open_console (void)
 {
-    int fd = g_open ("/dev/console", O_RDONLY | O_NOCTTY);
+    int fd;
+
+    if (getuid () != 0)
+        return -1;
+
+    fd = g_open ("/dev/console", O_RDONLY | O_NOCTTY);
     if (fd < 0)
         g_warning ("Error opening /dev/console: %s", strerror (errno));
     return fd;