[gnome-terminal] server: Don't allow running the server as non-user



commit 1244dbb6f0381cedfd9247c1d7cc91b55476d708
Author: Christian Persch <chpe gnome org>
Date:   Thu Sep 12 19:42:08 2013 +0200

    server: Don't allow running the server as non-user
    
    It just doesn't work to run it as root/under su/under sudo, so make it just
    error out already.

 src/server.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/server.c b/src/server.c
index 4e6013b..d7ebedb 100644
--- a/src/server.c
+++ b/src/server.c
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include <unistd.h>
+#include <sys/types.h>
 
 #include <glib.h>
 #include <glib/gi18n.h>
@@ -71,6 +72,14 @@ main (int argc, char **argv)
   const char *home_dir;
   GError *error = NULL;
 
+  if (G_UNLIKELY (getuid () != geteuid () ||
+                  getgid () != getegid () ||
+                  geteuid () == 0 || 
+                  getegid () == 0)) {
+    g_printerr ("Wrong euid/egid, exiting.\n");
+    return EXIT_FAILURE;
+  }
+
   setlocale (LC_ALL, "");
 
   terminal_i18n_init (TRUE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]