static void determine_hostname(void)
{
- static char buf[256];
+ static char buf[257];
if (!hostname) {
if (gethostname(buf, 255) == -1) {
perror("gethostname");
- hostname = "localhost";
+ hostname = "localhost.";
} else {
+ // ensure the hostname is FQDN
+ if (!strchr(buf, '.')) {
+ size_t len = strlen(buf);
+ buf[len] = '.';
+ buf[len+1] = '\0';
+ }
hostname = buf;
}
+ } else {
+ if (!strchr(hostname, '.')) {
+ abortf("Hostname must be FQDN.\n(If necessary, put a period at the end, like so: --hostname '%s.')\n", hostname);
+ }
}
}