From: Kruti Pendharkar Date: Tue, 24 Jun 2025 16:26:22 +0000 (-0700) Subject: Change to common source files not applicable to open-vm-tools. X-Git-Tag: stable-13.1.0~154 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=35b7a45080a367c7be3ebc6b21d5e9a6d776e58d;p=thirdparty%2Fopen-vm-tools.git Change to common source files not applicable to open-vm-tools. --- diff --git a/open-vm-tools/vgauth/common/prefs.h b/open-vm-tools/vgauth/common/prefs.h index 6c58f3f4b..718053257 100644 --- a/open-vm-tools/vgauth/common/prefs.h +++ b/open-vm-tools/vgauth/common/prefs.h @@ -1,5 +1,6 @@ /********************************************************* - * Copyright (C) 2011-2019,2023 VMware, Inc. All rights reserved. + * Copyright (c) 2011-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 @@ -167,6 +168,9 @@ msgCatalog = /etc/vmware-tools/vgauth/messages /** Where the localized version of the messages were installed. */ #define VGAUTH_PREF_LOCALIZATION_DIR "msgCatalog" +/** If symlinks or junctions are allowed in alias store file path */ +#define VGAUTH_PREF_ALLOW_SYMLINKS "allowSymlinks" + /* * Pref values */ diff --git a/open-vm-tools/vgauth/serviceImpl/alias.c b/open-vm-tools/vgauth/serviceImpl/alias.c index b9d5134bc..052ab7bfb 100644 --- a/open-vm-tools/vgauth/serviceImpl/alias.c +++ b/open-vm-tools/vgauth/serviceImpl/alias.c @@ -67,6 +67,7 @@ #define ALIASSTORE_FILE_PREFIX "user-" #define ALIASSTORE_FILE_SUFFIX ".xml" +static gboolean allowSymlinks = FALSE; static gchar *aliasStoreRootDir = DEFAULT_ALIASSTORE_ROOT_DIR; #ifdef _WIN32 @@ -647,18 +648,20 @@ ServiceLoadFileContentsWin(const gchar *fileName, goto done; } - /* - * Check if fileName is real path. - */ - if ((realPath = ServiceFileGetPathByHandle(hFile)) == NULL) { - err = VGAUTH_E_FAIL; - goto done; - } - if (g_strcmp0(realPath, fileName) != 0) { - Warning("%s: Real path (%s) is not same as file path (%s)\n", - __FUNCTION__, realPath, fileName); - err = VGAUTH_E_FAIL; - goto done; + if (!allowSymlinks) { + /* + * Check if fileName is real path. + */ + if ((realPath = ServiceFileGetPathByHandle(hFile)) == NULL) { + err = VGAUTH_E_FAIL; + goto done; + } + if (_stricmp(realPath, fileName) != 0) { + Warning("%s: Real path (%s) is not same as file path (%s)\n", + __FUNCTION__, realPath, fileName); + err = VGAUTH_E_FAIL; + goto done; + } } /* @@ -858,19 +861,21 @@ ServiceLoadFileContentsPosix(const gchar *fileName, goto done; } - /* - * Check if fileName is real path. - */ - if (realpath(fileName, realPath) == NULL) { - Warning("%s: realpath() failed. errno (%d)\n", __FUNCTION__, errno); - err = VGAUTH_E_FAIL; - goto done; - } - if (g_strcmp0(realPath, fileName) != 0) { - Warning("%s: Real path (%s) is not same as file path (%s)\n", - __FUNCTION__, realPath, fileName); - err = VGAUTH_E_FAIL; - goto done; + if (!allowSymlinks) { + /* + * Check if fileName is real path. + */ + if (realpath(fileName, realPath) == NULL) { + Warning("%s: realpath() failed. errno (%d)\n", __FUNCTION__, errno); + err = VGAUTH_E_FAIL; + goto done; + } + if (g_strcmp0(realPath, fileName) != 0) { + Warning("%s: Real path (%s) is not same as file path (%s)\n", + __FUNCTION__, realPath, fileName); + err = VGAUTH_E_FAIL; + goto done; + } } /* @@ -3402,6 +3407,10 @@ ServiceAliasInitAliasStore(void) defaultDir = g_strdup(DEFAULT_ALIASSTORE_ROOT_DIR); #endif + allowSymlinks = Pref_GetBool(gPrefs, + VGAUTH_PREF_ALLOW_SYMLINKS, + VGAUTH_PREF_GROUP_NAME_SERVICE, + FALSE); /* * Find the alias store directory. This allows an installer to put * it somewhere else if necessary.