summaryrefslogtreecommitdiff
path: root/clients/common
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:47:40 +0200
commit0f03773b75548151a98cae8d696fcfc698a23bb7 (patch)
treeec8a373670a77f6dcc43a618e24fabdc2c26947d /clients/common
parentd8badb280ce2acfcd0ae6fb3d8d133cae6326b7c (diff)
downloadNetworkManager-0f03773b75548151a98cae8d696fcfc698a23bb7.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. (cherry picked from commit eac15501b2364a20505a90661e037a339a63b0ea)
Diffstat (limited to 'clients/common')
-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 b21ce37cf0..768e371e94 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -2268,17 +2268,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;