[gnome-network][PATCH] Some bugs fixes



I have proposed a patch to fix two bugs:

* in netinfo when you launch a port scan and you try to exit tool while
a child process is still running, the tool doesn't exit cleanly.

* bug #114894 

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Carlos Garcia Campos a.k.a. KaL
   elkalmail yahoo es
   carlosgc gnome org
 Grupo Linups
   Usuarios de SL/Linux de la UPSAM
 http://www.linups.org
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=		  
PGP key: http://pgp.rediris.es:11371/pks/lookup?op=get&search=0x523E6462
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-network/gnome-netinfo/ChangeLog,v
retrieving revision 1.93
diff -u -u -r1.93 ChangeLog
--- ChangeLog	2 Oct 2003 21:26:16 -0000	1.93
+++ ChangeLog	26 Oct 2003 11:50:34 -0000
@@ -1,3 +1,12 @@
+2003-10-26  Carlos García Campos <carlosgc gnome org>
+
+	* callbacks.[ch] (gn_quit_app), gnome-netinfo.glade: 
+	  kill of all the children before exit
+	* netinfo.[ch] (validate_host): function to validate a host 
+	  fixes bug #114894
+	* ping.c (ping_do), scan.c (scan_do), traceroute.c (traceroute_do):
+	  validates the host before doing the action, fixes bug #114894
+	  
 2003-10-02  Carlos García Campos <carlosgc gnome org>
 
 	* netinfo.c (get_ip_version): added a function to get the 
Index: callbacks.c
===================================================================
RCS file: /cvs/gnome/gnome-network/gnome-netinfo/callbacks.c,v
retrieving revision 1.25
diff -u -u -r1.25 callbacks.c
--- callbacks.c	25 Aug 2003 15:54:37 -0000	1.25
+++ callbacks.c	26 Oct 2003 11:50:34 -0000
@@ -32,6 +32,10 @@
 #include "scan.h"
 #include "finger.h"
 
+#include "sys/wait.h"
+#include "unistd.h"
+#include "sys/types.h"
+
 /* Ping callbacks */
 void
 on_ping_activate (GtkWidget * widget, gpointer data)
@@ -136,6 +140,23 @@
 	} else {
 		finger_do (finger);
 	}
+}
+
+void
+gn_quit_app (GtkWidget * widget, gpointer data)
+{
+	gint status, pid;
+
+	pid = getpid () + 1;
+
+	while (waitpid (-1, &status, WNOHANG) == 0) {
+		if (waitpid (pid, &status, WNOHANG) == 0)
+			kill (pid, SIGKILL);
+		pid ++;
+	}
+
+	gtk_main_quit ();
+
 }
 
 void
Index: callbacks.h
===================================================================
RCS file: /cvs/gnome/gnome-network/gnome-netinfo/callbacks.h,v
retrieving revision 1.9
diff -u -u -r1.9 callbacks.h
--- callbacks.h	31 Jul 2003 20:34:40 -0000	1.9
+++ callbacks.h	26 Oct 2003 11:50:35 -0000
@@ -15,6 +15,8 @@
 void on_finger_activate (GtkWidget * editable, gpointer data);
 
 /* General stuff */
+void gn_quit_app (GtkWidget * widget, gpointer data);
+
 void on_about_activate (GtkWidget * parent, gpointer data);
 
 void on_copy_activate (GtkWidget * notebook, gpointer data);
Index: gnome-netinfo.glade
===================================================================
RCS file: /cvs/gnome/gnome-network/gnome-netinfo/gnome-netinfo.glade,v
retrieving revision 1.26
diff -u -u -r1.26 gnome-netinfo.glade
--- gnome-netinfo.glade	31 Jul 2003 20:34:40 -0000	1.26
+++ gnome-netinfo.glade	26 Oct 2003 11:50:35 -0000
@@ -14,7 +14,7 @@
   <property name="default_height">490</property>
   <property name="resizable">True</property>
   <property name="destroy_with_parent">False</property>
-  <signal name="delete_event" handler="gtk_main_quit" last_modification_time="Mon, 09 Dec 2002 02:18:33 GMT"/>
+  <signal name="delete_event" handler="gn_quit_app" last_modification_time="Sun, 26 Oct 2003 10:04:54 GMT"/>
 
   <child>
     <widget class="GtkVBox" id="vbox_main">
@@ -38,7 +38,7 @@
 		    <widget class="GtkImageMenuItem" id="m_quit">
 		      <property name="visible">True</property>
 		      <property name="stock_item">GNOMEUIINFO_MENU_EXIT_ITEM</property>
-		      <signal name="activate" handler="gtk_main_quit" last_modification_time="Mon, 07 Jul 2003 12:37:48 GMT"/>
+		      <signal name="activate" handler="gn_quit_app" last_modification_time="Sun, 26 Oct 2003 10:05:12 GMT"/>
 		    </widget>
 		  </child>
 		</widget>
@@ -58,7 +58,7 @@
 		    <widget class="GtkImageMenuItem" id="m_copy">
 		      <property name="visible">True</property>
 		      <property name="stock_item">GNOMEUIINFO_MENU_COPY_ITEM</property>
