#ifndef IMGCUST_UNITTEST
static const char* RUNDIR = "/run";
static const char* VARRUNDIR = "/var/run";
+static const char* VARRUNIMCDIR = "/var/run/vmware-imc";
#endif
static const char* TMPDIR = "/tmp";
#ifdef IMGCUST_UNITTEST
baseDirPath = TMPDIR;
#else
+ // PR 2942062, Use /var/run/vmware-imc if the directory exists
// PR 2127543, Use /var/run or /run but /tmp firstly
- if (File_IsDirectory(VARRUNDIR)) {
+ if (File_IsDirectory(VARRUNIMCDIR)) {
+ baseDirPath = VARRUNIMCDIR;
+ } else if (File_IsDirectory(VARRUNDIR)) {
baseDirPath = VARRUNDIR;
} else if (File_IsDirectory(RUNDIR)) {
baseDirPath = RUNDIR;
/*********************************************************
- * Copyright (C) 2006-2021 VMware, Inc. All rights reserved.
+ * Copyright (C) 2006-2022 VMware, Inc. All rights reserved.
*
* 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
int randIndex;
#ifndef _WIN32
/*
- * PR 2115630. On Linux, use /var/run or /run directory
- * to hold the package.
+ * The directories in the array must be sorted by priority from high to low.
+ * PR 2942062. On Nested ESXi, use /var/run/vmware-imc directory to hold the
+ * package if it exists.
+ * PR 2115630. On Linux, use /var/run or /run directory to hold the package.
*/
- const char *runDir = "/run";
- const char *varRunDir = "/var/run";
-
- if (File_IsDirectory(varRunDir)) {
- dir = strdup(varRunDir);
- if (dir == NULL) {
- g_warning("%s: strdup failed\n", __FUNCTION__);
- goto exit;
- }
- } else if (File_IsDirectory(runDir)) {
- dir = strdup(runDir);
- if (dir == NULL) {
- g_warning("%s: strdup failed\n", __FUNCTION__);
- goto exit;
+ const char *searchDirs[] = {
+ "/var/run/vmware-imc", // The highest priority
+ "/var/run",
+ "/run" // The lowest priority
+ };
+
+ size_t index;
+ for (index = 0; index < ARRAYSIZE(searchDirs); index++) {
+ if (File_IsDirectory(searchDirs[index])) {
+ dir = strdup(searchDirs[index]);
+ if (dir == NULL) {
+ g_warning("%s: strdup failed\n", __FUNCTION__);
+ goto exit;
+ }
+ break;
}
}
#endif