From 8746e5d7befb3d8496f32c6370c37c37992d21fc Mon Sep 17 00:00:00 2001 From: Egor Date: Thu, 22 Jan 2026 17:02:40 +0200 Subject: [PATCH] main: ensure hostname is FQDN --- src/main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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); + } } } -- 2.56.0