]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
charon-nm: Terminate if signaled by NetworkManager
authorTobias Brunner <tobias@strongswan.org>
Tue, 6 Sep 2016 07:25:27 +0000 (09:25 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 27 Oct 2020 09:44:33 +0000 (10:44 +0100)
This only happens during shutdown, not after terminating a connection.

Fixes #3579.

src/charon-nm/nm/nm_backend.c

index 379a2f30b7ddb4530d9f903a31d4ad4f60d509a9..1d668839002a420e1cabeffc3006dcd04480e25b 100644 (file)
@@ -14,6 +14,9 @@
  * for more details.
  */
 
+#include <sys/types.h>
+#include <unistd.h>
+
 #include "nm_service.h"
 #include "nm_creds.h"
 #include "nm_handler.h"
@@ -54,12 +57,21 @@ struct nm_backend_t {
  */
 static nm_backend_t *nm_backend = NULL;
 
+/**
+ * Terminate the daemon if signaled by NM
+ */
+static void terminate(void *plugin, void *arg)
+{
+       kill(getpid(), SIGTERM);
+}
+
 /**
  * NM plugin processing routine, creates and handles NMVpnServicePlugin
  */
 static job_requeue_t run(nm_backend_t *this)
 {
        this->loop = g_main_loop_new(NULL, FALSE);
+       g_signal_connect(this->plugin, "quit", G_CALLBACK(terminate), NULL);
        g_main_loop_run(this->loop);
        return JOB_REQUEUE_NONE;
 }