From: Egor Date: Thu, 22 Jan 2026 15:02:40 +0000 (+0200) Subject: main: ensure hostname is FQDN X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=8746e5d7befb3d8496f32c6370c37c37992d21fc;p=patchyircd.git main: ensure hostname is FQDN --- diff --git a/src/main.cpp b/src/main.cpp index 91532fa..06ab55c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -169,14 +169,24 @@ static void accept_from_sock(struct listener *listener) 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); + } } }