[PATCH] NetworkManager dies if PPTP activation fails due to timeout



Hi,

When trying to establish a VPN connection using PPTP which times out,
NetworkManager gets killed. 

The reason is that pppd runs with the same process group ID as NetworkManager 
and the PPTP service. On timeouts, pppd gets the signal SIGTERM which is also 
sent to all other processes of this group.  Thus, both NetworkManager and the 
PPTP services get killed, too.

The following patch resolves this issue by setting the process group ID of the 
pppd process to its own process ID. I have attached two patches (one against 
HEAD and one against STABLE).

Perhaps this is interesting for other services like dialup too.

Regards
Helmut
Index: vpn-daemons/pptp/src/nm-ppp-starter.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/vpn-daemons/pptp/src/nm-ppp-starter.c,v
retrieving revision 1.14
diff -u -r1.14 nm-ppp-starter.c
--- vpn-daemons/pptp/src/nm-ppp-starter.c	30 Oct 2006 11:23:26 -0000	1.14
+++ vpn-daemons/pptp/src/nm-ppp-starter.c	23 Nov 2006 08:36:46 -0000
@@ -768,6 +768,19 @@
 }
 
 /*
+ * nm_pptp_child_setup
+ *
+ * Set the process group ID of the newly forked process
+ *
+ */
+void nm_pptp_child_setup (gpointer user_data G_GNUC_UNUSED)
+{
+  /* We are in the child process at this point */
+  pid_t pid = getpid ();
+  setpgid (pid, pid);
+}
+
+/*
  * nm_ppp_start_vpn_binary
  *
  * Start the ppp binary with a set of arguments and a config file.
@@ -832,7 +845,7 @@
     }
 
   if (!g_spawn_async_with_pipes (NULL, (char **) ppp_argv->pdata, NULL,
-				 G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, &stdin_fd,
+				 G_SPAWN_DO_NOT_REAP_CHILD, &nm_pptp_child_setup, NULL, &pid, &stdin_fd,
 				 NULL, NULL, &error))
     {
       g_ptr_array_foreach(free_later,(GFunc)g_free,NULL);
Index: vpn-daemons/pptp/src/nm-pptp-service.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/vpn-daemons/pptp/src/Attic/nm-pptp-service.c,v
retrieving revision 1.4.2.3
diff -u -r1.4.2.3 nm-pptp-service.c
--- vpn-daemons/pptp/src/nm-pptp-service.c	1 Nov 2006 16:33:27 -0000	1.4.2.3
+++ vpn-daemons/pptp/src/nm-pptp-service.c	23 Nov 2006 08:39:41 -0000
@@ -341,6 +341,18 @@
   nm_pptp_schedule_quit_timer (data, 10000);
 }
 
+/*
+ * nm_pptp_child_setup
+ *
+ * Set the process group ID of the newly forked process
+ *
+ */
+void nm_pptp_child_setup (gpointer user_data G_GNUC_UNUSED)
+{
+  /* We are in the child process here */
+  pid_t pid = getpid ();
+  setpgid (pid, pid);
+}
 
 /*
  * nm_pptp_start_vpn_binary
@@ -459,7 +471,7 @@
   g_ptr_array_add (pptp_argv, NULL);
 
   if (!g_spawn_async_with_pipes (NULL, (char **) pptp_argv->pdata, NULL,
-				 G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, &stdin_fd,
+				 G_SPAWN_DO_NOT_REAP_CHILD, &nm_pptp_child_setup, NULL, &pid, &stdin_fd,
 				 NULL, NULL, &error))
     {
       g_ptr_array_free (pptp_argv, TRUE);


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