From 02eb604ceb69f150d3ea104190ef924628001357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 5 Feb 2024 18:23:21 +0800 Subject: [PATCH] Platform (Linux): use $HOSTNAME if available Ref: #710 --- src/util/platform/FFPlatform_unix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/platform/FFPlatform_unix.c b/src/util/platform/FFPlatform_unix.c index 255211a34..22066964d 100644 --- a/src/util/platform/FFPlatform_unix.c +++ b/src/util/platform/FFPlatform_unix.c @@ -150,7 +150,10 @@ static void getUserName(FFPlatform* platform, const struct passwd* pwd) static void getHostName(FFPlatform* platform, const struct utsname* uts) { - ffStrbufAppendS(&platform->hostName, uts->nodename); + const char* hostname = getenv("HOSTNAME"); + if(!ffStrSet(hostname) && uts) + hostname = uts->nodename; + ffStrbufAppendS(&platform->hostName, hostname); } static void getUserShell(FFPlatform* platform, const struct passwd* pwd)