From: John Wolfe Date: Tue, 12 Jul 2022 16:56:01 +0000 (-0700) Subject: Common source file changes not directly applicable to open-vm-tools. X-Git-Tag: stable-12.1.0~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df0099727e96292279398c3fbd7f3901f215e4f3;p=thirdparty%2Fopen-vm-tools.git Common source file changes not directly applicable to open-vm-tools. --- diff --git a/open-vm-tools/libDeployPkg/linuxDeployment.c b/open-vm-tools/libDeployPkg/linuxDeployment.c index 2a9b319de..b1f9c8dd0 100644 --- a/open-vm-tools/libDeployPkg/linuxDeployment.c +++ b/open-vm-tools/libDeployPkg/linuxDeployment.c @@ -113,6 +113,7 @@ static const char* ERRORED = "ERRORED"; #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"; @@ -1327,8 +1328,11 @@ Deploy(const char* packageName) #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; diff --git a/open-vm-tools/services/plugins/deployPkg/deployPkg.c b/open-vm-tools/services/plugins/deployPkg/deployPkg.c index ddc1728d8..4d70765a5 100644 --- a/open-vm-tools/services/plugins/deployPkg/deployPkg.c +++ b/open-vm-tools/services/plugins/deployPkg/deployPkg.c @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -441,23 +441,26 @@ DeployPkgGetTempDir(void) 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