Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dotnet] - remove ubuntu:noble's ubuntu user capturing 1000 uid & gid #1178

Merged
9 changes: 9 additions & 0 deletions src/dotnet/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ ARG VARIANT=9.0-bookworm-slim
FROM mcr.microsoft.com/dotnet/sdk:${VARIANT}
ENV PATH $PATH:/home/vscode/.dotnet:/home/vscode/.dotnet/tools

ARG VARIANT
RUN if [ "${VARIANT#*noble}" != "$VARIANT" ]; then \
gauravsaini04 marked this conversation as resolved.
Show resolved Hide resolved
if id "ubuntu" &>/dev/null; then \
samruddhikhandale marked this conversation as resolved.
Show resolved Hide resolved
echo "Deleting user 'ubuntu' for $VARIANT" && userdel -f -r ubuntu || echo "Failed to delete ubuntu user for $VARIANT"; \
else \
echo "User 'ubuntu' does not exist for $VARIANT"; \
fi; \
fi

# clear this environment variable so xml docs from NuGet packages are unpackaged. The default dotnet/sdk image sets it to 'skip'.
# see https://github.com/dotnet/dotnet-docker/issues/2790
ENV NUGET_XMLDOC_MODE=
18 changes: 18 additions & 0 deletions src/dotnet/test-project/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,23 @@ check "usr-local-etc-config-does-not-exist" test ! -f "/usr/local/etc/gitconfig"

checkPackageVersion "pwsh" "7.4.4" "PowerShell"

check_ubuntu_user() {
gauravsaini04 marked this conversation as resolved.
Show resolved Hide resolved
if ! id -u ubuntu > /dev/null 2>&1; then
echo -e "✔️ User ubuntu does not exist."
else
echo -e "❌ User ubuntu exists."
exit 1;
fi
echo -e "\n\nList of all users:";
cat /etc/passwd;
}

if grep -q 'VERSION_CODENAME=noble' /etc/os-release; then
echo -e "\nThe base image is ubuntu:noble. Checking user Ubuntu.."
check "uid" "check_ubuntu_user"
else
echo -e "\nCannot check user Ubuntu. The base image is not ubuntu:noble."
fi

# Report result
reportResults
Loading