diff --git a/src/libnm-core-impl/nm-keyfile-utils.c b/src/libnm-core-impl/nm-keyfile-utils.c index 95073bcc9..fdf00677c 100644 --- a/src/libnm-core-impl/nm-keyfile-utils.c +++ b/src/libnm-core-impl/nm-keyfile-utils.c @@ -682,22 +682,3 @@ nm_keyfile_key_decode(const char *key, char **out_to_free) #endif return name; } - -void -nm_keyfile_add_group(GKeyFile *keyfile, const char *group) -{ - nm_assert(keyfile); - nm_assert(group); - - /* You can only call this function if the group doesn't exist yet. - * Because, we are about to add a dummy key, so we would have to - * be sure that the key doesn't exist. */ - nm_assert(!g_key_file_has_group(keyfile, group)); - - /* Ensure the group is present. - * There is no API for that, so add and remove a dummy key. - * For a profile it matters whether a setting is present or not, - * and we need to ensure that we persist the presence of the setting to keyfile*/ - g_key_file_set_value(keyfile, group, ".X", "1"); - g_key_file_remove_key(keyfile, group, ".X", NULL); -} diff --git a/src/libnm-core-impl/nm-keyfile.c b/src/libnm-core-impl/nm-keyfile.c index 69b49fa0b..e4559e3c5 100644 --- a/src/libnm-core-impl/nm-keyfile.c +++ b/src/libnm-core-impl/nm-keyfile.c @@ -18,6 +18,7 @@ #include #include +#include "libnm-glib-aux/nm-keyfile-aux.h" #include "libnm-glib-aux/nm-uuid.h" #include "libnm-glib-aux/nm-str-buf.h" #include "libnm-glib-aux/nm-secret-utils.h" @@ -2502,7 +2503,7 @@ wired_s390_options_writer_full(KeyfileWriterInfo *info, /* groups in the keyfile are ordered. When we are about to add [ethernet-s390-options], * we want to also have an [ethernet] group, first. */ - nm_keyfile_add_group(info->keyfile, setting_alias ?: NM_SETTING_WIRED_SETTING_NAME); + nm_key_file_add_group(info->keyfile, setting_alias ?: NM_SETTING_WIRED_SETTING_NAME); } for (i = 0; i < n; i++) { @@ -4475,7 +4476,7 @@ nm_keyfile_write(NMConnection *connection, || g_key_file_has_group(info.keyfile, setting_name)) { /* we have a section for the setting. Nothing to do. */ } else { - nm_keyfile_add_group(info.keyfile, setting_alias ?: setting_name); + nm_key_file_add_group(info.keyfile, setting_alias ?: setting_name); } if (NM_IS_SETTING_WIREGUARD(setting)) { diff --git a/src/libnm-core-intern/nm-keyfile-utils.h b/src/libnm-core-intern/nm-keyfile-utils.h index b7758c053..604daf515 100644 --- a/src/libnm-core-intern/nm-keyfile-utils.h +++ b/src/libnm-core-intern/nm-keyfile-utils.h @@ -88,6 +88,4 @@ const char *nm_keyfile_key_encode(const char *name, char **out_to_free); const char *nm_keyfile_key_decode(const char *key, char **out_to_free); -void nm_keyfile_add_group(GKeyFile *keyfile, const char *group); - #endif /* __NM_KEYFILE_UTILS_H__ */ diff --git a/src/libnm-glib-aux/nm-keyfile-aux.c b/src/libnm-glib-aux/nm-keyfile-aux.c index 20a4690f2..42f4f8be0 100644 --- a/src/libnm-glib-aux/nm-keyfile-aux.c +++ b/src/libnm-glib-aux/nm-keyfile-aux.c @@ -485,3 +485,22 @@ nm_key_file_db_prune(NMKeyFileDB *self, } } } + +void +nm_key_file_add_group(GKeyFile *keyfile, const char *group) +{ + nm_assert(keyfile); + nm_assert(group); + + /* You can only call this function if the group doesn't exist yet. + * Because, we are about to add a dummy key, so we would have to + * be sure that the key doesn't exist. */ + nm_assert(!g_key_file_has_group(keyfile, group)); + + /* Ensure the group is present. + * There is no API for that, so add and remove a dummy key. + * For a profile it matters whether a setting is present or not, + * and we need to ensure that we persist the presence of the setting to keyfile*/ + g_key_file_set_value(keyfile, group, ".X", "1"); + g_key_file_remove_key(keyfile, group, ".X", NULL); +} diff --git a/src/libnm-glib-aux/nm-keyfile-aux.h b/src/libnm-glib-aux/nm-keyfile-aux.h index 7ada40299..50cfdfcd3 100644 --- a/src/libnm-glib-aux/nm-keyfile-aux.h +++ b/src/libnm-glib-aux/nm-keyfile-aux.h @@ -58,4 +58,6 @@ void nm_key_file_db_prune(NMKeyFileDB *self, /*****************************************************************************/ +void nm_key_file_add_group(GKeyFile *keyfile, const char *group); + #endif /* __NM_KEYFILE_AUX_H__ */