initrd: add comment on top of connections and conf snippets
Example: $ cat /run/NetworkManager/conf.d/15-carrier-timeout.conf # Created by nm-initrd-generator (from "rd.net.timeout.carrier") [device-15-carrier-timeout] match-device=* carrier-wait-timeout=12000
This commit is contained in:
@@ -25,6 +25,18 @@
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_keyfile_comment(GKeyFile *keyfile, char *reason)
|
||||||
|
{
|
||||||
|
gs_free char *comment = NULL;
|
||||||
|
|
||||||
|
comment = g_strdup_printf(" Created by nm-initrd-generator%s%s%s",
|
||||||
|
reason ? " (" : "",
|
||||||
|
reason ? reason : "",
|
||||||
|
reason ? ")" : "");
|
||||||
|
g_key_file_set_comment(keyfile, NULL, NULL, comment, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
output_conn(gpointer key, gpointer value, gpointer user_data)
|
output_conn(gpointer key, gpointer value, gpointer user_data)
|
||||||
{
|
{
|
||||||
@@ -48,9 +60,12 @@ output_conn(gpointer key, gpointer value, gpointer user_data)
|
|||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
file = nm_keyfile_write(connection, NM_KEYFILE_HANDLER_FLAGS_NONE, NULL, NULL, &error);
|
file = nm_keyfile_write(connection, NM_KEYFILE_HANDLER_FLAGS_NONE, NULL, NULL, &error);
|
||||||
if (file == NULL)
|
if (!file)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
|
if (connections_dir)
|
||||||
|
add_keyfile_comment(file, NULL);
|
||||||
|
|
||||||
data = g_key_file_to_data(file, &len, &error);
|
data = g_key_file_to_data(file, &len, &error);
|
||||||
if (!data)
|
if (!data)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
@@ -198,6 +213,8 @@ main(int argc, char *argv[])
|
|||||||
NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE "-15-carrier-timeout",
|
NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE "-15-carrier-timeout",
|
||||||
NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT,
|
NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT,
|
||||||
carrier_timeout_sec * 1000);
|
carrier_timeout_sec * 1000);
|
||||||
|
if (!dump_to_stdout)
|
||||||
|
add_keyfile_comment(keyfile, "from \"rd.net.timeout.carrier\"");
|
||||||
|
|
||||||
v = (NMUtilsNamedValue){
|
v = (NMUtilsNamedValue){
|
||||||
.name = g_strdup_printf("%s/15-carrier-timeout.conf", run_config_dir),
|
.name = g_strdup_printf("%s/15-carrier-timeout.conf", run_config_dir),
|
||||||
|
Reference in New Issue
Block a user