Read hostname after setting up loopback interface
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 22 Apr 2009 20:39:09 +0000 (21:39 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 22 Apr 2009 20:39:09 +0000 (21:39 +0100)
plugins/loopback.c

index 22a61fb..04b29e1 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <errno.h>
 #include <unistd.h>
+#include <limits.h>
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <connman/plugin.h>
 #include <connman/log.h>
 
+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;
 }