]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Change to common source files not applicable to open-vm-tools.
authorKruti Pendharkar <kp025370@broadcom.com>
Tue, 24 Jun 2025 16:26:22 +0000 (09:26 -0700)
committerKruti Pendharkar <kp025370@broadcom.com>
Tue, 24 Jun 2025 16:26:22 +0000 (09:26 -0700)
open-vm-tools/vgauth/common/prefs.h
open-vm-tools/vgauth/serviceImpl/alias.c

index 6c58f3f4b4db278381c47d7354f6ce09a1a93de5..71805325747b53fc5f8ab816929911cb893a8aae 100644 (file)
@@ -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
  */
index b9d5134bc6153a8c4ce3d809a448b20d131dd021..052ab7bfb852ce5b67d0709a27aed76ba2ef2bef 100644 (file)
@@ -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.