From: Kruti Pendharkar Date: Fri, 17 Oct 2025 04:25:49 +0000 (-0700) Subject: Change to common source files not applicable to open-vm-tools. X-Git-Tag: stable-13.1.0~52 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=efdab83797a5b8ccbb9f4de74c56969d0baffdae;p=thirdparty%2Fopen-vm-tools.git Change to common source files not applicable to open-vm-tools. --- diff --git a/open-vm-tools/libvmtools/i18n.c b/open-vm-tools/libvmtools/i18n.c index 3085f72d7..bbed57ed4 100644 --- a/open-vm-tools/libvmtools/i18n.c +++ b/open-vm-tools/libvmtools/i18n.c @@ -1,5 +1,6 @@ /********************************************************* - * Copyright (C) 2010-2020 VMware, Inc. All rights reserved. + * Copyright (c) 2010-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 @@ -216,12 +217,22 @@ MsgGetUserLanguage(void) * Windows implementation. Derive the ISO names from the user's current * locale. */ + LCID locale; + DWORD sessionId = 0; wchar_t ctryName[10]; /* MSDN says: max is nine characters + terminator. */ wchar_t langName[10]; /* MSDN says: max is nine characters + terminator. */ - if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, + if (ProcessIdToSessionId(GetCurrentProcessId(), &sessionId) && sessionId == 0) { + locale = LOCALE_SYSTEM_DEFAULT; + g_debug("%s: get SYSTEM default locale.\n", __FUNCTION__); + } else { + locale = LOCALE_USER_DEFAULT; + g_debug("%s: get USER default locale.\n", __FUNCTION__); + } + + if (GetLocaleInfo(locale, LOCALE_SISO3166CTRYNAME, ctryName, ARRAYSIZE(ctryName)) == 0 || - GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, + GetLocaleInfo(locale, LOCALE_SISO639LANGNAME, langName, ARRAYSIZE(langName)) == 0) { g_warning("Couldn't retrieve user locale data, error = %u.", GetLastError()); lang = g_strdup("C"); @@ -675,7 +686,7 @@ VMTools_BindTextDomain(const char *domain, lang = usrlang; } - g_debug("%s: user locale=%s\n", __FUNCTION__, lang); + g_debug("%s: using locale=%s\n", __FUNCTION__, lang); /* * Use the default install directory if none is provided. diff --git a/open-vm-tools/vgauth/common/i18n.c b/open-vm-tools/vgauth/common/i18n.c index 6d1292d62..59ee3858c 100644 --- a/open-vm-tools/vgauth/common/i18n.c +++ b/open-vm-tools/vgauth/common/i18n.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (c) 2011-2019,2024 Broadcom. All Rights Reserved. + * Copyright (c) 2010-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 @@ -448,12 +448,22 @@ MsgGetUserLanguage(void) * Windows implementation. Derive the ISO names from the user's current * locale. */ + LCID locale; + DWORD sessionId = 0; wchar_t ctryName[10]; /* MSDN says: max is nine characters + terminator. */ wchar_t langName[10]; /* MSDN says: max is nine characters + terminator. */ - if (GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, + if (ProcessIdToSessionId(GetCurrentProcessId(), &sessionId) && sessionId == 0) { + locale = LOCALE_SYSTEM_DEFAULT; + g_debug("%s: get SYSTEM default locale.\n", __FUNCTION__); + } else { + locale = LOCALE_USER_DEFAULT; + g_debug("%s: get USER default locale.\n", __FUNCTION__); + } + + if (GetLocaleInfoW(locale, LOCALE_SISO3166CTRYNAME, ctryName, (sizeof(ctryName)/sizeof(langName[0]))) == 0 || - GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, + GetLocaleInfoW(locale, LOCALE_SISO639LANGNAME, langName, (sizeof(langName)/sizeof(langName[0]))) == 0) { g_warning("Couldn't retrieve user locale data, error = %u.", GetLastError()); lang = g_strdup("C"); @@ -709,7 +719,7 @@ I18n_BindTextDomain(const char *domain, * to the installed location. */ - g_debug("%s: user locale=%s\n", __FUNCTION__, lang); + g_debug("%s: using locale=%s\n", __FUNCTION__, lang); file = g_strdup_printf("%s%smessages%s%s%s%s.vmsg", catdir, DIRSEPS, DIRSEPS, lang, DIRSEPS, domain);