diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-05-20 16:55:57 -0700 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-05-20 16:55:57 -0700 |
| commit | e442116524b9471cfe796f15526426924c6d7fea (patch) | |
| tree | d648b2c7121c4cd92ce1bf5a8296c0ef5c9c9791 /lib/command.c | |
| parent | d998c0f7138e7b4ecdd49dbbc8257bc13cebde35 (diff) | |
vtysh-integrated-fix.patch
Lost config when switching back and forth between 'service integrated-vtysh-config'.
Also it was possible to have config files not be read in if they were not generated.
Ticket: CM-6011, CM-6033
Reviewed By: Daniel Walton <dwalton@cumulusnetworks.com>
Testing Done: See bugs
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/lib/command.c b/lib/command.c index 07f8674e30..b034369d98 100644 --- a/lib/command.c +++ b/lib/command.c @@ -3010,6 +3010,7 @@ DEFUN (config_write_file, char *config_file_sav = NULL; int ret = CMD_WARNING; struct vty *file_vty; + struct stat conf_stat; /* Check and see if we are operating under vtysh configuration */ if (host.config == NULL) @@ -3058,25 +3059,28 @@ DEFUN (config_write_file, } vty_close (file_vty); - if (unlink (config_file_sav) != 0) - if (errno != ENOENT) - { - vty_out (vty, "Can't unlink backup configuration file %s.%s", config_file_sav, - VTY_NEWLINE); - goto finished; - } - if (link (config_file, config_file_sav) != 0) + if (stat(config_file, &conf_stat) >= 0) { - vty_out (vty, "Can't backup old configuration file %s.%s", config_file_sav, - VTY_NEWLINE); - goto finished; - } - sync (); - if (unlink (config_file) != 0) - { - vty_out (vty, "Can't unlink configuration file %s.%s", config_file, - VTY_NEWLINE); - goto finished; + if (unlink (config_file_sav) != 0) + if (errno != ENOENT) + { + vty_out (vty, "Can't unlink backup configuration file %s.%s", config_file_sav, + VTY_NEWLINE); + goto finished; + } + if (link (config_file, config_file_sav) != 0) + { + vty_out (vty, "Can't backup old configuration file %s.%s", config_file_sav, + VTY_NEWLINE); + goto finished; + } + sync (); + if (unlink (config_file) != 0) + { + vty_out (vty, "Can't unlink configuration file %s.%s", config_file, + VTY_NEWLINE); + goto finished; + } } if (link (config_file_tmp, config_file) != 0) { |
