diff options
author | Nico Berlee <nico.berlee@on2it.net> | 2022-10-23 16:42:51 +0200 |
---|---|---|
committer | Nico Berlee <nico.berlee@on2it.net> | 2022-10-25 07:40:01 +0200 |
commit | 36d223bb6b758966ca3de434c723791faf7178ee (patch) | |
tree | f2941d5e1a917c14df034198954ce71b2c801071 /vtysh | |
parent | Merge pull request #11673 from cscarpitta/srv6-per-vrf-sid (diff) | |
download | frr-36d223bb6b758966ca3de434c723791faf7178ee.tar.xz frr-36d223bb6b758966ca3de434c723791faf7178ee.zip |
vtysh: Ensure an empty string does not get printed for host/domain
vtysh show running-config is showing:
frr version 8.3.1_git
frr defaults traditional
hostname test
log file /etc/frr/frr.log informational
log timestamp precision 3
domainname
service integrated-vtysh-config
domainname should not be printed in this case at all. If the
host has no search/domainname configured, frr_reload.py
crashes on invalid config from `vtysh show running-config`
Basically the same change as commit a7141b8
Signed-off-by: Nico Berlee <nico.berlee@on2it.net>
Diffstat (limited to 'vtysh')
-rw-r--r-- | vtysh/vtysh_config.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index d98f83dbf..0f28b49f7 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -652,18 +652,21 @@ int vtysh_read_config(const char *config_default_dir, bool dry_run) */ void vtysh_config_write(void) { + const char *name; char line[512]; - if (cmd_hostname_get()) { - snprintf(line, sizeof(line), "hostname %s", cmd_hostname_get()); + name = cmd_hostname_get(); + if (name && name[0] != '\0') { + snprintf(line, sizeof(line), "hostname %s", name); vtysh_config_parse_line(NULL, line); } - if (cmd_domainname_get()) { - snprintf(line, sizeof(line), "domainname %s", - cmd_domainname_get()); + name = cmd_domainname_get(); + if (name && name[0] != '\0') { + snprintf(line, sizeof(line), "domainname %s", name); vtysh_config_parse_line(NULL, line); } + if (vtysh_write_integrated == WRITE_INTEGRATED_NO) vtysh_config_parse_line(NULL, "no service integrated-vtysh-config"); |