[network-manager-openvpn] properties: simplify blob handling for import
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn] properties: simplify blob handling for import
- Date: Thu, 28 Jan 2016 10:30:34 +0000 (UTC)
commit 4a94aa814f26bad03e1277b1d0d978deadb129ae
Author: Matthias Berndt <matthias_berndt gmx de>
Date: Tue Jan 26 22:55:24 2016 +0100
properties: simplify blob handling for import
https://mail.gnome.org/archives/networkmanager-list/2016-January/msg00047.html
https://mail.gnome.org/archives/networkmanager-list/2016-January/msg00072.html
properties/import-export.c | 29 +----------------------------
1 files changed, 1 insertions(+), 28 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index 680a045..c6ba723 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -218,8 +218,6 @@ handle_blob_item (const char ***line,
GError **error)
{
gboolean success = FALSE;
- const char *blob_mark_start, *blob_mark_end;
- const char *blob_mark_start2 = NULL, *blob_mark_end2 = NULL;
const char *start_tag, *end_tag;
char *filename = NULL;
char *dirname = NULL;
@@ -239,25 +237,15 @@ handle_blob_item (const char ***line,
if (!strcmp (key, NM_OPENVPN_KEY_CA)) {
start_tag = CA_BLOB_START_TAG;
end_tag = CA_BLOB_END_TAG;
- blob_mark_start = CERT_BEGIN;
- blob_mark_end = CERT_END;
} else if (!strcmp (key, NM_OPENVPN_KEY_CERT)) {
start_tag = CERT_BLOB_START_TAG;
end_tag = CERT_BLOB_END_TAG;
- blob_mark_start = CERT_BEGIN;
- blob_mark_end = CERT_END;
} else if (!strcmp (key, NM_OPENVPN_KEY_TA)) {
start_tag = TLS_AUTH_BLOB_START_TAG;
end_tag = TLS_AUTH_BLOB_END_TAG;
- blob_mark_start = STATIC_KEY_BEGIN;
- blob_mark_end = STATIC_KEY_END;
} else if (!strcmp (key, NM_OPENVPN_KEY_KEY)) {
start_tag = KEY_BLOB_START_TAG;
end_tag = KEY_BLOB_END_TAG;
- blob_mark_start = PRIV_KEY_BEGIN;
- blob_mark_end = PRIV_KEY_END;
- blob_mark_start2 = RSA_PRIV_KEY_BEGIN;
- blob_mark_end2 = RSA_PRIV_KEY_END;
} else
g_return_val_if_reached (FALSE);
p = *line;
@@ -266,25 +254,14 @@ handle_blob_item (const char ***line,
NEXT_LINE;
- if (blob_mark_start2 && !strcmp (*p, blob_mark_start2)) {
- blob_mark_start = blob_mark_start2;
- blob_mark_end = blob_mark_end2;
- } else if (strcmp (*p, blob_mark_start))
- goto finish;
-
- NEXT_LINE;
in_file = g_string_new (NULL);
- while (*p && strcmp (*p, blob_mark_end)) {
+ while (*p && strcmp (*p, end_tag)) {
g_string_append (in_file, *p);
g_string_append_c (in_file, '\n');
NEXT_LINE;
}
- NEXT_LINE;
- if (strncmp (*p, end_tag, strlen (end_tag)))
- goto finish;
-
/* Construct file name to write the data in */
filename = g_strdup_printf ("%s-%s.pem", name, key);
dirname = g_build_filename (g_get_home_dir (), ".cert", NULL);
@@ -300,15 +277,11 @@ handle_blob_item (const char ***line,
}
/* Write the new file */
- g_string_prepend_c (in_file, '\n');
- g_string_prepend (in_file, blob_mark_start);
- g_string_append_printf (in_file, "%s\n", blob_mark_end);
success = g_file_set_contents (path, in_file->str, -1, error);
if (!success)
goto finish;
nm_setting_vpn_add_data_item (s_vpn, key, path);
-
finish:
*line = p;
g_free (filename);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]