Index: src/bug-buddy.c
===================================================================
RCS file: /cvs/gnome/bug-buddy/src/bug-buddy.c,v
retrieving revision 1.139
diff -u -p -r1.139 bug-buddy.c
--- src/bug-buddy.c	4 Sep 2006 21:02:13 -0000	1.139
+++ src/bug-buddy.c	17 Oct 2006 13:19:22 -0000
@@ -31,6 +31,9 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
+#include <sys/utsname.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #include <errno.h>
 
@@ -41,7 +44,7 @@
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <libgnomecanvas/gnome-canvas-pixbuf.h>
 #include <libgnome/libgnometypebuiltins.h>
-
+#include <gdk/gdkx.h>
 
 #include <libxml/tree.h>
 #include <libxml/parser.h>
@@ -66,6 +69,7 @@
 #define USE_PROXY_AUTH	"/system/http_proxy/use_authentication"
 #define PROXY_USER	"/system/http_proxy/authentication_user"
 #define PROXY_PASSWORD	"/system/http_proxy/authentication_password"
+#define ACCESSIBILITY_KEY "/desktop/gnome/interface/accessibility"
 
 static GOptionData gopt_data;
 static int bug_count = 0;
@@ -1054,6 +1058,109 @@ fill_include_file (char *filename, Glade
 }
 
 
+static void
+fill_system_info (GladeXML *xml)
+{
+	GConfClient *gconf_client;
+	GtkTextView *text_view;
+	GtkTextIter end;
+	GtkTextBuffer *buffer;
+	GString *system_info;
+	struct utsname uts_buf;
+	char *str, *file;
+	gboolean has_selinux, enforcing, a11y;
+	gchar **lines;
+	int n_lines, i;
+	
+	g_return_if_fail (xml != NULL);
+	
+	system_info = g_string_new ("");
+
+	if (uname (&uts_buf) == 0) {
+		g_string_append_printf (system_info, "System: %s %s %s %s\n", uts_buf.sysname, uts_buf.release, uts_buf.version, uts_buf.machine);
+	}
+
+	/* X server checks */
+	g_string_append_printf (system_info, "X Vendor: %s\n", ServerVendor (gdk_display));
+	g_string_append_printf (system_info, "X Vendor Release: %d\n", VendorRelease (gdk_display));
+	
+	
+	/* Selinux checks */
+	has_selinux = FALSE;
+	if (g_file_get_contents ("/proc/filesystems", &str, NULL, NULL)) {
+		has_selinux = strstr (str, "selinuxfs") != NULL;
+		g_free (str);
+	}
+	if (has_selinux) {
+		enforcing = TRUE;
+		if (g_file_get_contents ("/selinux/enforce", &str, NULL, NULL)) {
+			enforcing = strcmp (str, "0") != 0;
+			g_free (str);
+		}
+		g_string_append_printf (system_info, "Selinux: %s\n", enforcing?"Enforcing":"Permissive");
+	} else {
+		g_string_append_printf (system_info, "Selinux: No\n");
+	}
+
+	gconf_client = gconf_client_get_default ();
+	a11y = gconf_client_get_bool (gconf_client, ACCESSIBILITY_KEY, NULL);
+	g_object_unref (gconf_client);
+	g_string_append_printf (system_info, "Accessibility: %s\n", a11y?"Enabled":"Disabled");
+
+	if (g_file_get_contents ("/proc/filesystems", &str, NULL, NULL)) {
+		has_selinux = strstr (str, "selinuxfs") != NULL;
+		g_free (str);
+	}
+	
+	/* .xsession-errors: read file */
+	file = g_build_filename (g_get_home_dir (), ".xsession-errors", NULL);
+	if (g_file_get_contents (file, &str, NULL, NULL)) {
+		lines = g_strsplit (str, "\n", -1);
+		g_free (str);
+		n_lines = 0;
+		while (lines[n_lines] != NULL)
+			n_lines++;
+
+		if (n_lines > 0) {
+			struct stat buf;
+			char *mtime_age = NULL;
+			time_t age = 0; 
+
+			
+			if (stat (file, &buf) == 0) {
+				age = time (NULL) - buf.st_mtime;
+				if (age > 5) {
+					mtime_age = g_strdup_printf (" (%d sec old)", age);
+				}
+			}
+				
+			g_string_append_printf (system_info,
+						"----------- .xsession-errors%s ---------------------\n",
+						mtime_age?mtime_age:"");
+			g_free (mtime_age);
+		}
+			
+		for (i = MAX (0, n_lines-16); i < n_lines; i++) {
+			if (lines[i][0] != 0)
+				g_string_append_printf (system_info, "%s\n", lines[i]);
+		}
+		if (n_lines > 0)
+			g_string_append (system_info, "--------------------------------------------------\n");
+		
+		g_strfreev (lines);
+	}
+	g_free (file);
+
+	g_string_append (system_info, "\n");
+	
+	text_view = GTK_TEXT_VIEW (glade_xml_get_widget (xml, "gdb-text"));
+	buffer = gtk_text_view_get_buffer (text_view);
+	gtk_text_buffer_get_end_iter (buffer, &end);
+	gtk_text_buffer_insert (buffer, &end, system_info->str, system_info->len);
+
+	g_string_free (system_info, TRUE);
+}
+
 
 int
 main (int argc, char *argv[])
@@ -1174,6 +1281,8 @@ main (int argc, char *argv[])
 		gtk_statusbar_push (GTK_STATUSBAR (statusbar),
 			    	    DEBUGGING, _("Collecting info from the crash..."));
 
+		fill_system_info (xml);
+		
 		fill_proccess_info (gopt_data.pid, xml);
 
 		if (gopt_data.pid > 0) {
