mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-23 11:40:22 +01:00
keyfile/writer: fix password_raw_writer() to write NMSetting8021x:password-raw
After refactoring libnm-core to use GBytes instead of GByteArray/DBUS_TYPE_G_UCHAR_ARRAY, it was forgotten to update keyfile writer. This causes keyfile writer to skip the NMSetting8021x:password-raw setting and raise a g_critical() warning. Fixes:c43f88907b(cherry picked from commitc651b27793)
This commit is contained in:
parent
7496cad4aa
commit
7f8e486723
2 changed files with 31 additions and 11 deletions
|
|
@ -2564,10 +2564,22 @@ test_write_wired_8021x_tls_connection_blob (void)
|
|||
char *new_priv_key;
|
||||
const char *uuid;
|
||||
GError *error = NULL;
|
||||
GBytes *password_raw = NULL;
|
||||
#define PASSWORD_RAW "password-raw\0test"
|
||||
|
||||
connection = create_wired_tls_connection (NM_SETTING_802_1X_CK_SCHEME_BLOB);
|
||||
g_assert (connection != NULL);
|
||||
|
||||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||
g_assert (s_8021x);
|
||||
|
||||
password_raw = g_bytes_new (PASSWORD_RAW, STRLEN (PASSWORD_RAW));
|
||||
g_object_set (s_8021x,
|
||||
NM_SETTING_802_1X_PASSWORD_RAW,
|
||||
password_raw,
|
||||
NULL);
|
||||
g_bytes_unref (password_raw);
|
||||
|
||||
/* Write out the connection */
|
||||
success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, geteuid (), getegid (), &testfile, &error);
|
||||
if (!success) {
|
||||
|
|
@ -2610,6 +2622,11 @@ test_write_wired_8021x_tls_connection_blob (void)
|
|||
g_assert (nm_setting_802_1x_get_client_cert_scheme (s_8021x) == NM_SETTING_802_1X_CK_SCHEME_PATH);
|
||||
g_assert (nm_setting_802_1x_get_private_key_scheme (s_8021x) == NM_SETTING_802_1X_CK_SCHEME_PATH);
|
||||
|
||||
password_raw = nm_setting_802_1x_get_password_raw (s_8021x);
|
||||
g_assert (password_raw);
|
||||
g_assert (g_bytes_get_size (password_raw) == STRLEN (PASSWORD_RAW));
|
||||
g_assert (!memcmp (g_bytes_get_data (password_raw, NULL), PASSWORD_RAW, STRLEN (PASSWORD_RAW)));
|
||||
|
||||
unlink (testfile);
|
||||
g_free (testfile);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <nm-setting.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
|
|
@ -42,7 +41,6 @@
|
|||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-logging.h"
|
||||
#include "writer.h"
|
||||
|
|
@ -345,19 +343,24 @@ password_raw_writer (GKeyFile *file,
|
|||
const GValue *value)
|
||||
{
|
||||
const char *setting_name = nm_setting_get_name (setting);
|
||||
GByteArray *array;
|
||||
int i, *tmp_array;
|
||||
GBytes *array;
|
||||
int *tmp_array;
|
||||
gsize i, len;
|
||||
const char *data;
|
||||
|
||||
g_return_if_fail (G_VALUE_HOLDS (value, DBUS_TYPE_G_UCHAR_ARRAY));
|
||||
g_return_if_fail (G_VALUE_HOLDS (value, G_TYPE_BYTES));
|
||||
|
||||
array = (GByteArray *) g_value_get_boxed (value);
|
||||
if (!array || !array->len)
|
||||
array = (GBytes *) g_value_get_boxed (value);
|
||||
if (!array)
|
||||
return;
|
||||
data = g_bytes_get_data (array, &len);
|
||||
if (!data || !len)
|
||||
return;
|
||||
|
||||
tmp_array = g_new (gint, array->len);
|
||||
for (i = 0; i < array->len; i++)
|
||||
tmp_array[i] = (int) array->data[i];
|
||||
nm_keyfile_plugin_kf_set_integer_list (file, setting_name, key, tmp_array, array->len);
|
||||
tmp_array = g_new (gint, len);
|
||||
for (i = 0; i < len; i++)
|
||||
tmp_array[i] = (int) data[i];
|
||||
nm_keyfile_plugin_kf_set_integer_list (file, setting_name, key, tmp_array, len);
|
||||
g_free (tmp_array);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue