summaryrefslogtreecommitdiff
path: root/lib/command.c
diff options
context:
space:
mode:
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;
}