fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/40219?usp=email )
Change subject: vty: config_write_file_cmd: keep host.config intact ......................................................................
vty: config_write_file_cmd: keep host.config intact
TODO
Change-Id: I07daba20209f275673967175211193a3731ff1e2 Related: OS#6440 --- M src/vty/command.c 1 file changed, 8 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/19/40219/1
diff --git a/src/vty/command.c b/src/vty/command.c index 8594290..38bbbb2 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -3489,6 +3489,7 @@ "Set file path to store the config, or replace if already exists\n") { char *failed_file; + const char *path; int rc;
if (host.app_info->config_is_consistent) { @@ -3500,16 +3501,18 @@ } }
- if (argc == 1) - host_config_set(argv[0]); + if (argc == 1) /* store to a new file */ + path = argv[0]; + else /* overwrite the startup config */ + path = host.config;
- if (host.config == NULL) { + if (path == NULL) { vty_out(vty, "Can't save to configuration file, using vtysh.%s", VTY_NEWLINE); return CMD_WARNING; }
- rc = write_config_file(host.config, &failed_file); + rc = write_config_file(path, &failed_file); switch (rc) { case -1: vty_out(vty, "Can't open configuration file %s.%s", @@ -3542,7 +3545,7 @@ rc = CMD_WARNING; break; default: - vty_out(vty, "Configuration saved to %s%s", host.config, VTY_NEWLINE); + vty_out(vty, "Configuration saved to %s%s", path, VTY_NEWLINE); rc = CMD_SUCCESS; break; }