Bug #60014 Fix



Attached is a patch for gnome-terminal, addressing the lack of an error
message when the SHELL environment variable is set to "" (either by
being clobbered, or by having no shell specified in /etc/passwd).  It is
against the current 1.4 CVS as of right about the time of this message.

I thought about changing the pty error function into a generic error
function that could be used for the next bug we find, but I didn't want
to take on to much for my first bugfix!

If someone could commit this for me, I'd greatly appreciate it!

So do I set the bug to FIXED now? ;)


--- gnome-terminal.c	Thu Sep 13 17:53:02 2001
+++ /root/gnome-terminal.c	Thu Sep 13 17:51:38 2001
@@ -2156,6 +2156,36 @@
 		gtk_widget_queue_draw(widget);
 }
 
+/* do this because gnome-terminal doesn't like an empty SHELL var  */
+static void
+show_shell_error_dialog (int errcode)
+{
+	char *tmpmsg, *errmsg;
+	GtkWidget *dialog;
+
+	perror ("Error: unable to fork");
+
+	tmpmsg = errcode ? 
+		g_strdup_printf(_("The error was: %s"), g_strerror(errcode)) : 
+		_("If the SHELL environment variable is empty, or\n"
+		  "there is no specified in the passwd file for your user,\n"
+		  "one of these problems need to be corrected for the\n"
+		  "to run."); 
+	
+	errmsg =  g_strdup_printf(_("There has been an error while "
+				    "trying to log in.\n\n%s"), tmpmsg);
+	
+	
+	dialog = gnome_message_box_new (errmsg,
+					GNOME_MESSAGE_BOX_ERROR,
+					GNOME_STOCK_BUTTON_OK, NULL);
+							
+	gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
+
+	if (errcode) g_free(tmpmsg);
+	g_free(errmsg);
+}
+
 /* do this because there have been only 5 bug reports about this */
 static void
 show_pty_error_dialog (int errcode)
@@ -2340,6 +2370,14 @@
 
 	gtk_widget_show (hbox);
 	get_shell_name (&shell, &name, cfg->invoke_as_login_shell);
+	errno = 0;
+	if(!strlen(shell) > 0) {
+		show_shell_error_dialog(errno);
+		g_free (shell);
+		g_free (name);
+		
+		return NULL;
+	}
 
 	scrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (term->adjustment));
 	gtk_object_set_data (GTK_OBJECT (term), "scrollbar", scrollbar);


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