]> git.ipfire.org Git - people/ms/network.git/commitdiff
ipsec: Properly shut down connections when destroyed
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Aug 2017 21:39:43 +0000 (21:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Aug 2017 21:39:43 +0000 (21:39 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.ipsec
src/functions/functions.util

index d75d920dc94d30c4110270eca3bcd80aae4bb7df..702527ddb5d5855f48b1f0c1f6ce9af1740b26fd 100644 (file)
@@ -94,7 +94,7 @@ cli_ipsec_connection() {
                                ipsec_connection_new $@
                                ;;
                        destroy)
-                               ipsec_connection_destroy $@
+                               cli_ipsec_connection_destroy $@
                                ;;
                        ""|*)
                                if [ -n "${action}" ]; then
@@ -106,6 +106,20 @@ cli_ipsec_connection() {
        fi
 }
 
+cli_ipsec_connection_destroy() {
+       local connection="${1}"
+
+       if ! ipsec_connection_destroy "${connection}"; then
+               return ${EXIT_ERROR}
+       fi
+
+       # Inform strongswan about the changes
+       ipsec_strongswan_load
+
+       # Configure strongswan autostart
+       ipsec_strongswan_autostart
+}
+
 cli_ipsec_connection_show() {
        local connection="${1}"
 
@@ -1022,14 +1036,16 @@ ipsec_connection_destroy() {
                fi
 
                log DEBUG "Deleting VPN IPsec connection ${connection}"
+
+               # Delete strongswan configuration file
+               file_delete "${NETWORK_IPSEC_SWANCTL_CONNECTIONS_DIR}/${connection}.conf"
+
                if ! rm -rf "${NETWORK_IPSEC_CONNS_DIR}/${connection}"; then
                        log ERROR "Deleting the VPN IPsec connection ${connection} was not sucessful"
                        return ${EXIT_ERROR}
                fi
-       done
 
-       # Configure strongswan autostart
-       ipsec_strongswan_autostart
+       done
 }
 
 # List all ipsec connections
index 91601de65d6e57d602740670a229f56c6845dd15..d1e2a92b283490d5eb46854cc447704171808b16 100644 (file)
@@ -211,6 +211,12 @@ fappend() {
        print "%s" "$@" >> ${file} 2>/dev/null
 }
 
+file_delete() {
+       local file=${1}
+
+       unlink "${file}" 2>/dev/null
+}
+
 file_exists() {
        local file=${1}