Commit 452f8e2e authored by Mike Frysinger's avatar Mike Frysinger

hostname: -s: do not look up details via dns

This changes the hostname behavior to match other systems and its own
documentation.  Namely, that -s just parses the result of the active
gethostname() and does not attempt any network/DNS traffic.  Other
distros like Fedora/RedHat and Debian/Ubuntu have also changed their
behavior in this regard.

URL: https://bugzilla.redhat.com/319981
URL: https://bugzilla.redhat.com/531702
URL: https://bugs.debian.org/552482
URL: https://bugs.gentoo.org/515836
parent 8e9db22b
......@@ -201,11 +201,6 @@ static void showhname(char *hname, int c)
case 'f':
printf("%s\n", hp->h_name);
break;
case 's':
if (p != NULL)
*p = '\0';
printf("%s\n", hp->h_name);
break;
}
}
......@@ -392,7 +387,12 @@ int main(int argc, char **argv)
fprintf(stderr, _("gethostname()=`%s'\n"), myname);
if (!type)
printf("%s\n", myname);
else
else if (type == 's') {
char *p = strchr(myname, '.');
if (p)
*p = '\0';
printf("%s\n", myname);
} else
showhname(myname, type);
break;
case 3:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment