mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 05:58:01 +02:00
libnm/vpn: fix secret comparison
One setting may contain a superset or subset of the another. Be sure not to ignore the presence of extra secret properties.
This commit is contained in:
parent
99fea5f380
commit
16f8651908
2 changed files with 34 additions and 12 deletions
|
|
@ -713,17 +713,15 @@ need_secrets (NMSetting *setting)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
compare_one_secret (NMSettingVpn *a,
|
_compare_secrets (NMSettingVpn *a,
|
||||||
NMSettingVpn *b,
|
NMSettingVpn *b,
|
||||||
NMSettingCompareFlags flags)
|
NMSettingCompareFlags flags)
|
||||||
{
|
{
|
||||||
GHashTable *a_secrets, *b_secrets;
|
GHashTable *a_secrets;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
const char *key, *val;
|
const char *key, *val;
|
||||||
|
|
||||||
a_secrets = NM_SETTING_VPN_GET_PRIVATE (a)->secrets;
|
a_secrets = NM_SETTING_VPN_GET_PRIVATE (a)->secrets;
|
||||||
b_secrets = NM_SETTING_VPN_GET_PRIVATE (b)->secrets;
|
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, a_secrets);
|
g_hash_table_iter_init (&iter, a_secrets);
|
||||||
while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &val)) {
|
while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &val)) {
|
||||||
NMSettingSecretFlags a_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
NMSettingSecretFlags a_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
||||||
|
|
@ -752,6 +750,19 @@ compare_one_secret (NMSettingVpn *a,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
compare_one_secret (NMSettingVpn *a,
|
||||||
|
NMSettingVpn *b,
|
||||||
|
NMSettingCompareFlags flags)
|
||||||
|
{
|
||||||
|
if (!_compare_secrets (a, b, flags))
|
||||||
|
return FALSE;
|
||||||
|
if (!_compare_secrets (b, a, flags))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
compare_property (NMSetting *setting,
|
compare_property (NMSetting *setting,
|
||||||
NMSetting *other,
|
NMSetting *other,
|
||||||
|
|
|
||||||
|
|
@ -616,17 +616,15 @@ need_secrets (NMSetting *setting)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
compare_one_secret (NMSettingVPN *a,
|
_compare_secrets (NMSettingVPN *a,
|
||||||
NMSettingVPN *b,
|
NMSettingVPN *b,
|
||||||
NMSettingCompareFlags flags)
|
NMSettingCompareFlags flags)
|
||||||
{
|
{
|
||||||
GHashTable *a_secrets, *b_secrets;
|
GHashTable *a_secrets;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
const char *key, *val;
|
const char *key, *val;
|
||||||
|
|
||||||
a_secrets = NM_SETTING_VPN_GET_PRIVATE (a)->secrets;
|
a_secrets = NM_SETTING_VPN_GET_PRIVATE (a)->secrets;
|
||||||
b_secrets = NM_SETTING_VPN_GET_PRIVATE (b)->secrets;
|
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, a_secrets);
|
g_hash_table_iter_init (&iter, a_secrets);
|
||||||
while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &val)) {
|
while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &val)) {
|
||||||
NMSettingSecretFlags a_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
NMSettingSecretFlags a_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
||||||
|
|
@ -655,6 +653,19 @@ compare_one_secret (NMSettingVPN *a,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
compare_one_secret (NMSettingVPN *a,
|
||||||
|
NMSettingVPN *b,
|
||||||
|
NMSettingCompareFlags flags)
|
||||||
|
{
|
||||||
|
if (!_compare_secrets (a, b, flags))
|
||||||
|
return FALSE;
|
||||||
|
if (!_compare_secrets (b, a, flags))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
compare_property (NMSetting *setting,
|
compare_property (NMSetting *setting,
|
||||||
NMSetting *other,
|
NMSetting *other,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue