From ec0fad5ebd4ca0724b1d6be4966413fc31741ff6 Mon Sep 17 00:00:00 2001 From: Pablo Ulloa Date: Mon, 18 Mar 2024 23:40:12 +0000 Subject: [PATCH] Coalescing home directory for remoteUser following commons-utils logic --- package.json | 2 +- src/spec-configuration/containerFeaturesConfiguration.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c457362c..45abd623 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@devcontainers/cli", "description": "Dev Containers CLI", - "version": "0.57.0", + "version": "0.57.1", "bin": { "devcontainer": "devcontainer.js" }, diff --git a/src/spec-configuration/containerFeaturesConfiguration.ts b/src/spec-configuration/containerFeaturesConfiguration.ts index d5cf48ef..bf47adef 100644 --- a/src/spec-configuration/containerFeaturesConfiguration.ts +++ b/src/spec-configuration/containerFeaturesConfiguration.ts @@ -291,10 +291,12 @@ function escapeQuotesForShell(input: string) { export function getFeatureLayers(featuresConfig: FeaturesConfig, containerUser: string, remoteUser: string, isBuildah = false, useBuildKitBuildContexts = false, contentSourceRootPath = '/tmp/build-features') { + const coalesceHomeDir = (user: string) => `$(if [ -d "$(${getEntPasswdShellCommand(user)} | cut -d: -f6)" ]; then echo "$(${getEntPasswdShellCommand(user)} | cut -d: -f6)"; else echo "/home/${user}"; fi)`; + const builtinsEnvFile = `${path.posix.join(FEATURES_CONTAINER_TEMP_DEST_FOLDER, 'devcontainer-features.builtin.env')}`; let result = `RUN \\ echo "_CONTAINER_USER_HOME=$(${getEntPasswdShellCommand(containerUser)} | cut -d: -f6)" >> ${builtinsEnvFile} && \\ -echo "_REMOTE_USER_HOME=$(${getEntPasswdShellCommand(remoteUser)} | cut -d: -f6)" >> ${builtinsEnvFile} +echo "_REMOTE_USER_HOME=${coalesceHomeDir(remoteUser)}" >> ${builtinsEnvFile} `;