Unverified Commit e7f7d194 authored by Pablo Ulloa's avatar Pablo Ulloa Committed by GitHub

[common-utils] fix bug when user home is custom by base docker (#703)

* [common-utils] fix bug when user home is custom by base docker

* bumped minor version

* reduced conditions to improve readability
parent 9852ca88
{
"id": "common-utils",
"version": "2.1.3",
"version": "2.2.0",
"name": "Common Utilities",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils",
"description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",
......
......@@ -407,6 +407,9 @@ fi
if [ "${USERNAME}" = "root" ]; then
user_home="/root"
# Check if user already has a home directory other than /home/${USERNAME}
elif [ "/home/${USERNAME}" != $( getent passwd $USERNAME | cut -d: -f6 ) ]; then
user_home=$( getent passwd $USERNAME | cut -d: -f6 )
else
user_home="/home/${USERNAME}"
if [ ! -d "${user_home}" ]; then
......
#!/bin/bash
set -e
# Optional: Import test library
source dev-container-features-test-lib
# Definition specific tests
check "user is customUser" grep customUser <(whoami)
check "home is /customHome" grep "/customHome" <(getent passwd customUser | cut -d: -f6)
# Report result
reportResults
FROM ubuntu:focal
RUN groupadd customUser -g 30000 && \
useradd customUser -u 30000 -g 30000 --create-home --home-dir /customHome
#!/bin/bash
set -e
# Optional: Import test library
source dev-container-features-test-lib
# Definition specific tests
check "user is customUser" grep customUser <(whoami)
check "home is /home/customUser" grep "/home/customUser" <(getent passwd customUser | cut -d: -f6)
# Report result
reportResults
......@@ -183,5 +183,21 @@
"configureZshAsDefaultShell": true
}
}
},
"devcontainer-custom-home": {
"build": {
"dockerfile": "Dockerfile"
},
"remoteUser": "customUser",
"features": {
"common-utils": {}
}
},
"devcontainer-custom-user-default-home": {
"image": "mcr.microsoft.com/devcontainers/base:alpine",
"remoteUser": "customUser",
"features": {
"common-utils": {}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment