-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: New "networkmanager.passthrough" structure (LP: #2080301) #522
base: main
Are you sure you want to change the base?
Changes from all commits
a67463a
a2d5e8c
23cd665
f3762c9
f94a59f
b954585
8addc9a
a381373
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -448,39 +448,44 @@ parse_bond_arp_ip_targets(GKeyFile* kf, GArray **targets_arr) | |
|
||
/* Read the key-value pairs from the keyfile and pass them through to a map */ | ||
STATIC void | ||
read_passthrough(GKeyFile* kf, GData** list) | ||
read_passthrough(GKeyFile* kf, GHashTable** list) | ||
{ | ||
gchar **groups = NULL; | ||
gchar **keys = NULL; | ||
gchar *group_key = NULL; | ||
gchar *value = NULL; | ||
gsize klen = 0; | ||
gsize glen = 0; | ||
GHashTable* group; | ||
|
||
if (!*list) | ||
g_datalist_init(list); | ||
if (*list == NULL) { | ||
*list = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | ||
} | ||
groups = g_key_file_get_groups(kf, &glen); | ||
if (groups) { | ||
if (groups != NULL) { | ||
for (unsigned i = 0; i < glen; ++i) { | ||
klen = 0; | ||
group = g_hash_table_lookup(*list, groups[i]); | ||
if (group == NULL) { | ||
group = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | ||
} | ||
keys = g_key_file_get_keys(kf, groups[i], &klen, NULL); | ||
if (klen == 0) { | ||
/* empty group */ | ||
g_datalist_set_data_full(list, g_strconcat(groups[i], ".", NETPLAN_NM_EMPTY_GROUP, NULL), g_strdup(""), g_free); | ||
g_hash_table_insert(*list, g_strdup(groups[i]), group); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: I think this might leak memory, iff the key or value already exists in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this particular case, Although, there is a different memory leak there: thanks to the |
||
g_strfreev(keys); | ||
continue; | ||
} | ||
for (unsigned j = 0; j < klen; ++j) { | ||
value = g_key_file_get_string(kf, groups[i], keys[j], NULL); | ||
if (!value) { | ||
if (value == NULL) { | ||
// LCOV_EXCL_START | ||
g_warning("netplan: Keyfile: cannot read value of %s.%s", groups[i], keys[j]); | ||
continue; | ||
// LCOV_EXCL_STOP | ||
} | ||
group_key = g_strconcat(groups[i], ".", keys[j], NULL); | ||
g_datalist_set_data_full(list, group_key, value, g_free); | ||
g_free(group_key); | ||
g_hash_table_insert(group, g_strdup(keys[j]), value); | ||
} | ||
g_hash_table_insert(*list, g_strdup(groups[i]), group); | ||
g_strfreev(keys); | ||
} | ||
g_strfreev(groups); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: This assumption is broken by the
network-manager-openconnect
plugin, as described in LP#2080301. We might be able to special case thevpn-secrets
group similarly as we did withtc
, to keep things simple... Although, that might make us run into similar issues in the future for other "edge cases".