summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2019-04-23 14:55:32 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2019-05-06 10:10:00 +0200
commiteac15501b2364a20505a90661e037a339a63b0ea (patch)
treea17604275ecc3d9570557b79975de816e7cf6562 /clients
parentee96387578ca5428b9836dda382f9e6d64d5a7a8 (diff)
downloadNetworkManager-eac15501b2364a20505a90661e037a339a63b0ea.tar.gz
cli: parse escape sequences when reading an 802.1x private key
In this way it become possible to specify a filename that includes one of the delimiters.
Diffstat (limited to 'clients')
-rw-r--r--clients/common/nm-meta-setting-desc.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
index b24eb17c2d..858c8a5312 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -2255,17 +2255,25 @@ _set_fcn_cert_8021x (ARGS_SET_FCN)
vtable = &nm_setting_8021x_scheme_vtable[property_info->property_typ_data->subtype.cert_8021x.scheme_type];
if (vtable->is_secret) {
- gs_free char *path = NULL;
nm_auto_free_secret char *password_free = NULL;
- char *password;
-
- path = g_strdup (value);
- password = path + strcspn (path, " \t");
- if (password[0] != '\0') {
- password[0] = '\0';
- password++;
- while (nm_utils_is_separator (password[0]))
- password++;
+ gs_free const char **strv = NULL;
+ const char *password;
+ const char *path;
+ gsize len;
+
+ strv = nm_utils_escaped_tokens_split (value, NM_ASCII_SPACES);
+ len = NM_PTRARRAY_LEN (strv);
+ if (len > 2) {
+ g_set_error_literal (error,
+ NM_UTILS_ERROR,
+ NM_UTILS_ERROR_INVALID_ARGUMENT,
+ _("too many arguments. Please only specify a private key file and optionally a password"));
+ return FALSE;
+ }
+
+ path = len > 0 ? strv[0] : NULL;
+ if (len == 2) {
+ password = strv[1];
} else {
password_free = g_strdup (vtable->passwd_func (NM_SETTING_802_1X (setting)));
password = password_free;