libnm-core: change DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES
Change all DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES, and update corresponding APIs. Notably, this means they are now refcounted rather than being copied. Update the rest of NM for the changes. The daemon still converts SSIDs to GByteArrays internally, because changing it to use GBytes has lots of trickle-down effects. It can possibly be changed later.
This commit is contained in:
@@ -423,6 +423,34 @@ nmc_convert_string_hash_to_string (const GValue *src_value, GValue *dest_value)
|
|||||||
g_value_take_string (dest_value, g_string_free (string, FALSE));
|
g_value_take_string (dest_value, g_string_free (string, FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nmc_convert_bytes_to_string (const GValue *src_value, GValue *dest_value)
|
||||||
|
{
|
||||||
|
GBytes *bytes;
|
||||||
|
const guint8 *array;
|
||||||
|
gsize length;
|
||||||
|
GString *printable;
|
||||||
|
guint i = 0;
|
||||||
|
|
||||||
|
bytes = g_value_get_boxed (src_value);
|
||||||
|
|
||||||
|
printable = g_string_new ("[");
|
||||||
|
|
||||||
|
if (bytes) {
|
||||||
|
array = g_bytes_get_data (bytes, &length);
|
||||||
|
while (i < MIN (length, 35)) {
|
||||||
|
if (i > 0)
|
||||||
|
g_string_append_c (printable, ' ');
|
||||||
|
g_string_append_printf (printable, "0x%02X", array[i++]);
|
||||||
|
}
|
||||||
|
if (i < length)
|
||||||
|
g_string_append (printable, " ... ");
|
||||||
|
}
|
||||||
|
g_string_append_c (printable, ']');
|
||||||
|
|
||||||
|
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nmc_value_transforms_register (void)
|
nmc_value_transforms_register (void)
|
||||||
{
|
{
|
||||||
@@ -436,6 +464,10 @@ nmc_value_transforms_register (void)
|
|||||||
g_value_register_transform_func (G_TYPE_HASH_TABLE,
|
g_value_register_transform_func (G_TYPE_HASH_TABLE,
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
nmc_convert_string_hash_to_string);
|
nmc_convert_string_hash_to_string);
|
||||||
|
|
||||||
|
g_value_register_transform_func (G_TYPE_BYTES,
|
||||||
|
G_TYPE_STRING,
|
||||||
|
nmc_convert_bytes_to_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMClient *
|
static NMClient *
|
||||||
|
@@ -663,19 +663,22 @@ wep_key_type_to_string (NMWepKeyType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
byte_array_to_string (const GByteArray *array)
|
bytes_to_string (GBytes *bytes)
|
||||||
{
|
{
|
||||||
|
const guint8 *data;
|
||||||
|
gsize len;
|
||||||
GString *cert = NULL;
|
GString *cert = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (array && array->len > 0)
|
if (!bytes)
|
||||||
cert = g_string_new (NULL);
|
return NULL;
|
||||||
|
data = g_bytes_get_data (bytes, &len);
|
||||||
|
|
||||||
for (i = 0; array && i < array->len; i++) {
|
cert = g_string_new (NULL);
|
||||||
g_string_append_printf (cert, "%02X", array->data[i]);
|
for (i = 0; i < len; i++)
|
||||||
}
|
g_string_append_printf (cert, "%02X", data[i]);
|
||||||
|
|
||||||
return cert ? g_string_free (cert, FALSE) : NULL;
|
return g_string_free (cert, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@@ -843,7 +846,7 @@ nmc_property_802_1X_get_ca_cert (NMSetting *setting)
|
|||||||
|
|
||||||
scheme = nm_setting_802_1x_get_ca_cert_scheme (s_8021X);
|
scheme = nm_setting_802_1x_get_ca_cert_scheme (s_8021X);
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||||
ca_cert_str = byte_array_to_string (nm_setting_802_1x_get_ca_cert_blob (s_8021X));
|
ca_cert_str = bytes_to_string (nm_setting_802_1x_get_ca_cert_blob (s_8021X));
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
ca_cert_str = g_strdup (nm_setting_802_1x_get_ca_cert_path (s_8021X));
|
ca_cert_str = g_strdup (nm_setting_802_1x_get_ca_cert_path (s_8021X));
|
||||||
|
|
||||||
@@ -859,7 +862,7 @@ nmc_property_802_1X_get_client_cert (NMSetting *setting)
|
|||||||
|
|
||||||
scheme = nm_setting_802_1x_get_client_cert_scheme (s_8021X);
|
scheme = nm_setting_802_1x_get_client_cert_scheme (s_8021X);
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||||
client_cert_str = byte_array_to_string (nm_setting_802_1x_get_client_cert_blob (s_8021X));
|
client_cert_str = bytes_to_string (nm_setting_802_1x_get_client_cert_blob (s_8021X));
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
client_cert_str = g_strdup (nm_setting_802_1x_get_client_cert_path (s_8021X));
|
client_cert_str = g_strdup (nm_setting_802_1x_get_client_cert_path (s_8021X));
|
||||||
|
|
||||||
@@ -875,7 +878,7 @@ nmc_property_802_1X_get_phase2_ca_cert (NMSetting *setting)
|
|||||||
|
|
||||||
scheme = nm_setting_802_1x_get_phase2_ca_cert_scheme (s_8021X);
|
scheme = nm_setting_802_1x_get_phase2_ca_cert_scheme (s_8021X);
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||||
phase2_ca_cert_str = byte_array_to_string (nm_setting_802_1x_get_phase2_ca_cert_blob (s_8021X));
|
phase2_ca_cert_str = bytes_to_string (nm_setting_802_1x_get_phase2_ca_cert_blob (s_8021X));
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
phase2_ca_cert_str = g_strdup (nm_setting_802_1x_get_phase2_ca_cert_path (s_8021X));
|
phase2_ca_cert_str = g_strdup (nm_setting_802_1x_get_phase2_ca_cert_path (s_8021X));
|
||||||
|
|
||||||
@@ -891,7 +894,7 @@ nmc_property_802_1X_get_phase2_client_cert (NMSetting *setting)
|
|||||||
|
|
||||||
scheme = nm_setting_802_1x_get_phase2_client_cert_scheme (s_8021X);
|
scheme = nm_setting_802_1x_get_phase2_client_cert_scheme (s_8021X);
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||||
phase2_client_cert_str = byte_array_to_string (nm_setting_802_1x_get_phase2_client_cert_blob (s_8021X));
|
phase2_client_cert_str = bytes_to_string (nm_setting_802_1x_get_phase2_client_cert_blob (s_8021X));
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
phase2_client_cert_str = g_strdup (nm_setting_802_1x_get_phase2_client_cert_path (s_8021X));
|
phase2_client_cert_str = g_strdup (nm_setting_802_1x_get_phase2_client_cert_path (s_8021X));
|
||||||
|
|
||||||
@@ -902,7 +905,7 @@ static char *
|
|||||||
nmc_property_802_1X_get_password_raw (NMSetting *setting)
|
nmc_property_802_1X_get_password_raw (NMSetting *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
|
NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
|
||||||
return byte_array_to_string (nm_setting_802_1x_get_password_raw (s_8021X));
|
return bytes_to_string (nm_setting_802_1x_get_password_raw (s_8021X));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@@ -914,7 +917,7 @@ nmc_property_802_1X_get_private_key (NMSetting *setting)
|
|||||||
|
|
||||||
scheme = nm_setting_802_1x_get_private_key_scheme (s_8021X);
|
scheme = nm_setting_802_1x_get_private_key_scheme (s_8021X);
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||||
private_key_str = byte_array_to_string (nm_setting_802_1x_get_private_key_blob (s_8021X));
|
private_key_str = bytes_to_string (nm_setting_802_1x_get_private_key_blob (s_8021X));
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
private_key_str = g_strdup (nm_setting_802_1x_get_private_key_path (s_8021X));
|
private_key_str = g_strdup (nm_setting_802_1x_get_private_key_path (s_8021X));
|
||||||
|
|
||||||
@@ -930,7 +933,7 @@ nmc_property_802_1X_get_phase2_private_key (NMSetting *setting)
|
|||||||
|
|
||||||
scheme = nm_setting_802_1x_get_phase2_private_key_scheme (s_8021X);
|
scheme = nm_setting_802_1x_get_phase2_private_key_scheme (s_8021X);
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||||
phase2_private_key_str = byte_array_to_string (nm_setting_802_1x_get_phase2_private_key_blob (s_8021X));
|
phase2_private_key_str = bytes_to_string (nm_setting_802_1x_get_phase2_private_key_blob (s_8021X));
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
phase2_private_key_str = g_strdup (nm_setting_802_1x_get_phase2_private_key_path (s_8021X));
|
phase2_private_key_str = g_strdup (nm_setting_802_1x_get_phase2_private_key_path (s_8021X));
|
||||||
|
|
||||||
@@ -1382,12 +1385,14 @@ static char *
|
|||||||
nmc_property_olpc_get_ssid (NMSetting *setting)
|
nmc_property_olpc_get_ssid (NMSetting *setting)
|
||||||
{
|
{
|
||||||
NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
|
NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
char *ssid_str = NULL;
|
char *ssid_str = NULL;
|
||||||
|
|
||||||
ssid = nm_setting_olpc_mesh_get_ssid (s_olpc_mesh);
|
ssid = nm_setting_olpc_mesh_get_ssid (s_olpc_mesh);
|
||||||
if (ssid)
|
if (ssid) {
|
||||||
ssid_str = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
|
||||||
|
g_bytes_get_size (ssid));
|
||||||
|
}
|
||||||
|
|
||||||
return ssid_str;
|
return ssid_str;
|
||||||
}
|
}
|
||||||
@@ -1525,12 +1530,14 @@ static char *
|
|||||||
nmc_property_wireless_get_ssid (NMSetting *setting)
|
nmc_property_wireless_get_ssid (NMSetting *setting)
|
||||||
{
|
{
|
||||||
NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
|
NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
char *ssid_str = NULL;
|
char *ssid_str = NULL;
|
||||||
|
|
||||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
if (ssid)
|
if (ssid) {
|
||||||
ssid_str = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
|
||||||
|
g_bytes_get_size (ssid));
|
||||||
|
}
|
||||||
|
|
||||||
return ssid_str;
|
return ssid_str;
|
||||||
}
|
}
|
||||||
|
@@ -134,11 +134,12 @@ ssid_transform_to_entry (GBinding *binding,
|
|||||||
GValue *target_value,
|
GValue *target_value,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
char *utf8;
|
char *utf8;
|
||||||
|
|
||||||
ssid = g_value_get_boxed (source_value);
|
ssid = g_value_get_boxed (source_value);
|
||||||
utf8 = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
utf8 = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
|
||||||
|
g_bytes_get_size (ssid));
|
||||||
g_value_take_string (target_value, utf8);
|
g_value_take_string (target_value, utf8);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -151,14 +152,14 @@ ssid_transform_from_entry (GBinding *binding,
|
|||||||
{
|
{
|
||||||
NMSettingWireless *s_wireless = user_data;
|
NMSettingWireless *s_wireless = user_data;
|
||||||
const char *text;
|
const char *text;
|
||||||
const GByteArray *old_ssid;
|
GBytes *old_ssid, *ssid;
|
||||||
GByteArray *ssid;
|
|
||||||
char *utf8;
|
char *utf8;
|
||||||
|
|
||||||
text = g_value_get_string (source_value);
|
text = g_value_get_string (source_value);
|
||||||
|
|
||||||
old_ssid = nm_setting_wireless_get_ssid (s_wireless);
|
old_ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
utf8 = nm_utils_ssid_to_utf8 (old_ssid->data, old_ssid->len);
|
utf8 = nm_utils_ssid_to_utf8 (g_bytes_get_data (old_ssid, NULL),
|
||||||
|
g_bytes_get_size (old_ssid));
|
||||||
|
|
||||||
if (!g_strcmp0 (text, utf8)) {
|
if (!g_strcmp0 (text, utf8)) {
|
||||||
g_free (utf8);
|
g_free (utf8);
|
||||||
@@ -166,8 +167,7 @@ ssid_transform_from_entry (GBinding *binding,
|
|||||||
}
|
}
|
||||||
g_free (utf8);
|
g_free (utf8);
|
||||||
|
|
||||||
ssid = g_byte_array_new ();
|
ssid = g_bytes_new (text, strlen (text));
|
||||||
g_byte_array_append (ssid, (guint8 *)text, strlen (text));
|
|
||||||
g_value_take_boxed (target_value, ssid);
|
g_value_take_boxed (target_value, ssid);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -329,12 +329,13 @@ request_secrets_from_ui (NmtSecretAgentRequest *request)
|
|||||||
|
|
||||||
if (nm_connection_is_type (request->connection, NM_SETTING_WIRELESS_SETTING_NAME)) {
|
if (nm_connection_is_type (request->connection, NM_SETTING_WIRELESS_SETTING_NAME)) {
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
char *ssid_utf8;
|
char *ssid_utf8;
|
||||||
|
|
||||||
s_wireless = nm_connection_get_setting_wireless (request->connection);
|
s_wireless = nm_connection_get_setting_wireless (request->connection);
|
||||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
ssid_utf8 = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
ssid_utf8 = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
|
||||||
|
g_bytes_get_size (ssid));
|
||||||
|
|
||||||
title = _("Authentication required by wireless network");
|
title = _("Authentication required by wireless network");
|
||||||
msg = g_strdup_printf (_("Passwords or encryption keys are required to access the wireless network '%s'."), ssid_utf8);
|
msg = g_strdup_printf (_("Passwords or encryption keys are required to access the wireless network '%s'."), ssid_utf8);
|
||||||
|
@@ -94,31 +94,31 @@ typedef struct {
|
|||||||
char *identity;
|
char *identity;
|
||||||
char *anonymous_identity;
|
char *anonymous_identity;
|
||||||
char *pac_file;
|
char *pac_file;
|
||||||
GByteArray *ca_cert;
|
GBytes *ca_cert;
|
||||||
char *ca_path;
|
char *ca_path;
|
||||||
char *subject_match;
|
char *subject_match;
|
||||||
GSList *altsubject_matches;
|
GSList *altsubject_matches;
|
||||||
GByteArray *client_cert;
|
GBytes *client_cert;
|
||||||
char *phase1_peapver;
|
char *phase1_peapver;
|
||||||
char *phase1_peaplabel;
|
char *phase1_peaplabel;
|
||||||
char *phase1_fast_provisioning;
|
char *phase1_fast_provisioning;
|
||||||
char *phase2_auth;
|
char *phase2_auth;
|
||||||
char *phase2_autheap;
|
char *phase2_autheap;
|
||||||
GByteArray *phase2_ca_cert;
|
GBytes *phase2_ca_cert;
|
||||||
char *phase2_ca_path;
|
char *phase2_ca_path;
|
||||||
char *phase2_subject_match;
|
char *phase2_subject_match;
|
||||||
GSList *phase2_altsubject_matches;
|
GSList *phase2_altsubject_matches;
|
||||||
GByteArray *phase2_client_cert;
|
GBytes *phase2_client_cert;
|
||||||
char *password;
|
char *password;
|
||||||
NMSettingSecretFlags password_flags;
|
NMSettingSecretFlags password_flags;
|
||||||
GByteArray *password_raw;
|
GBytes *password_raw;
|
||||||
NMSettingSecretFlags password_raw_flags;
|
NMSettingSecretFlags password_raw_flags;
|
||||||
char *pin;
|
char *pin;
|
||||||
NMSettingSecretFlags pin_flags;
|
NMSettingSecretFlags pin_flags;
|
||||||
GByteArray *private_key;
|
GBytes *private_key;
|
||||||
char *private_key_password;
|
char *private_key_password;
|
||||||
NMSettingSecretFlags private_key_password_flags;
|
NMSettingSecretFlags private_key_password_flags;
|
||||||
GByteArray *phase2_private_key;
|
GBytes *phase2_private_key;
|
||||||
char *phase2_private_key_password;
|
char *phase2_private_key_password;
|
||||||
NMSettingSecretFlags phase2_private_key_password_flags;
|
NMSettingSecretFlags phase2_private_key_password_flags;
|
||||||
gboolean system_ca_certs;
|
gboolean system_ca_certs;
|
||||||
@@ -416,13 +416,20 @@ nm_setting_802_1x_get_system_ca_certs (NMSetting8021x *setting)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMSetting8021xCKScheme
|
static NMSetting8021xCKScheme
|
||||||
get_cert_scheme (GByteArray *array)
|
get_cert_scheme (GBytes *bytes)
|
||||||
{
|
{
|
||||||
if (!array || !array->len)
|
gconstpointer data;
|
||||||
|
gsize length;
|
||||||
|
|
||||||
|
if (!bytes)
|
||||||
return NM_SETTING_802_1X_CK_SCHEME_UNKNOWN;
|
return NM_SETTING_802_1X_CK_SCHEME_UNKNOWN;
|
||||||
|
|
||||||
if ( (array->len > strlen (SCHEME_PATH))
|
data = g_bytes_get_data (bytes, &length);
|
||||||
&& !memcmp (array->data, SCHEME_PATH, strlen (SCHEME_PATH)))
|
if (!length)
|
||||||
|
return NM_SETTING_802_1X_CK_SCHEME_UNKNOWN;
|
||||||
|
|
||||||
|
if ( (length > strlen (SCHEME_PATH))
|
||||||
|
&& !memcmp (data, SCHEME_PATH, strlen (SCHEME_PATH)))
|
||||||
return NM_SETTING_802_1X_CK_SCHEME_PATH;
|
return NM_SETTING_802_1X_CK_SCHEME_PATH;
|
||||||
|
|
||||||
return NM_SETTING_802_1X_CK_SCHEME_BLOB;
|
return NM_SETTING_802_1X_CK_SCHEME_BLOB;
|
||||||
@@ -459,7 +466,7 @@ nm_setting_802_1x_get_ca_cert_scheme (NMSetting8021x *setting)
|
|||||||
*
|
*
|
||||||
* Returns: the CA certificate data
|
* Returns: the CA certificate data
|
||||||
**/
|
**/
|
||||||
const GByteArray *
|
GBytes *
|
||||||
nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting)
|
nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
@@ -489,16 +496,18 @@ const char *
|
|||||||
nm_setting_802_1x_get_ca_cert_path (NMSetting8021x *setting)
|
nm_setting_802_1x_get_ca_cert_path (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
|
gconstpointer data;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||||
|
|
||||||
scheme = nm_setting_802_1x_get_ca_cert_scheme (setting);
|
scheme = nm_setting_802_1x_get_ca_cert_scheme (setting);
|
||||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||||
|
|
||||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->ca_cert->data + strlen (SCHEME_PATH));
|
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->ca_cert, NULL);
|
||||||
|
return (const char *)data + strlen (SCHEME_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GByteArray *
|
static GBytes *
|
||||||
path_to_scheme_value (const char *path)
|
path_to_scheme_value (const char *path)
|
||||||
{
|
{
|
||||||
GByteArray *array;
|
GByteArray *array;
|
||||||
@@ -507,11 +516,11 @@ path_to_scheme_value (const char *path)
|
|||||||
|
|
||||||
/* Add the path scheme tag to the front, then the fielname */
|
/* Add the path scheme tag to the front, then the fielname */
|
||||||
array = g_byte_array_sized_new (strlen (path) + strlen (SCHEME_PATH) + 1);
|
array = g_byte_array_sized_new (strlen (path) + strlen (SCHEME_PATH) + 1);
|
||||||
g_assert (array);
|
|
||||||
g_byte_array_append (array, (const guint8 *) SCHEME_PATH, strlen (SCHEME_PATH));
|
g_byte_array_append (array, (const guint8 *) SCHEME_PATH, strlen (SCHEME_PATH));
|
||||||
g_byte_array_append (array, (const guint8 *) path, strlen (path));
|
g_byte_array_append (array, (const guint8 *) path, strlen (path));
|
||||||
g_byte_array_append (array, (const guint8 *) "\0", 1);
|
g_byte_array_append (array, (const guint8 *) "\0", 1);
|
||||||
return array;
|
|
||||||
|
return g_byte_array_free_to_bytes (array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -558,11 +567,7 @@ nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
|
|||||||
|
|
||||||
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
||||||
|
|
||||||
/* Clear out any previous ca_cert blob */
|
g_clear_pointer (&priv->ca_cert, g_bytes_unref);
|
||||||
if (priv->ca_cert) {
|
|
||||||
g_byte_array_free (priv->ca_cert, TRUE);
|
|
||||||
priv->ca_cert = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cert_path) {
|
if (!cert_path) {
|
||||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CA_CERT);
|
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CA_CERT);
|
||||||
@@ -576,9 +581,10 @@ nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
|
|||||||
if (out_format)
|
if (out_format)
|
||||||
*out_format = NM_SETTING_802_1X_CK_FORMAT_X509;
|
*out_format = NM_SETTING_802_1X_CK_FORMAT_X509;
|
||||||
|
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||||
priv->ca_cert = g_byte_array_ref (data);
|
priv->ca_cert = g_byte_array_free_to_bytes (data);
|
||||||
else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
data = NULL;
|
||||||
|
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
priv->ca_cert = path_to_scheme_value (cert_path);
|
priv->ca_cert = path_to_scheme_value (cert_path);
|
||||||
else
|
else
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
@@ -589,7 +595,8 @@ nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
|
|||||||
_("CA certificate must be in X.509 format"));
|
_("CA certificate must be in X.509 format"));
|
||||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CA_CERT);
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CA_CERT);
|
||||||
}
|
}
|
||||||
g_byte_array_unref (data);
|
if (data)
|
||||||
|
g_byte_array_unref (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CA_CERT);
|
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CA_CERT);
|
||||||
@@ -788,7 +795,7 @@ nm_setting_802_1x_get_client_cert_scheme (NMSetting8021x *setting)
|
|||||||
*
|
*
|
||||||
* Returns: the client certificate data
|
* Returns: the client certificate data
|
||||||
**/
|
**/
|
||||||
const GByteArray *
|
GBytes *
|
||||||
nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting)
|
nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
@@ -815,13 +822,15 @@ const char *
|
|||||||
nm_setting_802_1x_get_client_cert_path (NMSetting8021x *setting)
|
nm_setting_802_1x_get_client_cert_path (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
|
gconstpointer data;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||||
|
|
||||||
scheme = nm_setting_802_1x_get_client_cert_scheme (setting);
|
scheme = nm_setting_802_1x_get_client_cert_scheme (setting);
|
||||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||||
|
|
||||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->client_cert->data + strlen (SCHEME_PATH));
|
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->client_cert, NULL);
|
||||||
|
return (const char *)data + strlen (SCHEME_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -872,11 +881,7 @@ nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
|
|||||||
|
|
||||||
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
||||||
|
|
||||||
/* Clear out any previous ca_cert blob */
|
g_clear_pointer (&priv->client_cert, g_bytes_unref);
|
||||||
if (priv->client_cert) {
|
|
||||||
g_byte_array_free (priv->client_cert, TRUE);
|
|
||||||
priv->client_cert = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cert_path) {
|
if (!cert_path) {
|
||||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
|
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
|
||||||
@@ -908,14 +913,16 @@ nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||||
priv->client_cert = g_byte_array_ref (data);
|
priv->client_cert = g_byte_array_free_to_bytes (data);
|
||||||
else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
data = NULL;
|
||||||
|
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
priv->client_cert = path_to_scheme_value (cert_path);
|
priv->client_cert = path_to_scheme_value (cert_path);
|
||||||
else
|
else
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
g_byte_array_unref (data);
|
if (data)
|
||||||
|
g_byte_array_unref (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
|
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
|
||||||
@@ -1054,7 +1061,7 @@ nm_setting_802_1x_get_phase2_ca_cert_scheme (NMSetting8021x *setting)
|
|||||||
*
|
*
|
||||||
* Returns: the "phase 2" CA certificate data
|
* Returns: the "phase 2" CA certificate data
|
||||||
**/
|
**/
|
||||||
const GByteArray *
|
GBytes *
|
||||||
nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting)
|
nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
@@ -1084,13 +1091,15 @@ const char *
|
|||||||
nm_setting_802_1x_get_phase2_ca_cert_path (NMSetting8021x *setting)
|
nm_setting_802_1x_get_phase2_ca_cert_path (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
|
gconstpointer data;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||||
|
|
||||||
scheme = nm_setting_802_1x_get_phase2_ca_cert_scheme (setting);
|
scheme = nm_setting_802_1x_get_phase2_ca_cert_scheme (setting);
|
||||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||||
|
|
||||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_ca_cert->data + strlen (SCHEME_PATH));
|
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_ca_cert, NULL);
|
||||||
|
return (const char *)data + strlen (SCHEME_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1137,11 +1146,7 @@ nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
|
|||||||
|
|
||||||
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
||||||
|
|
||||||
/* Clear out any previous ca_cert blob */
|
g_clear_pointer (&priv->phase2_ca_cert, g_bytes_unref);
|
||||||
if (priv->phase2_ca_cert) {
|
|
||||||
g_byte_array_free (priv->phase2_ca_cert, TRUE);
|
|
||||||
priv->phase2_ca_cert = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cert_path) {
|
if (!cert_path) {
|
||||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CA_CERT);
|
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CA_CERT);
|
||||||
@@ -1155,9 +1160,10 @@ nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
|
|||||||
if (out_format)
|
if (out_format)
|
||||||
*out_format = NM_SETTING_802_1X_CK_FORMAT_X509;
|
*out_format = NM_SETTING_802_1X_CK_FORMAT_X509;
|
||||||
|
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||||
priv->phase2_ca_cert = g_byte_array_ref (data);
|
priv->phase2_ca_cert = g_byte_array_free_to_bytes (data);
|
||||||
else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
data = NULL;
|
||||||
|
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
priv->phase2_ca_cert = path_to_scheme_value (cert_path);
|
priv->phase2_ca_cert = path_to_scheme_value (cert_path);
|
||||||
else
|
else
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
@@ -1168,7 +1174,8 @@ nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
|
|||||||
_("invalid certificate format"));
|
_("invalid certificate format"));
|
||||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CA_CERT);
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CA_CERT);
|
||||||
}
|
}
|
||||||
g_byte_array_unref (data);
|
if (data)
|
||||||
|
g_byte_array_unref (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CA_CERT);
|
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CA_CERT);
|
||||||
@@ -1371,7 +1378,7 @@ nm_setting_802_1x_get_phase2_client_cert_scheme (NMSetting8021x *setting)
|
|||||||
*
|
*
|
||||||
* Returns: the "phase 2" client certificate data
|
* Returns: the "phase 2" client certificate data
|
||||||
**/
|
**/
|
||||||
const GByteArray *
|
GBytes *
|
||||||
nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting)
|
nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
@@ -1398,13 +1405,15 @@ const char *
|
|||||||
nm_setting_802_1x_get_phase2_client_cert_path (NMSetting8021x *setting)
|
nm_setting_802_1x_get_phase2_client_cert_path (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
|
gconstpointer data;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||||
|
|
||||||
scheme = nm_setting_802_1x_get_phase2_client_cert_scheme (setting);
|
scheme = nm_setting_802_1x_get_phase2_client_cert_scheme (setting);
|
||||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||||
|
|
||||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_client_cert->data + strlen (SCHEME_PATH));
|
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_client_cert, NULL);
|
||||||
|
return (const char *)data + strlen (SCHEME_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1455,11 +1464,7 @@ nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
|
|||||||
|
|
||||||
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
||||||
|
|
||||||
/* Clear out any previous ca_cert blob */
|
g_clear_pointer (&priv->phase2_client_cert, g_bytes_unref);
|
||||||
if (priv->phase2_client_cert) {
|
|
||||||
g_byte_array_free (priv->phase2_client_cert, TRUE);
|
|
||||||
priv->phase2_client_cert = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cert_path) {
|
if (!cert_path) {
|
||||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
||||||
@@ -1492,14 +1497,16 @@ nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||||
priv->phase2_client_cert = g_byte_array_ref (data);
|
priv->phase2_client_cert = g_byte_array_free_to_bytes (data);
|
||||||
else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
data = NULL;
|
||||||
|
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
priv->phase2_client_cert = path_to_scheme_value (cert_path);
|
priv->phase2_client_cert = path_to_scheme_value (cert_path);
|
||||||
else
|
else
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
g_byte_array_unref (data);
|
if (data)
|
||||||
|
g_byte_array_unref (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
||||||
@@ -1543,7 +1550,7 @@ nm_setting_802_1x_get_password_flags (NMSetting8021x *setting)
|
|||||||
* UTF-8-encoded array of bytes, as specified by the
|
* UTF-8-encoded array of bytes, as specified by the
|
||||||
* #NMSetting8021x:password-raw property
|
* #NMSetting8021x:password-raw property
|
||||||
**/
|
**/
|
||||||
const GByteArray *
|
GBytes *
|
||||||
nm_setting_802_1x_get_password_raw (NMSetting8021x *setting)
|
nm_setting_802_1x_get_password_raw (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||||
@@ -1630,7 +1637,7 @@ nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting)
|
|||||||
*
|
*
|
||||||
* Returns: the private key data
|
* Returns: the private key data
|
||||||
**/
|
**/
|
||||||
const GByteArray *
|
GBytes *
|
||||||
nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting)
|
nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
@@ -1657,17 +1664,28 @@ const char *
|
|||||||
nm_setting_802_1x_get_private_key_path (NMSetting8021x *setting)
|
nm_setting_802_1x_get_private_key_path (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
|
gconstpointer data;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||||
|
|
||||||
scheme = nm_setting_802_1x_get_private_key_scheme (setting);
|
scheme = nm_setting_802_1x_get_private_key_scheme (setting);
|
||||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||||
|
|
||||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->private_key->data + strlen (SCHEME_PATH));
|
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->private_key, NULL);
|
||||||
|
return (const char *)data + strlen (SCHEME_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GByteArray *
|
static void
|
||||||
file_to_byte_array (const char *filename)
|
free_secure_bytes (gpointer data)
|
||||||
|
{
|
||||||
|
GByteArray *array = data;
|
||||||
|
|
||||||
|
memset (array->data, 0, array->len);
|
||||||
|
g_byte_array_unref (array);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GBytes *
|
||||||
|
file_to_secure_bytes (const char *filename)
|
||||||
{
|
{
|
||||||
char *contents;
|
char *contents;
|
||||||
GByteArray *array = NULL;
|
GByteArray *array = NULL;
|
||||||
@@ -1679,7 +1697,7 @@ file_to_byte_array (const char *filename)
|
|||||||
g_assert (array->len == length);
|
g_assert (array->len == length);
|
||||||
g_free (contents);
|
g_free (contents);
|
||||||
}
|
}
|
||||||
return array;
|
return g_bytes_new_with_free_func (array->data, array->len, free_secure_bytes, array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1766,9 +1784,7 @@ nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
|
|||||||
|
|
||||||
/* Clear out any previous private key data */
|
/* Clear out any previous private key data */
|
||||||
if (priv->private_key) {
|
if (priv->private_key) {
|
||||||
/* Try not to leave the private key around in memory */
|
g_bytes_unref (priv->private_key);
|
||||||
memset (priv->private_key->data, 0, priv->private_key->len);
|
|
||||||
g_byte_array_free (priv->private_key, TRUE);
|
|
||||||
priv->private_key = NULL;
|
priv->private_key = NULL;
|
||||||
key_cleared = TRUE;
|
key_cleared = TRUE;
|
||||||
}
|
}
|
||||||
@@ -1790,7 +1806,7 @@ nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
|
|||||||
priv->private_key_password = g_strdup (password);
|
priv->private_key_password = g_strdup (password);
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||||
/* Shouldn't fail this since we just verified the private key above */
|
/* Shouldn't fail this since we just verified the private key above */
|
||||||
priv->private_key = file_to_byte_array (key_path);
|
priv->private_key = file_to_secure_bytes (key_path);
|
||||||
g_assert (priv->private_key);
|
g_assert (priv->private_key);
|
||||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
priv->private_key = path_to_scheme_value (key_path);
|
priv->private_key = path_to_scheme_value (key_path);
|
||||||
@@ -1803,10 +1819,8 @@ nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
|
|||||||
g_assert (format != NM_CRYPTO_FILE_FORMAT_UNKNOWN);
|
g_assert (format != NM_CRYPTO_FILE_FORMAT_UNKNOWN);
|
||||||
if (format == NM_CRYPTO_FILE_FORMAT_PKCS12) {
|
if (format == NM_CRYPTO_FILE_FORMAT_PKCS12) {
|
||||||
if (priv->client_cert)
|
if (priv->client_cert)
|
||||||
g_byte_array_free (priv->client_cert, TRUE);
|
g_bytes_unref (priv->client_cert);
|
||||||
|
priv->client_cert = g_bytes_ref (priv->private_key);
|
||||||
priv->client_cert = g_byte_array_sized_new (priv->private_key->len);
|
|
||||||
g_byte_array_append (priv->client_cert, priv->private_key->data, priv->private_key->len);
|
|
||||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
|
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1872,7 +1886,8 @@ nm_setting_802_1x_get_private_key_format (NMSetting8021x *setting)
|
|||||||
|
|
||||||
switch (nm_setting_802_1x_get_private_key_scheme (setting)) {
|
switch (nm_setting_802_1x_get_private_key_scheme (setting)) {
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||||
if (crypto_is_pkcs12_data (priv->private_key->data, priv->private_key->len))
|
if (crypto_is_pkcs12_data (g_bytes_get_data (priv->private_key, NULL),
|
||||||
|
g_bytes_get_size (priv->private_key)))
|
||||||
return NM_SETTING_802_1X_CK_FORMAT_PKCS12;
|
return NM_SETTING_802_1X_CK_FORMAT_PKCS12;
|
||||||
return NM_SETTING_802_1X_CK_FORMAT_RAW_KEY;
|
return NM_SETTING_802_1X_CK_FORMAT_RAW_KEY;
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||||
@@ -1957,7 +1972,7 @@ nm_setting_802_1x_get_phase2_private_key_scheme (NMSetting8021x *setting)
|
|||||||
*
|
*
|
||||||
* Returns: the "phase 2" private key data
|
* Returns: the "phase 2" private key data
|
||||||
**/
|
**/
|
||||||
const GByteArray *
|
GBytes *
|
||||||
nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting)
|
nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
@@ -1984,13 +1999,15 @@ const char *
|
|||||||
nm_setting_802_1x_get_phase2_private_key_path (NMSetting8021x *setting)
|
nm_setting_802_1x_get_phase2_private_key_path (NMSetting8021x *setting)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
|
gconstpointer data;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||||
|
|
||||||
scheme = nm_setting_802_1x_get_phase2_private_key_scheme (setting);
|
scheme = nm_setting_802_1x_get_phase2_private_key_scheme (setting);
|
||||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||||
|
|
||||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_private_key->data + strlen (SCHEME_PATH));
|
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_private_key, NULL);
|
||||||
|
return (const char *)data + strlen (SCHEME_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2077,9 +2094,7 @@ nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
|
|||||||
|
|
||||||
/* Clear out any previous private key data */
|
/* Clear out any previous private key data */
|
||||||
if (priv->phase2_private_key) {
|
if (priv->phase2_private_key) {
|
||||||
/* Try not to leave the private key around in memory */
|
g_bytes_unref (priv->phase2_private_key);
|
||||||
memset (priv->phase2_private_key->data, 0, priv->phase2_private_key->len);
|
|
||||||
g_byte_array_free (priv->phase2_private_key, TRUE);
|
|
||||||
priv->phase2_private_key = NULL;
|
priv->phase2_private_key = NULL;
|
||||||
key_cleared = TRUE;
|
key_cleared = TRUE;
|
||||||
}
|
}
|
||||||
@@ -2101,7 +2116,7 @@ nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
|
|||||||
priv->phase2_private_key_password = g_strdup (password);
|
priv->phase2_private_key_password = g_strdup (password);
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||||
/* Shouldn't fail this since we just verified the private key above */
|
/* Shouldn't fail this since we just verified the private key above */
|
||||||
priv->phase2_private_key = file_to_byte_array (key_path);
|
priv->phase2_private_key = file_to_secure_bytes (key_path);
|
||||||
g_assert (priv->phase2_private_key);
|
g_assert (priv->phase2_private_key);
|
||||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||||
priv->phase2_private_key = path_to_scheme_value (key_path);
|
priv->phase2_private_key = path_to_scheme_value (key_path);
|
||||||
@@ -2114,10 +2129,9 @@ nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
|
|||||||
g_assert (format != NM_CRYPTO_FILE_FORMAT_UNKNOWN);
|
g_assert (format != NM_CRYPTO_FILE_FORMAT_UNKNOWN);
|
||||||
if (format == NM_CRYPTO_FILE_FORMAT_PKCS12) {
|
if (format == NM_CRYPTO_FILE_FORMAT_PKCS12) {
|
||||||
if (priv->phase2_client_cert)
|
if (priv->phase2_client_cert)
|
||||||
g_byte_array_free (priv->phase2_client_cert, TRUE);
|
g_bytes_unref (priv->phase2_client_cert);
|
||||||
|
|
||||||
priv->phase2_client_cert = g_byte_array_sized_new (priv->phase2_private_key->len);
|
priv->phase2_client_cert = g_bytes_ref (priv->phase2_private_key);
|
||||||
g_byte_array_append (priv->phase2_client_cert, priv->phase2_private_key->data, priv->phase2_private_key->len);
|
|
||||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2152,8 +2166,8 @@ nm_setting_802_1x_get_phase2_private_key_format (NMSetting8021x *setting)
|
|||||||
|
|
||||||
switch (nm_setting_802_1x_get_phase2_private_key_scheme (setting)) {
|
switch (nm_setting_802_1x_get_phase2_private_key_scheme (setting)) {
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||||
if (crypto_is_pkcs12_data (priv->phase2_private_key->data,
|
if (crypto_is_pkcs12_data (g_bytes_get_data (priv->phase2_private_key, NULL),
|
||||||
priv->phase2_private_key->len))
|
g_bytes_get_size (priv->phase2_private_key)))
|
||||||
return NM_SETTING_802_1X_CK_FORMAT_PKCS12;
|
return NM_SETTING_802_1X_CK_FORMAT_PKCS12;
|
||||||
return NM_SETTING_802_1X_CK_FORMAT_RAW_KEY;
|
return NM_SETTING_802_1X_CK_FORMAT_RAW_KEY;
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||||
@@ -2181,7 +2195,7 @@ need_secrets_password (NMSetting8021x *self,
|
|||||||
NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
|
NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
|
||||||
|
|
||||||
if ( (!priv->password || !strlen (priv->password))
|
if ( (!priv->password || !strlen (priv->password))
|
||||||
&& (!priv->password_raw || !priv->password_raw->len)) {
|
&& (!priv->password_raw || !g_bytes_get_size (priv->password_raw))) {
|
||||||
g_ptr_array_add (secrets, NM_SETTING_802_1X_PASSWORD);
|
g_ptr_array_add (secrets, NM_SETTING_802_1X_PASSWORD);
|
||||||
g_ptr_array_add (secrets, NM_SETTING_802_1X_PASSWORD_RAW);
|
g_ptr_array_add (secrets, NM_SETTING_802_1X_PASSWORD_RAW);
|
||||||
}
|
}
|
||||||
@@ -2199,7 +2213,7 @@ need_secrets_sim (NMSetting8021x *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
need_private_key_password (const GByteArray *blob,
|
need_private_key_password (GBytes *blob,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *password)
|
const char *password)
|
||||||
{
|
{
|
||||||
@@ -2210,7 +2224,8 @@ need_private_key_password (const GByteArray *blob,
|
|||||||
if (path)
|
if (path)
|
||||||
format = crypto_verify_private_key (path, password, NULL);
|
format = crypto_verify_private_key (path, password, NULL);
|
||||||
else if (blob)
|
else if (blob)
|
||||||
format = crypto_verify_private_key_data (blob->data, blob->len,
|
format = crypto_verify_private_key_data (g_bytes_get_data (blob, NULL),
|
||||||
|
g_bytes_get_size (blob),
|
||||||
password, NULL);
|
password, NULL);
|
||||||
else
|
else
|
||||||
g_warning ("%s: unknown private key password scheme", __func__);
|
g_warning ("%s: unknown private key password scheme", __func__);
|
||||||
@@ -2226,7 +2241,7 @@ need_secrets_tls (NMSetting8021x *self,
|
|||||||
{
|
{
|
||||||
NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
|
NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
const GByteArray *blob = NULL;
|
GBytes *blob = NULL;
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
|
|
||||||
if (phase2) {
|
if (phase2) {
|
||||||
@@ -2273,7 +2288,7 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||||||
_("property is missing"));
|
_("property is missing"));
|
||||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!priv->phase2_client_cert->len) {
|
} else if (!g_bytes_get_size (priv->phase2_client_cert)) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
NM_SETTING_802_1X_ERROR,
|
NM_SETTING_802_1X_ERROR,
|
||||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||||
@@ -2290,7 +2305,7 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||||||
_("property is missing"));
|
_("property is missing"));
|
||||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!priv->phase2_private_key->len) {
|
} else if (!g_bytes_get_size (priv->phase2_private_key)) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
NM_SETTING_802_1X_ERROR,
|
NM_SETTING_802_1X_ERROR,
|
||||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||||
@@ -2300,21 +2315,9 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If the private key is PKCS#12, check that it matches the client cert */
|
/* If the private key is PKCS#12, check that it matches the client cert */
|
||||||
if (crypto_is_pkcs12_data (priv->phase2_private_key->data,
|
if (crypto_is_pkcs12_data (g_bytes_get_data (priv->phase2_private_key, NULL),
|
||||||
priv->phase2_private_key->len)) {
|
g_bytes_get_size (priv->phase2_private_key))) {
|
||||||
if (priv->phase2_private_key->len != priv->phase2_client_cert->len) {
|
if (!g_bytes_equal (priv->phase2_private_key, priv->phase2_client_cert)) {
|
||||||
g_set_error (error,
|
|
||||||
NM_SETTING_802_1X_ERROR,
|
|
||||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
|
||||||
_("has to match '%s' property for PKCS#12"),
|
|
||||||
NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
|
|
||||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (memcmp (priv->phase2_private_key->data,
|
|
||||||
priv->phase2_client_cert->data,
|
|
||||||
priv->phase2_private_key->len)) {
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
NM_SETTING_802_1X_ERROR,
|
NM_SETTING_802_1X_ERROR,
|
||||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||||
@@ -2332,7 +2335,7 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||||||
_("property is missing"));
|
_("property is missing"));
|
||||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT);
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!priv->client_cert->len) {
|
} else if (!g_bytes_get_size (priv->client_cert)) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
NM_SETTING_802_1X_ERROR,
|
NM_SETTING_802_1X_ERROR,
|
||||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||||
@@ -2349,7 +2352,7 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||||||
_("property is missing"));
|
_("property is missing"));
|
||||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PRIVATE_KEY);
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PRIVATE_KEY);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!priv->private_key->len) {
|
} else if (!g_bytes_get_size (priv->private_key)) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
NM_SETTING_802_1X_ERROR,
|
NM_SETTING_802_1X_ERROR,
|
||||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||||
@@ -2359,21 +2362,9 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If the private key is PKCS#12, check that it matches the client cert */
|
/* If the private key is PKCS#12, check that it matches the client cert */
|
||||||
if (crypto_is_pkcs12_data (priv->private_key->data,
|
if (crypto_is_pkcs12_data (g_bytes_get_data (priv->private_key, NULL),
|
||||||
priv->private_key->len)) {
|
g_bytes_get_size (priv->private_key))) {
|
||||||
if (priv->private_key->len != priv->client_cert->len) {
|
if (!g_bytes_equal (priv->private_key, priv->client_cert)) {
|
||||||
g_set_error (error,
|
|
||||||
NM_SETTING_802_1X_ERROR,
|
|
||||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
|
||||||
_("has to match '%s' property for PKCS#12"),
|
|
||||||
NM_SETTING_802_1X_PRIVATE_KEY);
|
|
||||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (memcmp (priv->private_key->data,
|
|
||||||
priv->client_cert->data,
|
|
||||||
priv->private_key->len)) {
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
NM_SETTING_802_1X_ERROR,
|
NM_SETTING_802_1X_ERROR,
|
||||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||||
@@ -2593,21 +2584,25 @@ need_secrets (NMSetting *setting)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
verify_cert (GByteArray *array, const char *prop_name, GError **error)
|
verify_cert (GBytes *bytes, const char *prop_name, GError **error)
|
||||||
{
|
{
|
||||||
if (!array)
|
gconstpointer data;
|
||||||
|
gsize length;
|
||||||
|
|
||||||
|
if (!bytes)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
switch (get_cert_scheme (array)) {
|
switch (get_cert_scheme (bytes)) {
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||||
/* For path-based schemes, verify that the path is zero-terminated */
|
/* For path-based schemes, verify that the path is zero-terminated */
|
||||||
if (array->data[array->len - 1] == '\0') {
|
data = g_bytes_get_data (bytes, &length);
|
||||||
|
if (((const guchar *)data)[length - 1] == '\0') {
|
||||||
/* And ensure it's UTF-8 valid too so we can pass it through
|
/* And ensure it's UTF-8 valid too so we can pass it through
|
||||||
* D-Bus and stuff like that.
|
* D-Bus and stuff like that.
|
||||||
*/
|
*/
|
||||||
if (g_utf8_validate ((const char *) (array->data + strlen (SCHEME_PATH)), -1, NULL))
|
if (g_utf8_validate ((const char *)data + strlen (SCHEME_PATH), -1, NULL))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2769,7 +2764,7 @@ finalize (GObject *object)
|
|||||||
g_free (priv->phase2_subject_match);
|
g_free (priv->phase2_subject_match);
|
||||||
g_free (priv->password);
|
g_free (priv->password);
|
||||||
if (priv->password_raw)
|
if (priv->password_raw)
|
||||||
g_byte_array_free (priv->password_raw, TRUE);
|
g_bytes_unref (priv->password_raw);
|
||||||
g_free (priv->pin);
|
g_free (priv->pin);
|
||||||
|
|
||||||
g_slist_free_full (priv->eap, g_free);
|
g_slist_free_full (priv->eap, g_free);
|
||||||
@@ -2777,39 +2772,37 @@ finalize (GObject *object)
|
|||||||
g_slist_free_full (priv->phase2_altsubject_matches, g_free);
|
g_slist_free_full (priv->phase2_altsubject_matches, g_free);
|
||||||
|
|
||||||
if (priv->ca_cert)
|
if (priv->ca_cert)
|
||||||
g_byte_array_free (priv->ca_cert, TRUE);
|
g_bytes_unref (priv->ca_cert);
|
||||||
if (priv->client_cert)
|
if (priv->client_cert)
|
||||||
g_byte_array_free (priv->client_cert, TRUE);
|
g_bytes_unref (priv->client_cert);
|
||||||
if (priv->private_key)
|
if (priv->private_key)
|
||||||
g_byte_array_free (priv->private_key, TRUE);
|
g_bytes_unref (priv->private_key);
|
||||||
g_free (priv->private_key_password);
|
g_free (priv->private_key_password);
|
||||||
if (priv->phase2_ca_cert)
|
if (priv->phase2_ca_cert)
|
||||||
g_byte_array_free (priv->phase2_ca_cert, TRUE);
|
g_bytes_unref (priv->phase2_ca_cert);
|
||||||
if (priv->phase2_client_cert)
|
if (priv->phase2_client_cert)
|
||||||
g_byte_array_free (priv->phase2_client_cert, TRUE);
|
g_bytes_unref (priv->phase2_client_cert);
|
||||||
if (priv->phase2_private_key)
|
if (priv->phase2_private_key)
|
||||||
g_byte_array_free (priv->phase2_private_key, TRUE);
|
g_bytes_unref (priv->phase2_private_key);
|
||||||
g_free (priv->phase2_private_key_password);
|
g_free (priv->phase2_private_key_password);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_setting_802_1x_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_setting_802_1x_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GByteArray *
|
static GBytes *
|
||||||
set_cert_prop_helper (const GValue *value, const char *prop_name, GError **error)
|
set_cert_prop_helper (const GValue *value, const char *prop_name, GError **error)
|
||||||
{
|
{
|
||||||
gboolean valid;
|
gboolean valid;
|
||||||
GByteArray *data = NULL;
|
GBytes *bytes = NULL;
|
||||||
|
|
||||||
data = g_value_dup_boxed (value);
|
bytes = g_value_dup_boxed (value);
|
||||||
/* Verify the new data */
|
/* Verify the new data */
|
||||||
if (data) {
|
if (bytes) {
|
||||||
valid = verify_cert (data, prop_name, error);
|
valid = verify_cert (bytes, prop_name, error);
|
||||||
if (!valid) {
|
if (!valid)
|
||||||
g_byte_array_free (data, TRUE);
|
g_clear_pointer (&bytes, g_bytes_unref);
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return data;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2838,10 +2831,8 @@ set_property (GObject *object, guint prop_id,
|
|||||||
priv->pac_file = g_value_dup_string (value);
|
priv->pac_file = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_CA_CERT:
|
case PROP_CA_CERT:
|
||||||
if (priv->ca_cert) {
|
if (priv->ca_cert)
|
||||||
g_byte_array_free (priv->ca_cert, TRUE);
|
g_bytes_unref (priv->ca_cert);
|
||||||
priv->ca_cert = NULL;
|
|
||||||
}
|
|
||||||
priv->ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CA_CERT, &error);
|
priv->ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CA_CERT, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
||||||
@@ -2862,10 +2853,8 @@ set_property (GObject *object, guint prop_id,
|
|||||||
priv->altsubject_matches = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
priv->altsubject_matches = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||||
break;
|
break;
|
||||||
case PROP_CLIENT_CERT:
|
case PROP_CLIENT_CERT:
|
||||||
if (priv->client_cert) {
|
if (priv->client_cert)
|
||||||
g_byte_array_free (priv->client_cert, TRUE);
|
g_bytes_unref (priv->client_cert);
|
||||||
priv->client_cert = NULL;
|
|
||||||
}
|
|
||||||
priv->client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CLIENT_CERT, &error);
|
priv->client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CLIENT_CERT, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
||||||
@@ -2894,10 +2883,8 @@ set_property (GObject *object, guint prop_id,
|
|||||||
priv->phase2_autheap = g_value_dup_string (value);
|
priv->phase2_autheap = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_PHASE2_CA_CERT:
|
case PROP_PHASE2_CA_CERT:
|
||||||
if (priv->phase2_ca_cert) {
|
if (priv->phase2_ca_cert)
|
||||||
g_byte_array_free (priv->phase2_ca_cert, TRUE);
|
g_bytes_unref (priv->phase2_ca_cert);
|
||||||
priv->phase2_ca_cert = NULL;
|
|
||||||
}
|
|
||||||
priv->phase2_ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CA_CERT, &error);
|
priv->phase2_ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CA_CERT, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
||||||
@@ -2918,10 +2905,8 @@ set_property (GObject *object, guint prop_id,
|
|||||||
priv->phase2_altsubject_matches = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
priv->phase2_altsubject_matches = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||||
break;
|
break;
|
||||||
case PROP_PHASE2_CLIENT_CERT:
|
case PROP_PHASE2_CLIENT_CERT:
|
||||||
if (priv->phase2_client_cert) {
|
if (priv->phase2_client_cert)
|
||||||
g_byte_array_free (priv->phase2_client_cert, TRUE);
|
g_bytes_unref (priv->phase2_client_cert);
|
||||||
priv->phase2_client_cert = NULL;
|
|
||||||
}
|
|
||||||
priv->phase2_client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CLIENT_CERT, &error);
|
priv->phase2_client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CLIENT_CERT, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
||||||
@@ -2938,17 +2923,15 @@ set_property (GObject *object, guint prop_id,
|
|||||||
break;
|
break;
|
||||||
case PROP_PASSWORD_RAW:
|
case PROP_PASSWORD_RAW:
|
||||||
if (priv->password_raw)
|
if (priv->password_raw)
|
||||||
g_byte_array_free (priv->password_raw, TRUE);
|
g_bytes_unref (priv->password_raw);
|
||||||
priv->password_raw = g_value_dup_boxed (value);
|
priv->password_raw = g_value_dup_boxed (value);
|
||||||
break;
|
break;
|
||||||
case PROP_PASSWORD_RAW_FLAGS:
|
case PROP_PASSWORD_RAW_FLAGS:
|
||||||
priv->password_raw_flags = g_value_get_uint (value);
|
priv->password_raw_flags = g_value_get_uint (value);
|
||||||
break;
|
break;
|
||||||
case PROP_PRIVATE_KEY:
|
case PROP_PRIVATE_KEY:
|
||||||
if (priv->private_key) {
|
if (priv->private_key)
|
||||||
g_byte_array_free (priv->private_key, TRUE);
|
g_bytes_unref (priv->private_key);
|
||||||
priv->private_key = NULL;
|
|
||||||
}
|
|
||||||
priv->private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PRIVATE_KEY, &error);
|
priv->private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PRIVATE_KEY, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_warning ("Error setting private key (invalid data): (%d) %s",
|
g_warning ("Error setting private key (invalid data): (%d) %s",
|
||||||
@@ -2964,10 +2947,8 @@ set_property (GObject *object, guint prop_id,
|
|||||||
priv->private_key_password_flags = g_value_get_uint (value);
|
priv->private_key_password_flags = g_value_get_uint (value);
|
||||||
break;
|
break;
|
||||||
case PROP_PHASE2_PRIVATE_KEY:
|
case PROP_PHASE2_PRIVATE_KEY:
|
||||||
if (priv->phase2_private_key) {
|
if (priv->phase2_private_key)
|
||||||
g_byte_array_free (priv->phase2_private_key, TRUE);
|
g_bytes_unref (priv->phase2_private_key);
|
||||||
priv->phase2_private_key = NULL;
|
|
||||||
}
|
|
||||||
priv->phase2_private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, &error);
|
priv->phase2_private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_warning ("Error setting private key (invalid data): (%d) %s",
|
g_warning ("Error setting private key (invalid data): (%d) %s",
|
||||||
@@ -3203,9 +3184,13 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_CA_CERT,
|
(object_class, PROP_CA_CERT,
|
||||||
g_param_spec_boxed (NM_SETTING_802_1X_CA_CERT, "", "",
|
g_param_spec_boxed (NM_SETTING_802_1X_CA_CERT, "", "",
|
||||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
G_TYPE_BYTES,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_CA_CERT,
|
||||||
|
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||||
|
_nm_utils_bytes_to_dbus,
|
||||||
|
_nm_utils_bytes_from_dbus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMSetting8021x:ca-path:
|
* NMSetting8021x:ca-path:
|
||||||
@@ -3268,9 +3253,13 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_CLIENT_CERT,
|
(object_class, PROP_CLIENT_CERT,
|
||||||
g_param_spec_boxed (NM_SETTING_802_1X_CLIENT_CERT, "", "",
|
g_param_spec_boxed (NM_SETTING_802_1X_CLIENT_CERT, "", "",
|
||||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
G_TYPE_BYTES,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_CLIENT_CERT,
|
||||||
|
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||||
|
_nm_utils_bytes_to_dbus,
|
||||||
|
_nm_utils_bytes_from_dbus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMSetting8021x:phase1-peapver:
|
* NMSetting8021x:phase1-peapver:
|
||||||
@@ -3377,9 +3366,13 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_PHASE2_CA_CERT,
|
(object_class, PROP_PHASE2_CA_CERT,
|
||||||
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_CA_CERT, "", "",
|
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_CA_CERT, "", "",
|
||||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
G_TYPE_BYTES,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PHASE2_CA_CERT,
|
||||||
|
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||||
|
_nm_utils_bytes_to_dbus,
|
||||||
|
_nm_utils_bytes_from_dbus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMSetting8021x:phase2-ca-path:
|
* NMSetting8021x:phase2-ca-path:
|
||||||
@@ -3447,9 +3440,13 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_PHASE2_CLIENT_CERT,
|
(object_class, PROP_PHASE2_CLIENT_CERT,
|
||||||
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_CLIENT_CERT, "", "",
|
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_CLIENT_CERT, "", "",
|
||||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
G_TYPE_BYTES,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PHASE2_CLIENT_CERT,
|
||||||
|
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||||
|
_nm_utils_bytes_to_dbus,
|
||||||
|
_nm_utils_bytes_from_dbus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMSetting8021x:password:
|
* NMSetting8021x:password:
|
||||||
@@ -3491,10 +3488,14 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_PASSWORD_RAW,
|
(object_class, PROP_PASSWORD_RAW,
|
||||||
g_param_spec_boxed (NM_SETTING_802_1X_PASSWORD_RAW, "", "",
|
g_param_spec_boxed (NM_SETTING_802_1X_PASSWORD_RAW, "", "",
|
||||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
G_TYPE_BYTES,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
NM_SETTING_PARAM_SECRET |
|
NM_SETTING_PARAM_SECRET |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PASSWORD_RAW,
|
||||||
|
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||||
|
_nm_utils_bytes_to_dbus,
|
||||||
|
_nm_utils_bytes_from_dbus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMSetting8021x:password-raw-flags:
|
* NMSetting8021x:password-raw-flags:
|
||||||
@@ -3543,9 +3544,13 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_PRIVATE_KEY,
|
(object_class, PROP_PRIVATE_KEY,
|
||||||
g_param_spec_boxed (NM_SETTING_802_1X_PRIVATE_KEY, "", "",
|
g_param_spec_boxed (NM_SETTING_802_1X_PRIVATE_KEY, "", "",
|
||||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
G_TYPE_BYTES,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PRIVATE_KEY,
|
||||||
|
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||||
|
_nm_utils_bytes_to_dbus,
|
||||||
|
_nm_utils_bytes_from_dbus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMSetting8021x:private-key-password:
|
* NMSetting8021x:private-key-password:
|
||||||
@@ -3608,9 +3613,13 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_PHASE2_PRIVATE_KEY,
|
(object_class, PROP_PHASE2_PRIVATE_KEY,
|
||||||
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, "", "",
|
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, "", "",
|
||||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
G_TYPE_BYTES,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY,
|
||||||
|
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||||
|
_nm_utils_bytes_to_dbus,
|
||||||
|
_nm_utils_bytes_from_dbus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMSetting8021x:phase2-private-key-password:
|
* NMSetting8021x:phase2-private-key-password:
|
||||||
|
@@ -182,7 +182,7 @@ const char * nm_setting_802_1x_get_ca_path (NMSetting8
|
|||||||
const char * nm_setting_802_1x_get_phase2_ca_path (NMSetting8021x *setting);
|
const char * nm_setting_802_1x_get_phase2_ca_path (NMSetting8021x *setting);
|
||||||
|
|
||||||
NMSetting8021xCKScheme nm_setting_802_1x_get_ca_cert_scheme (NMSetting8021x *setting);
|
NMSetting8021xCKScheme nm_setting_802_1x_get_ca_cert_scheme (NMSetting8021x *setting);
|
||||||
const GByteArray * nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting);
|
GBytes * nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting);
|
||||||
const char * nm_setting_802_1x_get_ca_cert_path (NMSetting8021x *setting);
|
const char * nm_setting_802_1x_get_ca_cert_path (NMSetting8021x *setting);
|
||||||
gboolean nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
|
gboolean nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
|
||||||
const char *cert_path,
|
const char *cert_path,
|
||||||
@@ -204,7 +204,7 @@ gboolean nm_setting_802_1x_remove_altsubject_match_by_value (NMSetting8
|
|||||||
void nm_setting_802_1x_clear_altsubject_matches (NMSetting8021x *setting);
|
void nm_setting_802_1x_clear_altsubject_matches (NMSetting8021x *setting);
|
||||||
|
|
||||||
NMSetting8021xCKScheme nm_setting_802_1x_get_client_cert_scheme (NMSetting8021x *setting);
|
NMSetting8021xCKScheme nm_setting_802_1x_get_client_cert_scheme (NMSetting8021x *setting);
|
||||||
const GByteArray * nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting);
|
GBytes * nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting);
|
||||||
const char * nm_setting_802_1x_get_client_cert_path (NMSetting8021x *setting);
|
const char * nm_setting_802_1x_get_client_cert_path (NMSetting8021x *setting);
|
||||||
gboolean nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
|
gboolean nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
|
||||||
const char *cert_path,
|
const char *cert_path,
|
||||||
@@ -223,7 +223,7 @@ const char * nm_setting_802_1x_get_phase2_auth (NMSetting8
|
|||||||
const char * nm_setting_802_1x_get_phase2_autheap (NMSetting8021x *setting);
|
const char * nm_setting_802_1x_get_phase2_autheap (NMSetting8021x *setting);
|
||||||
|
|
||||||
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_ca_cert_scheme (NMSetting8021x *setting);
|
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_ca_cert_scheme (NMSetting8021x *setting);
|
||||||
const GByteArray * nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting);
|
GBytes * nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting);
|
||||||
const char * nm_setting_802_1x_get_phase2_ca_cert_path (NMSetting8021x *setting);
|
const char * nm_setting_802_1x_get_phase2_ca_cert_path (NMSetting8021x *setting);
|
||||||
gboolean nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
|
gboolean nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
|
||||||
const char *cert_path,
|
const char *cert_path,
|
||||||
@@ -245,7 +245,7 @@ gboolean nm_setting_802_1x_remove_phase2_altsubject_match_by_value (NMS
|
|||||||
void nm_setting_802_1x_clear_phase2_altsubject_matches (NMSetting8021x *setting);
|
void nm_setting_802_1x_clear_phase2_altsubject_matches (NMSetting8021x *setting);
|
||||||
|
|
||||||
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_client_cert_scheme (NMSetting8021x *setting);
|
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_client_cert_scheme (NMSetting8021x *setting);
|
||||||
const GByteArray * nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting);
|
GBytes * nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting);
|
||||||
const char * nm_setting_802_1x_get_phase2_client_cert_path (NMSetting8021x *setting);
|
const char * nm_setting_802_1x_get_phase2_client_cert_path (NMSetting8021x *setting);
|
||||||
gboolean nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
|
gboolean nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
|
||||||
const char *cert_path,
|
const char *cert_path,
|
||||||
@@ -255,14 +255,14 @@ gboolean nm_setting_802_1x_set_phase2_client_cert (NMSett
|
|||||||
|
|
||||||
const char * nm_setting_802_1x_get_password (NMSetting8021x *setting);
|
const char * nm_setting_802_1x_get_password (NMSetting8021x *setting);
|
||||||
NMSettingSecretFlags nm_setting_802_1x_get_password_flags (NMSetting8021x *setting);
|
NMSettingSecretFlags nm_setting_802_1x_get_password_flags (NMSetting8021x *setting);
|
||||||
const GByteArray * nm_setting_802_1x_get_password_raw (NMSetting8021x *setting);
|
GBytes * nm_setting_802_1x_get_password_raw (NMSetting8021x *setting);
|
||||||
NMSettingSecretFlags nm_setting_802_1x_get_password_raw_flags (NMSetting8021x *setting);
|
NMSettingSecretFlags nm_setting_802_1x_get_password_raw_flags (NMSetting8021x *setting);
|
||||||
|
|
||||||
const char * nm_setting_802_1x_get_pin (NMSetting8021x *setting);
|
const char * nm_setting_802_1x_get_pin (NMSetting8021x *setting);
|
||||||
NMSettingSecretFlags nm_setting_802_1x_get_pin_flags (NMSetting8021x *setting);
|
NMSettingSecretFlags nm_setting_802_1x_get_pin_flags (NMSetting8021x *setting);
|
||||||
|
|
||||||
NMSetting8021xCKScheme nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting);
|
NMSetting8021xCKScheme nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting);
|
||||||
const GByteArray * nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting);
|
GBytes * nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting);
|
||||||
const char * nm_setting_802_1x_get_private_key_path (NMSetting8021x *setting);
|
const char * nm_setting_802_1x_get_private_key_path (NMSetting8021x *setting);
|
||||||
gboolean nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
|
gboolean nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
|
||||||
const char *key_path,
|
const char *key_path,
|
||||||
@@ -276,7 +276,7 @@ NMSettingSecretFlags nm_setting_802_1x_get_private_key_password_flags (NMSett
|
|||||||
NMSetting8021xCKFormat nm_setting_802_1x_get_private_key_format (NMSetting8021x *setting);
|
NMSetting8021xCKFormat nm_setting_802_1x_get_private_key_format (NMSetting8021x *setting);
|
||||||
|
|
||||||
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_private_key_scheme (NMSetting8021x *setting);
|
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_private_key_scheme (NMSetting8021x *setting);
|
||||||
const GByteArray * nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting);
|
GBytes * nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting);
|
||||||
const char * nm_setting_802_1x_get_phase2_private_key_path (NMSetting8021x *setting);
|
const char * nm_setting_802_1x_get_phase2_private_key_path (NMSetting8021x *setting);
|
||||||
gboolean nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
|
gboolean nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
|
||||||
const char *key_path,
|
const char *key_path,
|
||||||
|
@@ -50,7 +50,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_OLPC_MESH)
|
|||||||
#define NM_SETTING_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_OLPC_MESH, NMSettingOlpcMeshPrivate))
|
#define NM_SETTING_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_OLPC_MESH, NMSettingOlpcMeshPrivate))
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
guint32 channel;
|
guint32 channel;
|
||||||
char *dhcp_anycast_addr;
|
char *dhcp_anycast_addr;
|
||||||
} NMSettingOlpcMeshPrivate;
|
} NMSettingOlpcMeshPrivate;
|
||||||
@@ -81,7 +81,7 @@ nm_setting_olpc_mesh_init (NMSettingOlpcMesh *setting)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const GByteArray *
|
GBytes *
|
||||||
nm_setting_olpc_mesh_get_ssid (NMSettingOlpcMesh *setting)
|
nm_setting_olpc_mesh_get_ssid (NMSettingOlpcMesh *setting)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (setting), NULL);
|
g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (setting), NULL);
|
||||||
@@ -109,6 +109,7 @@ static gboolean
|
|||||||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||||
{
|
{
|
||||||
NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE (setting);
|
NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE (setting);
|
||||||
|
gsize length;
|
||||||
|
|
||||||
if (!priv->ssid) {
|
if (!priv->ssid) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
@@ -119,7 +120,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!priv->ssid->len || priv->ssid->len > 32) {
|
length = g_bytes_get_size (priv->ssid);
|
||||||
|
if (length == 0 || length > 32) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
NM_SETTING_OLPC_MESH_ERROR,
|
NM_SETTING_OLPC_MESH_ERROR,
|
||||||
NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY,
|
NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY,
|
||||||
@@ -156,7 +158,7 @@ finalize (GObject *object)
|
|||||||
NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE (object);
|
NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE (object);
|
||||||
|
|
||||||
if (priv->ssid)
|
if (priv->ssid)
|
||||||
g_byte_array_free (priv->ssid, TRUE);
|
g_bytes_unref (priv->ssid);
|
||||||
g_free (priv->dhcp_anycast_addr);
|
g_free (priv->dhcp_anycast_addr);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_setting_olpc_mesh_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_setting_olpc_mesh_parent_class)->finalize (object);
|
||||||
@@ -171,7 +173,7 @@ set_property (GObject *object, guint prop_id,
|
|||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_SSID:
|
case PROP_SSID:
|
||||||
if (priv->ssid)
|
if (priv->ssid)
|
||||||
g_byte_array_free (priv->ssid, TRUE);
|
g_bytes_unref (priv->ssid);
|
||||||
priv->ssid = g_value_dup_boxed (value);
|
priv->ssid = g_value_dup_boxed (value);
|
||||||
break;
|
break;
|
||||||
case PROP_CHANNEL:
|
case PROP_CHANNEL:
|
||||||
@@ -232,10 +234,14 @@ nm_setting_olpc_mesh_class_init (NMSettingOlpcMeshClass *setting_class)
|
|||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_SSID,
|
(object_class, PROP_SSID,
|
||||||
g_param_spec_boxed (NM_SETTING_OLPC_MESH_SSID, "", "",
|
g_param_spec_boxed (NM_SETTING_OLPC_MESH_SSID, "", "",
|
||||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
G_TYPE_BYTES,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
NM_SETTING_PARAM_INFERRABLE |
|
NM_SETTING_PARAM_INFERRABLE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_OLPC_MESH_SSID,
|
||||||
|
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||||
|
_nm_utils_bytes_to_dbus,
|
||||||
|
_nm_utils_bytes_from_dbus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMSettingOlpcMesh:channel:
|
* NMSettingOlpcMesh:channel:
|
||||||
|
@@ -74,7 +74,7 @@ typedef struct {
|
|||||||
GType nm_setting_olpc_mesh_get_type (void);
|
GType nm_setting_olpc_mesh_get_type (void);
|
||||||
|
|
||||||
NMSetting * nm_setting_olpc_mesh_new (void);
|
NMSetting * nm_setting_olpc_mesh_new (void);
|
||||||
const GByteArray *nm_setting_olpc_mesh_get_ssid (NMSettingOlpcMesh *setting);
|
GBytes * nm_setting_olpc_mesh_get_ssid (NMSettingOlpcMesh *setting);
|
||||||
guint32 nm_setting_olpc_mesh_get_channel (NMSettingOlpcMesh *setting);
|
guint32 nm_setting_olpc_mesh_get_channel (NMSettingOlpcMesh *setting);
|
||||||
const char * nm_setting_olpc_mesh_get_dhcp_anycast_address (NMSettingOlpcMesh *setting);
|
const char * nm_setting_olpc_mesh_get_dhcp_anycast_address (NMSettingOlpcMesh *setting);
|
||||||
|
|
||||||
|
@@ -65,7 +65,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS)
|
|||||||
#define NM_SETTING_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS, NMSettingWirelessPrivate))
|
#define NM_SETTING_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS, NMSettingWirelessPrivate))
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
char *mode;
|
char *mode;
|
||||||
char *band;
|
char *band;
|
||||||
guint32 channel;
|
guint32 channel;
|
||||||
@@ -315,7 +315,7 @@ nm_setting_wireless_new (void)
|
|||||||
*
|
*
|
||||||
* Returns: the #NMSettingWireless:ssid property of the setting
|
* Returns: the #NMSettingWireless:ssid property of the setting
|
||||||
**/
|
**/
|
||||||
const GByteArray *
|
GBytes *
|
||||||
nm_setting_wireless_get_ssid (NMSettingWireless *setting)
|
nm_setting_wireless_get_ssid (NMSettingWireless *setting)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||||
@@ -703,6 +703,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||||||
const char *valid_modes[] = { NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NM_SETTING_WIRELESS_MODE_AP, NULL };
|
const char *valid_modes[] = { NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NM_SETTING_WIRELESS_MODE_AP, NULL };
|
||||||
const char *valid_bands[] = { "a", "bg", NULL };
|
const char *valid_bands[] = { "a", "bg", NULL };
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
|
gsize length;
|
||||||
|
|
||||||
if (!priv->ssid) {
|
if (!priv->ssid) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
@@ -713,7 +714,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!priv->ssid->len || priv->ssid->len > 32) {
|
length = g_bytes_get_size (priv->ssid);
|
||||||
|
if (length == 0 || length > 32) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
NM_SETTING_WIRELESS_ERROR,
|
NM_SETTING_WIRELESS_ERROR,
|
||||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||||
@@ -845,7 +847,7 @@ finalize (GObject *object)
|
|||||||
g_free (priv->band);
|
g_free (priv->band);
|
||||||
|
|
||||||
if (priv->ssid)
|
if (priv->ssid)
|
||||||
g_byte_array_free (priv->ssid, TRUE);
|
g_bytes_unref (priv->ssid);
|
||||||
g_free (priv->bssid);
|
g_free (priv->bssid);
|
||||||
g_free (priv->device_mac_address);
|
g_free (priv->device_mac_address);
|
||||||
g_free (priv->cloned_mac_address);
|
g_free (priv->cloned_mac_address);
|
||||||
@@ -864,7 +866,7 @@ set_property (GObject *object, guint prop_id,
|
|||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_SSID:
|
case PROP_SSID:
|
||||||
if (priv->ssid)
|
if (priv->ssid)
|
||||||
g_byte_array_free (priv->ssid, TRUE);
|
g_bytes_unref (priv->ssid);
|
||||||
priv->ssid = g_value_dup_boxed (value);
|
priv->ssid = g_value_dup_boxed (value);
|
||||||
break;
|
break;
|
||||||
case PROP_MODE:
|
case PROP_MODE:
|
||||||
@@ -992,9 +994,13 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_SSID,
|
(object_class, PROP_SSID,
|
||||||
g_param_spec_boxed (NM_SETTING_WIRELESS_SSID, "", "",
|
g_param_spec_boxed (NM_SETTING_WIRELESS_SSID, "", "",
|
||||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
G_TYPE_BYTES,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_WIRELESS_SSID,
|
||||||
|
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||||
|
_nm_utils_bytes_to_dbus,
|
||||||
|
_nm_utils_bytes_from_dbus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMSettingWireless:mode:
|
* NMSettingWireless:mode:
|
||||||
|
@@ -116,7 +116,7 @@ GType nm_setting_wireless_get_type (void);
|
|||||||
|
|
||||||
NMSetting *nm_setting_wireless_new (void);
|
NMSetting *nm_setting_wireless_new (void);
|
||||||
|
|
||||||
const GByteArray *nm_setting_wireless_get_ssid (NMSettingWireless *setting);
|
GBytes *nm_setting_wireless_get_ssid (NMSettingWireless *setting);
|
||||||
const char *nm_setting_wireless_get_mode (NMSettingWireless *setting);
|
const char *nm_setting_wireless_get_mode (NMSettingWireless *setting);
|
||||||
const char *nm_setting_wireless_get_band (NMSettingWireless *setting);
|
const char *nm_setting_wireless_get_band (NMSettingWireless *setting);
|
||||||
guint32 nm_setting_wireless_get_channel (NMSettingWireless *setting);
|
guint32 nm_setting_wireless_get_channel (NMSettingWireless *setting);
|
||||||
|
@@ -44,6 +44,11 @@ void _nm_utils_strdict_to_dbus (const GValue *prop_value,
|
|||||||
void _nm_utils_strdict_from_dbus (const GValue *dbus_value,
|
void _nm_utils_strdict_from_dbus (const GValue *dbus_value,
|
||||||
GValue *prop_value);
|
GValue *prop_value);
|
||||||
|
|
||||||
|
void _nm_utils_bytes_to_dbus (const GValue *prop_value,
|
||||||
|
GValue *dbus_value);
|
||||||
|
void _nm_utils_bytes_from_dbus (const GValue *dbus_value,
|
||||||
|
GValue *prop_value);
|
||||||
|
|
||||||
void _nm_utils_ip4_dns_to_dbus (const GValue *prop_value,
|
void _nm_utils_ip4_dns_to_dbus (const GValue *prop_value,
|
||||||
GValue *dbus_value);
|
GValue *dbus_value);
|
||||||
void _nm_utils_ip4_dns_from_dbus (const GValue *dbus_value,
|
void _nm_utils_ip4_dns_from_dbus (const GValue *dbus_value,
|
||||||
|
@@ -626,6 +626,35 @@ _nm_utils_copy_array_to_slist (const GPtrArray *array,
|
|||||||
return g_slist_reverse (slist);
|
return g_slist_reverse (slist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_nm_utils_bytes_to_dbus (const GValue *prop_value,
|
||||||
|
GValue *dbus_value)
|
||||||
|
{
|
||||||
|
GBytes *bytes = g_value_get_boxed (prop_value);
|
||||||
|
GByteArray *ba = NULL;
|
||||||
|
|
||||||
|
if (bytes) {
|
||||||
|
ba = g_byte_array_new ();
|
||||||
|
g_byte_array_append (ba,
|
||||||
|
g_bytes_get_data (bytes, NULL),
|
||||||
|
g_bytes_get_size (bytes));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_value_take_boxed (dbus_value, ba);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_nm_utils_bytes_from_dbus (const GValue *dbus_value,
|
||||||
|
GValue *prop_value)
|
||||||
|
{
|
||||||
|
GByteArray *ba = g_value_dup_boxed (dbus_value);
|
||||||
|
GBytes *bytes = NULL;
|
||||||
|
|
||||||
|
if (ba)
|
||||||
|
bytes = g_byte_array_free_to_bytes (ba);
|
||||||
|
g_value_take_boxed (prop_value, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
GSList *
|
GSList *
|
||||||
_nm_utils_strv_to_slist (char **strv)
|
_nm_utils_strv_to_slist (char **strv)
|
||||||
{
|
{
|
||||||
|
@@ -92,33 +92,6 @@ _nm_utils_convert_gvalue_hash_to_string (const GValue *src_value, GValue *dest_v
|
|||||||
g_string_free (printable, FALSE);
|
g_string_free (printable, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_nm_utils_convert_byte_array_to_string (const GValue *src_value, GValue *dest_value)
|
|
||||||
{
|
|
||||||
GArray *array;
|
|
||||||
GString *printable;
|
|
||||||
guint i = 0;
|
|
||||||
|
|
||||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_UCHAR_ARRAY));
|
|
||||||
|
|
||||||
array = (GArray *) g_value_get_boxed (src_value);
|
|
||||||
|
|
||||||
printable = g_string_new ("[");
|
|
||||||
if (array) {
|
|
||||||
while (i < MIN (array->len, 35)) {
|
|
||||||
if (i > 0)
|
|
||||||
g_string_append_c (printable, ' ');
|
|
||||||
g_string_append_printf (printable, "0x%02X",
|
|
||||||
g_array_index (array, unsigned char, i++));
|
|
||||||
}
|
|
||||||
if (i < array->len)
|
|
||||||
g_string_append (printable, " ... ");
|
|
||||||
}
|
|
||||||
g_string_append_c (printable, ']');
|
|
||||||
|
|
||||||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_nm_value_transforms_register (void)
|
_nm_value_transforms_register (void)
|
||||||
{
|
{
|
||||||
@@ -134,9 +107,6 @@ _nm_value_transforms_register (void)
|
|||||||
g_value_register_transform_func (DBUS_TYPE_G_MAP_OF_VARIANT,
|
g_value_register_transform_func (DBUS_TYPE_G_MAP_OF_VARIANT,
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
_nm_utils_convert_gvalue_hash_to_string);
|
_nm_utils_convert_gvalue_hash_to_string);
|
||||||
g_value_register_transform_func (DBUS_TYPE_G_UCHAR_ARRAY,
|
|
||||||
G_TYPE_STRING,
|
|
||||||
_nm_utils_convert_byte_array_to_string);
|
|
||||||
registered = TRUE;
|
registered = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -721,7 +721,7 @@ test_connection_to_dbus_deprecated_props (void)
|
|||||||
{
|
{
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSetting *s_wireless;
|
NMSetting *s_wireless;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
GHashTable *hash, *wireless_hash;
|
GHashTable *hash, *wireless_hash;
|
||||||
GValue *sec_val;
|
GValue *sec_val;
|
||||||
@@ -732,12 +732,11 @@ test_connection_to_dbus_deprecated_props (void)
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
s_wireless = nm_setting_wireless_new ();
|
s_wireless = nm_setting_wireless_new ();
|
||||||
ssid = g_byte_array_new ();
|
ssid = g_bytes_new ("1234567", 7);
|
||||||
g_byte_array_append (ssid, (const guint8 *) "1234567", 7);
|
|
||||||
g_object_set (s_wireless,
|
g_object_set (s_wireless,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NULL);
|
NULL);
|
||||||
g_byte_array_unref (ssid);
|
g_bytes_unref (ssid);
|
||||||
nm_connection_add_setting (connection, s_wireless);
|
nm_connection_add_setting (connection, s_wireless);
|
||||||
|
|
||||||
/* Hash should not have an 802-11-wireless.security property */
|
/* Hash should not have an 802-11-wireless.security property */
|
||||||
@@ -962,7 +961,7 @@ test_connection_replace_settings_from_connection ()
|
|||||||
gboolean success;
|
gboolean success;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
NMSetting *setting;
|
NMSetting *setting;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
char *uuid = NULL;
|
char *uuid = NULL;
|
||||||
const char *expected_id = "Awesome connection";
|
const char *expected_id = "Awesome connection";
|
||||||
|
|
||||||
@@ -988,13 +987,12 @@ test_connection_replace_settings_from_connection ()
|
|||||||
setting = nm_setting_wireless_new ();
|
setting = nm_setting_wireless_new ();
|
||||||
g_assert (setting);
|
g_assert (setting);
|
||||||
|
|
||||||
ssid = g_byte_array_new ();
|
ssid = g_bytes_new ("1234567", 7);
|
||||||
g_byte_array_append (ssid, (const guint8 *) "1234567", 7);
|
|
||||||
g_object_set (setting,
|
g_object_set (setting,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
nm_connection_add_setting (replacement, setting);
|
nm_connection_add_setting (replacement, setting);
|
||||||
|
|
||||||
/* Replace settings and test */
|
/* Replace settings and test */
|
||||||
@@ -1709,7 +1707,7 @@ test_connection_good_base_types (void)
|
|||||||
NMSetting *setting;
|
NMSetting *setting;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GByteArray *array;
|
GBytes *ssid;
|
||||||
const char *bdaddr = "11:22:33:44:55:66";
|
const char *bdaddr = "11:22:33:44:55:66";
|
||||||
|
|
||||||
/* Try a basic wired connection */
|
/* Try a basic wired connection */
|
||||||
@@ -1740,13 +1738,12 @@ test_connection_good_base_types (void)
|
|||||||
add_generic_settings (connection, NM_SETTING_WIRELESS_SETTING_NAME);
|
add_generic_settings (connection, NM_SETTING_WIRELESS_SETTING_NAME);
|
||||||
|
|
||||||
setting = nm_setting_wireless_new ();
|
setting = nm_setting_wireless_new ();
|
||||||
array = g_byte_array_new ();
|
ssid = g_bytes_new ("1234567", 7);
|
||||||
g_byte_array_append (array, (const guint8 *) "1234567", 7);
|
|
||||||
g_object_set (setting,
|
g_object_set (setting,
|
||||||
NM_SETTING_WIRELESS_SSID, array,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
g_byte_array_free (array, TRUE);
|
g_bytes_unref (ssid);
|
||||||
nm_connection_add_setting (connection, setting);
|
nm_connection_add_setting (connection, setting);
|
||||||
|
|
||||||
success = nm_connection_verify (connection, &error);
|
success = nm_connection_verify (connection, &error);
|
||||||
@@ -2908,14 +2905,14 @@ _add_setting_fcn_olpc_mesh (NMConnection *con)
|
|||||||
{
|
{
|
||||||
NMSetting *setting;
|
NMSetting *setting;
|
||||||
const char *ssid_data = "ssid-test";
|
const char *ssid_data = "ssid-test";
|
||||||
GByteArray *ssid = g_byte_array_new ();
|
GBytes *ssid;
|
||||||
|
|
||||||
g_byte_array_append (ssid, (const guint8 *) ssid_data, strlen (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
setting = g_object_new (NM_TYPE_SETTING_OLPC_MESH,
|
setting = g_object_new (NM_TYPE_SETTING_OLPC_MESH,
|
||||||
NM_SETTING_OLPC_MESH_SSID, ssid,
|
NM_SETTING_OLPC_MESH_SSID, ssid,
|
||||||
NM_SETTING_OLPC_MESH_CHANNEL, 1,
|
NM_SETTING_OLPC_MESH_CHANNEL, 1,
|
||||||
NULL);
|
NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
nm_connection_add_setting (con, setting);
|
nm_connection_add_setting (con, setting);
|
||||||
return setting;
|
return setting;
|
||||||
@@ -2984,13 +2981,13 @@ _add_setting_fcn_wireless (NMConnection *con)
|
|||||||
{
|
{
|
||||||
NMSetting *setting;
|
NMSetting *setting;
|
||||||
const char *ssid_data = "ssid-test";
|
const char *ssid_data = "ssid-test";
|
||||||
GByteArray *ssid = g_byte_array_new ();
|
GBytes *ssid;
|
||||||
|
|
||||||
g_byte_array_append (ssid, (const guint8 *) ssid_data, strlen (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
setting = g_object_new (NM_TYPE_SETTING_WIRELESS,
|
setting = g_object_new (NM_TYPE_SETTING_WIRELESS,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NULL);
|
NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
nm_connection_add_setting (con, setting);
|
nm_connection_add_setting (con, setting);
|
||||||
return setting;
|
return setting;
|
||||||
|
@@ -399,7 +399,7 @@ wifi_connection_new (void)
|
|||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 };
|
unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 };
|
||||||
char *uuid;
|
char *uuid;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -422,12 +422,11 @@ wifi_connection_new (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (tmpssid));
|
ssid = g_bytes_new (tmpssid, sizeof (tmpssid));
|
||||||
g_byte_array_append (ssid, &tmpssid[0], sizeof (tmpssid));
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NULL);
|
NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
/* Wifi security */
|
/* Wifi security */
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
static void
|
static void
|
||||||
compare_blob_data (const char *test,
|
compare_blob_data (const char *test,
|
||||||
const char *key_path,
|
const char *key_path,
|
||||||
const GByteArray *key)
|
GBytes *key)
|
||||||
{
|
{
|
||||||
char *contents = NULL;
|
char *contents = NULL;
|
||||||
gsize len = 0;
|
gsize len = 0;
|
||||||
@@ -45,11 +45,11 @@ compare_blob_data (const char *test,
|
|||||||
|
|
||||||
ASSERT (len > 0, test, "blob key file invalid (size 0)");
|
ASSERT (len > 0, test, "blob key file invalid (size 0)");
|
||||||
|
|
||||||
ASSERT (len == key->len,
|
ASSERT (len == g_bytes_get_size (key),
|
||||||
test, "blob key file (%d) and setting key data (%d) lengths don't match",
|
test, "blob key file (%d) and setting key data (%d) lengths don't match",
|
||||||
len, key->len);
|
len, g_bytes_get_size (key));
|
||||||
|
|
||||||
ASSERT (memcmp (contents, key->data, len) == 0,
|
ASSERT (memcmp (contents, g_bytes_get_data (key, NULL), len) == 0,
|
||||||
test, "blob key file and blob key data don't match");
|
test, "blob key file and blob key data don't match");
|
||||||
|
|
||||||
g_free (contents);
|
g_free (contents);
|
||||||
@@ -58,9 +58,9 @@ compare_blob_data (const char *test,
|
|||||||
#define SCHEME_PATH "file://"
|
#define SCHEME_PATH "file://"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_scheme_path (GByteArray *value, const char *path)
|
check_scheme_path (GBytes *value, const char *path)
|
||||||
{
|
{
|
||||||
guint8 *p = value->data;
|
const guint8 *p = g_bytes_get_data (value, NULL);
|
||||||
|
|
||||||
g_assert (memcmp (p, SCHEME_PATH, strlen (SCHEME_PATH)) == 0);
|
g_assert (memcmp (p, SCHEME_PATH, strlen (SCHEME_PATH)) == 0);
|
||||||
p += strlen (SCHEME_PATH);
|
p += strlen (SCHEME_PATH);
|
||||||
@@ -79,7 +79,7 @@ test_private_key_import (const char *path,
|
|||||||
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
|
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
|
||||||
NMSetting8021xCKFormat tmp_fmt;
|
NMSetting8021xCKFormat tmp_fmt;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GByteArray *tmp_key = NULL, *client_cert = NULL;
|
GBytes *tmp_key = NULL, *client_cert = NULL;
|
||||||
const char *pw;
|
const char *pw;
|
||||||
|
|
||||||
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
|
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
|
||||||
@@ -108,14 +108,14 @@ test_private_key_import (const char *path,
|
|||||||
"private-key-import", "failed to compare private key password");
|
"private-key-import", "failed to compare private key password");
|
||||||
|
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||||
tmp_key = (GByteArray *) nm_setting_802_1x_get_private_key_blob (s_8021x);
|
tmp_key = nm_setting_802_1x_get_private_key_blob (s_8021x);
|
||||||
ASSERT (tmp_key != NULL, "private-key-import", "missing private key blob");
|
ASSERT (tmp_key != NULL, "private-key-import", "missing private key blob");
|
||||||
compare_blob_data ("private-key-import", path, tmp_key);
|
compare_blob_data ("private-key-import", path, tmp_key);
|
||||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) {
|
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) {
|
||||||
g_object_get (s_8021x, NM_SETTING_802_1X_PRIVATE_KEY, &tmp_key, NULL);
|
g_object_get (s_8021x, NM_SETTING_802_1X_PRIVATE_KEY, &tmp_key, NULL);
|
||||||
ASSERT (tmp_key != NULL, "private-key-import", "missing private key value");
|
ASSERT (tmp_key != NULL, "private-key-import", "missing private key value");
|
||||||
check_scheme_path (tmp_key, path);
|
check_scheme_path (tmp_key, path);
|
||||||
g_byte_array_free (tmp_key, TRUE);
|
g_bytes_unref (tmp_key);
|
||||||
} else
|
} else
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
|
|
||||||
@@ -128,13 +128,11 @@ test_private_key_import (const char *path,
|
|||||||
ASSERT (client_cert != NULL, "private-key-import", "missing client certificate value");
|
ASSERT (client_cert != NULL, "private-key-import", "missing client certificate value");
|
||||||
|
|
||||||
/* make sure they are the same */
|
/* make sure they are the same */
|
||||||
ASSERT (tmp_key->len == client_cert->len,
|
ASSERT (g_bytes_equal (tmp_key, client_cert),
|
||||||
"private-key-import", "unexpected different private key and client cert lengths");
|
|
||||||
ASSERT (memcmp (tmp_key->data, client_cert->data, tmp_key->len) == 0,
|
|
||||||
"private-key-import", "unexpected different private key and client cert data");
|
"private-key-import", "unexpected different private key and client cert data");
|
||||||
|
|
||||||
g_byte_array_free (tmp_key, TRUE);
|
g_bytes_unref (tmp_key);
|
||||||
g_byte_array_free (client_cert, TRUE);
|
g_bytes_unref (client_cert);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (s_8021x);
|
g_object_unref (s_8021x);
|
||||||
@@ -150,7 +148,7 @@ test_phase2_private_key_import (const char *path,
|
|||||||
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
|
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
|
||||||
NMSetting8021xCKFormat tmp_fmt;
|
NMSetting8021xCKFormat tmp_fmt;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GByteArray *tmp_key = NULL, *client_cert = NULL;
|
GBytes *tmp_key = NULL, *client_cert = NULL;
|
||||||
const char *pw;
|
const char *pw;
|
||||||
|
|
||||||
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
|
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
|
||||||
@@ -179,7 +177,7 @@ test_phase2_private_key_import (const char *path,
|
|||||||
"phase2-private-key-import", "failed to compare private key password");
|
"phase2-private-key-import", "failed to compare private key password");
|
||||||
|
|
||||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||||
tmp_key = (GByteArray *) nm_setting_802_1x_get_phase2_private_key_blob (s_8021x);
|
tmp_key = nm_setting_802_1x_get_phase2_private_key_blob (s_8021x);
|
||||||
ASSERT (tmp_key != NULL, "phase2-private-key-import", "missing private key blob");
|
ASSERT (tmp_key != NULL, "phase2-private-key-import", "missing private key blob");
|
||||||
compare_blob_data ("phase2-private-key-import", path, tmp_key);
|
compare_blob_data ("phase2-private-key-import", path, tmp_key);
|
||||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) {
|
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) {
|
||||||
@@ -198,13 +196,11 @@ test_phase2_private_key_import (const char *path,
|
|||||||
ASSERT (client_cert != NULL, "private-key-import", "missing client certificate value");
|
ASSERT (client_cert != NULL, "private-key-import", "missing client certificate value");
|
||||||
|
|
||||||
/* make sure they are the same */
|
/* make sure they are the same */
|
||||||
ASSERT (tmp_key->len == client_cert->len,
|
ASSERT (g_bytes_equal (tmp_key, client_cert),
|
||||||
"private-key-import", "unexpected different private key and client cert lengths");
|
|
||||||
ASSERT (memcmp (tmp_key->data, client_cert->data, tmp_key->len) == 0,
|
|
||||||
"private-key-import", "unexpected different private key and client cert data");
|
"private-key-import", "unexpected different private key and client cert data");
|
||||||
|
|
||||||
g_byte_array_free (tmp_key, TRUE);
|
g_bytes_unref (tmp_key);
|
||||||
g_byte_array_free (client_cert, TRUE);
|
g_bytes_unref (client_cert);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (s_8021x);
|
g_object_unref (s_8021x);
|
||||||
|
@@ -236,7 +236,9 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection)
|
|||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
const char *ctype, *ap_bssid;
|
const char *ctype, *ap_bssid;
|
||||||
const GByteArray *setting_ssid;
|
GBytes *setting_ssid;
|
||||||
|
const guint8 *setting_ssid_data;
|
||||||
|
gsize setting_ssid_len;
|
||||||
const GByteArray *ap_ssid;
|
const GByteArray *ap_ssid;
|
||||||
const char *setting_bssid;
|
const char *setting_bssid;
|
||||||
const char *setting_mode;
|
const char *setting_mode;
|
||||||
@@ -258,9 +260,12 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection)
|
|||||||
ap_ssid = nm_access_point_get_ssid (ap);
|
ap_ssid = nm_access_point_get_ssid (ap);
|
||||||
g_warn_if_fail (ap_ssid != NULL);
|
g_warn_if_fail (ap_ssid != NULL);
|
||||||
setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
|
setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
if (!setting_ssid || !ap_ssid || (setting_ssid->len != ap_ssid->len))
|
if (!setting_ssid || !ap_ssid)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (memcmp (setting_ssid->data, ap_ssid->data, ap_ssid->len) != 0)
|
setting_ssid_data = g_bytes_get_data (setting_ssid, &setting_ssid_len);
|
||||||
|
if (setting_ssid_len != ap_ssid->len)
|
||||||
|
return FALSE;
|
||||||
|
if (memcmp (setting_ssid_data, ap_ssid->data, ap_ssid->len) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* BSSID checks */
|
/* BSSID checks */
|
||||||
|
@@ -222,6 +222,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
|||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingOlpcMesh *s_mesh;
|
NMSettingOlpcMesh *s_mesh;
|
||||||
guint32 channel;
|
guint32 channel;
|
||||||
|
GBytes *ssid;
|
||||||
const char *anycast_addr;
|
const char *anycast_addr;
|
||||||
|
|
||||||
connection = nm_device_get_connection (device);
|
connection = nm_device_get_connection (device);
|
||||||
@@ -233,8 +234,11 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
|||||||
channel = nm_setting_olpc_mesh_get_channel (s_mesh);
|
channel = nm_setting_olpc_mesh_get_channel (s_mesh);
|
||||||
if (channel != 0)
|
if (channel != 0)
|
||||||
_mesh_set_channel (self, channel);
|
_mesh_set_channel (self, channel);
|
||||||
|
|
||||||
|
ssid = nm_setting_olpc_mesh_get_ssid (s_mesh);
|
||||||
nm_platform_mesh_set_ssid (nm_device_get_ifindex (device),
|
nm_platform_mesh_set_ssid (nm_device_get_ifindex (device),
|
||||||
nm_setting_olpc_mesh_get_ssid (s_mesh));
|
g_bytes_get_data (ssid, NULL),
|
||||||
|
g_bytes_get_size (ssid));
|
||||||
|
|
||||||
anycast_addr = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh);
|
anycast_addr = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh);
|
||||||
nm_device_set_dhcp_anycast_address (device, anycast_addr);
|
nm_device_set_dhcp_anycast_address (device, anycast_addr);
|
||||||
|
@@ -985,6 +985,8 @@ complete_connection (NMDevice *device,
|
|||||||
char *str_ssid = NULL;
|
char *str_ssid = NULL;
|
||||||
NMAccessPoint *ap = NULL;
|
NMAccessPoint *ap = NULL;
|
||||||
const GByteArray *ssid = NULL;
|
const GByteArray *ssid = NULL;
|
||||||
|
GByteArray *tmp_ssid = NULL;
|
||||||
|
GBytes *setting_ssid = NULL;
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
gboolean hidden = FALSE;
|
gboolean hidden = FALSE;
|
||||||
|
|
||||||
@@ -1002,8 +1004,8 @@ complete_connection (NMDevice *device,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
if (!ssid || !ssid->len) {
|
if (!setting_ssid || g_bytes_get_size (setting_ssid) == 0) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
NM_WIFI_ERROR,
|
NM_WIFI_ERROR,
|
||||||
NM_WIFI_ERROR_CONNECTION_INVALID,
|
NM_WIFI_ERROR_CONNECTION_INVALID,
|
||||||
@@ -1066,7 +1068,13 @@ complete_connection (NMDevice *device,
|
|||||||
* for the SSID. The AP object will still be used for encryption
|
* for the SSID. The AP object will still be used for encryption
|
||||||
* settings and such.
|
* settings and such.
|
||||||
*/
|
*/
|
||||||
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
|
if (setting_ssid) {
|
||||||
|
ssid = tmp_ssid = g_byte_array_new ();
|
||||||
|
g_byte_array_append (tmp_ssid,
|
||||||
|
g_bytes_get_data (setting_ssid, NULL),
|
||||||
|
g_bytes_get_size (setting_ssid));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssid == NULL) {
|
if (ssid == NULL) {
|
||||||
@@ -1086,8 +1094,11 @@ complete_connection (NMDevice *device,
|
|||||||
if (!nm_ap_complete_connection (ap,
|
if (!nm_ap_complete_connection (ap,
|
||||||
connection,
|
connection,
|
||||||
is_manf_default_ssid (ssid),
|
is_manf_default_ssid (ssid),
|
||||||
error))
|
error)) {
|
||||||
|
if (tmp_ssid)
|
||||||
|
g_byte_array_unref (tmp_ssid);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The kernel doesn't support Ad-Hoc WPA connections well at this time,
|
/* The kernel doesn't support Ad-Hoc WPA connections well at this time,
|
||||||
@@ -1099,6 +1110,8 @@ complete_connection (NMDevice *device,
|
|||||||
NM_SETTING_WIRELESS_ERROR,
|
NM_SETTING_WIRELESS_ERROR,
|
||||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||||
"WPA Ad-Hoc disabled due to kernel bugs");
|
"WPA Ad-Hoc disabled due to kernel bugs");
|
||||||
|
if (tmp_ssid)
|
||||||
|
g_byte_array_unref (tmp_ssid);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1113,6 +1126,8 @@ complete_connection (NMDevice *device,
|
|||||||
NULL,
|
NULL,
|
||||||
TRUE);
|
TRUE);
|
||||||
g_free (str_ssid);
|
g_free (str_ssid);
|
||||||
|
if (tmp_ssid)
|
||||||
|
g_byte_array_unref (tmp_ssid);
|
||||||
|
|
||||||
if (hidden)
|
if (hidden)
|
||||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_HIDDEN, TRUE, NULL);
|
g_object_set (s_wifi, NM_SETTING_WIRELESS_HIDDEN, TRUE, NULL);
|
||||||
@@ -1474,20 +1489,25 @@ build_hidden_probe_list (NMDeviceWifi *self)
|
|||||||
hidden_filter_func,
|
hidden_filter_func,
|
||||||
NULL);
|
NULL);
|
||||||
if (connections && connections->data) {
|
if (connections && connections->data) {
|
||||||
ssids = g_ptr_array_sized_new (max_scan_ssids - 1);
|
ssids = g_ptr_array_new_full (max_scan_ssids - 1, (GDestroyNotify) g_byte_array_unref);
|
||||||
g_ptr_array_add (ssids, nullssid); /* Add wildcard SSID */
|
g_ptr_array_add (ssids, g_byte_array_ref (nullssid)); /* Add wildcard SSID */
|
||||||
}
|
}
|
||||||
|
|
||||||
for (iter = connections; iter; iter = g_slist_next (iter)) {
|
for (iter = connections; iter; iter = g_slist_next (iter)) {
|
||||||
NMConnection *connection = iter->data;
|
NMConnection *connection = iter->data;
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
|
GByteArray *ssid_array;
|
||||||
|
|
||||||
s_wifi = (NMSettingWireless *) nm_connection_get_setting_wireless (connection);
|
s_wifi = (NMSettingWireless *) nm_connection_get_setting_wireless (connection);
|
||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
g_assert (ssid);
|
g_assert (ssid);
|
||||||
g_ptr_array_add (ssids, (gpointer) ssid);
|
ssid_array = g_byte_array_new ();
|
||||||
|
g_byte_array_append (ssid_array,
|
||||||
|
g_bytes_get_data (ssid, NULL),
|
||||||
|
g_bytes_get_size (ssid));
|
||||||
|
g_ptr_array_add (ssids, ssid_array);
|
||||||
}
|
}
|
||||||
g_slist_free (connections);
|
g_slist_free (connections);
|
||||||
|
|
||||||
@@ -1536,10 +1556,8 @@ request_wireless_scan (gpointer user_data)
|
|||||||
nm_device_add_pending_action (NM_DEVICE (self), "scan", TRUE);
|
nm_device_add_pending_action (NM_DEVICE (self), "scan", TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssids) {
|
if (ssids)
|
||||||
/* Elements owned by the connections, so we don't free them here */
|
g_ptr_array_unref (ssids);
|
||||||
g_ptr_array_free (ssids, TRUE);
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
_LOGD (LOGD_WIFI_SCAN, "scan requested but not allowed at this time");
|
_LOGD (LOGD_WIFI_SCAN, "scan requested but not allowed at this time");
|
||||||
|
|
||||||
@@ -1657,7 +1675,11 @@ try_fill_ssid_for_hidden_ap (NMAccessPoint *ap)
|
|||||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||||
if (s_wifi) {
|
if (s_wifi) {
|
||||||
if (nm_settings_connection_has_seen_bssid (NM_SETTINGS_CONNECTION (connection), bssid)) {
|
if (nm_settings_connection_has_seen_bssid (NM_SETTINGS_CONNECTION (connection), bssid)) {
|
||||||
nm_ap_set_ssid (ap, nm_setting_wireless_get_ssid (s_wifi));
|
GBytes *ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
|
|
||||||
|
nm_ap_set_ssid (ap,
|
||||||
|
g_bytes_get_data (ssid, NULL),
|
||||||
|
g_bytes_get_size (ssid));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2190,7 +2212,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
|
|||||||
if (devstate == NM_DEVICE_STATE_CONFIG) {
|
if (devstate == NM_DEVICE_STATE_CONFIG) {
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
|
|
||||||
connection = nm_device_get_connection (NM_DEVICE (self));
|
connection = nm_device_get_connection (NM_DEVICE (self));
|
||||||
g_return_if_fail (connection);
|
g_return_if_fail (connection);
|
||||||
@@ -2205,7 +2227,8 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
|
|||||||
"Activation: (wifi) Stage 2 of 5 (Device Configure) successful. %s '%s'.",
|
"Activation: (wifi) Stage 2 of 5 (Device Configure) successful. %s '%s'.",
|
||||||
priv->mode == NM_802_11_MODE_AP ? "Started Wi-Fi Hotspot" :
|
priv->mode == NM_802_11_MODE_AP ? "Started Wi-Fi Hotspot" :
|
||||||
"Connected to wireless network",
|
"Connected to wireless network",
|
||||||
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)");
|
ssid ? nm_utils_escape_ssid (g_bytes_get_data (ssid, NULL),
|
||||||
|
g_bytes_get_size (ssid)) : "(none)");
|
||||||
nm_device_activate_schedule_stage3_ip_config_start (device);
|
nm_device_activate_schedule_stage3_ip_config_start (device);
|
||||||
} else if (devstate == NM_DEVICE_STATE_ACTIVATED)
|
} else if (devstate == NM_DEVICE_STATE_ACTIVATED)
|
||||||
periodic_update (self, NULL);
|
periodic_update (self, NULL);
|
||||||
@@ -3028,9 +3051,11 @@ activation_success_handler (NMDevice *device)
|
|||||||
* instead.
|
* instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* If the better match was a hidden AP, update it's SSID */
|
/* If the better match was a hidden AP, update its SSID */
|
||||||
if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len))
|
if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len)) {
|
||||||
nm_ap_set_ssid (tmp_ap, nm_ap_get_ssid (ap));
|
ssid = nm_ap_get_ssid (ap);
|
||||||
|
nm_ap_set_ssid (tmp_ap, ssid->data, ssid->len);
|
||||||
|
}
|
||||||
|
|
||||||
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
|
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
|
||||||
nm_ap_get_dbus_path (tmp_ap));
|
nm_ap_get_dbus_path (tmp_ap));
|
||||||
|
@@ -478,7 +478,7 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
|
|||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
NMSetting8021x *s_8021x;
|
NMSetting8021x *s_8021x;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid, *ap_ssid_bytes;
|
||||||
const char *mode, *key_mgmt, *auth_alg, *leap_username;
|
const char *mode, *key_mgmt, *auth_alg, *leap_username;
|
||||||
gboolean adhoc = FALSE;
|
gboolean adhoc = FALSE;
|
||||||
|
|
||||||
@@ -488,17 +488,19 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
|
|||||||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||||
|
|
||||||
/* Fill in missing SSID */
|
/* Fill in missing SSID */
|
||||||
|
ap_ssid_bytes = g_bytes_new (ap_ssid->data, ap_ssid->len);
|
||||||
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
if (!ssid)
|
if (!ssid)
|
||||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, ap_ssid, NULL);
|
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, ap_ssid_bytes, NULL);
|
||||||
else if ( ssid->len != ap_ssid->len
|
else if (!g_bytes_equal (ssid, ap_ssid_bytes)) {
|
||||||
|| memcmp (ssid->data, ap_ssid->data, ssid->len)) {
|
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
NM_SETTING_WIRELESS_ERROR,
|
NM_SETTING_WIRELESS_ERROR,
|
||||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||||
"Setting SSID did not match AP SSID");
|
"Setting SSID did not match AP SSID");
|
||||||
|
g_bytes_unref (ap_ssid_bytes);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
g_bytes_unref (ap_ssid_bytes);
|
||||||
|
|
||||||
if (lock_bssid && !nm_setting_wireless_get_bssid (s_wifi))
|
if (lock_bssid && !nm_setting_wireless_get_bssid (s_wifi))
|
||||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL);
|
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL);
|
||||||
|
@@ -111,6 +111,7 @@ set_property (GObject *object, guint prop_id,
|
|||||||
const GValue *value, GParamSpec *pspec)
|
const GValue *value, GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
NMAccessPoint *ap = NM_AP (object);
|
NMAccessPoint *ap = NM_AP (object);
|
||||||
|
GByteArray *ssid;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_FLAGS:
|
case PROP_FLAGS:
|
||||||
@@ -123,7 +124,11 @@ set_property (GObject *object, guint prop_id,
|
|||||||
nm_ap_set_rsn_flags (ap, g_value_get_uint (value));
|
nm_ap_set_rsn_flags (ap, g_value_get_uint (value));
|
||||||
break;
|
break;
|
||||||
case PROP_SSID:
|
case PROP_SSID:
|
||||||
nm_ap_set_ssid (ap, (GByteArray *) g_value_get_boxed (value));
|
ssid = g_value_get_boxed (value);
|
||||||
|
if (ssid)
|
||||||
|
nm_ap_set_ssid (ap, ssid->data, ssid->len);
|
||||||
|
else
|
||||||
|
nm_ap_set_ssid (ap, NULL, 0);
|
||||||
break;
|
break;
|
||||||
case PROP_FREQUENCY:
|
case PROP_FREQUENCY:
|
||||||
nm_ap_set_freq (ap, g_value_get_uint (value));
|
nm_ap_set_freq (ap, g_value_get_uint (value));
|
||||||
@@ -393,7 +398,6 @@ foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
|
|||||||
|
|
||||||
if (!strcmp (key, "SSID")) {
|
if (!strcmp (key, "SSID")) {
|
||||||
guint32 len = MIN (32, array->len);
|
guint32 len = MIN (32, array->len);
|
||||||
GByteArray *ssid;
|
|
||||||
|
|
||||||
/* Stupid ieee80211 layer uses <hidden> */
|
/* Stupid ieee80211 layer uses <hidden> */
|
||||||
if (((len == 8) || (len == 9))
|
if (((len == 8) || (len == 9))
|
||||||
@@ -403,10 +407,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
|
|||||||
if (nm_utils_is_empty_ssid ((const guint8 *) array->data, len))
|
if (nm_utils_is_empty_ssid ((const guint8 *) array->data, len))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (len);
|
nm_ap_set_ssid (ap, (const guint8 *) array->data, len);
|
||||||
g_byte_array_append (ssid, (const guint8 *) array->data, len);
|
|
||||||
nm_ap_set_ssid (ap, ssid);
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
|
||||||
} else if (!strcmp (key, "BSSID")) {
|
} else if (!strcmp (key, "BSSID")) {
|
||||||
char *addr;
|
char *addr;
|
||||||
|
|
||||||
@@ -588,7 +589,7 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||||||
NMAccessPoint *ap;
|
NMAccessPoint *ap;
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
NMSettingWirelessSecurity *s_wireless_sec;
|
NMSettingWirelessSecurity *s_wireless_sec;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const char *mode, *band, *key_mgmt;
|
const char *mode, *band, *key_mgmt;
|
||||||
guint32 channel;
|
guint32 channel;
|
||||||
NM80211ApSecurityFlags flags;
|
NM80211ApSecurityFlags flags;
|
||||||
@@ -601,11 +602,11 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||||||
|
|
||||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
g_return_val_if_fail (ssid != NULL, NULL);
|
g_return_val_if_fail (ssid != NULL, NULL);
|
||||||
g_return_val_if_fail (ssid->len > 0, NULL);
|
g_return_val_if_fail (g_bytes_get_size (ssid) > 0, NULL);
|
||||||
|
|
||||||
ap = nm_ap_new ();
|
ap = nm_ap_new ();
|
||||||
nm_ap_set_fake (ap, TRUE);
|
nm_ap_set_fake (ap, TRUE);
|
||||||
nm_ap_set_ssid (ap, ssid);
|
nm_ap_set_ssid (ap, g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
|
||||||
|
|
||||||
// FIXME: bssid too?
|
// FIXME: bssid too?
|
||||||
|
|
||||||
@@ -773,20 +774,18 @@ const GByteArray * nm_ap_get_ssid (const NMAccessPoint *ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ap_set_ssid (NMAccessPoint *ap, const GByteArray * ssid)
|
nm_ap_set_ssid (NMAccessPoint *ap, const guint8 *ssid, gsize len)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMAccessPointPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
g_return_if_fail (ssid == NULL || len > 0);
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
if (ssid == priv->ssid)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* same SSID */
|
/* same SSID */
|
||||||
if ((ssid && priv->ssid) && (ssid->len == priv->ssid->len)) {
|
if ((ssid && priv->ssid) && (len == priv->ssid->len)) {
|
||||||
if (!memcmp (ssid->data, priv->ssid->data, ssid->len))
|
if (!memcmp (ssid, priv->ssid->data, len))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -796,14 +795,8 @@ nm_ap_set_ssid (NMAccessPoint *ap, const GByteArray * ssid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ssid) {
|
if (ssid) {
|
||||||
/* Should never get zero-length SSIDs */
|
priv->ssid = g_byte_array_new ();
|
||||||
g_warn_if_fail (ssid->len > 0);
|
g_byte_array_append (priv->ssid, ssid, len);
|
||||||
|
|
||||||
if (ssid->len) {
|
|
||||||
priv->ssid = g_byte_array_sized_new (ssid->len);
|
|
||||||
priv->ssid->len = ssid->len;
|
|
||||||
memcpy (priv->ssid->data, ssid->data, ssid->len);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (ap), NM_AP_SSID);
|
g_object_notify (G_OBJECT (ap), NM_AP_SSID);
|
||||||
@@ -1109,7 +1102,7 @@ nm_ap_check_compatible (NMAccessPoint *self,
|
|||||||
NMAccessPointPrivate *priv;
|
NMAccessPointPrivate *priv;
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
NMSettingWirelessSecurity *s_wireless_sec;
|
NMSettingWirelessSecurity *s_wireless_sec;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const char *mode;
|
const char *mode;
|
||||||
const char *band;
|
const char *band;
|
||||||
const char *bssid;
|
const char *bssid;
|
||||||
@@ -1130,7 +1123,7 @@ nm_ap_check_compatible (NMAccessPoint *self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ( ssid && priv->ssid &&
|
if ( ssid && priv->ssid &&
|
||||||
!nm_utils_same_ssid (ssid->data, ssid->len,
|
!nm_utils_same_ssid (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid),
|
||||||
priv->ssid->data, priv->ssid->len,
|
priv->ssid->data, priv->ssid->len,
|
||||||
TRUE))
|
TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@@ -67,7 +67,7 @@ void nm_ap_set_supplicant_path (NMAccessPoint *ap,
|
|||||||
const char *path);
|
const char *path);
|
||||||
|
|
||||||
const GByteArray *nm_ap_get_ssid (const NMAccessPoint * ap);
|
const GByteArray *nm_ap_get_ssid (const NMAccessPoint * ap);
|
||||||
void nm_ap_set_ssid (NMAccessPoint * ap, const GByteArray * ssid);
|
void nm_ap_set_ssid (NMAccessPoint * ap, const guint8 * ssid, gsize len);
|
||||||
|
|
||||||
NM80211ApFlags nm_ap_get_flags (NMAccessPoint *ap);
|
NM80211ApFlags nm_ap_get_flags (NMAccessPoint *ap);
|
||||||
void nm_ap_set_flags (NMAccessPoint *ap, NM80211ApFlags flags);
|
void nm_ap_set_flags (NMAccessPoint *ap, NM80211ApFlags flags);
|
||||||
|
@@ -114,7 +114,7 @@ set_items (NMSetting *setting, const KeyData *items)
|
|||||||
{
|
{
|
||||||
const KeyData *item;
|
const KeyData *item;
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
GByteArray *tmp;
|
GBytes *tmp;
|
||||||
|
|
||||||
for (item = items; item && item->key; item++) {
|
for (item = items; item && item->key; item++) {
|
||||||
g_assert (item->key);
|
g_assert (item->key);
|
||||||
@@ -138,12 +138,11 @@ set_items (NMSetting *setting, const KeyData *items)
|
|||||||
|
|
||||||
g_assert (item->str == NULL);
|
g_assert (item->str == NULL);
|
||||||
g_object_set (G_OBJECT (setting), item->key, foo, NULL);
|
g_object_set (G_OBJECT (setting), item->key, foo, NULL);
|
||||||
} else if (pspec->value_type == DBUS_TYPE_G_UCHAR_ARRAY) {
|
} else if (pspec->value_type == G_TYPE_BYTES) {
|
||||||
g_assert (item->str);
|
g_assert (item->str);
|
||||||
tmp = g_byte_array_sized_new (strlen (item->str));
|
tmp = g_bytes_new (item->str, strlen (item->str));
|
||||||
g_byte_array_append (tmp, (const guint8 *) item->str, strlen (item->str));
|
|
||||||
g_object_set (G_OBJECT (setting), item->key, tmp, NULL);
|
g_object_set (G_OBJECT (setting), item->key, tmp, NULL);
|
||||||
g_byte_array_free (tmp, TRUE);
|
g_bytes_unref (tmp);
|
||||||
} else {
|
} else {
|
||||||
/* Special types, check based on property name */
|
/* Special types, check based on property name */
|
||||||
if (!strcmp (item->key, NM_SETTING_WIRELESS_SECURITY_PROTO))
|
if (!strcmp (item->key, NM_SETTING_WIRELESS_SECURITY_PROTO))
|
||||||
@@ -223,7 +222,7 @@ create_basic (const char *ssid,
|
|||||||
{
|
{
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingWireless *s_wifi = NULL;
|
NMSettingWireless *s_wifi = NULL;
|
||||||
GByteArray *tmp;
|
GBytes *tmp;
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
|
|
||||||
@@ -231,10 +230,9 @@ create_basic (const char *ssid,
|
|||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
/* SSID */
|
/* SSID */
|
||||||
tmp = g_byte_array_sized_new (strlen (ssid));
|
tmp = g_bytes_new (ssid, strlen (ssid));
|
||||||
g_byte_array_append (tmp, (const guint8 *) ssid, strlen (ssid));
|
|
||||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, tmp, NULL);
|
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, tmp, NULL);
|
||||||
g_byte_array_free (tmp, TRUE);
|
g_bytes_unref (tmp);
|
||||||
|
|
||||||
/* BSSID */
|
/* BSSID */
|
||||||
if (bssid)
|
if (bssid)
|
||||||
|
@@ -754,7 +754,7 @@ mesh_set_channel (NMPlatform *platform, int ifindex, guint32 channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
mesh_set_ssid (NMPlatform *platform, int ifindex, const GByteArray *ssid)
|
mesh_set_ssid (NMPlatform *platform, int ifindex, const guint8 *ssid, gsize len)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -3276,14 +3276,14 @@ mesh_set_channel (NMPlatform *platform, int ifindex, guint32 channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
mesh_set_ssid (NMPlatform *platform, int ifindex, const GByteArray *ssid)
|
mesh_set_ssid (NMPlatform *platform, int ifindex, const guint8 *ssid, gsize len)
|
||||||
{
|
{
|
||||||
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
|
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
|
||||||
|
|
||||||
if (!wifi_data)
|
if (!wifi_data)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return wifi_utils_set_mesh_ssid (wifi_data, ssid);
|
return wifi_utils_set_mesh_ssid (wifi_data, ssid, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@@ -1377,14 +1377,14 @@ nm_platform_mesh_set_channel (int ifindex, guint32 channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_platform_mesh_set_ssid (int ifindex, const GByteArray *ssid)
|
nm_platform_mesh_set_ssid (int ifindex, const guint8 *ssid, gsize len)
|
||||||
{
|
{
|
||||||
reset_error ();
|
reset_error ();
|
||||||
|
|
||||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||||
g_return_val_if_fail (ssid != NULL, FALSE);
|
g_return_val_if_fail (ssid != NULL, FALSE);
|
||||||
|
|
||||||
return klass->mesh_set_ssid (platform, ifindex, ssid);
|
return klass->mesh_set_ssid (platform, ifindex, ssid, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
@@ -433,7 +433,7 @@ typedef struct {
|
|||||||
|
|
||||||
guint32 (*mesh_get_channel) (NMPlatform *, int ifindex);
|
guint32 (*mesh_get_channel) (NMPlatform *, int ifindex);
|
||||||
gboolean (*mesh_set_channel) (NMPlatform *, int ifindex, guint32 channel);
|
gboolean (*mesh_set_channel) (NMPlatform *, int ifindex, guint32 channel);
|
||||||
gboolean (*mesh_set_ssid) (NMPlatform *, int ifindex, const GByteArray *ssid);
|
gboolean (*mesh_set_ssid) (NMPlatform *, int ifindex, const guint8 *ssid, gsize len);
|
||||||
|
|
||||||
GArray * (*ip4_address_get_all) (NMPlatform *, int ifindex);
|
GArray * (*ip4_address_get_all) (NMPlatform *, int ifindex);
|
||||||
GArray * (*ip6_address_get_all) (NMPlatform *, int ifindex);
|
GArray * (*ip6_address_get_all) (NMPlatform *, int ifindex);
|
||||||
@@ -573,7 +573,7 @@ void nm_platform_wifi_indicate_addressing_running (int ifindex, gboolean
|
|||||||
|
|
||||||
guint32 nm_platform_mesh_get_channel (int ifindex);
|
guint32 nm_platform_mesh_get_channel (int ifindex);
|
||||||
gboolean nm_platform_mesh_set_channel (int ifindex, guint32 channel);
|
gboolean nm_platform_mesh_set_channel (int ifindex, guint32 channel);
|
||||||
gboolean nm_platform_mesh_set_ssid (int ifindex, const GByteArray *ssid);
|
gboolean nm_platform_mesh_set_ssid (int ifindex, const guint8 *ssid, gsize len);
|
||||||
|
|
||||||
GArray *nm_platform_ip4_address_get_all (int ifindex);
|
GArray *nm_platform_ip4_address_get_all (int ifindex);
|
||||||
GArray *nm_platform_ip6_address_get_all (int ifindex);
|
GArray *nm_platform_ip6_address_get_all (int ifindex);
|
||||||
|
@@ -66,7 +66,7 @@ struct WifiData {
|
|||||||
gboolean (*set_mesh_channel) (WifiData *data, guint32 channel);
|
gboolean (*set_mesh_channel) (WifiData *data, guint32 channel);
|
||||||
|
|
||||||
/* ssid == NULL means "auto SSID" */
|
/* ssid == NULL means "auto SSID" */
|
||||||
gboolean (*set_mesh_ssid) (WifiData *data, const GByteArray *ssid);
|
gboolean (*set_mesh_ssid) (WifiData *data, const guint8 *ssid, gsize len);
|
||||||
|
|
||||||
gboolean (*indicate_addressing_running) (WifiData *data, gboolean running);
|
gboolean (*indicate_addressing_running) (WifiData *data, gboolean running);
|
||||||
};
|
};
|
||||||
|
@@ -420,18 +420,15 @@ wifi_wext_set_mesh_channel (WifiData *data, guint32 channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
wifi_wext_set_mesh_ssid (WifiData *data, const GByteArray *ssid)
|
wifi_wext_set_mesh_ssid (WifiData *data, const guint8 *ssid, gsize len)
|
||||||
{
|
{
|
||||||
WifiDataWext *wext = (WifiDataWext *) data;
|
WifiDataWext *wext = (WifiDataWext *) data;
|
||||||
struct iwreq wrq;
|
struct iwreq wrq;
|
||||||
guint32 len = 0;
|
|
||||||
char buf[IW_ESSID_MAX_SIZE + 1];
|
char buf[IW_ESSID_MAX_SIZE + 1];
|
||||||
|
|
||||||
memset (buf, 0, sizeof (buf));
|
memset (buf, 0, sizeof (buf));
|
||||||
if (ssid) {
|
memcpy (buf, ssid, MIN (sizeof (buf) - 1, len));
|
||||||
len = ssid->len;
|
|
||||||
memcpy (buf, ssid->data, MIN (sizeof (buf) - 1, len));
|
|
||||||
}
|
|
||||||
wrq.u.essid.pointer = (caddr_t) buf;
|
wrq.u.essid.pointer = (caddr_t) buf;
|
||||||
wrq.u.essid.length = len;
|
wrq.u.essid.length = len;
|
||||||
wrq.u.essid.flags = (len > 0) ? 1 : 0; /* 1=enable SSID, 0=disable/any */
|
wrq.u.essid.flags = (len > 0) ? 1 : 0; /* 1=enable SSID, 0=disable/any */
|
||||||
@@ -444,7 +441,7 @@ wifi_wext_set_mesh_ssid (WifiData *data, const GByteArray *ssid)
|
|||||||
nm_log_err (LOGD_HW | LOGD_WIFI | LOGD_OLPC,
|
nm_log_err (LOGD_HW | LOGD_WIFI | LOGD_OLPC,
|
||||||
"(%s): error setting SSID to '%s': %s",
|
"(%s): error setting SSID to '%s': %s",
|
||||||
wext->parent.iface,
|
wext->parent.iface,
|
||||||
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(null)",
|
ssid ? nm_utils_escape_ssid (ssid, len) : "(null)",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -207,11 +207,11 @@ wifi_utils_set_mesh_channel (WifiData *data, guint32 channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
wifi_utils_set_mesh_ssid (WifiData *data, const GByteArray *ssid)
|
wifi_utils_set_mesh_ssid (WifiData *data, const guint8 *ssid, gsize len)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (data != NULL, FALSE);
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
g_return_val_if_fail (data->set_mesh_ssid != NULL, FALSE);
|
g_return_val_if_fail (data->set_mesh_ssid != NULL, FALSE);
|
||||||
return data->set_mesh_ssid (data, ssid);
|
return data->set_mesh_ssid (data, ssid, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@@ -71,6 +71,6 @@ guint32 wifi_utils_get_mesh_channel (WifiData *data);
|
|||||||
|
|
||||||
gboolean wifi_utils_set_mesh_channel (WifiData *data, guint32 channel);
|
gboolean wifi_utils_set_mesh_channel (WifiData *data, guint32 channel);
|
||||||
|
|
||||||
gboolean wifi_utils_set_mesh_ssid (WifiData *data, const GByteArray *ssid);
|
gboolean wifi_utils_set_mesh_ssid (WifiData *data, const guint8 *ssid, gsize len);
|
||||||
|
|
||||||
#endif /* __WIFI_UTILS_H__ */
|
#endif /* __WIFI_UTILS_H__ */
|
||||||
|
@@ -2282,7 +2282,7 @@ fill_wpa_ciphers (shvarFile *ifcfg,
|
|||||||
static char *
|
static char *
|
||||||
parse_wpa_psk (shvarFile *ifcfg,
|
parse_wpa_psk (shvarFile *ifcfg,
|
||||||
const char *file,
|
const char *file,
|
||||||
const GByteArray *ssid,
|
GBytes *ssid,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
shvarFile *keys_ifcfg;
|
shvarFile *keys_ifcfg;
|
||||||
@@ -3038,7 +3038,7 @@ error:
|
|||||||
static NMSetting *
|
static NMSetting *
|
||||||
make_wpa_setting (shvarFile *ifcfg,
|
make_wpa_setting (shvarFile *ifcfg,
|
||||||
const char *file,
|
const char *file,
|
||||||
const GByteArray *ssid,
|
GBytes *ssid,
|
||||||
gboolean adhoc,
|
gboolean adhoc,
|
||||||
NMSetting8021x **s_8021x,
|
NMSetting8021x **s_8021x,
|
||||||
GError **error)
|
GError **error)
|
||||||
@@ -3208,7 +3208,7 @@ error:
|
|||||||
static NMSetting *
|
static NMSetting *
|
||||||
make_wireless_security_setting (shvarFile *ifcfg,
|
make_wireless_security_setting (shvarFile *ifcfg,
|
||||||
const char *file,
|
const char *file,
|
||||||
const GByteArray *ssid,
|
GBytes *ssid,
|
||||||
gboolean adhoc,
|
gboolean adhoc,
|
||||||
NMSetting8021x **s_8021x,
|
NMSetting8021x **s_8021x,
|
||||||
GError **error)
|
GError **error)
|
||||||
@@ -3243,7 +3243,7 @@ make_wireless_setting (shvarFile *ifcfg,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
GByteArray *array = NULL;
|
GBytes *bytes = NULL;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
|
s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
|
||||||
@@ -3324,10 +3324,9 @@ make_wireless_setting (shvarFile *ifcfg,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
array = g_byte_array_sized_new (ssid_len);
|
bytes = g_bytes_new (p, ssid_len);
|
||||||
g_byte_array_append (array, (const guint8 *) p, ssid_len);
|
g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, bytes, NULL);
|
||||||
g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, array, NULL);
|
g_bytes_unref (bytes);
|
||||||
g_byte_array_free (array, TRUE);
|
|
||||||
g_free (value);
|
g_free (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3420,7 +3419,7 @@ wireless_connection_from_ifcfg (const char *file,
|
|||||||
NMSetting *con_setting = NULL;
|
NMSetting *con_setting = NULL;
|
||||||
NMSetting *wireless_setting = NULL;
|
NMSetting *wireless_setting = NULL;
|
||||||
NMSetting8021x *s_8021x = NULL;
|
NMSetting8021x *s_8021x = NULL;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
NMSetting *security_setting = NULL;
|
NMSetting *security_setting = NULL;
|
||||||
char *printable_ssid = NULL;
|
char *printable_ssid = NULL;
|
||||||
const char *mode;
|
const char *mode;
|
||||||
@@ -3442,9 +3441,10 @@ wireless_connection_from_ifcfg (const char *file,
|
|||||||
nm_connection_add_setting (connection, wireless_setting);
|
nm_connection_add_setting (connection, wireless_setting);
|
||||||
|
|
||||||
ssid = nm_setting_wireless_get_ssid (NM_SETTING_WIRELESS (wireless_setting));
|
ssid = nm_setting_wireless_get_ssid (NM_SETTING_WIRELESS (wireless_setting));
|
||||||
if (ssid)
|
if (ssid) {
|
||||||
printable_ssid = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
printable_ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
|
||||||
else
|
g_bytes_get_size (ssid));
|
||||||
|
} else
|
||||||
printable_ssid = g_strdup_printf ("unmanaged");
|
printable_ssid = g_strdup_printf ("unmanaged");
|
||||||
|
|
||||||
mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (wireless_setting));
|
mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (wireless_setting));
|
||||||
|
@@ -2796,7 +2796,7 @@ test_read_wifi_open (void)
|
|||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
const char *mac;
|
const char *mac;
|
||||||
char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 };
|
char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 };
|
||||||
const char *expected_id = "System blahblah (test-wifi-open)";
|
const char *expected_id = "System blahblah (test-wifi-open)";
|
||||||
@@ -2887,18 +2887,18 @@ test_read_wifi_open (void)
|
|||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_MTU);
|
NM_SETTING_WIRELESS_MTU);
|
||||||
|
|
||||||
array = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
ASSERT (array != NULL,
|
ASSERT (ssid != NULL,
|
||||||
"wifi-open-verify-wireless", "failed to verify %s: missing %s / %s key",
|
"wifi-open-verify-wireless", "failed to verify %s: missing %s / %s key",
|
||||||
TEST_IFCFG_WIFI_OPEN,
|
TEST_IFCFG_WIFI_OPEN,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (array->len == strlen (expected_ssid),
|
ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid),
|
||||||
"wifi-open-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
"wifi-open-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
||||||
TEST_IFCFG_WIFI_OPEN,
|
TEST_IFCFG_WIFI_OPEN,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0,
|
ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0,
|
||||||
"wifi-open-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
"wifi-open-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
||||||
TEST_IFCFG_WIFI_OPEN,
|
TEST_IFCFG_WIFI_OPEN,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
@@ -3051,7 +3051,7 @@ test_read_wifi_open_ssid_hex (void)
|
|||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
const char *expected_id = "System blahblah (test-wifi-open-ssid-hex)";
|
const char *expected_id = "System blahblah (test-wifi-open-ssid-hex)";
|
||||||
const char *expected_ssid = "blahblah";
|
const char *expected_ssid = "blahblah";
|
||||||
|
|
||||||
@@ -3100,18 +3100,18 @@ test_read_wifi_open_ssid_hex (void)
|
|||||||
NM_SETTING_WIRELESS_SETTING_NAME);
|
NM_SETTING_WIRELESS_SETTING_NAME);
|
||||||
|
|
||||||
/* SSID */
|
/* SSID */
|
||||||
array = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
ASSERT (array != NULL,
|
ASSERT (ssid != NULL,
|
||||||
"wifi-open-ssid-hex-verify-wireless", "failed to verify %s: missing %s / %s key",
|
"wifi-open-ssid-hex-verify-wireless", "failed to verify %s: missing %s / %s key",
|
||||||
TEST_IFCFG_WIFI_OPEN_SSID_HEX,
|
TEST_IFCFG_WIFI_OPEN_SSID_HEX,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (array->len == strlen (expected_ssid),
|
ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid),
|
||||||
"wifi-open-ssid-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
"wifi-open-ssid-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
||||||
TEST_IFCFG_WIFI_OPEN_SSID_HEX,
|
TEST_IFCFG_WIFI_OPEN_SSID_HEX,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0,
|
ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0,
|
||||||
"wifi-open-ssid-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
"wifi-open-ssid-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
||||||
TEST_IFCFG_WIFI_OPEN_SSID_HEX,
|
TEST_IFCFG_WIFI_OPEN_SSID_HEX,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
@@ -3168,7 +3168,7 @@ test_read_wifi_open_ssid_quoted (void)
|
|||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
const char *expected_id = "System foo\"bar\\ (test-wifi-open-ssid-quoted)";
|
const char *expected_id = "System foo\"bar\\ (test-wifi-open-ssid-quoted)";
|
||||||
const char *expected_ssid = "foo\"bar\\";
|
const char *expected_ssid = "foo\"bar\\";
|
||||||
|
|
||||||
@@ -3217,18 +3217,18 @@ test_read_wifi_open_ssid_quoted (void)
|
|||||||
NM_SETTING_WIRELESS_SETTING_NAME);
|
NM_SETTING_WIRELESS_SETTING_NAME);
|
||||||
|
|
||||||
/* SSID */
|
/* SSID */
|
||||||
array = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
ASSERT (array != NULL,
|
ASSERT (ssid != NULL,
|
||||||
"wifi-open-ssid-quoted-verify-wireless", "failed to verify %s: missing %s / %s key",
|
"wifi-open-ssid-quoted-verify-wireless", "failed to verify %s: missing %s / %s key",
|
||||||
TEST_IFCFG_WIFI_OPEN_SSID_QUOTED,
|
TEST_IFCFG_WIFI_OPEN_SSID_QUOTED,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (array->len == strlen (expected_ssid),
|
ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid),
|
||||||
"wifi-open-ssid-quoted-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
"wifi-open-ssid-quoted-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
||||||
TEST_IFCFG_WIFI_OPEN_SSID_QUOTED,
|
TEST_IFCFG_WIFI_OPEN_SSID_QUOTED,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0,
|
ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0,
|
||||||
"wifi-open-ssid-quoted-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
"wifi-open-ssid-quoted-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
||||||
TEST_IFCFG_WIFI_OPEN_SSID_QUOTED,
|
TEST_IFCFG_WIFI_OPEN_SSID_QUOTED,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
@@ -3258,7 +3258,7 @@ test_read_wifi_wep (void)
|
|||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
const char *mac;
|
const char *mac;
|
||||||
char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 };
|
char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 };
|
||||||
const char *expected_id = "System blahblah (test-wifi-wep)";
|
const char *expected_id = "System blahblah (test-wifi-wep)";
|
||||||
@@ -3353,18 +3353,18 @@ test_read_wifi_wep (void)
|
|||||||
NM_SETTING_WIRELESS_MTU);
|
NM_SETTING_WIRELESS_MTU);
|
||||||
|
|
||||||
/* SSID */
|
/* SSID */
|
||||||
array = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
ASSERT (array != NULL,
|
ASSERT (ssid != NULL,
|
||||||
"wifi-wep-verify-wireless", "failed to verify %s: missing %s / %s key",
|
"wifi-wep-verify-wireless", "failed to verify %s: missing %s / %s key",
|
||||||
TEST_IFCFG_WIFI_WEP,
|
TEST_IFCFG_WIFI_WEP,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (array->len == strlen (expected_ssid),
|
ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid),
|
||||||
"wifi-wep-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
"wifi-wep-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
||||||
TEST_IFCFG_WIFI_WEP,
|
TEST_IFCFG_WIFI_WEP,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0,
|
ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0,
|
||||||
"wifi-wep-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
"wifi-wep-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
||||||
TEST_IFCFG_WIFI_WEP,
|
TEST_IFCFG_WIFI_WEP,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
@@ -3516,7 +3516,7 @@ test_read_wifi_wep_adhoc (void)
|
|||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
const char *expected_id = "System blahblah (test-wifi-wep-adhoc)";
|
const char *expected_id = "System blahblah (test-wifi-wep-adhoc)";
|
||||||
const char *expected_ssid = "blahblah";
|
const char *expected_ssid = "blahblah";
|
||||||
const char *expected_mode = "adhoc";
|
const char *expected_mode = "adhoc";
|
||||||
@@ -3579,18 +3579,18 @@ test_read_wifi_wep_adhoc (void)
|
|||||||
NM_SETTING_WIRELESS_SETTING_NAME);
|
NM_SETTING_WIRELESS_SETTING_NAME);
|
||||||
|
|
||||||
/* SSID */
|
/* SSID */
|
||||||
array = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
ASSERT (array != NULL,
|
ASSERT (ssid != NULL,
|
||||||
"wifi-wep-adhoc-verify-wireless", "failed to verify %s: missing %s / %s key",
|
"wifi-wep-adhoc-verify-wireless", "failed to verify %s: missing %s / %s key",
|
||||||
TEST_IFCFG_WIFI_WEP_ADHOC,
|
TEST_IFCFG_WIFI_WEP_ADHOC,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (array->len == strlen (expected_ssid),
|
ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid),
|
||||||
"wifi-wep-adhoc-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
"wifi-wep-adhoc-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
||||||
TEST_IFCFG_WIFI_WEP_ADHOC,
|
TEST_IFCFG_WIFI_WEP_ADHOC,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0,
|
ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0,
|
||||||
"wifi-wep-adhoc-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
"wifi-wep-adhoc-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
||||||
TEST_IFCFG_WIFI_WEP_ADHOC,
|
TEST_IFCFG_WIFI_WEP_ADHOC,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
@@ -4308,7 +4308,7 @@ test_read_wifi_wpa_psk (void)
|
|||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
const char *mac;
|
const char *mac;
|
||||||
char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 };
|
char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 };
|
||||||
const char *expected_id = "System blahblah (test-wifi-wpa-psk)";
|
const char *expected_id = "System blahblah (test-wifi-wpa-psk)";
|
||||||
@@ -4412,18 +4412,18 @@ test_read_wifi_wpa_psk (void)
|
|||||||
NM_SETTING_WIRELESS_MTU);
|
NM_SETTING_WIRELESS_MTU);
|
||||||
|
|
||||||
/* SSID */
|
/* SSID */
|
||||||
array = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
ASSERT (array != NULL,
|
ASSERT (ssid != NULL,
|
||||||
"wifi-wpa-psk-verify-wireless", "failed to verify %s: missing %s / %s key",
|
"wifi-wpa-psk-verify-wireless", "failed to verify %s: missing %s / %s key",
|
||||||
TEST_IFCFG_WIFI_WPA_PSK,
|
TEST_IFCFG_WIFI_WPA_PSK,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (array->len == strlen (expected_ssid),
|
ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid),
|
||||||
"wifi-wpa-psk-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
"wifi-wpa-psk-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
||||||
TEST_IFCFG_WIFI_WPA_PSK,
|
TEST_IFCFG_WIFI_WPA_PSK,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0,
|
ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0,
|
||||||
"wifi-wpa-psk-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
"wifi-wpa-psk-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
||||||
TEST_IFCFG_WIFI_WPA_PSK,
|
TEST_IFCFG_WIFI_WPA_PSK,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
@@ -5005,7 +5005,7 @@ test_read_wifi_wpa_psk_hex (void)
|
|||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
const char *expected_id = "System blahblah (test-wifi-wpa-psk-hex)";
|
const char *expected_id = "System blahblah (test-wifi-wpa-psk-hex)";
|
||||||
const char *expected_ssid = "blahblah";
|
const char *expected_ssid = "blahblah";
|
||||||
const char *expected_key_mgmt = "wpa-psk";
|
const char *expected_key_mgmt = "wpa-psk";
|
||||||
@@ -5056,18 +5056,18 @@ test_read_wifi_wpa_psk_hex (void)
|
|||||||
NM_SETTING_WIRELESS_SETTING_NAME);
|
NM_SETTING_WIRELESS_SETTING_NAME);
|
||||||
|
|
||||||
/* SSID */
|
/* SSID */
|
||||||
array = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
ASSERT (array != NULL,
|
ASSERT (ssid != NULL,
|
||||||
"wifi-wpa-psk-hex-verify-wireless", "failed to verify %s: missing %s / %s key",
|
"wifi-wpa-psk-hex-verify-wireless", "failed to verify %s: missing %s / %s key",
|
||||||
TEST_IFCFG_WIFI_WPA_PSK_HEX,
|
TEST_IFCFG_WIFI_WPA_PSK_HEX,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (array->len == strlen (expected_ssid),
|
ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid),
|
||||||
"wifi-wpa-psk-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
"wifi-wpa-psk-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value length",
|
||||||
TEST_IFCFG_WIFI_WPA_PSK_HEX,
|
TEST_IFCFG_WIFI_WPA_PSK_HEX,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0,
|
ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0,
|
||||||
"wifi-wpa-psk-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
"wifi-wpa-psk-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
||||||
TEST_IFCFG_WIFI_WPA_PSK_HEX,
|
TEST_IFCFG_WIFI_WPA_PSK_HEX,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
@@ -5702,7 +5702,7 @@ test_write_wifi_hidden (void)
|
|||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
shvarFile *f;
|
shvarFile *f;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
|
const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
@@ -5723,8 +5723,7 @@ test_write_wifi_hidden (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, sizeof (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
@@ -5732,7 +5731,7 @@ test_write_wifi_hidden (void)
|
|||||||
NM_SETTING_WIRELESS_HIDDEN, TRUE,
|
NM_SETTING_WIRELESS_HIDDEN, TRUE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
success = nm_connection_verify (connection, &error);
|
success = nm_connection_verify (connection, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@@ -8029,7 +8028,7 @@ test_write_wifi_open (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
|
const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
|
||||||
const char *bssid = "11:22:33:44:55:66";
|
const char *bssid = "11:22:33:44:55:66";
|
||||||
guint32 channel = 9, mtu = 1345;
|
guint32 channel = 9, mtu = 1345;
|
||||||
@@ -8056,8 +8055,7 @@ test_write_wifi_open (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, sizeof (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
@@ -8069,7 +8067,7 @@ test_write_wifi_open (void)
|
|||||||
NM_SETTING_WIRELESS_MTU, mtu,
|
NM_SETTING_WIRELESS_MTU, mtu,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* IP4 setting */
|
/* IP4 setting */
|
||||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||||
@@ -8170,7 +8168,7 @@ test_write_wifi_open_hex_ssid (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd };
|
const unsigned char ssid_data[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd };
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
@@ -8192,15 +8190,14 @@ test_write_wifi_open_hex_ssid (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, sizeof (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* IP4 setting */
|
/* IP4 setting */
|
||||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||||
@@ -8285,8 +8282,8 @@ test_write_wifi_wep (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
@@ -8308,15 +8305,14 @@ test_write_wifi_wep (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -8427,8 +8423,8 @@ test_write_wifi_wep_adhoc (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
NMIP4Address *addr;
|
NMIP4Address *addr;
|
||||||
const guint32 ip1 = htonl (0x01010103);
|
const guint32 ip1 = htonl (0x01010103);
|
||||||
@@ -8455,15 +8451,14 @@ test_write_wifi_wep_adhoc (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "adhoc",
|
NM_SETTING_WIRELESS_MODE, "adhoc",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -8577,8 +8572,8 @@ test_write_wifi_wep_passphrase (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
@@ -8600,15 +8595,14 @@ test_write_wifi_wep_passphrase (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -8717,8 +8711,8 @@ test_write_wifi_wep_40_ascii (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = "blahblah40";
|
const char *ssid_data = "blahblah40";
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
@@ -8740,15 +8734,14 @@ test_write_wifi_wep_40_ascii (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -8859,8 +8852,8 @@ test_write_wifi_wep_104_ascii (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = "blahblah104";
|
const char *ssid_data = "blahblah104";
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
@@ -8882,15 +8875,14 @@ test_write_wifi_wep_104_ascii (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -9001,8 +8993,8 @@ test_write_wifi_leap (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
@@ -9024,15 +9016,14 @@ test_write_wifi_leap (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -9140,8 +9131,8 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -9164,13 +9155,12 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags)
|
|||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -9280,8 +9270,8 @@ test_write_wifi_wpa_psk (const char *name,
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
|
|
||||||
g_return_if_fail (psk != NULL);
|
g_return_if_fail (psk != NULL);
|
||||||
|
|
||||||
@@ -9304,15 +9294,14 @@ test_write_wifi_wpa_psk (const char *name,
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -9427,8 +9416,8 @@ test_write_wifi_wpa_psk_adhoc (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
NMIP4Address *addr;
|
NMIP4Address *addr;
|
||||||
const guint32 ip1 = htonl (0x01010103);
|
const guint32 ip1 = htonl (0x01010103);
|
||||||
const guint32 gw = htonl (0x01010101);
|
const guint32 gw = htonl (0x01010101);
|
||||||
@@ -9454,8 +9443,7 @@ test_write_wifi_wpa_psk_adhoc (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
@@ -9464,7 +9452,7 @@ test_write_wifi_wpa_psk_adhoc (void)
|
|||||||
NM_SETTING_WIRELESS_BAND, "bg",
|
NM_SETTING_WIRELESS_BAND, "bg",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -9576,7 +9564,7 @@ test_write_wifi_wpa_eap_tls (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const char *ssid_data = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
@@ -9598,15 +9586,14 @@ test_write_wifi_wpa_eap_tls (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (strlen (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, (const unsigned char *) ssid_data, strlen (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -9741,7 +9728,7 @@ test_write_wifi_wpa_eap_ttls_tls (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const char *ssid_data = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
@@ -9763,15 +9750,14 @@ test_write_wifi_wpa_eap_ttls_tls (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (strlen (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, (const unsigned char *) ssid_data, strlen (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -9924,7 +9910,7 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const char *ssid_data = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
connection = nm_simple_connection_new ();
|
||||||
@@ -9946,15 +9932,14 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (strlen (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, (const unsigned char *) ssid_data, strlen (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -10078,8 +10063,8 @@ test_write_wifi_wpa_then_open (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
|
|
||||||
/* Test that writing out a WPA config then changing that to an open
|
/* Test that writing out a WPA config then changing that to an open
|
||||||
* config doesn't leave various WPA-related keys lying around in the ifcfg.
|
* config doesn't leave various WPA-related keys lying around in the ifcfg.
|
||||||
@@ -10107,15 +10092,14 @@ test_write_wifi_wpa_then_open (void)
|
|||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -10269,9 +10253,9 @@ test_write_wifi_wpa_then_wep_with_perms (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
char **perms;
|
char **perms;
|
||||||
const unsigned char ssid_data[] = "SomeSSID";
|
const char *ssid_data = "SomeSSID";
|
||||||
|
|
||||||
/* Test that writing out a WPA config then changing that to a WEP
|
/* Test that writing out a WPA config then changing that to a WEP
|
||||||
* config works and doesn't cause infinite loop or other issues.
|
* config works and doesn't cause infinite loop or other issues.
|
||||||
@@ -10304,15 +10288,14 @@ test_write_wifi_wpa_then_wep_with_perms (void)
|
|||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -10474,7 +10457,7 @@ test_write_wifi_dynamic_wep_leap (void)
|
|||||||
char *routefile = NULL;
|
char *routefile = NULL;
|
||||||
char *route6file = NULL;
|
char *route6file = NULL;
|
||||||
gboolean ignore_error = FALSE;
|
gboolean ignore_error = FALSE;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const char *ssid_data = "blahblah";
|
const char *ssid_data = "blahblah";
|
||||||
shvarFile *ifcfg;
|
shvarFile *ifcfg;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
@@ -10500,15 +10483,14 @@ test_write_wifi_dynamic_wep_leap (void)
|
|||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (strlen (ssid_data));
|
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||||
g_byte_array_append (ssid, (const unsigned char *) ssid_data, strlen (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wireless security setting */
|
/* Wireless security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -10988,7 +10970,7 @@ test_write_wifi_wep_agent_keys (void)
|
|||||||
NMSettingIP6Config *s_ip6;
|
NMSettingIP6Config *s_ip6;
|
||||||
char *uuid;
|
char *uuid;
|
||||||
const char *str_ssid = "foobarbaz";
|
const char *str_ssid = "foobarbaz";
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
char *testfile = NULL;
|
char *testfile = NULL;
|
||||||
@@ -11035,13 +11017,12 @@ test_write_wifi_wep_agent_keys (void)
|
|||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (strlen (str_ssid));
|
ssid = g_bytes_new (str_ssid, strlen (str_ssid));
|
||||||
g_byte_array_append (ssid, (guint8 *) str_ssid, strlen (str_ssid));
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||||
NULL);
|
NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wifi security setting */
|
/* Wifi security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
|
@@ -197,7 +197,7 @@ typedef struct ObjectType {
|
|||||||
const char *setting_key;
|
const char *setting_key;
|
||||||
NMSetting8021xCKScheme (*scheme_func)(NMSetting8021x *setting);
|
NMSetting8021xCKScheme (*scheme_func)(NMSetting8021x *setting);
|
||||||
const char * (*path_func) (NMSetting8021x *setting);
|
const char * (*path_func) (NMSetting8021x *setting);
|
||||||
const GByteArray * (*blob_func) (NMSetting8021x *setting);
|
GBytes * (*blob_func) (NMSetting8021x *setting);
|
||||||
const char *ifcfg_key;
|
const char *ifcfg_key;
|
||||||
const char *suffix;
|
const char *suffix;
|
||||||
} ObjectType;
|
} ObjectType;
|
||||||
@@ -282,7 +282,7 @@ write_object (NMSetting8021x *s_8021x,
|
|||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
const GByteArray *blob = NULL;
|
GBytes *blob = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (ifcfg != NULL, FALSE);
|
g_return_val_if_fail (ifcfg != NULL, FALSE);
|
||||||
g_return_val_if_fail (objtype != NULL, FALSE);
|
g_return_val_if_fail (objtype != NULL, FALSE);
|
||||||
@@ -347,7 +347,10 @@ write_object (NMSetting8021x *s_8021x,
|
|||||||
* can use paths from now on instead of pushing around the certificate
|
* can use paths from now on instead of pushing around the certificate
|
||||||
* data itself.
|
* data itself.
|
||||||
*/
|
*/
|
||||||
success = write_secret_file (new_file, (const char *) blob->data, blob->len, &write_error);
|
success = write_secret_file (new_file,
|
||||||
|
(const char *) g_bytes_get_data (blob, NULL),
|
||||||
|
g_bytes_get_size (blob),
|
||||||
|
&write_error);
|
||||||
if (success) {
|
if (success) {
|
||||||
svSetValue (ifcfg, objtype->ifcfg_key, new_file, FALSE);
|
svSetValue (ifcfg, objtype->ifcfg_key, new_file, FALSE);
|
||||||
g_free (new_file);
|
g_free (new_file);
|
||||||
@@ -800,7 +803,9 @@ write_wireless_setting (NMConnection *connection,
|
|||||||
{
|
{
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
char *tmp, *tmp2;
|
char *tmp, *tmp2;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
|
const guint8 *ssid_data;
|
||||||
|
gsize ssid_len;
|
||||||
const char *mode, *bssid;
|
const char *mode, *bssid;
|
||||||
const char *device_mac, *cloned_mac;
|
const char *device_mac, *cloned_mac;
|
||||||
char buf[33];
|
char buf[33];
|
||||||
@@ -852,7 +857,8 @@ write_wireless_setting (NMConnection *connection,
|
|||||||
"Missing SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME);
|
"Missing SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!ssid->len || ssid->len > 32) {
|
ssid_data = g_bytes_get_data (ssid, &ssid_len);
|
||||||
|
if (!ssid_len || ssid_len > 32) {
|
||||||
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
|
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
|
||||||
"Invalid SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME);
|
"Invalid SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -861,8 +867,8 @@ write_wireless_setting (NMConnection *connection,
|
|||||||
/* If the SSID contains any non-printable characters, we need to use the
|
/* If the SSID contains any non-printable characters, we need to use the
|
||||||
* hex notation of the SSID instead.
|
* hex notation of the SSID instead.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < ssid->len; i++) {
|
for (i = 0; i < ssid_len; i++) {
|
||||||
if (!g_ascii_isprint (ssid->data[i])) {
|
if (!g_ascii_isprint (ssid_data[i])) {
|
||||||
hex_ssid = TRUE;
|
hex_ssid = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -872,16 +878,16 @@ write_wireless_setting (NMConnection *connection,
|
|||||||
GString *str;
|
GString *str;
|
||||||
|
|
||||||
/* Hex SSIDs don't get quoted */
|
/* Hex SSIDs don't get quoted */
|
||||||
str = g_string_sized_new (ssid->len * 2 + 3);
|
str = g_string_sized_new (ssid_len * 2 + 3);
|
||||||
g_string_append (str, "0x");
|
g_string_append (str, "0x");
|
||||||
for (i = 0; i < ssid->len; i++)
|
for (i = 0; i < ssid_len; i++)
|
||||||
g_string_append_printf (str, "%02X", ssid->data[i]);
|
g_string_append_printf (str, "%02X", ssid_data[i]);
|
||||||
svSetValue (ifcfg, "ESSID", str->str, TRUE);
|
svSetValue (ifcfg, "ESSID", str->str, TRUE);
|
||||||
g_string_free (str, TRUE);
|
g_string_free (str, TRUE);
|
||||||
} else {
|
} else {
|
||||||
/* Printable SSIDs always get quoted */
|
/* Printable SSIDs always get quoted */
|
||||||
memset (buf, 0, sizeof (buf));
|
memset (buf, 0, sizeof (buf));
|
||||||
memcpy (buf, ssid->data, ssid->len);
|
memcpy (buf, ssid_data, ssid_len);
|
||||||
tmp = svEscape (buf);
|
tmp = svEscape (buf);
|
||||||
|
|
||||||
/* svEscape will usually quote the string, but just for consistency,
|
/* svEscape will usually quote the string, but just for consistency,
|
||||||
|
@@ -880,7 +880,7 @@ make_wireless_connection_setting (const char *conn_name,
|
|||||||
NMSetting8021x **s_8021x,
|
NMSetting8021x **s_8021x,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GByteArray *array;
|
GBytes *bytes;
|
||||||
const char *mac = NULL;
|
const char *mac = NULL;
|
||||||
NMSettingWireless *wireless_setting = NULL;
|
NMSettingWireless *wireless_setting = NULL;
|
||||||
gboolean adhoc = FALSE;
|
gboolean adhoc = FALSE;
|
||||||
@@ -949,10 +949,9 @@ make_wireless_connection_setting (const char *conn_name,
|
|||||||
conn_name, ssid_len);
|
conn_name, ssid_len);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
array = g_byte_array_sized_new (ssid_len);
|
bytes = g_bytes_new (converted ? converted : conn_name, ssid_len);
|
||||||
g_byte_array_append (array, (const guint8 *) (converted ? converted : conn_name), ssid_len);
|
g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, bytes, NULL);
|
||||||
g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, array, NULL);
|
g_bytes_unref (bytes);
|
||||||
g_byte_array_free (array, TRUE);
|
|
||||||
g_free (converted);
|
g_free (converted);
|
||||||
} else {
|
} else {
|
||||||
g_set_error (error, ifnet_plugin_error_quark (), 0,
|
g_set_error (error, ifnet_plugin_error_quark (), 0,
|
||||||
@@ -1721,7 +1720,7 @@ error:
|
|||||||
|
|
||||||
typedef NMSetting8021xCKScheme (*SchemeFunc) (NMSetting8021x * setting);
|
typedef NMSetting8021xCKScheme (*SchemeFunc) (NMSetting8021x * setting);
|
||||||
typedef const char *(*PathFunc) (NMSetting8021x * setting);
|
typedef const char *(*PathFunc) (NMSetting8021x * setting);
|
||||||
typedef const GByteArray *(*BlobFunc) (NMSetting8021x * setting);
|
typedef GBytes *(*BlobFunc) (NMSetting8021x * setting);
|
||||||
|
|
||||||
typedef struct ObjectType {
|
typedef struct ObjectType {
|
||||||
const char *setting_key;
|
const char *setting_key;
|
||||||
@@ -1807,13 +1806,13 @@ static const ObjectType phase2_p12_type = {
|
|||||||
static gboolean
|
static gboolean
|
||||||
write_object (NMSetting8021x *s_8021x,
|
write_object (NMSetting8021x *s_8021x,
|
||||||
const char *conn_name,
|
const char *conn_name,
|
||||||
const GByteArray *override_data,
|
GBytes *override_data,
|
||||||
const ObjectType *objtype,
|
const ObjectType *objtype,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
NMSetting8021xCKScheme scheme;
|
NMSetting8021xCKScheme scheme;
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
const GByteArray *blob = NULL;
|
GBytes *blob = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (conn_name != NULL, FALSE);
|
g_return_val_if_fail (conn_name != NULL, FALSE);
|
||||||
g_return_val_if_fail (objtype != NULL, FALSE);
|
g_return_val_if_fail (objtype != NULL, FALSE);
|
||||||
@@ -1861,8 +1860,8 @@ write_8021x_certs (NMSetting8021x *s_8021x,
|
|||||||
char *password = NULL;
|
char *password = NULL;
|
||||||
const ObjectType *otype = NULL;
|
const ObjectType *otype = NULL;
|
||||||
gboolean is_pkcs12 = FALSE, success = FALSE;
|
gboolean is_pkcs12 = FALSE, success = FALSE;
|
||||||
const GByteArray *blob = NULL;
|
GBytes *blob = NULL;
|
||||||
GByteArray *enc_key = NULL;
|
GBytes *enc_key = NULL;
|
||||||
gchar *generated_pw = NULL;
|
gchar *generated_pw = NULL;
|
||||||
|
|
||||||
/* CA certificate */
|
/* CA certificate */
|
||||||
@@ -1909,13 +1908,17 @@ write_8021x_certs (NMSetting8021x *s_8021x,
|
|||||||
* private key file, it'll be encrypted, so we don't need to re-encrypt.
|
* private key file, it'll be encrypted, so we don't need to re-encrypt.
|
||||||
*/
|
*/
|
||||||
if (blob && !is_pkcs12) {
|
if (blob && !is_pkcs12) {
|
||||||
|
GByteArray *tmp_enc_key;
|
||||||
|
|
||||||
/* Encrypt the unencrypted private key with the fake password */
|
/* Encrypt the unencrypted private key with the fake password */
|
||||||
enc_key =
|
tmp_enc_key =
|
||||||
nm_utils_rsa_key_encrypt (blob->data, blob->len, password, &generated_pw,
|
nm_utils_rsa_key_encrypt (g_bytes_get_data (blob, NULL), g_bytes_get_size (blob),
|
||||||
error);
|
password, &generated_pw, error);
|
||||||
if (!enc_key)
|
if (!tmp_enc_key)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
enc_key = g_byte_array_free_to_bytes (tmp_enc_key);
|
||||||
|
|
||||||
if (generated_pw)
|
if (generated_pw)
|
||||||
password = generated_pw;
|
password = generated_pw;
|
||||||
}
|
}
|
||||||
@@ -1952,8 +1955,8 @@ out:
|
|||||||
g_free (generated_pw);
|
g_free (generated_pw);
|
||||||
}
|
}
|
||||||
if (enc_key) {
|
if (enc_key) {
|
||||||
memset (enc_key->data, 0, enc_key->len);
|
memset ((gpointer) g_bytes_get_data (enc_key, NULL), 0, g_bytes_get_size (enc_key));
|
||||||
g_byte_array_free (enc_key, TRUE);
|
g_bytes_unref (enc_key);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -2224,7 +2227,9 @@ write_wireless_setting (NMConnection *connection,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
|
const guint8 *ssid_data;
|
||||||
|
gsize ssid_len;
|
||||||
const char *mac, *bssid, *mode;
|
const char *mac, *bssid, *mode;
|
||||||
char buf[33];
|
char buf[33];
|
||||||
guint32 mtu, i;
|
guint32 mtu, i;
|
||||||
@@ -2246,7 +2251,8 @@ write_wireless_setting (NMConnection *connection,
|
|||||||
NM_SETTING_WIRELESS_SETTING_NAME);
|
NM_SETTING_WIRELESS_SETTING_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!ssid->len || ssid->len > 32) {
|
ssid_data = g_bytes_get_data (ssid, &ssid_len);
|
||||||
|
if (!ssid_len || ssid_len > 32) {
|
||||||
g_set_error (error, ifnet_plugin_error_quark (), 0,
|
g_set_error (error, ifnet_plugin_error_quark (), 0,
|
||||||
"Invalid SSID in '%s' setting",
|
"Invalid SSID in '%s' setting",
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME);
|
NM_SETTING_WIRELESS_SETTING_NAME);
|
||||||
@@ -2257,8 +2263,8 @@ write_wireless_setting (NMConnection *connection,
|
|||||||
* the hex notation of the SSID instead. (Because openrc doesn't
|
* the hex notation of the SSID instead. (Because openrc doesn't
|
||||||
* support these characters, see bug #356337)
|
* support these characters, see bug #356337)
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < ssid->len; i++) {
|
for (i = 0; i < ssid_len; i++) {
|
||||||
if (!g_ascii_isalnum (ssid->data[i])) {
|
if (!g_ascii_isalnum (ssid_data[i])) {
|
||||||
hex_ssid = TRUE;
|
hex_ssid = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2268,16 +2274,16 @@ write_wireless_setting (NMConnection *connection,
|
|||||||
GString *str;
|
GString *str;
|
||||||
|
|
||||||
/* Hex SSIDs don't get quoted */
|
/* Hex SSIDs don't get quoted */
|
||||||
str = g_string_sized_new (ssid->len * 2 + 3);
|
str = g_string_sized_new (ssid_len * 2 + 3);
|
||||||
g_string_append (str, "0x");
|
g_string_append (str, "0x");
|
||||||
for (i = 0; i < ssid->len; i++)
|
for (i = 0; i < ssid_len; i++)
|
||||||
g_string_append_printf (str, "%02X", ssid->data[i]);
|
g_string_append_printf (str, "%02X", ssid_data[i]);
|
||||||
update_wireless_ssid (connection, conn_name, str->str, hex_ssid);
|
update_wireless_ssid (connection, conn_name, str->str, hex_ssid);
|
||||||
ssid_str = g_string_free (str, FALSE);
|
ssid_str = g_string_free (str, FALSE);
|
||||||
} else {
|
} else {
|
||||||
/* Printable SSIDs get quoted */
|
/* Printable SSIDs get quoted */
|
||||||
memset (buf, 0, sizeof (buf));
|
memset (buf, 0, sizeof (buf));
|
||||||
memcpy (buf, ssid->data, ssid->len);
|
memcpy (buf, ssid_data, ssid_len);
|
||||||
g_strstrip (buf);
|
g_strstrip (buf);
|
||||||
update_wireless_ssid (connection, conn_name, buf, hex_ssid);
|
update_wireless_ssid (connection, conn_name, buf, hex_ssid);
|
||||||
ssid_str = g_strdup (buf);
|
ssid_str = g_strdup (buf);
|
||||||
@@ -2927,7 +2933,9 @@ static gchar *
|
|||||||
get_wireless_name (NMConnection * connection)
|
get_wireless_name (NMConnection * connection)
|
||||||
{
|
{
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
|
const guint8 *ssid_data;
|
||||||
|
gsize ssid_len;
|
||||||
gboolean hex_ssid = FALSE;
|
gboolean hex_ssid = FALSE;
|
||||||
gchar *result = NULL;
|
gchar *result = NULL;
|
||||||
char buf[33];
|
char buf[33];
|
||||||
@@ -2938,12 +2946,13 @@ get_wireless_name (NMConnection * connection)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
if (!ssid->len || ssid->len > 32) {
|
ssid_data = g_bytes_get_data (ssid, &ssid_len);
|
||||||
|
if (!ssid_len || ssid_len > 32) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ssid->len; i++) {
|
for (i = 0; i < ssid_len; i++) {
|
||||||
if (!g_ascii_isprint (ssid->data[i])) {
|
if (!g_ascii_isprint (ssid_data[i])) {
|
||||||
hex_ssid = TRUE;
|
hex_ssid = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2952,15 +2961,15 @@ get_wireless_name (NMConnection * connection)
|
|||||||
if (hex_ssid) {
|
if (hex_ssid) {
|
||||||
GString *str;
|
GString *str;
|
||||||
|
|
||||||
str = g_string_sized_new (ssid->len * 2 + 3);
|
str = g_string_sized_new (ssid_len * 2 + 3);
|
||||||
g_string_append (str, "0x");
|
g_string_append (str, "0x");
|
||||||
for (i = 0; i < ssid->len; i++)
|
for (i = 0; i < ssid_len; i++)
|
||||||
g_string_append_printf (str, "%02X", ssid->data[i]);
|
g_string_append_printf (str, "%02X", ssid_data[i]);
|
||||||
result = g_strdup (str->str);
|
result = g_strdup (str->str);
|
||||||
g_string_free (str, TRUE);
|
g_string_free (str, TRUE);
|
||||||
} else {
|
} else {
|
||||||
memset (buf, 0, sizeof (buf));
|
memset (buf, 0, sizeof (buf));
|
||||||
memcpy (buf, ssid->data, ssid->len);
|
memcpy (buf, ssid_data, ssid_len);
|
||||||
result = g_strdup_printf ("%s", buf);
|
result = g_strdup_printf ("%s", buf);
|
||||||
g_strstrip (result);
|
g_strstrip (result);
|
||||||
}
|
}
|
||||||
|
@@ -652,12 +652,12 @@ unescape_semicolons (char *str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GByteArray *
|
static GBytes *
|
||||||
get_uchar_array (GKeyFile *keyfile,
|
get_bytes (GKeyFile *keyfile,
|
||||||
const char *setting_name,
|
const char *setting_name,
|
||||||
const char *key,
|
const char *key,
|
||||||
gboolean zero_terminate,
|
gboolean zero_terminate,
|
||||||
gboolean unescape_semicolon)
|
gboolean unescape_semicolon)
|
||||||
{
|
{
|
||||||
GByteArray *array = NULL;
|
GByteArray *array = NULL;
|
||||||
char *tmp_string;
|
char *tmp_string;
|
||||||
@@ -711,21 +711,21 @@ get_uchar_array (GKeyFile *keyfile,
|
|||||||
|
|
||||||
if (array->len == 0) {
|
if (array->len == 0) {
|
||||||
g_byte_array_free (array, TRUE);
|
g_byte_array_free (array, TRUE);
|
||||||
array = NULL;
|
return NULL;
|
||||||
}
|
} else
|
||||||
return array;
|
return g_byte_array_free_to_bytes (array);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ssid_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const char *keyfile_path)
|
ssid_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const char *keyfile_path)
|
||||||
{
|
{
|
||||||
const char *setting_name = nm_setting_get_name (setting);
|
const char *setting_name = nm_setting_get_name (setting);
|
||||||
GByteArray *array;
|
GBytes *bytes;
|
||||||
|
|
||||||
array = get_uchar_array (keyfile, setting_name, key, FALSE, TRUE);
|
bytes = get_bytes (keyfile, setting_name, key, FALSE, TRUE);
|
||||||
if (array) {
|
if (bytes) {
|
||||||
g_object_set (setting, key, array, NULL);
|
g_object_set (setting, key, bytes, NULL);
|
||||||
g_byte_array_free (array, TRUE);
|
g_bytes_unref (bytes);
|
||||||
} else {
|
} else {
|
||||||
nm_log_warn (LOGD_SETTINGS, "%s: ignoring invalid SSID for %s / %s",
|
nm_log_warn (LOGD_SETTINGS, "%s: ignoring invalid SSID for %s / %s",
|
||||||
__func__, setting_name, key);
|
__func__, setting_name, key);
|
||||||
@@ -736,12 +736,12 @@ static void
|
|||||||
password_raw_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const char *keyfile_path)
|
password_raw_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const char *keyfile_path)
|
||||||
{
|
{
|
||||||
const char *setting_name = nm_setting_get_name (setting);
|
const char *setting_name = nm_setting_get_name (setting);
|
||||||
GByteArray *array;
|
GBytes *bytes;
|
||||||
|
|
||||||
array = get_uchar_array (keyfile, setting_name, key, FALSE, TRUE);
|
bytes = get_bytes (keyfile, setting_name, key, FALSE, TRUE);
|
||||||
if (array) {
|
if (bytes) {
|
||||||
g_object_set (setting, key, array, NULL);
|
g_object_set (setting, key, bytes, NULL);
|
||||||
g_byte_array_free (array, TRUE);
|
g_bytes_unref (bytes);
|
||||||
} else {
|
} else {
|
||||||
nm_log_warn (LOGD_SETTINGS, "%s: ignoring invalid raw password for %s / %s",
|
nm_log_warn (LOGD_SETTINGS, "%s: ignoring invalid raw password for %s / %s",
|
||||||
__func__, setting_name, key);
|
__func__, setting_name, key);
|
||||||
@@ -749,7 +749,7 @@ password_raw_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_cert_path (const char *keyfile_path, GByteArray *cert_path)
|
get_cert_path (const char *keyfile_path, const guint8 *cert_path, gsize cert_path_len)
|
||||||
{
|
{
|
||||||
const char *base;
|
const char *base;
|
||||||
char *p = NULL, *path, *dirname, *tmp;
|
char *p = NULL, *path, *dirname, *tmp;
|
||||||
@@ -757,8 +757,8 @@ get_cert_path (const char *keyfile_path, GByteArray *cert_path)
|
|||||||
g_return_val_if_fail (keyfile_path != NULL, NULL);
|
g_return_val_if_fail (keyfile_path != NULL, NULL);
|
||||||
g_return_val_if_fail (cert_path != NULL, NULL);
|
g_return_val_if_fail (cert_path != NULL, NULL);
|
||||||
|
|
||||||
base = path = g_malloc0 (cert_path->len + 1);
|
base = path = g_malloc0 (cert_path_len + 1);
|
||||||
memcpy (path, cert_path->data, cert_path->len);
|
memcpy (path, cert_path, cert_path_len);
|
||||||
|
|
||||||
if (path[0] == '/')
|
if (path[0] == '/')
|
||||||
return path;
|
return path;
|
||||||
@@ -791,37 +791,46 @@ has_cert_ext (const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_as_scheme (GByteArray *array, NMSetting *setting, const char *key)
|
handle_as_scheme (GBytes *bytes, NMSetting *setting, const char *key)
|
||||||
{
|
{
|
||||||
|
const guint8 *data;
|
||||||
|
gsize data_len;
|
||||||
|
|
||||||
|
data = g_bytes_get_data (bytes, &data_len);
|
||||||
|
|
||||||
/* It's the PATH scheme, can just set plain data */
|
/* It's the PATH scheme, can just set plain data */
|
||||||
if ( (array->len > strlen (SCHEME_PATH))
|
if ( (data_len > strlen (SCHEME_PATH))
|
||||||
&& g_str_has_prefix ((const char *) array->data, SCHEME_PATH)
|
&& g_str_has_prefix ((const char *) data, SCHEME_PATH)
|
||||||
&& (array->data[array->len - 1] == '\0')) {
|
&& (data[data_len - 1] == '\0')) {
|
||||||
g_object_set (setting, key, array, NULL);
|
g_object_set (setting, key, bytes, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_as_path (GByteArray *array,
|
handle_as_path (GBytes *bytes,
|
||||||
NMSetting *setting,
|
NMSetting *setting,
|
||||||
const char *key,
|
const char *key,
|
||||||
const char *keyfile_path)
|
const char *keyfile_path)
|
||||||
{
|
{
|
||||||
gsize validate_len = array->len;
|
const guint8 *data;
|
||||||
GByteArray *val;
|
gsize data_len;
|
||||||
|
gsize validate_len;
|
||||||
char *path;
|
char *path;
|
||||||
gboolean exists, success = FALSE;
|
gboolean exists, success = FALSE;
|
||||||
|
|
||||||
if (array->len > 500 || array->len < 1)
|
data = g_bytes_get_data (bytes, &data_len);
|
||||||
|
if (data_len > 500 || data_len < 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* If there's a trailing NULL tell g_utf8_validate() to to until the NULL */
|
/* If there's a trailing NULL tell g_utf8_validate() to to until the NULL */
|
||||||
if (array->data[array->len - 1] == '\0')
|
if (data[data_len - 1] == '\0')
|
||||||
validate_len = -1;
|
validate_len = -1;
|
||||||
|
else
|
||||||
|
validate_len = data_len;
|
||||||
|
|
||||||
if (g_utf8_validate ((const char *) array->data, validate_len, NULL) == FALSE)
|
if (g_utf8_validate ((const char *) data, validate_len, NULL) == FALSE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Might be a bare path without the file:// prefix; in that case
|
/* Might be a bare path without the file:// prefix; in that case
|
||||||
@@ -829,18 +838,22 @@ handle_as_path (GByteArray *array,
|
|||||||
* relative path to the current directory.
|
* relative path to the current directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
path = get_cert_path (keyfile_path, array);
|
path = get_cert_path (keyfile_path, data, data_len);
|
||||||
exists = g_file_test (path, G_FILE_TEST_EXISTS);
|
exists = g_file_test (path, G_FILE_TEST_EXISTS);
|
||||||
if ( exists
|
if ( exists
|
||||||
|| memchr (array->data, '/', array->len)
|
|| memchr (data, '/', data_len)
|
||||||
|| has_cert_ext (path)) {
|
|| has_cert_ext (path)) {
|
||||||
|
GByteArray *tmp;
|
||||||
|
GBytes *val;
|
||||||
|
|
||||||
/* Construct the proper value as required for the PATH scheme */
|
/* Construct the proper value as required for the PATH scheme */
|
||||||
val = g_byte_array_sized_new (strlen (SCHEME_PATH) + strlen (path) + 1);
|
tmp = g_byte_array_sized_new (strlen (SCHEME_PATH) + strlen (path) + 1);
|
||||||
g_byte_array_append (val, (const guint8 *) SCHEME_PATH, strlen (SCHEME_PATH));
|
g_byte_array_append (tmp, (const guint8 *) SCHEME_PATH, strlen (SCHEME_PATH));
|
||||||
g_byte_array_append (val, (const guint8 *) path, strlen (path));
|
g_byte_array_append (tmp, (const guint8 *) path, strlen (path));
|
||||||
g_byte_array_append (val, (const guint8 *) "\0", 1);
|
g_byte_array_append (tmp, (const guint8 *) "\0", 1);
|
||||||
|
val = g_byte_array_free_to_bytes (tmp);
|
||||||
g_object_set (setting, key, val, NULL);
|
g_object_set (setting, key, val, NULL);
|
||||||
g_byte_array_free (val, TRUE);
|
g_bytes_unref (val);
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
|
|
||||||
/* Warn if the certificate didn't exist */
|
/* Warn if the certificate didn't exist */
|
||||||
@@ -856,28 +869,28 @@ static void
|
|||||||
cert_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const char *keyfile_path)
|
cert_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const char *keyfile_path)
|
||||||
{
|
{
|
||||||
const char *setting_name = nm_setting_get_name (setting);
|
const char *setting_name = nm_setting_get_name (setting);
|
||||||
GByteArray *array;
|
GBytes *bytes;
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
|
|
||||||
array = get_uchar_array (keyfile, setting_name, key, TRUE, FALSE);
|
bytes = get_bytes (keyfile, setting_name, key, TRUE, FALSE);
|
||||||
if (array && array->len > 0) {
|
if (bytes) {
|
||||||
/* Try as a path + scheme (ie, starts with "file://") */
|
/* Try as a path + scheme (ie, starts with "file://") */
|
||||||
success = handle_as_scheme (array, setting, key);
|
success = handle_as_scheme (bytes, setting, key);
|
||||||
|
|
||||||
/* If not, it might be a plain path */
|
/* If not, it might be a plain path */
|
||||||
if (success == FALSE)
|
if (success == FALSE)
|
||||||
success = handle_as_path (array, setting, key, keyfile_path);
|
success = handle_as_path (bytes, setting, key, keyfile_path);
|
||||||
|
|
||||||
/* If neither of those two, assume blob with certificate data */
|
/* If neither of those two, assume blob with certificate data */
|
||||||
if (success == FALSE)
|
if (success == FALSE)
|
||||||
g_object_set (setting, key, array, NULL);
|
g_object_set (setting, key, bytes, NULL);
|
||||||
} else {
|
} else {
|
||||||
nm_log_warn (LOGD_SETTINGS, "%s: ignoring invalid key/cert value for %s / %s",
|
nm_log_warn (LOGD_SETTINGS, "%s: ignoring invalid key/cert value for %s / %s",
|
||||||
__func__, setting_name, key);
|
__func__, setting_name, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array)
|
if (bytes)
|
||||||
g_byte_array_free (array, TRUE);
|
g_bytes_unref (bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -1107,9 +1120,10 @@ read_one_setting_value (NMSetting *setting,
|
|||||||
uint_val = g_ascii_strtoull (tmp_str, NULL, 10);
|
uint_val = g_ascii_strtoull (tmp_str, NULL, 10);
|
||||||
g_free (tmp_str);
|
g_free (tmp_str);
|
||||||
g_object_set (setting, key, uint_val, NULL);
|
g_object_set (setting, key, uint_val, NULL);
|
||||||
} else if (type == DBUS_TYPE_G_UCHAR_ARRAY) {
|
} else if (type == G_TYPE_BYTES) {
|
||||||
gint *tmp;
|
gint *tmp;
|
||||||
GByteArray *array;
|
GByteArray *array;
|
||||||
|
GBytes *bytes;
|
||||||
gsize length;
|
gsize length;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -1128,8 +1142,9 @@ read_one_setting_value (NMSetting *setting,
|
|||||||
g_byte_array_append (array, (const unsigned char *) &v, sizeof (v));
|
g_byte_array_append (array, (const unsigned char *) &v, sizeof (v));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_set (setting, key, array, NULL);
|
bytes = g_byte_array_free_to_bytes (array);
|
||||||
g_byte_array_free (array, TRUE);
|
g_object_set (setting, key, bytes, NULL);
|
||||||
|
g_bytes_unref (bytes);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
} else if (type == G_TYPE_STRV) {
|
} else if (type == G_TYPE_STRV) {
|
||||||
gchar **sa;
|
gchar **sa;
|
||||||
|
@@ -1126,7 +1126,7 @@ test_write_wireless_connection (void)
|
|||||||
NMSettingIP6Config *s_ip6;
|
NMSettingIP6Config *s_ip6;
|
||||||
char *uuid;
|
char *uuid;
|
||||||
const char *bssid = "aa:b9:a1:74:55:44";
|
const char *bssid = "aa:b9:a1:74:55:44";
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 };
|
unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 };
|
||||||
gboolean success;
|
gboolean success;
|
||||||
NMConnection *reread;
|
NMConnection *reread;
|
||||||
@@ -1158,8 +1158,7 @@ test_write_wireless_connection (void)
|
|||||||
s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
|
s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wireless));
|
nm_connection_add_setting (connection, NM_SETTING (s_wireless));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (tmpssid));
|
ssid = g_bytes_new (tmpssid, sizeof (tmpssid));
|
||||||
g_byte_array_append (ssid, &tmpssid[0], sizeof (tmpssid));
|
|
||||||
|
|
||||||
g_object_set (s_wireless,
|
g_object_set (s_wireless,
|
||||||
NM_SETTING_WIRELESS_BSSID, bssid,
|
NM_SETTING_WIRELESS_BSSID, bssid,
|
||||||
@@ -1167,7 +1166,7 @@ test_write_wireless_connection (void)
|
|||||||
NM_SETTING_WIRED_MTU, 1000,
|
NM_SETTING_WIRED_MTU, 1000,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* IP4 setting */
|
/* IP4 setting */
|
||||||
|
|
||||||
@@ -1221,7 +1220,9 @@ test_read_string_ssid (void)
|
|||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
|
const guint8 *ssid_data;
|
||||||
|
gsize ssid_len;
|
||||||
const char *expected_ssid = "blah blah ssid 1234";
|
const char *expected_ssid = "blah blah ssid 1234";
|
||||||
|
|
||||||
connection = nm_keyfile_plugin_connection_from_file (TEST_STRING_SSID_FILE, NULL);
|
connection = nm_keyfile_plugin_connection_from_file (TEST_STRING_SSID_FILE, NULL);
|
||||||
@@ -1240,14 +1241,15 @@ test_read_string_ssid (void)
|
|||||||
NM_SETTING_WIRELESS_SETTING_NAME);
|
NM_SETTING_WIRELESS_SETTING_NAME);
|
||||||
|
|
||||||
/* SSID */
|
/* SSID */
|
||||||
array = nm_setting_wireless_get_ssid (s_wireless);
|
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||||
ASSERT (array != NULL,
|
ASSERT (ssid != NULL,
|
||||||
"connection-verify-wireless", "failed to verify %s: missing %s / %s key",
|
"connection-verify-wireless", "failed to verify %s: missing %s / %s key",
|
||||||
TEST_STRING_SSID_FILE,
|
TEST_STRING_SSID_FILE,
|
||||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||||
NM_SETTING_WIRELESS_SSID);
|
NM_SETTING_WIRELESS_SSID);
|
||||||
g_assert_cmpint (array->len, ==, strlen (expected_ssid));
|
ssid_data = g_bytes_get_data (ssid, &ssid_len);
|
||||||
g_assert (memcmp (array->data, expected_ssid, array->len) == 0);
|
g_assert_cmpint (ssid_len, ==, strlen (expected_ssid));
|
||||||
|
g_assert (memcmp (ssid_data, expected_ssid, ssid_len) == 0);
|
||||||
|
|
||||||
g_object_unref (connection);
|
g_object_unref (connection);
|
||||||
}
|
}
|
||||||
@@ -1260,7 +1262,7 @@ test_write_string_ssid (void)
|
|||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
NMSettingIP4Config *s_ip4;
|
NMSettingIP4Config *s_ip4;
|
||||||
char *uuid, *testfile = NULL, *tmp;
|
char *uuid, *testfile = NULL, *tmp;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
unsigned char tmpssid[] = { 65, 49, 50, 51, 32, 46, 92, 46, 36, 37, 126, 93 };
|
unsigned char tmpssid[] = { 65, 49, 50, 51, 32, 46, 92, 46, 36, 37, 126, 93 };
|
||||||
gboolean success;
|
gboolean success;
|
||||||
NMConnection *reread;
|
NMConnection *reread;
|
||||||
@@ -1289,10 +1291,9 @@ test_write_string_ssid (void)
|
|||||||
s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
|
s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wireless));
|
nm_connection_add_setting (connection, NM_SETTING (s_wireless));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (tmpssid));
|
ssid = g_bytes_new (tmpssid, sizeof (tmpssid));
|
||||||
g_byte_array_append (ssid, &tmpssid[0], sizeof (tmpssid));
|
|
||||||
g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* IP4 setting */
|
/* IP4 setting */
|
||||||
|
|
||||||
@@ -1350,7 +1351,9 @@ test_read_intlist_ssid (void)
|
|||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
|
const guint8 *ssid_data;
|
||||||
|
gsize ssid_len;
|
||||||
const char *expected_ssid = "blah1234";
|
const char *expected_ssid = "blah1234";
|
||||||
|
|
||||||
connection = nm_keyfile_plugin_connection_from_file (TEST_INTLIST_SSID_FILE, &error);
|
connection = nm_keyfile_plugin_connection_from_file (TEST_INTLIST_SSID_FILE, &error);
|
||||||
@@ -1365,10 +1368,11 @@ test_read_intlist_ssid (void)
|
|||||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
|
|
||||||
array = nm_setting_wireless_get_ssid (s_wifi);
|
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
g_assert (array != NULL);
|
g_assert (ssid != NULL);
|
||||||
g_assert_cmpint (array->len, ==, strlen (expected_ssid));
|
ssid_data = g_bytes_get_data (ssid, &ssid_len);
|
||||||
g_assert_cmpint (memcmp (array->data, expected_ssid, strlen (expected_ssid)), ==, 0);
|
g_assert_cmpint (ssid_len, ==, strlen (expected_ssid));
|
||||||
|
g_assert_cmpint (memcmp (ssid_data, expected_ssid, strlen (expected_ssid)), ==, 0);
|
||||||
|
|
||||||
g_object_unref (connection);
|
g_object_unref (connection);
|
||||||
}
|
}
|
||||||
@@ -1381,7 +1385,7 @@ test_write_intlist_ssid (void)
|
|||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingIP4Config *s_ip4;
|
NMSettingIP4Config *s_ip4;
|
||||||
char *uuid, *testfile = NULL;
|
char *uuid, *testfile = NULL;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
unsigned char tmpssid[] = { 65, 49, 50, 51, 0, 50, 50 };
|
unsigned char tmpssid[] = { 65, 49, 50, 51, 0, 50, 50 };
|
||||||
gboolean success;
|
gboolean success;
|
||||||
NMConnection *reread;
|
NMConnection *reread;
|
||||||
@@ -1414,10 +1418,9 @@ test_write_intlist_ssid (void)
|
|||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (tmpssid));
|
ssid = g_bytes_new (tmpssid, sizeof (tmpssid));
|
||||||
g_byte_array_append (ssid, &tmpssid[0], sizeof (tmpssid));
|
|
||||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* IP4 setting */
|
/* IP4 setting */
|
||||||
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
|
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
|
||||||
@@ -1474,7 +1477,9 @@ test_read_intlike_ssid (void)
|
|||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
|
const guint8 *ssid_data;
|
||||||
|
gsize ssid_len;
|
||||||
const char *expected_ssid = "101";
|
const char *expected_ssid = "101";
|
||||||
|
|
||||||
connection = nm_keyfile_plugin_connection_from_file (TEST_INTLIKE_SSID_FILE, &error);
|
connection = nm_keyfile_plugin_connection_from_file (TEST_INTLIKE_SSID_FILE, &error);
|
||||||
@@ -1489,10 +1494,11 @@ test_read_intlike_ssid (void)
|
|||||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
|
|
||||||
array = nm_setting_wireless_get_ssid (s_wifi);
|
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
g_assert (array != NULL);
|
g_assert (ssid != NULL);
|
||||||
g_assert_cmpint (array->len, ==, strlen (expected_ssid));
|
ssid_data = g_bytes_get_data (ssid, &ssid_len);
|
||||||
g_assert_cmpint (memcmp (array->data, expected_ssid, strlen (expected_ssid)), ==, 0);
|
g_assert_cmpint (ssid_len, ==, strlen (expected_ssid));
|
||||||
|
g_assert_cmpint (memcmp (ssid_data, expected_ssid, strlen (expected_ssid)), ==, 0);
|
||||||
|
|
||||||
g_object_unref (connection);
|
g_object_unref (connection);
|
||||||
}
|
}
|
||||||
@@ -1506,7 +1512,9 @@ test_read_intlike_ssid_2 (void)
|
|||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
|
const guint8 *ssid_data;
|
||||||
|
gsize ssid_len;
|
||||||
const char *expected_ssid = "11;12;13;";
|
const char *expected_ssid = "11;12;13;";
|
||||||
|
|
||||||
connection = nm_keyfile_plugin_connection_from_file (TEST_INTLIKE_SSID_2_FILE, &error);
|
connection = nm_keyfile_plugin_connection_from_file (TEST_INTLIKE_SSID_2_FILE, &error);
|
||||||
@@ -1521,10 +1529,11 @@ test_read_intlike_ssid_2 (void)
|
|||||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
|
|
||||||
array = nm_setting_wireless_get_ssid (s_wifi);
|
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
g_assert (array != NULL);
|
g_assert (ssid != NULL);
|
||||||
g_assert_cmpint (array->len, ==, strlen (expected_ssid));
|
ssid_data = g_bytes_get_data (ssid, &ssid_len);
|
||||||
g_assert_cmpint (memcmp (array->data, expected_ssid, strlen (expected_ssid)), ==, 0);
|
g_assert_cmpint (ssid_len, ==, strlen (expected_ssid));
|
||||||
|
g_assert_cmpint (memcmp (ssid_data, expected_ssid, strlen (expected_ssid)), ==, 0);
|
||||||
|
|
||||||
g_object_unref (connection);
|
g_object_unref (connection);
|
||||||
}
|
}
|
||||||
@@ -1537,7 +1546,7 @@ test_write_intlike_ssid (void)
|
|||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingIP4Config *s_ip4;
|
NMSettingIP4Config *s_ip4;
|
||||||
char *uuid, *testfile = NULL;
|
char *uuid, *testfile = NULL;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
unsigned char tmpssid[] = { 49, 48, 49 };
|
unsigned char tmpssid[] = { 49, 48, 49 };
|
||||||
gboolean success;
|
gboolean success;
|
||||||
NMConnection *reread;
|
NMConnection *reread;
|
||||||
@@ -1569,10 +1578,9 @@ test_write_intlike_ssid (void)
|
|||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (tmpssid));
|
ssid = g_bytes_new (tmpssid, sizeof (tmpssid));
|
||||||
g_byte_array_append (ssid, &tmpssid[0], sizeof (tmpssid));
|
|
||||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* IP4 setting */
|
/* IP4 setting */
|
||||||
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
|
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
|
||||||
@@ -1624,7 +1632,7 @@ test_write_intlike_ssid_2 (void)
|
|||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingIP4Config *s_ip4;
|
NMSettingIP4Config *s_ip4;
|
||||||
char *uuid, *testfile = NULL;
|
char *uuid, *testfile = NULL;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
unsigned char tmpssid[] = { 49, 49, 59, 49, 50, 59, 49, 51, 59};
|
unsigned char tmpssid[] = { 49, 49, 59, 49, 50, 59, 49, 51, 59};
|
||||||
gboolean success;
|
gboolean success;
|
||||||
NMConnection *reread;
|
NMConnection *reread;
|
||||||
@@ -1656,10 +1664,9 @@ test_write_intlike_ssid_2 (void)
|
|||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (tmpssid));
|
ssid = g_bytes_new (tmpssid, sizeof (tmpssid));
|
||||||
g_byte_array_append (ssid, &tmpssid[0], sizeof (tmpssid));
|
|
||||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* IP4 setting */
|
/* IP4 setting */
|
||||||
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
|
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
|
||||||
@@ -2190,7 +2197,7 @@ test_read_wired_8021x_tls_blob_connection (void)
|
|||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
const GByteArray *array;
|
GBytes *blob;
|
||||||
|
|
||||||
connection = nm_keyfile_plugin_connection_from_file (TEST_WIRED_TLS_BLOB_FILE, &error);
|
connection = nm_keyfile_plugin_connection_from_file (TEST_WIRED_TLS_BLOB_FILE, &error);
|
||||||
if (connection == NULL) {
|
if (connection == NULL) {
|
||||||
@@ -2234,9 +2241,9 @@ test_read_wired_8021x_tls_blob_connection (void)
|
|||||||
g_assert (tmp == NULL);
|
g_assert (tmp == NULL);
|
||||||
|
|
||||||
/* Validate the path */
|
/* Validate the path */
|
||||||
array = nm_setting_802_1x_get_ca_cert_blob (s_8021x);
|
blob = nm_setting_802_1x_get_ca_cert_blob (s_8021x);
|
||||||
g_assert (array != NULL);
|
g_assert (blob != NULL);
|
||||||
g_assert_cmpint (array->len, ==, 568);
|
g_assert_cmpint (g_bytes_get_size (blob), ==, 568);
|
||||||
|
|
||||||
tmp = nm_setting_802_1x_get_client_cert_path (s_8021x);
|
tmp = nm_setting_802_1x_get_client_cert_path (s_8021x);
|
||||||
g_assert_cmpstr (tmp, ==, "/home/dcbw/Desktop/certinfra/client.pem");
|
g_assert_cmpstr (tmp, ==, "/home/dcbw/Desktop/certinfra/client.pem");
|
||||||
@@ -3175,7 +3182,9 @@ test_read_new_wireless_group_names (void)
|
|||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
const GByteArray *array;
|
GBytes *ssid;
|
||||||
|
const guint8 *ssid_data;
|
||||||
|
gsize ssid_len;
|
||||||
const char *expected_ssid = "foobar";
|
const char *expected_ssid = "foobar";
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
@@ -3191,10 +3200,11 @@ test_read_new_wireless_group_names (void)
|
|||||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||||
g_assert (s_wifi);
|
g_assert (s_wifi);
|
||||||
|
|
||||||
array = nm_setting_wireless_get_ssid (s_wifi);
|
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
g_assert (array);
|
g_assert (ssid);
|
||||||
g_assert_cmpint (array->len, ==, strlen (expected_ssid));
|
ssid_data = g_bytes_get_data (ssid, &ssid_len);
|
||||||
g_assert_cmpint (memcmp (array->data, expected_ssid, array->len), ==, 0);
|
g_assert_cmpint (ssid_len, ==, strlen (expected_ssid));
|
||||||
|
g_assert_cmpint (memcmp (ssid_data, expected_ssid, ssid_len), ==, 0);
|
||||||
|
|
||||||
g_assert_cmpstr (nm_setting_wireless_get_mode (s_wifi), ==, NM_SETTING_WIRELESS_MODE_INFRA);
|
g_assert_cmpstr (nm_setting_wireless_get_mode (s_wifi), ==, NM_SETTING_WIRELESS_MODE_INFRA);
|
||||||
|
|
||||||
@@ -3215,7 +3225,7 @@ test_write_new_wireless_group_names (void)
|
|||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
char *uuid;
|
char *uuid;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 };
|
unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 };
|
||||||
const char *expected_psk = "asdfasdfasdfa12315";
|
const char *expected_psk = "asdfasdfasdfa12315";
|
||||||
gboolean success;
|
gboolean success;
|
||||||
@@ -3246,13 +3256,12 @@ test_write_new_wireless_group_names (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (tmpssid));
|
ssid = g_bytes_new (tmpssid, sizeof (tmpssid));
|
||||||
g_byte_array_append (ssid, &tmpssid[0], sizeof (tmpssid));
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA,
|
NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA,
|
||||||
NULL);
|
NULL);
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* WiFi security setting */
|
/* WiFi security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
|
@@ -391,24 +391,29 @@ ssid_writer (GKeyFile *file,
|
|||||||
const char *key,
|
const char *key,
|
||||||
const GValue *value)
|
const GValue *value)
|
||||||
{
|
{
|
||||||
GByteArray *array;
|
GBytes *bytes;
|
||||||
|
const guint8 *ssid_data;
|
||||||
|
gsize ssid_len;
|
||||||
const char *setting_name = nm_setting_get_name (setting);
|
const char *setting_name = nm_setting_get_name (setting);
|
||||||
gboolean new_format = TRUE;
|
gboolean new_format = TRUE;
|
||||||
unsigned int semicolons = 0;
|
unsigned int semicolons = 0;
|
||||||
int i, *tmp_array;
|
int i, *tmp_array;
|
||||||
char *ssid;
|
char *ssid;
|
||||||
|
|
||||||
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);
|
bytes = g_value_get_boxed (value);
|
||||||
if (!array || !array->len)
|
if (!bytes)
|
||||||
|
return;
|
||||||
|
ssid_data = g_bytes_get_data (bytes, &ssid_len);
|
||||||
|
if (ssid_len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Check whether each byte is printable. If not, we have to use an
|
/* Check whether each byte is printable. If not, we have to use an
|
||||||
* integer list, otherwise we can just use a string.
|
* integer list, otherwise we can just use a string.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < array->len; i++) {
|
for (i = 0; i < ssid_len; i++) {
|
||||||
char c = array->data[i] & 0xFF;
|
char c = ssid_data[i] & 0xFF;
|
||||||
if (!g_ascii_isprint (c)) {
|
if (!g_ascii_isprint (c)) {
|
||||||
new_format = FALSE;
|
new_format = FALSE;
|
||||||
break;
|
break;
|
||||||
@@ -418,26 +423,26 @@ ssid_writer (GKeyFile *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (new_format) {
|
if (new_format) {
|
||||||
ssid = g_malloc0 (array->len + semicolons + 1);
|
ssid = g_malloc0 (ssid_len + semicolons + 1);
|
||||||
if (semicolons == 0)
|
if (semicolons == 0)
|
||||||
memcpy (ssid, array->data, array->len);
|
memcpy (ssid, ssid_data, ssid_len);
|
||||||
else {
|
else {
|
||||||
/* Escape semicolons with backslashes to make strings
|
/* Escape semicolons with backslashes to make strings
|
||||||
* containing ';', such as '16;17;' unambiguous */
|
* containing ';', such as '16;17;' unambiguous */
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (i = 0; i < array->len; i++) {
|
for (i = 0; i < ssid_len; i++) {
|
||||||
if (array->data[i] == ';')
|
if (ssid_data[i] == ';')
|
||||||
ssid[j++] = '\\';
|
ssid[j++] = '\\';
|
||||||
ssid[j++] = array->data[i];
|
ssid[j++] = ssid_data[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nm_keyfile_plugin_kf_set_string (file, setting_name, key, ssid);
|
nm_keyfile_plugin_kf_set_string (file, setting_name, key, ssid);
|
||||||
g_free (ssid);
|
g_free (ssid);
|
||||||
} else {
|
} else {
|
||||||
tmp_array = g_new (gint, array->len);
|
tmp_array = g_new (gint, ssid_len);
|
||||||
for (i = 0; i < array->len; i++)
|
for (i = 0; i < ssid_len; i++)
|
||||||
tmp_array[i] = (int) array->data[i];
|
tmp_array[i] = (int) ssid_data[i];
|
||||||
nm_keyfile_plugin_kf_set_integer_list (file, setting_name, key, tmp_array, array->len);
|
nm_keyfile_plugin_kf_set_integer_list (file, setting_name, key, tmp_array, ssid_len);
|
||||||
g_free (tmp_array);
|
g_free (tmp_array);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,7 +479,7 @@ typedef struct ObjectType {
|
|||||||
NMSetting8021xCKScheme (*scheme_func) (NMSetting8021x *setting);
|
NMSetting8021xCKScheme (*scheme_func) (NMSetting8021x *setting);
|
||||||
NMSetting8021xCKFormat (*format_func) (NMSetting8021x *setting);
|
NMSetting8021xCKFormat (*format_func) (NMSetting8021x *setting);
|
||||||
const char * (*path_func) (NMSetting8021x *setting);
|
const char * (*path_func) (NMSetting8021x *setting);
|
||||||
const GByteArray * (*blob_func) (NMSetting8021x *setting);
|
GBytes * (*blob_func) (NMSetting8021x *setting);
|
||||||
} ObjectType;
|
} ObjectType;
|
||||||
|
|
||||||
static const ObjectType objtypes[10] = {
|
static const ObjectType objtypes[10] = {
|
||||||
@@ -531,7 +536,8 @@ static const ObjectType objtypes[10] = {
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_cert_key_file (const char *path,
|
write_cert_key_file (const char *path,
|
||||||
const GByteArray *data,
|
const guint8 *data,
|
||||||
|
gsize data_len,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
char *tmppath;
|
char *tmppath;
|
||||||
@@ -564,8 +570,8 @@ write_cert_key_file (const char *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
written = write (fd, data->data, data->len);
|
written = write (fd, data, data_len);
|
||||||
if (written != data->len) {
|
if (written != data_len) {
|
||||||
close (fd);
|
close (fd);
|
||||||
unlink (tmppath);
|
unlink (tmppath);
|
||||||
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
|
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
|
||||||
@@ -633,13 +639,16 @@ cert_writer (GKeyFile *file,
|
|||||||
|
|
||||||
nm_keyfile_plugin_kf_set_string (file, setting_name, key, path);
|
nm_keyfile_plugin_kf_set_string (file, setting_name, key, path);
|
||||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||||
const GByteArray *blob;
|
GBytes *blob;
|
||||||
|
const guint8 *blob_data;
|
||||||
|
gsize blob_len;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
char *new_path;
|
char *new_path;
|
||||||
|
|
||||||
blob = objtype->blob_func (NM_SETTING_802_1X (setting));
|
blob = objtype->blob_func (NM_SETTING_802_1X (setting));
|
||||||
g_assert (blob);
|
g_assert (blob);
|
||||||
|
blob_data = g_bytes_get_data (blob, &blob_len);
|
||||||
|
|
||||||
if (objtype->format_func) {
|
if (objtype->format_func) {
|
||||||
/* Get the extension for a private key */
|
/* Get the extension for a private key */
|
||||||
@@ -648,7 +657,7 @@ cert_writer (GKeyFile *file,
|
|||||||
ext = "p12";
|
ext = "p12";
|
||||||
} else {
|
} else {
|
||||||
/* DER or PEM format certificate? */
|
/* DER or PEM format certificate? */
|
||||||
if (blob->len > 2 && blob->data[0] == 0x30 && blob->data[1] == 0x82)
|
if (blob_len > 2 && blob_data[0] == 0x30 && blob_data[1] == 0x82)
|
||||||
ext = "der";
|
ext = "der";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,7 +667,7 @@ cert_writer (GKeyFile *file,
|
|||||||
new_path = g_strdup_printf ("%s/%s-%s.%s", keyfile_dir, uuid, objtype->suffix, ext);
|
new_path = g_strdup_printf ("%s/%s-%s.%s", keyfile_dir, uuid, objtype->suffix, ext);
|
||||||
g_assert (new_path);
|
g_assert (new_path);
|
||||||
|
|
||||||
success = write_cert_key_file (new_path, blob, &error);
|
success = write_cert_key_file (new_path, blob_data, blob_len, &error);
|
||||||
if (success) {
|
if (success) {
|
||||||
/* Write the path value to the keyfile */
|
/* Write the path value to the keyfile */
|
||||||
nm_keyfile_plugin_kf_set_string (file, setting_name, key, new_path);
|
nm_keyfile_plugin_kf_set_string (file, setting_name, key, new_path);
|
||||||
@@ -822,19 +831,23 @@ write_setting_value (NMSetting *setting,
|
|||||||
nm_keyfile_plugin_kf_set_boolean (info->keyfile, setting_name, key, g_value_get_boolean (value));
|
nm_keyfile_plugin_kf_set_boolean (info->keyfile, setting_name, key, g_value_get_boolean (value));
|
||||||
} else if (type == G_TYPE_CHAR) {
|
} else if (type == G_TYPE_CHAR) {
|
||||||
nm_keyfile_plugin_kf_set_integer (info->keyfile, setting_name, key, (int) g_value_get_schar (value));
|
nm_keyfile_plugin_kf_set_integer (info->keyfile, setting_name, key, (int) g_value_get_schar (value));
|
||||||
} else if (type == DBUS_TYPE_G_UCHAR_ARRAY) {
|
} else if (type == G_TYPE_BYTES) {
|
||||||
GByteArray *array;
|
GBytes *bytes;
|
||||||
|
const guint8 *data;
|
||||||
|
gsize len = 0;
|
||||||
|
|
||||||
array = (GByteArray *) g_value_get_boxed (value);
|
bytes = g_value_get_boxed (value);
|
||||||
if (array && array->len > 0) {
|
data = bytes ? g_bytes_get_data (bytes, &len) : NULL;
|
||||||
|
|
||||||
|
if (data != NULL && len > 0) {
|
||||||
int *tmp_array;
|
int *tmp_array;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
tmp_array = g_new (gint, array->len);
|
tmp_array = g_new (gint, len);
|
||||||
for (i = 0; i < array->len; i++)
|
for (i = 0; i < len; i++)
|
||||||
tmp_array[i] = (int) array->data[i];
|
tmp_array[i] = (int) data[i];
|
||||||
|
|
||||||
nm_keyfile_plugin_kf_set_integer_list (info->keyfile, setting_name, key, tmp_array, array->len);
|
nm_keyfile_plugin_kf_set_integer_list (info->keyfile, setting_name, key, tmp_array, len);
|
||||||
g_free (tmp_array);
|
g_free (tmp_array);
|
||||||
}
|
}
|
||||||
} else if (type == G_TYPE_STRV) {
|
} else if (type == G_TYPE_STRV) {
|
||||||
|
@@ -165,7 +165,7 @@ nm_supplicant_config_add_option (NMSupplicantConfig *self,
|
|||||||
static gboolean
|
static gboolean
|
||||||
nm_supplicant_config_add_blob (NMSupplicantConfig *self,
|
nm_supplicant_config_add_blob (NMSupplicantConfig *self,
|
||||||
const char *key,
|
const char *key,
|
||||||
const GByteArray *value,
|
GBytes *value,
|
||||||
const char *blobid)
|
const char *blobid)
|
||||||
{
|
{
|
||||||
NMSupplicantConfigPrivate *priv;
|
NMSupplicantConfigPrivate *priv;
|
||||||
@@ -173,16 +173,20 @@ nm_supplicant_config_add_blob (NMSupplicantConfig *self,
|
|||||||
ConfigOption *opt;
|
ConfigOption *opt;
|
||||||
OptType type;
|
OptType type;
|
||||||
GByteArray *blob;
|
GByteArray *blob;
|
||||||
|
const guint8 *data;
|
||||||
|
gsize data_len;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE);
|
g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE);
|
||||||
g_return_val_if_fail (key != NULL, FALSE);
|
g_return_val_if_fail (key != NULL, FALSE);
|
||||||
g_return_val_if_fail (value != NULL, FALSE);
|
g_return_val_if_fail (value != NULL, FALSE);
|
||||||
g_return_val_if_fail (value->len > 0, FALSE);
|
|
||||||
g_return_val_if_fail (blobid != NULL, FALSE);
|
g_return_val_if_fail (blobid != NULL, FALSE);
|
||||||
|
|
||||||
|
data = g_bytes_get_data (value, &data_len);
|
||||||
|
g_return_val_if_fail (data_len > 0, FALSE);
|
||||||
|
|
||||||
priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self);
|
priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self);
|
||||||
|
|
||||||
type = nm_supplicant_settings_verify_setting (key, (const char *) value->data, value->len);
|
type = nm_supplicant_settings_verify_setting (key, (const char *) data, data_len);
|
||||||
if (type == TYPE_INVALID) {
|
if (type == TYPE_INVALID) {
|
||||||
nm_log_warn (LOGD_SUPPLICANT, "Key '%s' and/or it's contained value is invalid.", key);
|
nm_log_warn (LOGD_SUPPLICANT, "Key '%s' and/or it's contained value is invalid.", key);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -194,8 +198,8 @@ nm_supplicant_config_add_blob (NMSupplicantConfig *self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
blob = g_byte_array_sized_new (value->len);
|
blob = g_byte_array_sized_new (data_len);
|
||||||
g_byte_array_append (blob, value->data, value->len);
|
g_byte_array_append (blob, data, data_len);
|
||||||
|
|
||||||
opt = g_slice_new0 (ConfigOption);
|
opt = g_slice_new0 (ConfigOption);
|
||||||
opt->value = g_strdup_printf ("blob://%s", blobid);
|
opt->value = g_strdup_printf ("blob://%s", blobid);
|
||||||
@@ -342,7 +346,7 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
|
|||||||
NMSupplicantConfigPrivate *priv;
|
NMSupplicantConfigPrivate *priv;
|
||||||
gboolean is_adhoc, is_ap;
|
gboolean is_adhoc, is_ap;
|
||||||
const char *mode, *band;
|
const char *mode, *band;
|
||||||
const GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const char *bssid;
|
const char *bssid;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE);
|
g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE);
|
||||||
@@ -359,7 +363,10 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
|
|||||||
priv->ap_scan = 1;
|
priv->ap_scan = 1;
|
||||||
|
|
||||||
ssid = nm_setting_wireless_get_ssid (setting);
|
ssid = nm_setting_wireless_get_ssid (setting);
|
||||||
if (!nm_supplicant_config_add_option (self, "ssid", (char *) ssid->data, ssid->len, FALSE)) {
|
if (!nm_supplicant_config_add_option (self, "ssid",
|
||||||
|
(char *) g_bytes_get_data (ssid, NULL),
|
||||||
|
g_bytes_get_size (ssid),
|
||||||
|
FALSE)) {
|
||||||
nm_log_warn (LOGD_SUPPLICANT, "Error adding SSID to supplicant config.");
|
nm_log_warn (LOGD_SUPPLICANT, "Error adding SSID to supplicant config.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -488,7 +495,7 @@ get_blob_id (const char *name, const char *seed_uid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define ADD_BLOB_VAL(field, name, con_uid) \
|
#define ADD_BLOB_VAL(field, name, con_uid) \
|
||||||
if (field && field->len) { \
|
if (field && g_bytes_get_size (field)) { \
|
||||||
char *uid = get_blob_id (name, con_uid); \
|
char *uid = get_blob_id (name, con_uid); \
|
||||||
success = nm_supplicant_config_add_blob (self, name, field, uid); \
|
success = nm_supplicant_config_add_blob (self, name, field, uid); \
|
||||||
g_free (uid); \
|
g_free (uid); \
|
||||||
@@ -724,7 +731,7 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
|
|||||||
const char *peapver, *value, *path;
|
const char *peapver, *value, *path;
|
||||||
gboolean success, added;
|
gboolean success, added;
|
||||||
GString *phase1, *phase2;
|
GString *phase1, *phase2;
|
||||||
const GByteArray *array;
|
GBytes *bytes;
|
||||||
gboolean fast = FALSE;
|
gboolean fast = FALSE;
|
||||||
guint32 i, num_eap;
|
guint32 i, num_eap;
|
||||||
gboolean fast_provisoning_allowed = FALSE;
|
gboolean fast_provisoning_allowed = FALSE;
|
||||||
@@ -740,12 +747,12 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
|
|||||||
if (!add_string_val (self, value, "password", FALSE, TRUE))
|
if (!add_string_val (self, value, "password", FALSE, TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
array = nm_setting_802_1x_get_password_raw (setting);
|
bytes = nm_setting_802_1x_get_password_raw (setting);
|
||||||
if (array) {
|
if (bytes) {
|
||||||
success = nm_supplicant_config_add_option (self,
|
success = nm_supplicant_config_add_option (self,
|
||||||
"password",
|
"password",
|
||||||
(const char *)array->data,
|
(const char *) g_bytes_get_data (bytes, NULL),
|
||||||
array->len,
|
g_bytes_get_size (bytes),
|
||||||
TRUE);
|
TRUE);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
nm_log_warn (LOGD_SUPPLICANT, "Error adding password-raw to supplicant config.");
|
nm_log_warn (LOGD_SUPPLICANT, "Error adding password-raw to supplicant config.");
|
||||||
@@ -886,8 +893,8 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
|
|||||||
/* CA certificate */
|
/* CA certificate */
|
||||||
switch (nm_setting_802_1x_get_ca_cert_scheme (setting)) {
|
switch (nm_setting_802_1x_get_ca_cert_scheme (setting)) {
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||||
array = nm_setting_802_1x_get_ca_cert_blob (setting);
|
bytes = nm_setting_802_1x_get_ca_cert_blob (setting);
|
||||||
ADD_BLOB_VAL (array, "ca_cert", con_uuid);
|
ADD_BLOB_VAL (bytes, "ca_cert", con_uuid);
|
||||||
break;
|
break;
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||||
path = nm_setting_802_1x_get_ca_cert_path (setting);
|
path = nm_setting_802_1x_get_ca_cert_path (setting);
|
||||||
@@ -901,8 +908,8 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
|
|||||||
/* Phase 2 CA certificate */
|
/* Phase 2 CA certificate */
|
||||||
switch (nm_setting_802_1x_get_phase2_ca_cert_scheme (setting)) {
|
switch (nm_setting_802_1x_get_phase2_ca_cert_scheme (setting)) {
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||||
array = nm_setting_802_1x_get_phase2_ca_cert_blob (setting);
|
bytes = nm_setting_802_1x_get_phase2_ca_cert_blob (setting);
|
||||||
ADD_BLOB_VAL (array, "ca_cert2", con_uuid);
|
ADD_BLOB_VAL (bytes, "ca_cert2", con_uuid);
|
||||||
break;
|
break;
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||||
path = nm_setting_802_1x_get_phase2_ca_cert_path (setting);
|
path = nm_setting_802_1x_get_phase2_ca_cert_path (setting);
|
||||||
@@ -929,8 +936,8 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
|
|||||||
added = FALSE;
|
added = FALSE;
|
||||||
switch (nm_setting_802_1x_get_private_key_scheme (setting)) {
|
switch (nm_setting_802_1x_get_private_key_scheme (setting)) {
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||||
array = nm_setting_802_1x_get_private_key_blob (setting);
|
bytes = nm_setting_802_1x_get_private_key_blob (setting);
|
||||||
ADD_BLOB_VAL (array, "private_key", con_uuid);
|
ADD_BLOB_VAL (bytes, "private_key", con_uuid);
|
||||||
added = TRUE;
|
added = TRUE;
|
||||||
break;
|
break;
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||||
@@ -967,8 +974,8 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
|
|||||||
*/
|
*/
|
||||||
switch (nm_setting_802_1x_get_client_cert_scheme (setting)) {
|
switch (nm_setting_802_1x_get_client_cert_scheme (setting)) {
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||||
array = nm_setting_802_1x_get_client_cert_blob (setting);
|
bytes = nm_setting_802_1x_get_client_cert_blob (setting);
|
||||||
ADD_BLOB_VAL (array, "client_cert", con_uuid);
|
ADD_BLOB_VAL (bytes, "client_cert", con_uuid);
|
||||||
break;
|
break;
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||||
path = nm_setting_802_1x_get_client_cert_path (setting);
|
path = nm_setting_802_1x_get_client_cert_path (setting);
|
||||||
@@ -985,8 +992,8 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
|
|||||||
added = FALSE;
|
added = FALSE;
|
||||||
switch (nm_setting_802_1x_get_phase2_private_key_scheme (setting)) {
|
switch (nm_setting_802_1x_get_phase2_private_key_scheme (setting)) {
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||||
array = nm_setting_802_1x_get_phase2_private_key_blob (setting);
|
bytes = nm_setting_802_1x_get_phase2_private_key_blob (setting);
|
||||||
ADD_BLOB_VAL (array, "private_key2", con_uuid);
|
ADD_BLOB_VAL (bytes, "private_key2", con_uuid);
|
||||||
added = TRUE;
|
added = TRUE;
|
||||||
break;
|
break;
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||||
@@ -1023,8 +1030,8 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
|
|||||||
*/
|
*/
|
||||||
switch (nm_setting_802_1x_get_phase2_client_cert_scheme (setting)) {
|
switch (nm_setting_802_1x_get_phase2_client_cert_scheme (setting)) {
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||||
array = nm_setting_802_1x_get_phase2_client_cert_blob (setting);
|
bytes = nm_setting_802_1x_get_phase2_client_cert_blob (setting);
|
||||||
ADD_BLOB_VAL (array, "client_cert2", con_uuid);
|
ADD_BLOB_VAL (bytes, "client_cert2", con_uuid);
|
||||||
break;
|
break;
|
||||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||||
path = nm_setting_802_1x_get_phase2_client_cert_path (setting);
|
path = nm_setting_802_1x_get_phase2_client_cert_path (setting);
|
||||||
|
@@ -120,7 +120,7 @@ test_wifi_open (void)
|
|||||||
char *uuid;
|
char *uuid;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
|
const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
|
||||||
const char *bssid_str = "11:22:33:44:55:66";
|
const char *bssid_str = "11:22:33:44:55:66";
|
||||||
|
|
||||||
@@ -143,8 +143,7 @@ test_wifi_open (void)
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, sizeof (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
@@ -153,7 +152,7 @@ test_wifi_open (void)
|
|||||||
NM_SETTING_WIRELESS_BAND, "bg",
|
NM_SETTING_WIRELESS_BAND, "bg",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* IP4 setting */
|
/* IP4 setting */
|
||||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||||
@@ -216,7 +215,7 @@ test_wifi_wep_key (const char *detail,
|
|||||||
char *uuid;
|
char *uuid;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
|
const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
|
||||||
const char *bssid_str = "11:22:33:44:55:66";
|
const char *bssid_str = "11:22:33:44:55:66";
|
||||||
|
|
||||||
@@ -239,8 +238,7 @@ test_wifi_wep_key (const char *detail,
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, sizeof (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
@@ -249,7 +247,7 @@ test_wifi_wep_key (const char *detail,
|
|||||||
NM_SETTING_WIRELESS_BAND, "bg",
|
NM_SETTING_WIRELESS_BAND, "bg",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wifi Security setting */
|
/* Wifi Security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
@@ -354,7 +352,7 @@ test_wifi_wpa_psk (const char *detail,
|
|||||||
char *uuid;
|
char *uuid;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GByteArray *ssid;
|
GBytes *ssid;
|
||||||
const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
|
const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
|
||||||
const char *bssid_str = "11:22:33:44:55:66";
|
const char *bssid_str = "11:22:33:44:55:66";
|
||||||
|
|
||||||
@@ -377,8 +375,7 @@ test_wifi_wpa_psk (const char *detail,
|
|||||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||||
|
|
||||||
ssid = g_byte_array_sized_new (sizeof (ssid_data));
|
ssid = g_bytes_new (ssid_data, sizeof (ssid_data));
|
||||||
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
|
|
||||||
|
|
||||||
g_object_set (s_wifi,
|
g_object_set (s_wifi,
|
||||||
NM_SETTING_WIRELESS_SSID, ssid,
|
NM_SETTING_WIRELESS_SSID, ssid,
|
||||||
@@ -387,7 +384,7 @@ test_wifi_wpa_psk (const char *detail,
|
|||||||
NM_SETTING_WIRELESS_BAND, "bg",
|
NM_SETTING_WIRELESS_BAND, "bg",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_byte_array_free (ssid, TRUE);
|
g_bytes_unref (ssid);
|
||||||
|
|
||||||
/* Wifi Security setting */
|
/* Wifi Security setting */
|
||||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
|
||||||
|
Reference in New Issue
Block a user