return only host part in local hostname if FQDN flag set to false
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 14 Sep 2017 08:56:51 +0000 (11:56 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 14 Sep 2017 08:56:51 +0000 (11:56 +0300)
src/libnetxms/tools.cpp

index 71f0689..0693b95 100644 (file)
@@ -3001,6 +3001,10 @@ TCHAR LIBNETXMS_EXPORTABLE *GetLocalHostName(TCHAR *buffer, size_t size, bool fq
    }
    else
    {
+      // some systems return FQDN in gethostname call
+      char *p = strchr(hostname, '.');
+      if (p != NULL)
+         *p = 0;
 #ifdef UNICODE
       MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, hostname, -1, buffer, size);
 #else