From ea4b917988a6b7e153e4b03b2444fdb2581bef9b Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 22 Apr 2009 21:39:09 +0100 Subject: Read hostname after setting up loopback interface --- plugins/loopback.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'plugins/loopback.c') diff --git a/plugins/loopback.c b/plugins/loopback.c index 22a61fb9..04b29e1d 100644 --- a/plugins/loopback.c +++ b/plugins/loopback.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,22 @@ #include #include +static int setup_hostname(void) +{ + char name[HOST_NAME_MAX + 1]; + + memset(name, 0, sizeof(name)); + + if (gethostname(name, HOST_NAME_MAX) < 0) { + connman_error("Failed to get current hostname"); + return -EIO; + } + + connman_info("System hostname is %s", name); + + return 0; +} + static int loopback_init(void) { struct ifreq ifr; @@ -98,6 +115,8 @@ static int loopback_init(void) done: close(sk); + setup_hostname(); + return err; } -- cgit v1.2.3