-		      <signal name="activate" handler="on_copy_activate" object="notebook" last_modification_time="Sun, 20 Jul 2003 22:11:25 GMT"/>
+		      <signal name="activate" handler="on_copy_activate" last_modification_time="Sun, 20 Jul 2003 22:11:25 GMT"/>
 		    </widget>
 		  </child>
 		</widget>
@@ -78,7 +78,7 @@
 		    <widget class="GtkImageMenuItem" id="m_about">
 		      <property name="visible">True</property>
 		      <property name="stock_item">GNOMEUIINFO_MENU_ABOUT_ITEM</property>
-		      <signal name="activate" handler="on_about_activate" object="main_window" last_modification_time="Sun, 20 Jul 2003 20:50:30 GMT"/>
+		      <signal name="activate" handler="on_about_activate" last_modification_time="Sun, 20 Jul 2003 20:50:30 GMT"/>
 		    </widget>
 		  </child>
 		</widget>
Index: netinfo.c
===================================================================
RCS file: /cvs/gnome/gnome-network/gnome-netinfo/netinfo.c,v
retrieving revision 1.14
diff -u -u -r1.14 netinfo.c
--- netinfo.c	2 Oct 2003 21:26:16 -0000	1.14
+++ netinfo.c	26 Oct 2003 11:50:35 -0000
@@ -120,6 +120,27 @@
 	return -1;
 }
 
+gboolean
+netinfo_validate_host (Netinfo * netinfo)
+{
+	struct hostent *hostname;
+	const gchar *host;
+
+	host = netinfo_get_host (netinfo);
+
+	hostname = gethostbyname2 (host, PF_INET6);
+	if (hostname == NULL) {
+		hostname = gethostbyname2 (host, AF_INET);
+		if (hostname == NULL) {
+			gnome_error_dialog_parented (_("The host cannot be found."),
+						     NULL);
+			return FALSE;
+		}
+	}
+
+	return TRUE;
+}
+
 void
 netinfo_process_command (Netinfo * netinfo)
 {
Index: netinfo.h
===================================================================
RCS file: /cvs/gnome/gnome-network/gnome-netinfo/netinfo.h,v
retrieving revision 1.14
diff -u -u -r1.14 netinfo.h
--- netinfo.h	2 Oct 2003 21:26:16 -0000	1.14
+++ netinfo.h	26 Oct 2003 11:50:35 -0000
@@ -116,6 +116,7 @@
 const gchar * netinfo_get_host (Netinfo * netinfo);
 const gchar * netinfo_get_user (Netinfo * netinfo);
 gint netinfo_get_ip_version (Netinfo * netinfo);
+gboolean netinfo_validate_host (Netinfo * netinfo);
 void netinfo_toggle_button (Netinfo * netinfo);
 void netinfo_toggle_state (Netinfo * netinfo, gboolean state,
 			   gpointer user_data);
Index: ping.c
===================================================================
RCS file: /cvs/gnome/gnome-network/gnome-netinfo/ping.c,v
retrieving revision 1.20
diff -u -u -r1.20 ping.c
--- ping.c	2 Oct 2003 21:26:16 -0000	1.20
+++ ping.c	26 Oct 2003 11:50:35 -0000
@@ -63,6 +63,11 @@
 
 	g_return_if_fail (netinfo != NULL);
 
+	if (netinfo_validate_host (netinfo) == FALSE) {
+		netinfo_stop_process_command (netinfo);
+		return;
+	}
+
 	count = netinfo_get_count (netinfo);
 	host = netinfo_get_host (netinfo);
 
Index: scan.c
===================================================================
RCS file: /cvs/gnome/gnome-network/gnome-netinfo/scan.c,v
retrieving revision 1.6
diff -u -u -r1.6 scan.c
--- scan.c	2 Oct 2003 21:26:16 -0000	1.6
+++ scan.c	26 Oct 2003 11:50:35 -0000
@@ -67,6 +67,11 @@
 
 	g_return_if_fail (netinfo != NULL);
 
+	if (netinfo_validate_host (netinfo) == FALSE) {
+		netinfo_stop_process_command (netinfo);
+		return;
+	}
+
 	host = netinfo_get_host (netinfo);
 
 	/* Clear the current output */
Index: traceroute.c
===================================================================
RCS file: /cvs/gnome/gnome-network/gnome-netinfo/traceroute.c,v
retrieving revision 1.17
diff -u -u -r1.17 traceroute.c
--- traceroute.c	2 Oct 2003 21:26:16 -0000	1.17
+++ traceroute.c	26 Oct 2003 11:50:35 -0000
@@ -47,6 +47,11 @@
         
 	g_return_if_fail (netinfo != NULL);
 
+	if (netinfo_validate_host (netinfo) == FALSE) {
+		netinfo_stop_process_command (netinfo);
+		return;
+	}
+
 	host = netinfo_get_host (netinfo);
 
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (netinfo->output));

Attachment: signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente



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