summaryrefslogtreecommitdiff
path: root/lib/command.c
diff options
context:
space:
mode:
authorMitesh Kanjariya <mitesh@cumulusnetworks.com>2017-08-25 15:26:33 -0700
committerMitesh Kanjariya <mitesh@cumulusnetworks.com>2017-08-25 15:39:14 -0700
commit4a48f1b70b5afe6371fc188811c09541afd6008d (patch)
tree0ec5cb4a9494f9689a44bba46c3445f07372162e /lib/command.c
parent6f9d219ae6cd65c8bdeda34f28805c7380ceed41 (diff)
lib: Fix make check failures
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
Diffstat (limited to 'lib/command.c')
-rw-r--r--lib/command.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/command.c b/lib/command.c
index 2d262c1146..13fee70c62 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;
}