diff --git a/0002-trivial-rename-a-badly-named-subroutine.patch b/0002-trivial-rename-a-badly-named-subroutine.patch new file mode 100644 index 0000000..c990dc4 --- /dev/null +++ b/0002-trivial-rename-a-badly-named-subroutine.patch @@ -0,0 +1,47 @@ +From b939d37b1333f74434bbf8f550ad55c7aef0138c Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Fri, 22 Jan 2016 17:19:43 +0100 +Subject: [PATCH 02/17] trivial: rename a badly named subroutine + +--- + properties/nm-libreswan.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/properties/nm-libreswan.c b/properties/nm-libreswan.c +index 5634d53..2240883 100644 +--- a/properties/nm-libreswan.c ++++ b/properties/nm-libreswan.c +@@ -315,9 +315,9 @@ init_one_pw_combo (LibreswanEditor *self, + + static gboolean + init_editor_plugin (LibreswanEditor *self, +- NMConnection *connection, +- gboolean new_connection, +- GError **error) ++ NMConnection *connection, ++ gboolean new_connection, ++ GError **error) + { + LibreswanEditorPrivate *priv = LIBRESWAN_EDITOR_GET_PRIVATE (self); + NMSettingVpn *s_vpn = NULL; +@@ -559,7 +559,7 @@ is_new_func (const char *key, const char *value, gpointer user_data) + } + + static NMVpnEditor * +-nm_vpn_editor_interface_new (NMConnection *connection, GError **error) ++nm_vpn_editor_new (NMConnection *connection, GError **error) + { + NMVpnEditor *object; + LibreswanEditorPrivate *priv; +@@ -712,7 +712,7 @@ get_capabilities (NMVpnEditorPlugin *iface) + static NMVpnEditor * + get_editor (NMVpnEditorPlugin *iface, NMConnection *connection, GError **error) + { +- return nm_vpn_editor_interface_new (connection, error); ++ return nm_vpn_editor_new (connection, error); + } + + static void +-- +2.5.0 + diff --git a/0003-import-export-add-a-terminating-newline.patch b/0003-import-export-add-a-terminating-newline.patch new file mode 100644 index 0000000..0c97cd4 --- /dev/null +++ b/0003-import-export-add-a-terminating-newline.patch @@ -0,0 +1,26 @@ +From e3c8b338d0e511a8b208627de34295d7321185dc Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Mon, 25 Jan 2016 10:15:00 +0100 +Subject: [PATCH 03/17] import/export: add a terminating newline + +A comspetic thing. +--- + common/utils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/common/utils.c b/common/utils.c +index 53c3878..5d573f4 100644 +--- a/common/utils.c ++++ b/common/utils.c +@@ -150,7 +150,7 @@ nm_libreswan_config_write (gint fd, + * libreswan fails parsing the configuration if you include the \n. + * WTF? + */ +- if (openswan) ++ if (openswan || !bus_name) + (void) write (fd, "\n", 1); + if (debug) + g_print ("\n"); +-- +2.5.0 + diff --git a/0004-service-disable-agresive-mode-when-there-s-no-group-.patch b/0004-service-disable-agresive-mode-when-there-s-no-group-.patch new file mode 100644 index 0000000..cc01be5 --- /dev/null +++ b/0004-service-disable-agresive-mode-when-there-s-no-group-.patch @@ -0,0 +1,95 @@ +From 2c510b631d5bec3cbd130cde308a5cff00adcd2e Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Thu, 21 Jan 2016 21:46:58 +0100 +Subject: [PATCH 04/17] service: disable agresive mode when there's no group + name + +--- + common/utils.c | 9 +++++++-- + properties/nm-libreswan.c | 10 ---------- + src/nm-libreswan-service.c | 11 ++++++++--- + 3 files changed, 15 insertions(+), 15 deletions(-) + +diff --git a/common/utils.c b/common/utils.c +index 5d573f4..eff64fb 100644 +--- a/common/utils.c ++++ b/common/utils.c +@@ -91,6 +91,7 @@ nm_libreswan_config_write (gint fd, + const char *default_username; + const char *phase1_alg_str; + const char *phase2_alg_str; ++ const char *leftid; + + /* We abuse the presence of bus name to decide if we're exporting + * the connection or actually configuring Pluto. */ +@@ -103,11 +104,15 @@ nm_libreswan_config_write (gint fd, + g_assert (s_vpn); + g_assert (con_name); + ++ leftid = nm_setting_vpn_get_data_item (s_vpn, NM_LIBRESWAN_LEFTID); ++ + write_config_option (fd, "conn %s\n", con_name); +- write_config_option (fd, " aggrmode=yes\n"); ++ if (leftid) { ++ write_config_option (fd, " aggrmode=yes\n"); ++ write_config_option (fd, " leftid=@%s\n", leftid); ++ } + write_config_option (fd, " authby=secret\n"); + write_config_option (fd, " left=%%defaultroute\n"); +- write_config_option (fd, " leftid=@%s\n", nm_setting_vpn_get_data_item (s_vpn, NM_LIBRESWAN_LEFTID)); + write_config_option (fd, " leftxauthclient=yes\n"); + write_config_option (fd, " leftmodecfgclient=yes\n"); + +diff --git a/properties/nm-libreswan.c b/properties/nm-libreswan.c +index 2240883..d3b4cf8 100644 +--- a/properties/nm-libreswan.c ++++ b/properties/nm-libreswan.c +@@ -119,16 +119,6 @@ check_validity (LibreswanEditor *self, GError **error) + return FALSE; + } + +- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "group_entry")); +- str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); +- if (!str || !strlen (str)) { +- g_set_error (error, +- LIBRESWAN_EDITOR_PLUGIN_ERROR, +- LIBRESWAN_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY, +- NM_LIBRESWAN_LEFTID); +- return FALSE; +- } +- + return TRUE; + } + +diff --git a/src/nm-libreswan-service.c b/src/nm-libreswan-service.c +index 335dd7b..e2a217f 100644 +--- a/src/nm-libreswan-service.c ++++ b/src/nm-libreswan-service.c +@@ -622,7 +622,7 @@ nm_libreswan_config_psk_write (NMSettingVpn *s_vpn, + const char *secrets_path, + GError **error) + { +- const char *pw_type, *psk, *leftid; ++ const char *pw_type, *psk, *leftid, *right; + int fd; + + /* Check for ignored group password */ +@@ -647,8 +647,13 @@ nm_libreswan_config_psk_write (NMSettingVpn *s_vpn, + } + + leftid = nm_setting_vpn_get_data_item (s_vpn, NM_LIBRESWAN_LEFTID); +- g_assert (leftid); +- write_config_option (fd, "@%s: PSK \"%s\"\n", leftid, psk); ++ if (leftid) { ++ write_config_option (fd, "@%s: PSK \"%s\"\n", leftid, psk); ++ } else { ++ right = nm_setting_vpn_get_data_item (s_vpn, NM_LIBRESWAN_RIGHT); ++ g_assert (right); ++ write_config_option (fd, "%s %%any: PSK \"%s\"\n", right, psk); ++ } + + close (fd); + return TRUE; +-- +2.5.0 + diff --git a/0005-service-always-set-modecfgpull-yes.patch b/0005-service-always-set-modecfgpull-yes.patch new file mode 100644 index 0000000..1f7b81b --- /dev/null +++ b/0005-service-always-set-modecfgpull-yes.patch @@ -0,0 +1,24 @@ +From fa7fc65ad032027a69d1a3b5cd13680feb92a8f7 Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Thu, 21 Jan 2016 21:48:16 +0100 +Subject: [PATCH 05/17] service: always set modecfgpull=yes + +--- + common/utils.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/common/utils.c b/common/utils.c +index eff64fb..1af8558 100644 +--- a/common/utils.c ++++ b/common/utils.c +@@ -130,6 +130,7 @@ nm_libreswan_config_write (gint fd, + write_config_option (fd, " remote_peer_type=cisco\n"); + write_config_option (fd, " rightxauthserver=yes\n"); + write_config_option (fd, " rightmodecfgserver=yes\n"); ++ write_config_option (fd, " modecfgpull=yes\n"); + + phase1_alg_str = nm_setting_vpn_get_data_item (s_vpn, NM_LIBRESWAN_IKE); + if (!phase1_alg_str || !strlen (phase1_alg_str)) +-- +2.5.0 + diff --git a/0006-service-avoid-setting-the-default-route-to-the-tunne.patch b/0006-service-avoid-setting-the-default-route-to-the-tunne.patch new file mode 100644 index 0000000..76cf2a7 --- /dev/null +++ b/0006-service-avoid-setting-the-default-route-to-the-tunne.patch @@ -0,0 +1,24 @@ +From d942f394bfaa6ecdb9edaee1bcc3ceb4eecc8a85 Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Mon, 25 Jan 2016 16:48:28 +0100 +Subject: [PATCH 06/17] service: avoid setting the default route to the tunnel + +--- + common/utils.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/common/utils.c b/common/utils.c +index 1af8558..2ef0bb1 100644 +--- a/common/utils.c ++++ b/common/utils.c +@@ -131,6 +131,7 @@ nm_libreswan_config_write (gint fd, + write_config_option (fd, " rightxauthserver=yes\n"); + write_config_option (fd, " rightmodecfgserver=yes\n"); + write_config_option (fd, " modecfgpull=yes\n"); ++ write_config_option (fd, " rightsubnet=0.0.0.0/0\n"); + + phase1_alg_str = nm_setting_vpn_get_data_item (s_vpn, NM_LIBRESWAN_IKE); + if (!phase1_alg_str || !strlen (phase1_alg_str)) +-- +2.5.0 + diff --git a/0007-properties-don-t-use-depreacted-GtkBox-subclasses.patch b/0007-properties-don-t-use-depreacted-GtkBox-subclasses.patch new file mode 100644 index 0000000..0a53503 --- /dev/null +++ b/0007-properties-don-t-use-depreacted-GtkBox-subclasses.patch @@ -0,0 +1,164 @@ +From e79f2cfc67013c819e392f883af7f987fc3ebd2d Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Fri, 22 Jan 2016 16:23:03 +0100 +Subject: [PATCH 07/17] properties: don't use depreacted GtkBox subclasses + +--- + properties/nm-libreswan-dialog.ui | 33 ++++++++++++++++++--------------- + 1 file changed, 18 insertions(+), 15 deletions(-) + +diff --git a/properties/nm-libreswan-dialog.ui b/properties/nm-libreswan-dialog.ui +index 56f6816..9f6f9fb 100644 +--- a/properties/nm-libreswan-dialog.ui ++++ b/properties/nm-libreswan-dialog.ui +@@ -1,7 +1,7 @@ + +- ++ + +- ++ + + + +@@ -24,23 +24,25 @@ + + + +- ++ + True + False + 12 ++ vertical + 16 + +- ++ + True + False ++ vertical + 6 + + + True + False +- 0 + <b>General</b> + True ++ 0 + + + False +@@ -146,10 +148,10 @@ + + True + False +- 0 + Gro_up password: + True + group_entry ++ 0 + + + 3 +@@ -162,10 +164,10 @@ + + True + False +- 0 + _Gateway: + True + gateway_entry ++ 0 + + + GTK_FILL +@@ -176,10 +178,10 @@ + + True + False +- 0 + G_roup name: + True + group_entry ++ 0 + + + 1 +@@ -216,10 +218,10 @@ + + True + False +- 0 + _User password: + True + group_entry ++ 0 + + + 2 +@@ -259,17 +261,18 @@ + + + +- ++ + True + False ++ vertical + 6 + + + True + False +- 0 + <b>Optional</b> + True ++ 0 + + + False +@@ -298,8 +301,8 @@ + + True + False +- 0 + User name: ++ 0 + + + GTK_FILL +@@ -322,8 +325,8 @@ + + True + False +- 0 + Phase1 Algorithms: ++ 0 + + + 1 +@@ -350,8 +353,8 @@ + + True + False +- 0 + Phase2 Algorithms: ++ 0 + + + 2 +@@ -378,8 +381,8 @@ + + True + False +- 0 + Domain: ++ 0 + + + 3 +-- +2.5.0 + diff --git a/0008-properties-don-t-use-depreacted-GtkGrid.patch b/0008-properties-don-t-use-depreacted-GtkGrid.patch new file mode 100644 index 0000000..cb5407e --- /dev/null +++ b/0008-properties-don-t-use-depreacted-GtkGrid.patch @@ -0,0 +1,288 @@ +From 6ee64ada349fdcd07a6df6d238ae0df57e3ce358 Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Fri, 22 Jan 2016 16:30:17 +0100 +Subject: [PATCH 08/17] properties: don't use depreacted GtkGrid + +--- + properties/nm-libreswan-dialog.ui | 99 ++++++++++++--------------------------- + 1 file changed, 29 insertions(+), 70 deletions(-) + +diff --git a/properties/nm-libreswan-dialog.ui b/properties/nm-libreswan-dialog.ui +index 9f6f9fb..f6d01e6 100644 +--- a/properties/nm-libreswan-dialog.ui ++++ b/properties/nm-libreswan-dialog.ui +@@ -56,22 +56,12 @@ + False + 12 + +- ++ + True + False +- 5 +- 3 +- 6 ++ vertical + 6 +- +- +- +- +- +- +- +- +- ++ 6 + + + True +@@ -86,9 +76,7 @@ + + + 2 +- 3 + 3 +- 4 + + + +@@ -105,15 +93,10 @@ + + + 2 +- 3 + 2 +- 3 + + + +- +- +- + + Show passwords + False +@@ -125,9 +108,7 @@ + + + 1 +- 2 + 4 +- 5 + + + +@@ -138,10 +119,7 @@ + + + 1 +- 2 + 3 +- 4 +- + + + +@@ -154,10 +132,8 @@ + 0 + + ++ 0 + 3 +- 4 +- GTK_FILL +- + + + +@@ -170,8 +146,8 @@ + 0 + + +- GTK_FILL +- ++ 0 ++ 0 + + + +@@ -184,10 +160,8 @@ + 0 + + ++ 0 + 1 +- 2 +- GTK_FILL +- + + + +@@ -197,8 +171,7 @@ + + + 1 +- 2 +- ++ 0 + + + +@@ -208,10 +181,7 @@ + + + 1 +- 2 + 1 +- 2 +- + + + +@@ -224,10 +194,8 @@ + 0 + + ++ 0 + 2 +- 3 +- GTK_FILL +- + + + +@@ -238,12 +206,21 @@ + + + 1 +- 2 + 2 +- 3 +- + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + +@@ -290,13 +267,11 @@ + True + False + +- ++ + True + False +- 4 +- 2 +- 6 + 6 ++ 6 + + + True +@@ -305,8 +280,8 @@ + 0 + + +- GTK_FILL +- ++ 0 ++ 0 + + + +@@ -317,8 +292,7 @@ + + + 1 +- 2 +- ++ 0 + + + +@@ -329,10 +303,8 @@ + 0 + + ++ 0 + 1 +- 2 +- GTK_FILL +- + + + +@@ -343,10 +315,7 @@ + + + 1 +- 2 + 1 +- 2 +- + + + +@@ -357,10 +326,8 @@ + 0 + + ++ 0 + 2 +- 3 +- GTK_FILL +- + + + +@@ -371,10 +338,7 @@ + + + 1 +- 2 + 2 +- 3 +- + + + +@@ -385,10 +349,8 @@ + 0 + + ++ 0 + 3 +- 4 +- GTK_FILL +- + + + +@@ -399,10 +361,7 @@ + + + 1 +- 2 + 3 +- 4 +- + + + +-- +2.5.0 + diff --git a/0009-properties-use-the-new-nma-based-password-widgets.patch b/0009-properties-use-the-new-nma-based-password-widgets.patch new file mode 100644 index 0000000..2a13efd --- /dev/null +++ b/0009-properties-use-the-new-nma-based-password-widgets.patch @@ -0,0 +1,717 @@ +From fafdb6c24a437038738be2e2613f28f827881575 Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Fri, 22 Jan 2016 16:36:56 +0100 +Subject: [PATCH 09/17] properties: use the new nma-based password widgets + +--- + properties/Makefile.am | 8 +- + properties/nm-libreswan-dialog.ui | 194 +++++++++++++++----------------------- + properties/nm-libreswan.c | 189 ++++++++++++------------------------- + 3 files changed, 142 insertions(+), 249 deletions(-) + +diff --git a/properties/Makefile.am b/properties/Makefile.am +index 0e318da..b7f19d0 100644 +--- a/properties/Makefile.am ++++ b/properties/Makefile.am +@@ -15,12 +15,14 @@ common_CFLAGS = \ + + libnm_vpn_plugin_libreswan_la_CFLAGS = \ + $(common_CFLAGS) \ +- $(LIBNM_CFLAGS) ++ $(LIBNM_CFLAGS) \ ++ $(LIBNMA_CFLAGS) + + libnm_libreswan_properties_la_CFLAGS = \ + -DNM_LIBRESWAN_OLD \ + $(common_CFLAGS) \ +- $(LIBNM_GLIB_CFLAGS) ++ $(LIBNM_GLIB_CFLAGS) \ ++ $(LIBNM_GTK_CFLAGS) + + libnm_vpn_plugin_libreswan_la_SOURCES = \ + nm-libreswan.c \ +@@ -32,11 +34,13 @@ libnm_libreswan_properties_la_SOURCES = \ + libnm_vpn_plugin_libreswan_la_LIBADD = \ + $(GTK_LIBS) \ + $(LIBNM_LIBS) \ ++ $(LIBNMA_LIBS) \ + $(top_builddir)/common/libnm-libreswan-common.la + + libnm_libreswan_properties_la_LIBADD = \ + $(GTK_LIBS) \ + $(LIBNM_GLIB_LIBS) \ ++ $(LIBNM_GTK_LIBS) \ + $(top_builddir)/common/libnm-vpn-plugin-libreswan-common.la + + libnm_vpn_plugin_libreswan_la_LDFLAGS = \ +diff --git a/properties/nm-libreswan-dialog.ui b/properties/nm-libreswan-dialog.ui +index f6d01e6..a5e6c74 100644 +--- a/properties/nm-libreswan-dialog.ui ++++ b/properties/nm-libreswan-dialog.ui +@@ -2,28 +2,6 @@ + + + +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- + + True + False +@@ -63,37 +41,27 @@ + 6 + 6 + +- ++ + True + False +- model1 +- +- +- +- 0 +- +- ++ _Gateway: ++ True ++ gateway_entry ++ 0 + + +- 2 +- 3 ++ 0 ++ 0 + + + +- ++ + True +- False +- model2 +- +- +- +- 0 +- +- ++ True + + +- 2 +- 2 ++ 1 ++ 0 + + + +@@ -108,7 +76,7 @@ + + + 1 +- 4 ++ 5 + + + +@@ -119,59 +87,57 @@ + + + 1 +- 3 ++ 4 + + + + + True + False +- Gro_up password: ++ _Secret: + True +- group_entry + 0 + + + 0 +- 3 ++ 4 + + + +- ++ + True + False +- _Gateway: ++ _User password: + True +- gateway_entry + 0 + + + 0 +- 0 ++ 2 + + + +- ++ + True +- False +- G_roup name: +- True +- group_entry +- 0 ++ True ++ False + + +- 0 +- 1 ++ 1 ++ 2 + + + +- ++ + True +- True ++ False ++ G_roup name: ++ True ++ 0 + + +- 1 +- 0 ++ 0 ++ 3 + + + +@@ -181,46 +147,35 @@ + + + 1 +- 1 ++ 3 + + + +- ++ + True + False +- _User password: +- True +- group_entry ++ User name: + 0 + + + 0 +- 2 ++ 1 + + + +- ++ + True + True +- False ++ + + + 1 +- 2 ++ 1 + + + + + +- +- +- +- +- +- +- +- +- + + + +@@ -247,7 +202,7 @@ + + True + False +- <b>Optional</b> ++ <b>Advanced</b> + True + 0 + +@@ -273,10 +228,10 @@ + 6 + 6 + +- ++ + True + False +- User name: ++ Phase1 Algorithms: + 0 + + +@@ -285,21 +240,10 @@ + + + +- +- True +- True +- +- +- +- 1 +- 0 +- +- +- +- ++ + True + False +- Phase1 Algorithms: ++ Phase2 Algorithms: + 0 + + +@@ -308,21 +252,10 @@ + + + +- +- True +- True +- +- +- +- 1 +- 1 +- +- +- +- ++ + True + False +- Phase2 Algorithms: ++ Domain: + 0 + + +@@ -331,26 +264,25 @@ + + + +- ++ + True + True + + + + 1 +- 2 ++ 0 + + + +- ++ + True +- False +- Domain: +- 0 ++ True ++ + + +- 0 +- 3 ++ 1 ++ 1 + + + +@@ -361,7 +293,7 @@ + + + 1 +- 3 ++ 2 + + + +@@ -383,4 +315,26 @@ + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + +diff --git a/properties/nm-libreswan.c b/properties/nm-libreswan.c +index d3b4cf8..7f4cf26 100644 +--- a/properties/nm-libreswan.c ++++ b/properties/nm-libreswan.c +@@ -38,10 +38,12 @@ + + #ifdef NM_LIBRESWAN_OLD + #define NM_VPN_LIBNM_COMPAT ++ + #include + #include + #include + #include ++#include + + #define LIBRESWAN_EDITOR_PLUGIN_ERROR NM_SETTING_VPN_ERROR + #define LIBRESWAN_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY +@@ -49,6 +51,7 @@ + #else /* !NM_LIBRESWAN_OLD */ + + #include ++#include + + #define LIBRESWAN_EDITOR_PLUGIN_ERROR NM_CONNECTION_ERROR + #define LIBRESWAN_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY +@@ -136,13 +139,9 @@ setup_password_widget (LibreswanEditor *self, + gboolean new_connection) + { + LibreswanEditorPrivate *priv = LIBRESWAN_EDITOR_GET_PRIVATE (self); +- NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; + GtkWidget *widget; + const char *value; + +- if (new_connection) +- secret_flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED; +- + widget = (GtkWidget *) gtk_builder_get_object (priv->builder, entry_name); + g_assert (widget); + gtk_size_group_add_widget (priv->group, widget); +@@ -150,10 +149,7 @@ setup_password_widget (LibreswanEditor *self, + if (s_vpn) { + value = nm_setting_vpn_get_secret (s_vpn, secret_name); + gtk_entry_set_text (GTK_ENTRY (widget), value ? value : ""); +- nm_setting_get_secret_flags (NM_SETTING (s_vpn), secret_name, &secret_flags, NULL); + } +- secret_flags &= ~(NM_SETTING_SECRET_FLAG_NOT_SAVED | NM_SETTING_SECRET_FLAG_NOT_REQUIRED); +- g_object_set_data (G_OBJECT (widget), "flags", GUINT_TO_POINTER (secret_flags)); + + g_signal_connect (widget, "changed", G_CALLBACK (stuff_changed_cb), self); + } +@@ -177,48 +173,13 @@ show_toggled_cb (GtkCheckButton *button, LibreswanEditor *self) + } + + static void +-pw_type_changed_helper (LibreswanEditor *self, GtkWidget *combo) +-{ +- LibreswanEditorPrivate *priv = LIBRESWAN_EDITOR_GET_PRIVATE (self); +- const char *entry = NULL; +- GtkWidget *widget; +- +- /* If the user chose "Not required", desensitize and clear the correct +- * password entry. +- */ +- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user_pass_type_combo")); +- if (combo == widget) +- entry = "user_password_entry"; +- else { +- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "group_pass_type_combo")); +- if (combo == widget) +- entry = "group_password_entry"; +- } +- if (!entry) +- return; +- +- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, entry)); +- g_assert (widget); +- +- switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combo))) { +- case PW_TYPE_ASK: +- case PW_TYPE_UNUSED: +- gtk_entry_set_text (GTK_ENTRY (widget), ""); +- gtk_widget_set_sensitive (widget, FALSE); +- break; +- default: +- gtk_widget_set_sensitive (widget, TRUE); +- break; +- } +-} +- +-static void +-pw_type_combo_changed_cb (GtkWidget *combo, gpointer user_data) ++password_storage_changed_cb (GObject *entry, ++ GParamSpec *pspec, ++ gpointer user_data) + { + LibreswanEditor *self = LIBRESWAN_EDITOR (user_data); + +- pw_type_changed_helper (self, combo); +- stuff_changed_cb (combo, self); ++ stuff_changed_cb (NULL, self); + } + + static const char * +@@ -237,72 +198,40 @@ secret_flags_to_pw_type (NMSettingVpn *s_vpn, const char *key) + } + + static void +-init_one_pw_combo (LibreswanEditor *self, +- NMSettingVpn *s_vpn, +- const char *combo_name, +- const char *secret_key, +- const char *type_key, +- const char *entry_name) ++init_password_icon (LibreswanEditor *self, ++ NMSettingVpn *s_vpn, ++ const char *secret_key, ++ const char *type_key, ++ const char *entry_name) + { + LibreswanEditorPrivate *priv = LIBRESWAN_EDITOR_GET_PRIVATE (self); +- int active = -1; +- GtkWidget *widget; +- GtkListStore *store; +- GtkTreeIter iter; +- const char *value = NULL; +- guint32 default_idx = 1; ++ GtkWidget *entry; ++ const char *value; ++ const char *flags = NULL; + +- /* If there's already a password and the password type can't be found in +- * the VPN settings, default to saving it. Otherwise, always ask for it. +- */ +- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, entry_name)); +- if (widget) { +- const char *tmp; ++ entry = GTK_WIDGET (gtk_builder_get_object (priv->builder, entry_name)); ++ g_assert (entry); + +- tmp = gtk_entry_get_text (GTK_ENTRY (widget)); +- if (tmp && strlen (tmp)) +- default_idx = 0; +- } ++ nma_utils_setup_password_storage (entry, 0, (NMSetting *) s_vpn, secret_key, ++ TRUE, FALSE); + +- store = gtk_list_store_new (1, G_TYPE_STRING); ++ /* If there's no password and no flags in the setting, ++ * initialize flags as "always-ask". ++ */ + if (s_vpn) { +- value = secret_flags_to_pw_type (s_vpn, secret_key); +- if (!value) +- value = nm_setting_vpn_get_data_item (s_vpn, type_key); +- } +- +- gtk_list_store_append (store, &iter); +- gtk_list_store_set (store, &iter, 0, _("Saved"), -1); +- if ((active < 0) && value) { +- if (!strcmp (value, NM_LIBRESWAN_PW_TYPE_SAVE)) +- active = 0; ++ flags = secret_flags_to_pw_type (s_vpn, secret_key); ++ if (!flags || !strcmp (flags, NM_LIBRESWAN_PW_TYPE_SAVE)) ++ flags = nm_setting_vpn_get_data_item (s_vpn, type_key); + } ++ value = gtk_entry_get_text (GTK_ENTRY (entry)); ++ if ((!value || !*value) && !flags) ++ nma_utils_update_password_storage (entry, NM_SETTING_SECRET_FLAG_NOT_SAVED, ++ (NMSetting *) s_vpn, secret_key); + +- gtk_list_store_append (store, &iter); +- gtk_list_store_set (store, &iter, 0, _("Always Ask"), -1); +- if ((active < 0) && value) { +- if (!strcmp (value, NM_LIBRESWAN_PW_TYPE_ASK)) +- active = 1; +- } +- +- gtk_list_store_append (store, &iter); +- gtk_list_store_set (store, &iter, 0, _("Not Required"), -1); +- if ((active < 0) && value) { +- if (!strcmp (value, NM_LIBRESWAN_PW_TYPE_UNUSED)) +- active = 2; +- } +- +- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, combo_name)); +- g_assert (widget); +- gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store)); +- g_object_unref (store); +- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active < 0 ? default_idx : active); +- pw_type_changed_helper (self, widget); +- +- g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (pw_type_combo_changed_cb), self); ++ g_signal_connect (entry, "notify::secondary-icon-name", ++ G_CALLBACK (password_storage_changed_cb), self); + } + +- + static gboolean + init_editor_plugin (LibreswanEditor *self, + NMConnection *connection, +@@ -352,18 +281,16 @@ init_editor_plugin (LibreswanEditor *self, + NM_LIBRESWAN_PSK_VALUE, + new_connection); + +- init_one_pw_combo (self, +- s_vpn, +- "user_pass_type_combo", +- NM_LIBRESWAN_XAUTH_PASSWORD, +- NM_LIBRESWAN_XAUTH_PASSWORD_INPUT_MODES, +- "user_password_entry"); +- init_one_pw_combo (self, +- s_vpn, +- "group_pass_type_combo", +- NM_LIBRESWAN_PSK_VALUE, +- NM_LIBRESWAN_PSK_INPUT_MODES, +- "group_password_entry"); ++ init_password_icon (self, ++ s_vpn, ++ NM_LIBRESWAN_XAUTH_PASSWORD, ++ NM_LIBRESWAN_XAUTH_PASSWORD_INPUT_MODES, ++ "user_password_entry"); ++ init_password_icon (self, ++ s_vpn, ++ NM_LIBRESWAN_PSK_VALUE, ++ NM_LIBRESWAN_PSK_INPUT_MODES, ++ "group_password_entry"); + + widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user_entry")); + g_return_val_if_fail (widget != NULL, FALSE); +@@ -434,33 +361,32 @@ static void + save_one_password (NMSettingVpn *s_vpn, + GtkBuilder *builder, + const char *entry_name, +- const char *combo_name, + const char *secret_key, + const char *type_key) + { +- NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; ++ NMSettingSecretFlags flags; + const char *data_val = NULL, *password; +- GtkWidget *entry, *combo; ++ GtkWidget *entry; + ++ /* Get secret flags */ + entry = GTK_WIDGET (gtk_builder_get_object (builder, entry_name)); +- flags = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (entry), "flags")); ++ flags = nma_utils_menu_to_secret_flags (entry); + +- combo = GTK_WIDGET (gtk_builder_get_object (builder, combo_name)); +- switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combo))) { +- case PW_TYPE_SAVE: ++ /* Save password and convert flags to legacy data items */ ++ switch (flags) { ++ case NM_SETTING_SECRET_FLAG_NONE: ++ case NM_SETTING_SECRET_FLAG_AGENT_OWNED: + password = gtk_entry_get_text (GTK_ENTRY (entry)); + if (password && strlen (password)) + nm_setting_vpn_add_secret (s_vpn, secret_key, password); + data_val = NM_LIBRESWAN_PW_TYPE_SAVE; + break; +- case PW_TYPE_UNUSED: ++ case NM_SETTING_SECRET_FLAG_NOT_REQUIRED: + data_val = NM_LIBRESWAN_PW_TYPE_UNUSED; +- flags |= NM_SETTING_SECRET_FLAG_NOT_REQUIRED; + break; +- case PW_TYPE_ASK: ++ case NM_SETTING_SECRET_FLAG_NOT_SAVED: + default: + data_val = NM_LIBRESWAN_PW_TYPE_ASK; +- flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED; + break; + } + +@@ -525,13 +451,11 @@ update_connection (NMVpnEditor *iface, + save_one_password (s_vpn, + priv->builder, + "user_password_entry", +- "user_pass_type_combo", + NM_LIBRESWAN_XAUTH_PASSWORD, + NM_LIBRESWAN_XAUTH_PASSWORD_INPUT_MODES); + save_one_password (s_vpn, + priv->builder, + "group_password_entry", +- "group_pass_type_combo", + NM_LIBRESWAN_PSK_VALUE, + NM_LIBRESWAN_PSK_INPUT_MODES); + +@@ -612,6 +536,17 @@ dispose (GObject *object) + LibreswanEditor *plugin = LIBRESWAN_EDITOR (object); + LibreswanEditorPrivate *priv = LIBRESWAN_EDITOR_GET_PRIVATE (plugin); + ++ GtkWidget *widget; ++ ++ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user_password_entry")); ++ g_signal_handlers_disconnect_by_func (G_OBJECT (widget), ++ (GCallback) password_storage_changed_cb, ++ plugin); ++ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "group_password_entry")); ++ g_signal_handlers_disconnect_by_func (G_OBJECT (widget), ++ (GCallback) password_storage_changed_cb, ++ plugin); ++ + if (priv->group) + g_object_unref (priv->group); + +-- +2.5.0 + diff --git a/0010-properties-some-more-UI-polish.patch b/0010-properties-some-more-UI-polish.patch new file mode 100644 index 0000000..5c625b6 --- /dev/null +++ b/0010-properties-some-more-UI-polish.patch @@ -0,0 +1,499 @@ +From 8d2f39ac3d5bfc20b9d7a78db05bfed9e5a29764 Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Fri, 22 Jan 2016 18:10:50 +0100 +Subject: [PATCH 10/17] properties: some more UI polish + +--- + properties/nm-libreswan-dialog.ui | 444 +++++++++++++++++++------------------- + 1 file changed, 219 insertions(+), 225 deletions(-) + +diff --git a/properties/nm-libreswan-dialog.ui b/properties/nm-libreswan-dialog.ui +index a5e6c74..0c77418 100644 +--- a/properties/nm-libreswan-dialog.ui ++++ b/properties/nm-libreswan-dialog.ui +@@ -29,158 +29,159 @@ + + + +- ++ + True + False +- 12 ++ 12 ++ 12 ++ vertical ++ 6 ++ 16 + +- ++ + True + False +- vertical +- 6 +- 6 +- +- +- True +- False +- _Gateway: +- True +- gateway_entry +- 0 +- +- +- 0 +- 0 +- +- +- +- +- True +- True +- +- +- 1 +- 0 +- +- +- +- +- Show passwords +- False +- True +- True +- False +- 0 +- True +- +- +- 1 +- 5 +- +- +- +- +- True +- True +- False +- +- +- 1 +- 4 +- +- +- +- +- True +- False +- _Secret: +- True +- 0 +- +- +- 0 +- 4 +- +- +- +- +- True +- False +- _User password: +- True +- 0 +- +- +- 0 +- 2 +- +- +- +- +- True +- True +- False +- +- +- 1 +- 2 +- +- +- +- +- True +- False +- G_roup name: +- True +- 0 +- +- +- 0 +- 3 +- +- +- +- +- True +- True +- +- +- 1 +- 3 +- +- +- +- +- True +- False +- User name: +- 0 +- +- +- 0 +- 1 +- +- +- +- +- True +- True +- +- +- +- 1 +- 1 +- +- +- +- +- ++ _Gateway: ++ True ++ gateway_entry ++ 0 + ++ ++ 0 ++ 0 ++ ++ ++ ++ ++ Show passwords ++ False ++ True ++ True ++ False ++ 0 ++ True ++ ++ ++ 1 ++ 5 ++ ++ ++ ++ ++ True ++ True ++ True ++ False ++ ++ ++ 1 ++ 4 ++ ++ ++ ++ ++ True ++ False ++ _Secret: ++ True ++ 0 ++ ++ ++ 0 ++ 4 ++ ++ ++ ++ ++ True ++ False ++ _User password: ++ True ++ 0 ++ ++ ++ 0 ++ 2 ++ ++ ++ ++ ++ True ++ True ++ True ++ False ++ ++ ++ 1 ++ 2 ++ ++ ++ ++ ++ True ++ False ++ G_roup name: ++ True ++ 0 ++ ++ ++ 0 ++ 3 ++ ++ ++ ++ ++ True ++ True ++ True ++ ++ ++ 1 ++ 3 ++ ++ ++ ++ ++ True ++ False ++ User name: ++ 0 ++ ++ ++ 0 ++ 1 ++ ++ ++ ++ ++ True ++ True ++ True ++ ++ ++ ++ 1 ++ 1 ++ ++ ++ ++ ++ True ++ True ++ end ++ True ++ ++ ++ 1 ++ 0 ++ ++ ++ ++ + + + +- True ++ False + True + 1 + +@@ -188,7 +189,7 @@ + + + False +- True ++ False + 0 + + +@@ -213,96 +214,89 @@ + + + +- ++ + True + False +- 12 ++ 12 ++ 12 ++ vertical ++ 6 ++ 16 + +- ++ + True + False +- +- +- True +- False +- 6 +- 6 +- +- +- True +- False +- Phase1 Algorithms: +- 0 +- +- +- 0 +- 0 +- +- +- +- +- True +- False +- Phase2 Algorithms: +- 0 +- +- +- 0 +- 1 +- +- +- +- +- True +- False +- Domain: +- 0 +- +- +- 0 +- 2 +- +- +- +- +- True +- True +- +- +- +- 1 +- 0 +- +- +- +- +- True +- True +- +- +- +- 1 +- 1 +- +- +- +- +- True +- True +- +- +- +- 1 +- 2 +- +- +- +- ++ Phase1 Algorithms: ++ 0 + ++ ++ 0 ++ 0 ++ ++ ++ ++ ++ True ++ False ++ Phase2 Algorithms: ++ 0 ++ ++ ++ 0 ++ 1 ++ ++ ++ ++ ++ True ++ False ++ Domain: ++ 0 ++ ++ ++ 0 ++ 2 ++ ++ ++ ++ ++ True ++ True ++ True ++ ++ ++ ++ 1 ++ 0 ++ ++ ++ ++ ++ True ++ True ++ True ++ ++ ++ ++ 1 ++ 1 ++ ++ ++ ++ ++ True ++ True ++ True ++ ++ ++ ++ 1 ++ 2 ++ + + + +- True ++ False + True + 1 + +-- +2.5.0 + diff --git a/0011-properties-hide-the-advanced-options.patch b/0011-properties-hide-the-advanced-options.patch new file mode 100644 index 0000000..f0e1519 --- /dev/null +++ b/0011-properties-hide-the-advanced-options.patch @@ -0,0 +1,99 @@ +From e3a56da48f49327b7ee381d9a33c3898df1f083c Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Mon, 25 Jan 2016 17:59:36 +0100 +Subject: [PATCH 11/17] properties: hide the advanced options + +--- + properties/nm-libreswan-dialog.ui | 60 ++++++++++++++++----------------------- + 1 file changed, 25 insertions(+), 35 deletions(-) + +diff --git a/properties/nm-libreswan-dialog.ui b/properties/nm-libreswan-dialog.ui +index 0c77418..0c526a6 100644 +--- a/properties/nm-libreswan-dialog.ui ++++ b/properties/nm-libreswan-dialog.ui +@@ -194,25 +194,11 @@ + + + +- ++ ++ 350 ++ 150 + True +- False +- vertical +- 6 +- +- +- True +- False +- <b>Advanced</b> +- True +- 0 +- +- +- False +- False +- 0 +- +- ++ True + + + True +@@ -223,18 +209,6 @@ + 6 + 16 + +- +- True +- False +- Phase1 Algorithms: +- 0 +- +- +- 0 +- 0 +- +- +- + + True + False +@@ -294,12 +268,28 @@ + 2 + + ++ ++ ++ True ++ False ++ Phase1 Algorithms: ++ 0 ++ ++ ++ 0 ++ 0 ++ ++ ++ ++ ++ ++ ++ True ++ False ++ Ad_vanced ++ True ++ end + +- +- False +- True +- 1 +- + + + +-- +2.5.0 + diff --git a/0012-properties-we-re-not-doing-IKEv2.patch b/0012-properties-we-re-not-doing-IKEv2.patch new file mode 100644 index 0000000..ad6667f --- /dev/null +++ b/0012-properties-we-re-not-doing-IKEv2.patch @@ -0,0 +1,25 @@ +From 47a6f9d4a85fc2a9e9c063a47d45e2276609c0bc Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Mon, 25 Jan 2016 18:12:49 +0100 +Subject: [PATCH 12/17] properties: we're not doing IKEv2 + +--- + properties/nm-libreswan.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/properties/nm-libreswan.c b/properties/nm-libreswan.c +index 7f4cf26..c3dc988 100644 +--- a/properties/nm-libreswan.c ++++ b/properties/nm-libreswan.c +@@ -62,7 +62,7 @@ + #include "utils.h" + + #define LIBRESWAN_PLUGIN_NAME _("IPsec based VPN") +-#define LIBRESWAN_PLUGIN_DESC _("IPsec, IKEv1, IKEv2 based VPN") ++#define LIBRESWAN_PLUGIN_DESC _("IPsec based VPN using IKEv1") + + #define ENC_TYPE_SECURE 0 + #define ENC_TYPE_WEAK 1 +-- +2.5.0 + diff --git a/0013-service-drop-off-the-bus-if-the-peer-vanishes-or-we-.patch b/0013-service-drop-off-the-bus-if-the-peer-vanishes-or-we-.patch new file mode 100644 index 0000000..c25bdb2 --- /dev/null +++ b/0013-service-drop-off-the-bus-if-the-peer-vanishes-or-we-.patch @@ -0,0 +1,25 @@ +From eae2391104513e53f57b16609126cf59d3ae59c4 Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Tue, 26 Jan 2016 13:58:27 +0100 +Subject: [PATCH 13/17] service: drop off the bus if the peer vanishes or we're + unneeded + +--- + src/nm-libreswan-service.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/nm-libreswan-service.c b/src/nm-libreswan-service.c +index e2a217f..4e3773e 100644 +--- a/src/nm-libreswan-service.c ++++ b/src/nm-libreswan-service.c +@@ -1826,6 +1826,7 @@ main (int argc, char *argv[]) + + plugin = g_initable_new (NM_TYPE_LIBRESWAN_PLUGIN, NULL, &error, + NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME, bus_name, ++ NM_VPN_SERVICE_PLUGIN_DBUS_WATCH_PEER, !debug, + NULL); + if (!plugin) { + g_warning ("Failed to initialize a plugin instance: %s", error->message); +-- +2.5.0 + diff --git a/0016-service-handle-the-eclipse-route-properly.patch b/0016-service-handle-the-eclipse-route-properly.patch new file mode 100644 index 0000000..c602024 --- /dev/null +++ b/0016-service-handle-the-eclipse-route-properly.patch @@ -0,0 +1,117 @@ +From 2163138a8275c1f859edd642e6790282df273eea Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Sun, 31 Jan 2016 23:26:38 +0100 +Subject: [PATCH 16/17] service: handle the eclipse route properly + +--- + src/nm-libreswan-service.c | 79 +++++++++++++++++++++++++++------------------- + 1 file changed, 46 insertions(+), 33 deletions(-) + +diff --git a/src/nm-libreswan-service.c b/src/nm-libreswan-service.c +index 4e3773e..0e1a76a 100644 +--- a/src/nm-libreswan-service.c ++++ b/src/nm-libreswan-service.c +@@ -1018,37 +1018,6 @@ lookup_string (GVariant *dict, const gchar *key) + return value; + } + +-static GVariant * +-route_to_gvariant (GVariant *env) +-{ +- GVariantBuilder builder; +- +- if (!lookup_string (env, "PLUTO_PEER_CLIENT")) +- return NULL; +- +- g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); +- +-#define _try_add(builder, variant) \ +- G_STMT_START { \ +- GVariant *_v = (variant); \ +- \ +- if (!_v) \ +- goto fail; \ +- g_variant_builder_add_value ((builder), _v); \ +- } G_STMT_END +- _try_add (&builder, addr4_to_gvariant (lookup_string (env, "PLUTO_PEER_CLIENT_NET"))); +- _try_add (&builder, netmask4_to_gvariant (lookup_string (env, "PLUTO_PEER_CLIENT_MASK"))); +- _try_add (&builder, addr4_to_gvariant (lookup_string (env, "PLUTO_NEXT_HOP"))); +- _try_add (&builder, g_variant_new_uint32 (0)); +- _try_add (&builder, addr4_to_gvariant (lookup_string (env, "PLUTO_MY_SOURCEIP"))); +-#undef _try_add +- +- return g_variant_builder_end (&builder); +-fail: +- g_variant_builder_clear (&builder); +- return NULL; +-} +- + static void + _take_route (GPtrArray *routes, GVariant *new, gboolean alive) + { +@@ -1085,6 +1054,50 @@ _take_route (GPtrArray *routes, GVariant *new, gboolean alive) + g_variant_unref (new); + } + ++static void ++handle_route (GPtrArray *routes, GVariant *env, gboolean alive) ++{ ++ GVariantBuilder builder; ++ const gchar *net, *mask, *next_hop, *my_sourceip; ++ ++ if (!lookup_string (env, "PLUTO_PEER_CLIENT")) ++ return; ++ ++ net = lookup_string (env, "PLUTO_PEER_CLIENT_NET"); ++ mask = lookup_string (env, "PLUTO_PEER_CLIENT_MASK"); ++ next_hop = lookup_string (env, "PLUTO_NEXT_HOP"); ++ my_sourceip = lookup_string (env, "PLUTO_MY_SOURCEIP"); ++ ++ if (!net || !mask || !next_hop || !my_sourceip) ++ return; ++ ++ if (g_strcmp0 (net, "0.0.0.0") == 0 && g_strcmp0 (mask, "0")) { ++ g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); ++ g_variant_builder_add_value (&builder, addr4_to_gvariant ("0.0.0.0")); ++ g_variant_builder_add_value (&builder, netmask4_to_gvariant ("128.0.0.0")); ++ g_variant_builder_add_value (&builder, addr4_to_gvariant (next_hop)); ++ g_variant_builder_add_value (&builder, g_variant_new_uint32 (0)); ++ g_variant_builder_add_value (&builder, addr4_to_gvariant (my_sourceip)); ++ _take_route (routes, g_variant_builder_end (&builder), alive); ++ ++ g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); ++ g_variant_builder_add_value (&builder, addr4_to_gvariant ("128.0.0.0")); ++ g_variant_builder_add_value (&builder, netmask4_to_gvariant ("128.0.0.0")); ++ g_variant_builder_add_value (&builder, addr4_to_gvariant (next_hop)); ++ g_variant_builder_add_value (&builder, g_variant_new_uint32 (0)); ++ g_variant_builder_add_value (&builder, addr4_to_gvariant (my_sourceip)); ++ _take_route (routes, g_variant_builder_end (&builder), alive); ++ } else { ++ g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); ++ g_variant_builder_add_value (&builder, addr4_to_gvariant (net)); ++ g_variant_builder_add_value (&builder, netmask4_to_gvariant (mask)); ++ g_variant_builder_add_value (&builder, addr4_to_gvariant (next_hop)); ++ g_variant_builder_add_value (&builder, g_variant_new_uint32 (0)); ++ g_variant_builder_add_value (&builder, addr4_to_gvariant (my_sourceip)); ++ _take_route (routes, g_variant_builder_end (&builder), alive); ++ } ++} ++ + static gboolean + handle_callback (NMDBusLibreswanHelper *object, + GDBusMethodInvocation *invocation, +@@ -1178,9 +1191,9 @@ handle_callback (NMDBusLibreswanHelper *object, + + /* This route */ + if (g_strcmp0 (verb, "route-client") == 0 || g_strcmp0 (verb, "route-host")) +- _take_route (priv->routes, route_to_gvariant (env), TRUE); ++ handle_route (priv->routes, env, TRUE); + else if (g_strcmp0 (verb, "unroute-client") == 0 || g_strcmp0 (verb, "unroute-host")) +- _take_route (priv->routes, route_to_gvariant (env), FALSE); ++ handle_route (priv->routes, env, FALSE); + + /* Routes */ + g_variant_builder_init (&builder, G_VARIANT_TYPE ("aau")); +-- +2.5.0 + diff --git a/0017-service-don-t-quit-while-we-re-not-done-yet.patch b/0017-service-don-t-quit-while-we-re-not-done-yet.patch new file mode 100644 index 0000000..4c36aef --- /dev/null +++ b/0017-service-don-t-quit-while-we-re-not-done-yet.patch @@ -0,0 +1,219 @@ +From 90893187ea6cf3279ece0bfed6a989cb72288658 Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Mon, 1 Feb 2016 10:01:49 +0100 +Subject: [PATCH 17/17] service: don't quit while we're not done yet + +NetworkManager may have asked us to quit, but we still need to ask +Libreswan to unconfigure the connection. +--- + src/nm-libreswan-service.c | 63 ++++++++++++++++++++++++++++++++++------------ + 1 file changed, 47 insertions(+), 16 deletions(-) + +diff --git a/src/nm-libreswan-service.c b/src/nm-libreswan-service.c +index 0e1a76a..eec6414 100644 +--- a/src/nm-libreswan-service.c ++++ b/src/nm-libreswan-service.c +@@ -109,6 +109,7 @@ typedef struct { + guint watch_id; + guint retry_id; + guint retries; ++ guint quit_blockers; + ConnectStep connect_step; + NMConnection *connection; + NMDBusLibreswanHelper *dbus_skeleton; +@@ -282,6 +283,25 @@ nm_libreswan_secrets_validate (NMSettingVpn *s_vpn, GError **error) + + /****************************************************************/ + ++static void ++block_quit (NMLibreswanPlugin *self) ++{ ++ NMLibreswanPluginPrivate *priv = NM_LIBRESWAN_PLUGIN_GET_PRIVATE (self); ++ priv->quit_blockers++; ++ DEBUG ("Block quit: %d blockers", priv->quit_blockers); ++} ++ ++static void ++unblock_quit (NMLibreswanPlugin *self) ++{ ++ NMLibreswanPluginPrivate *priv = NM_LIBRESWAN_PLUGIN_GET_PRIVATE (self); ++ if (--priv->quit_blockers == 0) ++ g_main_loop_quit (loop); ++ DEBUG ("Unblock quit: %d blockers", priv->quit_blockers); ++} ++ ++/****************************************************************/ ++ + static gboolean connect_step (NMLibreswanPlugin *self, GError **error); + static gboolean pr_cb (GIOChannel *source, GIOCondition condition, gpointer user_data); + +@@ -465,6 +485,7 @@ check_running_cb (GPid pid, gint status, gpointer user_data) + ret = WEXITSTATUS (status); + + DEBUG ("Spawn: child %d exited with status %d", pid, ret); ++ unblock_quit (self); + + /* Reap child */ + waitpid (pid, NULL, WNOHANG); +@@ -515,6 +536,7 @@ child_watch_cb (GPid pid, gint status, gpointer user_data) + priv->pid = 0; + + DEBUG ("Spawn: child %d exited", pid); ++ unblock_quit (self); + + if (WIFEXITED (status)) { + ret = WEXITSTATUS (status); +@@ -554,7 +576,8 @@ child_watch_cb (GPid pid, gint status, gpointer user_data) + g_clear_error (&error); + } + +-static gboolean do_spawn (GPid *out_pid, ++static gboolean do_spawn (NMLibreswanPlugin *self, ++ GPid *out_pid, + int *out_stdin, + int *out_stderr, + GError **error, +@@ -562,7 +585,8 @@ static gboolean do_spawn (GPid *out_pid, + ...) G_GNUC_NULL_TERMINATED; + + static gboolean +-do_spawn (GPid *out_pid, ++do_spawn (NMLibreswanPlugin *self, ++ GPid *out_pid, + int *out_stdin, + int *out_stderr, + GError **error, +@@ -614,6 +638,8 @@ do_spawn (GPid *out_pid, + *out_pid = pid; + + g_ptr_array_free (argv, TRUE); ++ if (success) ++ block_quit (self); + return success; + } + +@@ -661,7 +687,8 @@ nm_libreswan_config_psk_write (NMSettingVpn *s_vpn, + + /****************************************************************/ + +-static gboolean spawn_pty (int *out_stdout, ++static gboolean spawn_pty (NMLibreswanPlugin *self, ++ int *out_stdout, + int *out_stderr, + int *out_ptyin, + GPid *out_pid, +@@ -670,7 +697,8 @@ static gboolean spawn_pty (int *out_stdout, + ...) G_GNUC_NULL_TERMINATED; + + static gboolean +-spawn_pty (int *out_stdout, ++spawn_pty (NMLibreswanPlugin *self, ++ int *out_stdout, + int *out_stderr, + int *out_ptyin, + GPid *out_pid, +@@ -774,6 +802,7 @@ spawn_pty (int *out_stdout, + if (out_pid) + *out_pid = child_pid; + ++ block_quit (self); + return TRUE; + } + +@@ -1408,7 +1437,7 @@ connect_step (NMLibreswanPlugin *self, GError **error) + priv->connect_step++; + + case CONNECT_STEP_CHECK_RUNNING: +- if (!do_spawn (&priv->pid, NULL, NULL, error, priv->ipsec_path, "auto", "--status", NULL)) ++ if (!do_spawn (self, &priv->pid, NULL, NULL, error, priv->ipsec_path, "auto", "--status", NULL)) + return FALSE; + priv->watch_id = g_child_watch_add (priv->pid, check_running_cb, self); + return TRUE; +@@ -1422,7 +1451,7 @@ connect_step (NMLibreswanPlugin *self, GError **error) + return FALSE; + + /* Ensure the right IPsec kernel stack is loaded */ +- success = do_spawn (&priv->pid, NULL, NULL, error, stackman_path, "start", NULL); ++ success = do_spawn (self, &priv->pid, NULL, NULL, error, stackman_path, "start", NULL); + if (success) + priv->watch_id = g_child_watch_add (priv->pid, child_watch_cb, self); + return success; +@@ -1433,9 +1462,9 @@ connect_step (NMLibreswanPlugin *self, GError **error) + case CONNECT_STEP_IPSEC_START: + /* Start the IPsec service */ + if (priv->openswan) +- success = do_spawn (&priv->pid, NULL, NULL, error, priv->ipsec_path, "setup", "start", NULL); ++ success = do_spawn (self, &priv->pid, NULL, NULL, error, priv->ipsec_path, "setup", "start", NULL); + else { +- success = do_spawn (&priv->pid, NULL, NULL, error, ++ success = do_spawn (self, &priv->pid, NULL, NULL, error, + priv->pluto_path, "--config", SYSCONFDIR "/ipsec.conf", + NULL); + } +@@ -1448,14 +1477,14 @@ connect_step (NMLibreswanPlugin *self, GError **error) + case CONNECT_STEP_WAIT_READY: + if (!priv->retries) + priv->retries = 30; +- if (!do_spawn (&priv->pid, NULL, NULL, error, priv->ipsec_path, "auto", "--ready", NULL)) ++ if (!do_spawn (self, &priv->pid, NULL, NULL, error, priv->ipsec_path, "auto", "--ready", NULL)) + return FALSE; + priv->watch_id = g_child_watch_add (priv->pid, child_watch_cb, self); + return TRUE; + + case CONNECT_STEP_CONFIG_ADD: + g_assert (uuid); +- if (!do_spawn (&priv->pid, &fd, NULL, error, priv->ipsec_path, ++ if (!do_spawn (self, &priv->pid, &fd, NULL, error, priv->ipsec_path, + "auto", "--replace", "--config", "-", uuid, NULL)) + return FALSE; + priv->watch_id = g_child_watch_add (priv->pid, child_watch_cb, self); +@@ -1467,7 +1496,7 @@ connect_step (NMLibreswanPlugin *self, GError **error) + + case CONNECT_STEP_CONNECT: + g_assert (uuid); +- if (!spawn_pty (&up_stdout, &up_stderr, &up_pty, &priv->pid, error, ++ if (!spawn_pty (self, &up_stdout, &up_stderr, &up_pty, &priv->pid, error, + priv->ipsec_path, "auto", "--up", uuid, NULL)) + return FALSE; + priv->watch_id = g_child_watch_add (priv->pid, child_watch_cb, self); +@@ -1689,13 +1718,13 @@ real_disconnect (NMVpnServicePlugin *plugin, GError **error) + + if (!priv->managed) { + const char *uuid = nm_connection_get_uuid (priv->connection); +- ret = do_spawn (&priv->pid, NULL, NULL, error, ++ ret = do_spawn (plugin, &priv->pid, NULL, NULL, error, + priv->ipsec_path, "auto", "--delete", uuid, NULL); + } else if (priv->openswan) { +- ret = do_spawn (&priv->pid, NULL, NULL, error, ++ ret = do_spawn (plugin, &priv->pid, NULL, NULL, error, + priv->ipsec_path, "setup", "stop", NULL); + } else { +- ret = do_spawn (&priv->pid, NULL, NULL, error, ++ ret = do_spawn (plugin, &priv->pid, NULL, NULL, error, + priv->whack_path, "--shutdown", NULL); + } + +@@ -1786,7 +1815,8 @@ setup_signals (void) + static void + quit_mainloop (NMLibreswanPlugin *plugin, gpointer user_data) + { +- g_main_loop_quit ((GMainLoop *) user_data); ++ g_signal_handlers_disconnect_by_func (plugin, quit_mainloop, user_data); ++ unblock_quit (plugin); + } + + int +@@ -1868,8 +1898,9 @@ main (int argc, char *argv[]) + + loop = g_main_loop_new (NULL, FALSE); + ++ block_quit (plugin); + if (!persist) +- g_signal_connect (plugin, "quit", G_CALLBACK (quit_mainloop), loop); ++ g_signal_connect (plugin, "quit", G_CALLBACK (quit_mainloop), NULL); + + setup_signals (); + g_main_loop_run (loop); +-- +2.5.0 + diff --git a/NetworkManager-libreswan.spec b/NetworkManager-libreswan.spec index 5716175..842995a 100644 --- a/NetworkManager-libreswan.spec +++ b/NetworkManager-libreswan.spec @@ -5,12 +5,27 @@ Summary: NetworkManager VPN plug-in for IPsec VPN Name: NetworkManager-libreswan Version: 1.2.0 -Release: 0.2%{?snapshot}%{?dist} +Release: 0.3%{?snapshot}%{?dist} License: GPLv2+ URL: http://www.gnome.org/projects/NetworkManager/ Group: System Environment/Base Source0: https://download.gnome.org/sources/NetworkManager-libreswan/1.1/%{name}-1.1.90.tar.xz +Patch1: 0002-trivial-rename-a-badly-named-subroutine.patch +Patch2: 0003-import-export-add-a-terminating-newline.patch +Patch3: 0004-service-disable-agresive-mode-when-there-s-no-group-.patch +Patch4: 0005-service-always-set-modecfgpull-yes.patch +Patch5: 0006-service-avoid-setting-the-default-route-to-the-tunne.patch +Patch6: 0007-properties-don-t-use-depreacted-GtkBox-subclasses.patch +Patch7: 0008-properties-don-t-use-depreacted-GtkGrid.patch +Patch8: 0009-properties-use-the-new-nma-based-password-widgets.patch +Patch9: 0010-properties-some-more-UI-polish.patch +Patch10: 0011-properties-hide-the-advanced-options.patch +Patch11: 0012-properties-we-re-not-doing-IKEv2.patch +Patch12: 0013-service-drop-off-the-bus-if-the-peer-vanishes-or-we-.patch +Patch13: 0016-service-handle-the-eclipse-route-properly.patch +Patch14: 0017-service-don-t-quit-while-we-re-not-done-yet.patch + BuildRequires: gtk3-devel BuildRequires: libnl3-devel BuildRequires: NetworkManager-devel >= %{nm_version} @@ -25,6 +40,7 @@ Requires: NetworkManager >= %{nm_version} Requires: dbus Requires: /usr/sbin/ipsec Requires: shared-mime-info +Requires: autoconf automake Provides: NetworkManager-openswan = %{version}-%{release} Obsoletes: NetworkManager-openswan < %{version}-%{release} @@ -53,8 +69,23 @@ the libreswan server with NetworkManager (GNOME files). %prep %setup -q -n %{name}-1.1.90 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 %build +autoreconf -fi %configure \ --disable-static \ --enable-more-warnings=yes \ @@ -91,6 +122,9 @@ update-desktop-database &> /dev/null || : %changelog +* Mon Feb 1 2016 Lubomir Rintel - 1.2.0-0.3.beta1 +- Update to support Main mode & better Libreswan integration + * Tue Jan 19 2016 Lubomir Rintel - 1.2.0-0.2.beta1 - Update to NetworkManager-libreswan 1.2-beta1