Skip to content

Commit 1972239

Browse files
committed
Coalescing home directory for remoteUser following commons-utils logic
1 parent 1da368b commit 1972239

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/spec-configuration/containerFeaturesConfiguration.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,14 @@ function escapeQuotesForShell(input: string) {
291291

292292
export function getFeatureLayers(featuresConfig: FeaturesConfig, containerUser: string, remoteUser: string, isBuildah = false, useBuildKitBuildContexts = false, contentSourceRootPath = '/tmp/build-features') {
293293

294+
const coalesceHomeDir = (user: string) => `$(if [ -d "$(${getEntPasswdShellCommand(user)} | cut -d: -f6)" ]; then echo "$(${getEntPasswdShellCommand(user)} | cut -d: -f6)"; else echo "/home/${user}"; fi)`;
295+
294296
const useSELinuxLabel = process.platform === 'linux' && isBuildah;
297+
295298
const builtinsEnvFile = `${path.posix.join(FEATURES_CONTAINER_TEMP_DEST_FOLDER, 'devcontainer-features.builtin.env')}`;
296299
let result = `RUN \\
297300
echo "_CONTAINER_USER_HOME=$(${getEntPasswdShellCommand(containerUser)} | cut -d: -f6)" >> ${builtinsEnvFile} && \\
298-
echo "_REMOTE_USER_HOME=$(${getEntPasswdShellCommand(remoteUser)} | cut -d: -f6)" >> ${builtinsEnvFile}
301+
echo "_REMOTE_USER_HOME=${coalesceHomeDir(remoteUser)}" >> ${builtinsEnvFile}
299302
300303
`;
301304

0 commit comments

Comments
 (0)