cli: fix handling 802-1x.password-raw
https://bugzilla.gnome.org/show_bug.cgi?id=782836
This commit is contained in:
@@ -1701,11 +1701,12 @@ nmc_util_is_domain (const char *domain)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *value, GError **error)
|
nmc_property_set_bytes (NMSetting *setting, const char *prop, const char *value, GError **error)
|
||||||
{
|
{
|
||||||
char **strv = NULL, **iter;
|
gs_free char *val_strip = NULL;
|
||||||
char *val_strip;
|
gs_strfreev char **strv = NULL;
|
||||||
const char *delimiters = " \t,";
|
const char *delimiters = " \t,";
|
||||||
|
char **iter;
|
||||||
long int val_int;
|
long int val_int;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
GByteArray *array = NULL;
|
GByteArray *array = NULL;
|
||||||
@@ -1717,30 +1718,33 @@ nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *v
|
|||||||
|
|
||||||
/* First try hex string in the format of AAbbCCDd */
|
/* First try hex string in the format of AAbbCCDd */
|
||||||
bytes = nm_utils_hexstr2bin (val_strip);
|
bytes = nm_utils_hexstr2bin (val_strip);
|
||||||
if (bytes) {
|
if (bytes)
|
||||||
array = g_bytes_unref_to_array (bytes);
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
|
||||||
/* Otherwise, consider the following format: AA b 0xCc D */
|
/* Otherwise, consider the following format: AA b 0xCc D */
|
||||||
strv = nmc_strsplit_set (val_strip, delimiters, 0);
|
strv = nmc_strsplit_set (val_strip, delimiters, 0);
|
||||||
array = g_byte_array_sized_new (g_strv_length (strv));
|
array = g_byte_array_sized_new (g_strv_length (strv));
|
||||||
for (iter = strv; iter && *iter; iter++) {
|
for (iter = strv; iter && *iter; iter++) {
|
||||||
|
guint8 v8;
|
||||||
|
|
||||||
if (!nmc_string_to_int_base (g_strstrip (*iter), 16, TRUE, 0, 255, &val_int)) {
|
if (!nmc_string_to_int_base (g_strstrip (*iter), 16, TRUE, 0, 255, &val_int)) {
|
||||||
g_set_error (error, 1, 0, _("'%s' is not a valid hex character"), *iter);
|
g_set_error (error, 1, 0, _("'%s' is not a valid hex character"), *iter);
|
||||||
|
g_byte_array_free (array, TRUE);
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
g_byte_array_append (array, (const guint8 *) &val_int, 1);
|
v8 = val_int;
|
||||||
|
g_byte_array_append (array, &v8, 1);
|
||||||
}
|
}
|
||||||
|
bytes = g_byte_array_free_to_bytes (array);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (success)
|
if (success)
|
||||||
g_object_set (setting, prop, array, NULL);
|
g_object_set (setting, prop, bytes, NULL);
|
||||||
|
|
||||||
|
if (bytes)
|
||||||
|
g_bytes_unref (bytes);
|
||||||
|
|
||||||
g_strfreev (strv);
|
|
||||||
if (array)
|
|
||||||
g_byte_array_free (array, TRUE);
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2076,7 +2080,7 @@ DEFINE_SETTER_PRIV_KEY (_set_fcn_802_1x_phase2_private_key,
|
|||||||
static gboolean
|
static gboolean
|
||||||
_set_fcn_802_1x_password_raw (ARGS_SET_FCN)
|
_set_fcn_802_1x_password_raw (ARGS_SET_FCN)
|
||||||
{
|
{
|
||||||
return nmc_property_set_byte_array (setting, property_info->property_name, value, error);
|
return nmc_property_set_bytes (setting, property_info->property_name, value, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gconstpointer
|
static gconstpointer
|
||||||
|
Reference in New Issue
Block a user