summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMitesh Kanjariya <mitesh@cumulusnetworks.com>2017-08-26 00:26:33 +0200
committerMitesh Kanjariya <mitesh@cumulusnetworks.com>2017-08-26 00:39:14 +0200
commit4a48f1b70b5afe6371fc188811c09541afd6008d (patch)
tree0ec5cb4a9494f9689a44bba46c3445f07372162e /lib
parentprovide/use API to get hostname/domainname (diff)
downloadfrr-4a48f1b70b5afe6371fc188811c09541afd6008d.tar.xz
frr-4a48f1b70b5afe6371fc188811c09541afd6008d.zip
lib: Fix make check failures
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/command.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/command.c b/lib/command.c
index 2d262c114..13fee70c6 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -130,6 +130,12 @@ struct host host;
*/
const char *hostname_get(void)
{
+ struct utsname names;
+
+ if (!host.name) {
+ uname(&names);
+ host.name = XSTRDUP(MTYPE_HOST, names.nodename);
+ }
return host.name;
}
@@ -138,6 +144,12 @@ const char *hostname_get(void)
*/
const char *domainname_get(void)
{
+ struct utsname names;
+
+ if (!host.name || !host.domainname) {
+ uname(&names);
+ host.domainname = XSTRDUP(MTYPE_HOST, names.domainname);
+ }
return host.domainname;
}