From: Kruti Pendharkar Date: Tue, 22 Apr 2025 08:53:45 +0000 (-0700) Subject: Change to common source file not applicable to open-vm-tools. X-Git-Tag: stable-13.1.0~192 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6a86fed6de4ddc8637886ae9bb49c1d69ea9a4ea;p=thirdparty%2Fopen-vm-tools.git Change to common source file not applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/misc/hostname.c b/open-vm-tools/lib/misc/hostname.c index 376f7bc42..09c59030b 100644 --- a/open-vm-tools/lib/misc/hostname.c +++ b/open-vm-tools/lib/misc/hostname.c @@ -1,5 +1,6 @@ /********************************************************* - * Copyright (C) 2007-2017 VMware, Inc. All rights reserved. + * Copyright (c) 2007-2025 Broadcom. All Rights Reserved. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -28,10 +29,15 @@ #include #endif +#include +#include +#include + #include #include #include #include +#include #include "vmware.h" #include "str.h" @@ -201,6 +207,24 @@ Hostinfo_HostName(void) char *result = NULL; +#ifdef VMX86_SERVER + if (HostType_OSIsSimulator()) { + FILE *f = fopen("/var/run/vmware/HostSim_HostName.txt", "r"); + + if (f != NULL) { + char name[255] = {0}; + + (void)!fread(name, 1, sizeof(name) - 1, f); // ignore the result + fclose(f); + + if (strlen(name) > 0 && Unicode_IsStringValidUTF8(name) == TRUE) { + result = StrUtil_TrimWhitespace(name); + return result; + } + } + } +#endif + if ((uname(&un) == 0) && (*un.nodename != '\0')) { char *p; int error;