fixeria has uploaded this change for review.

View Change

vty: fix 'write file FILE' breaking 'show startup-config'

Change-Id: I224ae41096c12f544dfe35a2c3f381b3bb3ba75e
Related: OS#6440
---
M src/vty/command.c
1 file changed, 17 insertions(+), 5 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/17/36617/1
diff --git a/src/vty/command.c b/src/vty/command.c
index 1719690..d37516a 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -3490,6 +3490,7 @@
"Write to configuration file\n"
"Set file path to store the config, or replace if already exists\n")
{
+ const char *config_file;
char *failed_file;
int rc;

@@ -3503,15 +3504,16 @@
}

if (argc == 1)
- host_config_set(argv[0]);
-
- if (host.config == NULL) {
+ config_file = argv[0];
+ else /* write to the startup config file */
+ config_file = host_config_file();
+ if (config_file == 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(config_file, &failed_file);
switch (rc) {
case -1:
vty_out(vty, "Can't open configuration file %s.%s",
@@ -3544,7 +3546,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", config_file, VTY_NEWLINE);
rc = CMD_SUCCESS;
break;
}

To view, visit change 36617. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I224ae41096c12f544dfe35a2c3f381b3bb3ba75e
Gerrit-Change-Number: 36617
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-MessageType: newchange