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

Clean up file ownership issues #1493

Merged
merged 7 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 3.1/sdk/alpine3.10/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ RUN powershell_version=7.0.0-preview.6 \
&& echo "$powershell_sha512 PowerShell.Linux.Alpine.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.Alpine \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.Alpine.$powershell_version.nupkg \
&& chmod 755 /usr/share/powershell/pwsh \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/bionic/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ RUN powershell_version=7.0.0-preview.6 \
&& echo "$powershell_sha512 PowerShell.Linux.x64.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.x64 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.x64.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/bionic/arm32v7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ RUN powershell_version=7.0.0-preview.6 \
&& echo "$powershell_sha512 PowerShell.Linux.arm32.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.arm32 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.arm32.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/bionic/arm64v8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ RUN powershell_version=7.0.0-preview.6 \
&& echo "$powershell_sha512 PowerShell.Linux.arm64.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.arm64 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.arm64.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/buster/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ RUN powershell_version=7.0.0-preview.6 \
&& echo "$powershell_sha512 PowerShell.Linux.x64.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.x64 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.x64.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/buster/arm32v7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ RUN powershell_version=7.0.0-preview.6 \
&& echo "$powershell_sha512 PowerShell.Linux.arm32.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.arm32 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.arm32.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/buster/arm64v8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ RUN powershell_version=7.0.0-preview.6 \
&& echo "$powershell_sha512 PowerShell.Linux.arm64.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.arm64 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.arm64.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/focal/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ RUN powershell_version=7.0.0-preview.6 \
&& echo "$powershell_sha512 PowerShell.Linux.x64.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.x64 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.x64.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/focal/arm32v7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ RUN powershell_version=7.0.0-preview.6 \
&& echo "$powershell_sha512 PowerShell.Linux.arm32.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.arm32 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.arm32.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/focal/arm64v8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ RUN powershell_version=7.0.0-preview.6 \
&& echo "$powershell_sha512 PowerShell.Linux.arm64.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.arm64 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.arm64.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/nanoserver-1809/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN $powershell_version = '7.0.0-preview.6'; `
}; `
`
\dotnet\dotnet tool install --add-source . --tool-path \powershell --version $powershell_version PowerShell.Windows.x64; `
\dotnet\dotnet nuget locals all --clear; `
Remove-Item -Force PowerShell.Windows.x64.$powershell_version.nupkg; `
Remove-Item -Path \powershell\.store\powershell.windows.x64\$powershell_version\powershell.windows.x64\$powershell_version\powershell.windows.x64.$powershell_version.nupkg -Force

Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/nanoserver-1809/arm32v7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set "powershell_version=7.0.0-preview.6" `
&& call curl -SL --output PowerShell.Windows.arm32.%powershell_version%.nupkg https://pwshtool.blob.core.windows.net/tool/%powershell_version%/PowerShell.Windows.arm32.%powershell_version%.nupkg `
&& mkdir "%ProgramFiles%\powershell" `
&& call "%ProgramFiles%\dotnet\dotnet" tool install --add-source . --tool-path "%ProgramFiles%\powershell" --version %powershell_version% PowerShell.Windows.arm32 `
&& call "%ProgramFiles%\dotnet\dotnet" nuget locals all --clear `
&& call del PowerShell.Windows.arm32.%powershell_version%.nupkg `
&& call del "%ProgramFiles%\powershell\.store\powershell.windows.arm32\%powershell_version%\powershell.windows.arm32\%powershell_version%\powershell.windows.arm32.%powershell_version%.nupkg"

Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/nanoserver-1903/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN $powershell_version = '7.0.0-preview.6'; `
}; `
`
\dotnet\dotnet tool install --add-source . --tool-path \powershell --version $powershell_version PowerShell.Windows.x64; `
\dotnet\dotnet nuget locals all --clear; `
Remove-Item -Force PowerShell.Windows.x64.$powershell_version.nupkg; `
Remove-Item -Path \powershell\.store\powershell.windows.x64\$powershell_version\powershell.windows.x64\$powershell_version\powershell.windows.x64.$powershell_version.nupkg -Force

Expand Down
1 change: 1 addition & 0 deletions 3.1/sdk/nanoserver-1909/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN $powershell_version = '7.0.0-preview.6'; `
}; `
`
\dotnet\dotnet tool install --add-source . --tool-path \powershell --version $powershell_version PowerShell.Windows.x64; `
\dotnet\dotnet nuget locals all --clear; `
Remove-Item -Force PowerShell.Windows.x64.$powershell_version.nupkg; `
Remove-Item -Path \powershell\.store\powershell.windows.x64\$powershell_version\powershell.windows.x64\$powershell_version\powershell.windows.x64.$powershell_version.nupkg -Force

Expand Down
22 changes: 22 additions & 0 deletions tests/Microsoft.DotNet.Docker.Tests/ImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ private static string GetFilterRegexPattern(string filterEnvName)
return filter != null ? $"^{Regex.Escape(filter).Replace(@"\*", ".*").Replace(@"\?", ".")}$" : null;
}

[Theory]
mthalman marked this conversation as resolved.
Show resolved Hide resolved
[MemberData(nameof(GetImageData))]
public void VerifySDKImage_WorldWritableFilesCheck(ImageData imageData)
{
if (imageData.Version < new Version("3.1") || !DockerHelper.IsLinuxContainerModeEnabled)
{
return;
}

string worldWritableDirectoriesWithoutStickyBitCmd = @"find / -xdev -type d \( -perm -0002 -a ! -perm -1000 \)";
string worldWritableFilesCmd = "find / -xdev -type f -perm -o+w";
string command = $"/bin/sh -c \"{worldWritableDirectoriesWithoutStickyBitCmd} && {worldWritableFilesCmd}\"";
mthalman marked this conversation as resolved.
Show resolved Hide resolved

string output = _dockerHelper.Run(
image: imageData.GetImage(DotNetImageType.SDK, _dockerHelper),
name: imageData.GetIdentifier($"WorldWritableFiles"),
command: command
);

Assert.Empty(output);
}

[Theory]
[MemberData(nameof(GetImageData))]
public void VerifySdkImage_EnvironmentVariables(ImageData imageData)
Expand Down