[PATCH 5/5] keyfile: Read and write the new 8021x.password-raw field
- From: Evan Broder <evan ebroder net>
- To: networkmanager-list gnome org
- Subject: [PATCH 5/5] keyfile: Read and write the new 8021x.password-raw field
- Date: Thu, 17 Nov 2011 16:36:18 -0800
---
src/settings/plugins/keyfile/reader.c | 20 ++++++++++++++++++++
src/settings/plugins/keyfile/writer.c | 28 ++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c
index dd1868c..f973ce8 100644
--- a/src/settings/plugins/keyfile/reader.c
+++ b/src/settings/plugins/keyfile/reader.c
@@ -823,6 +823,22 @@ ssid_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const char
}
}
+static void
+password_raw_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const char *keyfile_path)
+{
+ const char *setting_name = nm_setting_get_name (setting);
+ GByteArray *array;
+
+ array = get_uchar_array (keyfile, setting_name, key, FALSE, TRUE);
+ if (array) {
+ g_object_set (setting, key, array, NULL);
+ g_byte_array_free (array, TRUE);
+ } else {
+ g_warning ("%s: ignoring invalid raw password for %s / %s",
+ __func__, setting_name, key);
+ }
+}
+
static char *
get_cert_path (const char *keyfile_path, GByteArray *cert_path)
{
@@ -1022,6 +1038,10 @@ static KeyParser key_parsers[] = {
TRUE,
ssid_parser },
{ NM_SETTING_802_1X_SETTING_NAME,
+ NM_SETTING_802_1X_PASSWORD_RAW,
+ TRUE,
+ password_raw_parser },
+ { NM_SETTING_802_1X_SETTING_NAME,
NM_SETTING_802_1X_CA_CERT,
TRUE,
cert_parser },
diff --git a/src/settings/plugins/keyfile/writer.c b/src/settings/plugins/keyfile/writer.c
index 2babe26..3bc8260 100644
--- a/src/settings/plugins/keyfile/writer.c
+++ b/src/settings/plugins/keyfile/writer.c
@@ -532,6 +532,31 @@ ssid_writer (GKeyFile *file,
}
}
+static void
+password_raw_writer (GKeyFile *file,
+ const char *keyfile_dir,
+ const char *uuid,
+ NMSetting *setting,
+ const char *key,
+ const GValue *value)
+{
+ const char *setting_name = nm_setting_get_name (setting);
+ GByteArray *array;
+ int i, *tmp_array;
+
+ g_return_if_fail (G_VALUE_HOLDS (value, DBUS_TYPE_G_UCHAR_ARRAY));
+
+ array = (GByteArray *) g_value_get_boxed (value);
+ if (!array || !array->len)
+ return;
+
+ tmp_array = g_new (gint, array->len);
+ for (i = 0; i < array->len; i++)
+ tmp_array[i] = (int) array->data[i];
+ g_key_file_set_integer_list (file, setting_name, key, tmp_array, array->len);
+ g_free (tmp_array);
+}
+
typedef struct ObjectType {
const char *key;
const char *suffix;
@@ -791,6 +816,9 @@ static KeyWriter key_writers[] = {
NM_SETTING_WIRELESS_SSID,
ssid_writer },
{ NM_SETTING_802_1X_SETTING_NAME,
+ NM_SETTING_802_1X_PASSWORD_RAW,
+ password_raw_writer },
+ { NM_SETTING_802_1X_SETTING_NAME,
NM_SETTING_802_1X_CA_CERT,
cert_writer },
{ NM_SETTING_802_1X_SETTING_NAME,
--
1.7.5.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]