summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2022-04-25 06:40:58 +0200
committerGitHub <noreply@github.com>2022-04-25 06:40:58 +0200
commitd45a846e5ca313e5ab132ef57c495cc0407b50d9 (patch)
tree8e0e953356d2bd23d8238120f14b1acf953f5dc1
parentMerge pull request #11064 from opensourcerouting/fix/allow_only_euid_0_runnin... (diff)
parentlib: Ensure an empty string does not get printed for host/domain (diff)
downloadfrr-d45a846e5ca313e5ab132ef57c495cc0407b50d9.tar.xz
frr-d45a846e5ca313e5ab132ef57c495cc0407b50d9.zip
Merge pull request #11067 from donaldsharp/domainname
lib: Ensure an empty string does not get printed for host/domain
-rw-r--r--lib/command.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/command.c b/lib/command.c
index 1989668bf..a42951005 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -445,11 +445,15 @@ static bool full_cli;
/* This function write configuration of this host. */
static int config_write_host(struct vty *vty)
{
- if (cmd_hostname_get())
- vty_out(vty, "hostname %s\n", cmd_hostname_get());
+ const char *name;
- if (cmd_domainname_get())
- vty_out(vty, "domainname %s\n", cmd_domainname_get());
+ name = cmd_hostname_get();
+ if (name && name[0] != '\0')
+ vty_out(vty, "hostname %s\n", name);
+
+ name = cmd_domainname_get();
+ if (name && name[0] != '\0')
+ vty_out(vty, "domainname %s\n", name);
/* The following are all configuration commands that are not sent to
* watchfrr. For instance watchfrr is hardcoded to log to syslog so