mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 03:28:31 +00:00
lib: Fix command copy running-config startup-config
to alias write file
Fixes: #1412 Signed-off-by: Juergen Werner <pogojotz@gmx.net>
This commit is contained in:
parent
b9d45c5c67
commit
642962252e
@ -1621,11 +1621,14 @@ DEFUN (show_commandtree,
|
|||||||
return cmd_list_cmds(vty, argc == 3);
|
return cmd_list_cmds(vty, argc == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vty_write_config(struct vty *vty)
|
static int vty_write_config(struct vty *vty)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
struct cmd_node *node;
|
struct cmd_node *node;
|
||||||
|
|
||||||
|
if (host.noconfig)
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
if (vty->type == VTY_TERM) {
|
if (vty->type == VTY_TERM) {
|
||||||
vty_out(vty, "%sCurrent configuration:%s", VTY_NEWLINE,
|
vty_out(vty, "%sCurrent configuration:%s", VTY_NEWLINE,
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
@ -1646,19 +1649,12 @@ static void vty_write_config(struct vty *vty)
|
|||||||
if (vty->type == VTY_TERM) {
|
if (vty->type == VTY_TERM) {
|
||||||
vty_out(vty, "end%s", VTY_NEWLINE);
|
vty_out(vty, "end%s", VTY_NEWLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write current configuration into file. */
|
static int file_write_config(struct vty *vty)
|
||||||
|
|
||||||
DEFUN (config_write,
|
|
||||||
config_write_cmd,
|
|
||||||
"write [<file|memory|terminal>]",
|
|
||||||
"Write running configuration to memory, network, or terminal\n"
|
|
||||||
"Write to configuration file\n"
|
|
||||||
"Write configuration currently in memory\n"
|
|
||||||
"Write configuration to terminal\n")
|
|
||||||
{
|
{
|
||||||
int idx_type = 1;
|
|
||||||
int fd, dirfd;
|
int fd, dirfd;
|
||||||
char *config_file, *slash;
|
char *config_file, *slash;
|
||||||
char *config_file_tmp = NULL;
|
char *config_file_tmp = NULL;
|
||||||
@ -1667,13 +1663,6 @@ DEFUN (config_write,
|
|||||||
struct vty *file_vty;
|
struct vty *file_vty;
|
||||||
struct stat conf_stat;
|
struct stat conf_stat;
|
||||||
|
|
||||||
// if command was 'write terminal' or 'show running-config'
|
|
||||||
if (argc == 2 && (!strcmp(argv[idx_type]->text, "terminal")
|
|
||||||
|| !strcmp(argv[0]->text, "show"))) {
|
|
||||||
vty_write_config(vty);
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (host.noconfig)
|
if (host.noconfig)
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
@ -1773,14 +1762,34 @@ finished:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Write current configuration into file. */
|
||||||
|
|
||||||
|
DEFUN (config_write,
|
||||||
|
config_write_cmd,
|
||||||
|
"write [<file|memory|terminal>]",
|
||||||
|
"Write running configuration to memory, network, or terminal\n"
|
||||||
|
"Write to configuration file\n"
|
||||||
|
"Write configuration currently in memory\n"
|
||||||
|
"Write configuration to terminal\n")
|
||||||
|
{
|
||||||
|
const int idx_type = 1;
|
||||||
|
|
||||||
|
// if command was 'write terminal' or 'write memory'
|
||||||
|
if (argc == 2 && (!strcmp(argv[idx_type]->text, "terminal"))) {
|
||||||
|
return vty_write_config(vty);
|
||||||
|
}
|
||||||
|
|
||||||
|
return file_write_config(vty);
|
||||||
|
}
|
||||||
|
|
||||||
/* ALIAS_FIXME for 'write <terminal|memory>' */
|
/* ALIAS_FIXME for 'write <terminal|memory>' */
|
||||||
DEFUN (show_running_config,
|
DEFUN (show_running_config,
|
||||||
show_running_config_cmd,
|
show_running_config_cmd,
|
||||||
"show running-config",
|
"show running-config",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
"running configuration (same as write terminal/memory)\n")
|
"running configuration (same as write terminal)\n")
|
||||||
{
|
{
|
||||||
return config_write(self, vty, argc, argv);
|
return vty_write_config(vty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ALIAS_FIXME for 'write file' */
|
/* ALIAS_FIXME for 'write file' */
|
||||||
@ -1789,11 +1798,9 @@ DEFUN (copy_runningconf_startupconf,
|
|||||||
"copy running-config startup-config",
|
"copy running-config startup-config",
|
||||||
"Copy configuration\n"
|
"Copy configuration\n"
|
||||||
"Copy running config to... \n"
|
"Copy running config to... \n"
|
||||||
"Copy running config to startup config (same as write file)\n")
|
"Copy running config to startup config (same as write file/memory)\n")
|
||||||
{
|
{
|
||||||
if (!host.noconfig)
|
return file_write_config(vty);
|
||||||
vty_write_config(vty);
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
}
|
||||||
/** -- **/
|
/** -- **/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user