[network-manager-libreswan/lr/main-mode: 3/5] service: disable agresive mode when there's no group name



commit 2c510b631d5bec3cbd130cde308a5cff00adcd2e
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Thu Jan 21 21:46:58 2016 +0100

    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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]