[network-manager-openswan/dcbw/libreswan: 7/12] core: work around libreswan config-terminating oddity
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openswan/dcbw/libreswan: 7/12] core: work around libreswan config-terminating oddity
- Date: Tue, 2 Dec 2014 01:02:53 +0000 (UTC)
commit 73136e8ff715316075e8f49610b546a399305024
Author: Dan Williams <dcbw redhat com>
Date: Mon Oct 20 16:35:37 2014 -0500
core: work around libreswan config-terminating oddity
libreswan doesn't want a \n on the last line of configuration,
but openswan segfaults if you don't have it. Yay.
src/nm-openswan-service.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/nm-openswan-service.c b/src/nm-openswan-service.c
index b00ca5f..3f33700 100644
--- a/src/nm-openswan-service.c
+++ b/src/nm-openswan-service.c
@@ -549,7 +549,10 @@ write_config_option (int fd, const char *format, ...)
}
static void
-nm_openswan_config_write (gint fd, NMConnection *connection, GError **error)
+nm_openswan_config_write (gint fd,
+ NMConnection *connection,
+ gboolean libreswan,
+ GError **error)
{
NMSettingVPN *s_vpn = nm_connection_get_setting_vpn (connection);
const char *con_name = nm_connection_get_uuid (connection);
@@ -600,7 +603,16 @@ nm_openswan_config_write (gint fd, NMConnection *connection, GError **error)
write_config_option (fd, " salifetime=24h\n");
write_config_option (fd, " ikelifetime=24h\n");
write_config_option (fd, " keyingtries=1\n");
- write_config_option (fd, " auto=add\n");
+ write_config_option (fd, " auto=add");
+
+ /* openswan requires a terminating \n (otherwise it segfaults) while
+ * libreswan fails parsing the configuration if you include the \n.
+ * WTF?
+ */
+ if (!libreswan)
+ (void) write (fd, "\n", 1);
+ if (debug)
+ g_print ("\n");
}
static gboolean
@@ -970,7 +982,7 @@ connect_step (NMOpenSwanPlugin *self, GError **error)
"auto", "--replace", "--config", "-", uuid, NULL))
return FALSE;
priv->watch_id = g_child_watch_add (priv->pid, pluto_watch_cb, self);
- nm_openswan_config_write (fd, priv->connection, error);
+ nm_openswan_config_write (fd, priv->connection, priv->libreswan, error);
close (fd);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]