[network-manager-openvpn: 11/27] properties: refactor do_export() (refactor writing "tls-auth")
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn: 11/27] properties: refactor do_export() (refactor writing "tls-auth")
- Date: Tue, 29 Mar 2016 11:32:13 +0000 (UTC)
commit 32264cb7c0f33802590e3439e7b33787bcd6c673
Author: Thomas Haller <thaller redhat com>
Date: Thu Mar 24 10:59:32 2016 +0100
properties: refactor do_export() (refactor writing "tls-auth")
properties/import-export.c | 25 +++++++++----------------
1 files changed, 9 insertions(+), 16 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index ede7e12..1ba0587 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -1650,8 +1650,6 @@ do_export_create (NMConnection *connection, const char *path, GError **error)
gs_free char *private_key = NULL;
const char *local_ip = NULL;
const char *remote_ip = NULL;
- gs_free char *tls_auth = NULL;
- const char *tls_auth_dir = NULL;
gs_free char *device = NULL;
const char *device_type = NULL;
const char *device_default = "tun";
@@ -1773,14 +1771,6 @@ do_export_create (NMConnection *connection, const char *path, GError **error)
if (_arg_is_set (value))
remote_ip = value;
- value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_TA);
- if (_arg_is_set (value))
- tls_auth = nmv_utils_str_utf8safe_unescape (value);
-
- value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_TA_DIR);
- if (_arg_is_set (value))
- tls_auth_dir = value;
-
value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE_RANDOM);
if (value && !strcmp (value, "yes"))
randomize_hosts = TRUE;
@@ -1904,17 +1894,20 @@ do_export_create (NMConnection *connection, const char *path, GError **error)
if (local_ip && remote_ip)
args_write_line (f, "ifconfig", local_ip, remote_ip);
- if ( !strcmp(connection_type, NM_OPENVPN_CONTYPE_TLS)
- || !strcmp(connection_type, NM_OPENVPN_CONTYPE_PASSWORD_TLS)) {
-
+ if (NM_IN_STRSET (connection_type,
+ NM_OPENVPN_CONTYPE_TLS,
+ NM_OPENVPN_CONTYPE_PASSWORD_TLS)) {
args_write_line_setting_value (f, "tls-remote", s_vpn, NM_OPENVPN_KEY_TLS_REMOTE);
args_write_line_setting_value (f, "remote-cert-tls", s_vpn, NM_OPENVPN_KEY_REMOTE_CERT_TLS);
- if (tls_auth) {
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_TA);
+ if (_arg_is_set (value)) {
+ gs_free char *s_free = NULL;
+
args_write_line (f,
"tls-auth",
- tls_auth,
- tls_auth_dir);
+ nmv_utils_str_utf8safe_unescape_c (value, &s_free),
+ _arg_is_set (nm_setting_vpn_get_data_item (s_vpn,
NM_OPENVPN_KEY_TA_DIR)));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]