Commit 34847cc7 authored by Nathan Dorfman's avatar Nathan Dorfman

ipsec: don't forget to clean up tunnel when finished

parents 2c458ec3 9aff6220
...@@ -648,11 +648,11 @@ l2tpd_watch_cb (GPid pid, gint status, gpointer user_data) ...@@ -648,11 +648,11 @@ l2tpd_watch_cb (GPid pid, gint status, gpointer user_data)
g_free(filename); g_free(filename);
filename = g_strdup_printf ("/var/run/nm-ipsec-l2tp.%d/ipsec.conf", my_pid); filename = g_strdup_printf ("/var/run/nm-ipsec-l2tp.%d/ipsec.conf", my_pid);
// unlink(filename); unlink(filename);
g_free(filename); g_free(filename);
filename = g_strdup_printf ("/var/run/nm-ipsec-l2tp.%d/ipsec.secrets", my_pid); filename = g_strdup_printf ("/var/run/nm-ipsec-l2tp.%d/ipsec.secrets", my_pid);
// unlink(filename); unlink(filename);
g_free(filename); g_free(filename);
filename = g_strdup_printf ("/var/run/nm-ipsec-l2tp.%d", my_pid); filename = g_strdup_printf ("/var/run/nm-ipsec-l2tp.%d", my_pid);
...@@ -853,6 +853,7 @@ nm_l2tp_stop_ipsec(void) ...@@ -853,6 +853,7 @@ nm_l2tp_stop_ipsec(void)
char session_name[128]; char session_name[128];
GPtrArray *whack_argv; GPtrArray *whack_argv;
g_message("ipsec prepare for shut down");
if (!(ipsec_binary=nm_find_ipsec())) return; if (!(ipsec_binary=nm_find_ipsec())) return;
sprintf(session_name, "nm-ipsec-l2tpd-%d", getpid()); sprintf(session_name, "nm-ipsec-l2tpd-%d", getpid());
...@@ -886,7 +887,7 @@ nm_l2tp_start_ipsec(NML2tpPlugin *plugin, ...@@ -886,7 +887,7 @@ nm_l2tp_start_ipsec(NML2tpPlugin *plugin,
char tmp_secrets[128]; char tmp_secrets[128];
char cmd1[4096],cmd11[4096],cmd2[4096]; char cmd1[4096],cmd11[4096],cmd2[4096];
char session_name[128]; char session_name[128];
guint sys=0; guint sys=0, sys_tmp=0;
int fd; int fd;
FILE *fp; FILE *fp;
...@@ -903,9 +904,17 @@ nm_l2tp_start_ipsec(NML2tpPlugin *plugin, ...@@ -903,9 +904,17 @@ nm_l2tp_start_ipsec(NML2tpPlugin *plugin,
sys += system("test -e /var/run/pluto/ipsec.info && . /var/run/pluto/ipsec.info;" sys += system("test -e /var/run/pluto/ipsec.info && . /var/run/pluto/ipsec.info;"
"PATH=/usr/local/sbin:/usr/sbin:/sbin; export PATH;" "PATH=/usr/local/sbin:/usr/sbin:/sbin; export PATH;"
"if [ \"x$defaultrouteaddr\" = \"x\" ]; then ipsec setup restart; fi"); "if [ \"x$defaultrouteaddr\" = \"x\" ]; then ipsec setup restart; fi");
if ( sys != sys_tmp ) {
sys_tmp = sys;
g_warning("Possible error in IPSec setup: determine defaultrouteaddr or in \"ipsec setup restart\"");
}
sys += system("PATH=/usr/local/sbin:/usr/sbin:/sbin ipsec whack" sys += system("PATH=/usr/local/sbin:/usr/sbin:/sbin ipsec whack"
" --listen"); " --listen");
if ( sys != sys_tmp ) {
sys_tmp = sys;
g_warning("Possible error in IPSec setup: ipsec whack --listen");
}
sprintf(cmd1,"test -e /var/run/pluto/ipsec.info && . /var/run/pluto/ipsec.info;" sprintf(cmd1,"test -e /var/run/pluto/ipsec.info && . /var/run/pluto/ipsec.info;"
"PATH=/usr/local/sbin:/usr/sbin:/sbin ipsec addconn " "PATH=/usr/local/sbin:/usr/sbin:/sbin ipsec addconn "
" ${defaultrouteaddr:+--defaultroute} $defaultrouteaddr" " ${defaultrouteaddr:+--defaultroute} $defaultrouteaddr"
...@@ -962,12 +971,32 @@ nm_l2tp_start_ipsec(NML2tpPlugin *plugin, ...@@ -962,12 +971,32 @@ nm_l2tp_start_ipsec(NML2tpPlugin *plugin,
close(fd); close(fd);
sys += system("PATH=\"/sbin:/usr/sbin:/usr/local/sbin:$PATH\" ipsec secrets"); sys += system("PATH=\"/sbin:/usr/sbin:/usr/local/sbin:$PATH\" ipsec secrets");
if ( sys != sys_tmp ) {
sys_tmp = sys;
g_warning("Possible error in IPSec setup: ipsec secrets");
}
sys += system(cmd11); sys += system(cmd11);
if ( sys != sys_tmp ) {
sys_tmp = sys;
g_warning("Possible error in IPSec setup: %s",cmd11);
}
sys += system(cmd1); sys += system(cmd1);
if ( sys != sys_tmp ) {
sys_tmp = sys;
g_warning("Possible error in IPSec setup: %s",cmd1);
}
sys += system(cmd2); sys += system(cmd2);
if ( sys != sys_tmp ) {
sys_tmp = sys;
g_warning("Possible error in IPSec setup: %s",cmd2);
}
rename(tmp_secrets, "/etc/ipsec.secrets"); rename(tmp_secrets, "/etc/ipsec.secrets");
sys += system("PATH=\"/sbin:/usr/sbin:/usr/local/sbin:$PATH\" ipsec secrets"); sys += system("PATH=\"/sbin:/usr/sbin:/usr/local/sbin:$PATH\" ipsec secrets");
if ( sys != sys_tmp ) {
sys_tmp = sys;
g_warning("Possible error in IPSec setup: ipsec secrets");
}
if (sys != 0) { if (sys != 0) {
g_set_error (error, g_set_error (error,
NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR,
...@@ -1470,6 +1499,7 @@ real_connect (NMVPNPlugin *plugin, ...@@ -1470,6 +1499,7 @@ real_connect (NMVPNPlugin *plugin,
g_message(_("starting ipsec")); g_message(_("starting ipsec"));
if (!nm_l2tp_start_ipsec(NM_L2TP_PLUGIN (plugin), s_vpn, error)) if (!nm_l2tp_start_ipsec(NM_L2TP_PLUGIN (plugin), s_vpn, error))
return FALSE; return FALSE;
priv->ipsec_up = TRUE;
} }
if (!nm_l2tp_start_l2tpd_binary (NM_L2TP_PLUGIN (plugin), s_vpn, error)) if (!nm_l2tp_start_l2tpd_binary (NM_L2TP_PLUGIN (plugin), s_vpn, error))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment