Merge pull request #11067 from donaldsharp/domainname

lib: Ensure an empty string does not get printed for host/domain
This commit is contained in:
Donatas Abraitis 2022-04-25 07:40:58 +03:00 committed by GitHub
commit d45a846e5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -445,11 +445,15 @@ static bool full_cli;
/* This function write configuration of this host. */ /* This function write configuration of this host. */
static int config_write_host(struct vty *vty) static int config_write_host(struct vty *vty)
{ {
if (cmd_hostname_get()) const char *name;
vty_out(vty, "hostname %s\n", cmd_hostname_get());
if (cmd_domainname_get()) name = cmd_hostname_get();
vty_out(vty, "domainname %s\n", cmd_domainname_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 /* The following are all configuration commands that are not sent to
* watchfrr. For instance watchfrr is hardcoded to log to syslog so * watchfrr. For instance watchfrr is hardcoded to log to syslog so