keyfile: use nm_connection_get_id() more
This commit is contained in:
@@ -695,20 +695,23 @@ nm_keyfile_plugin_write_connection (NMConnection *connection,
|
|||||||
char **out_path,
|
char **out_path,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
NMSettingConnection *s_con;
|
|
||||||
GKeyFile *key_file;
|
GKeyFile *key_file;
|
||||||
char *data;
|
char *data;
|
||||||
gsize len;
|
gsize len;
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
char *filename, *path;
|
char *filename, *path;
|
||||||
int err;
|
int err;
|
||||||
|
const char *id;
|
||||||
|
|
||||||
if (out_path)
|
if (out_path)
|
||||||
g_return_val_if_fail (*out_path == NULL, FALSE);
|
g_return_val_if_fail (*out_path == NULL, FALSE);
|
||||||
|
|
||||||
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
id = nm_connection_get_id (connection);
|
||||||
if (!s_con)
|
if (!id) {
|
||||||
return success;
|
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
|
||||||
|
"%s.%d: connection had no ID", __FILE__, __LINE__);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
key_file = g_key_file_new ();
|
key_file = g_key_file_new ();
|
||||||
nm_connection_for_each_setting_value (connection, write_setting_value, key_file);
|
nm_connection_for_each_setting_value (connection, write_setting_value, key_file);
|
||||||
@@ -716,7 +719,7 @@ nm_keyfile_plugin_write_connection (NMConnection *connection,
|
|||||||
if (!data)
|
if (!data)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
filename = _writer_id_to_filename (nm_setting_connection_get_id (s_con));
|
filename = _writer_id_to_filename (id);
|
||||||
path = g_build_filename (keyfile_dir, filename, NULL);
|
path = g_build_filename (keyfile_dir, filename, NULL);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user