Lookup hostname using gethostbyname instead of uts

Using uts doesn't work if the host has only a nodename, which is often the case on misconfigured systems.
gethostbyname will consolidate the nodename and whatever domainname by using a socket and NIS/YP/NSCD instead of uts ("uname").

Also fixed an indent issue.