File tree Expand file tree Collapse file tree 12 files changed +89
-8
lines changed
Expand file tree Collapse file tree 12 files changed +89
-8
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
2929 # Set up PowerShell module analysis cache path
3030 PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
3131 # Opt out of SocketsHttpHandler in DotNet Core 2.1 to use HttpClientHandler
32- # with installed libcurl4 package to resolve
32+ # with installed libcurl4 package to resolve
3333 # Invoke-WebRequest : Authentication failed" issue when executing using
3434 # docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [Invoke-WebRequest] [-Uri <HTTPS URL>]
3535 DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
6060 && rm -f /tmp/powershell-linux.tar.gz \
6161 # Create the pwsh symbolic link that points to powershell
6262 && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
63+ # Give all user execute permissions
64+ && chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
6365 # intialize powershell module cache
6466 && pwsh \
6567 -NoLogo \
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
3636 # Set up PowerShell module analysis cache path
3737 PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
3838 # Opt out of SocketsHttpHandler in DotNet Core 2.1 to use HttpClientHandler
39- # with installed libcurl4 package to resolve
39+ # with installed libcurl4 package to resolve
4040 # Invoke-WebRequest : Authentication failed" issue when executing using
4141 # docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [Invoke-WebRequest] [-Uri <HTTPS URL>]
4242 DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
4949 && locale-gen \
5050 # set execute permission on BlackArch strap shell script
5151 && chmod +x /tmp/strap.sh \
52- # update keyring server in /tmp/strap.sh
52+ # update keyring server in /tmp/strap.sh
5353 && sed -i "s|pgp.mit.edu|hkp://pool.sks-keyservers.net|g" /tmp/strap.sh \
5454 # run BlackArch strap shell script
5555 && /tmp/strap.sh \
7575 && rm -f /tmp/powershell-linux.tar.gz \
7676 # Create the pwsh symbolic link that points to powershell
7777 && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
78+ # Give all user execute permissions
79+ && chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
7880 # intialize powershell module cache
7981 && pwsh \
8082 -NoLogo \
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
3838 # Set up PowerShell module analysis cache path
3939 PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
4040 # Opt out of SocketsHttpHandler in DotNet Core 2.1 to use HttpClientHandler
41- # with installed libcurl4 package to resolve
41+ # with installed libcurl4 package to resolve
4242 # Invoke-WebRequest : Authentication failed" issue when executing using
4343 # docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [Invoke-WebRequest] [-Uri <HTTPS URL>]
4444 DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
6969 && apt-get install -y /tmp/powershell.deb \
7070 # remove powershell package
7171 && rm -f /tmp/powershell.deb \
72+ # Give all user execute permissions
73+ && chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
7274 # intialize powershell module cache
7375 && pwsh \
7476 -NoLogo \
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
5353 # Set up PowerShell module analysis cache path
5454 PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
5555 # Opt out of SocketsHttpHandler in DotNet Core 2.1 to use HttpClientHandler
56- # with installed libcurl4 package to resolve
56+ # with installed libcurl4 package to resolve
5757 # Invoke-WebRequest : Authentication failed" issue when executing using
5858 # docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [Invoke-WebRequest] [-Uri <HTTPS URL>]
5959 DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 \
7979 && locale-gen.sh \
8080 # create the pwsh symbolic link that points to powershell
8181 && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
82+ # Give all user execute permissions
83+ && chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
8284 # intialize powershell module cache
8385 && pwsh \
8486 -NoLogo \
Original file line number Diff line number Diff line change @@ -70,6 +70,8 @@ RUN apk add --no-cache \
7070 \
7171 # Create the pwsh-preview symbolic link that points to powershell
7272 && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh-preview \
73+ # Give all user execute permissions
74+ && chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
7375 # intialize powershell module cache
7476 && pwsh \
7577 -NoLogo \
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ FROM ${imageRepo}:${fromTag} AS installer-env
1313ARG PS_VERSION=6.2.0-preview.3
1414ARG PS_PACKAGE=powershell-${PS_VERSION}-linux-x64.tar.gz
1515ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
16- ARG PS_INSTALL_VERSION=6
16+ ARG PS_INSTALL_VERSION=6-preview
1717
1818# define the folder we will be installing PowerShell to
1919ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION
@@ -41,7 +41,7 @@ FROM ${imageRepo}:${fromTag}
4141COPY --from=installer-env ["/opt/microsoft/powershell" , "/opt/microsoft/powershell" ]
4242
4343# Define Args and Env needed to create links
44- ARG PS_INSTALL_VERSION=6
44+ ARG PS_INSTALL_VERSION=6-preview
4545ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
4646 \
4747 # Define ENVs for Localization/Globalization
Original file line number Diff line number Diff line change @@ -67,6 +67,8 @@ RUN apk add --no-cache \
6767 \
6868 # Create the pwsh symbolic link that points to powershell
6969 && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
70+ # Give all user execute permissions
71+ && chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
7072 # intialize powershell module cache
7173 && pwsh \
7274 -NoLogo \
Original file line number Diff line number Diff line change @@ -67,6 +67,8 @@ RUN apk add --no-cache \
6767 \
6868 # Create the pwsh symbolic link that points to powershell
6969 && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
70+ # Give all user execute permissions
71+ && chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
7072 # intialize powershell module cache
7173 && pwsh \
7274 -NoLogo \
Original file line number Diff line number Diff line change @@ -315,6 +315,40 @@ Describe "Linux Containers" -Tags 'Behavior', 'Linux' {
315315 }
316316 }
317317
318+ Context " permissions" {
319+ BeforeAll{
320+
321+ $permissionsTestCases = @ (
322+ $script :linuxContainerRunTests | ForEach-Object {
323+ @ {
324+ Name = $_.Name
325+ Channel = $_.Channel
326+ }
327+ }
328+ )
329+ }
330+
331+ it " The permissions for pwsh should be correct in <channel>-<Name>" - TestCases $permissionsTestCases - Skip:$script :skipLinuxRun {
332+ param (
333+ [Parameter (Mandatory = $true )]
334+ [string ]
335+ $name ,
336+ [string ]
337+ $Channel
338+ )
339+
340+ $path = ' /opt/microsoft/powershell/6/pwsh'
341+
342+ if ($Channel -eq ' preview' )
343+ {
344+ $path = ' /opt/microsoft/powershell/6-preview/pwsh'
345+ }
346+
347+ $permissions = Get-DockerImagePwshPermissions - Name $name - Path $path
348+ $permissions | Should -Match ' ^[\-rw]{3}x([\-rw]{2}x){2}$' - Because ' Everyone should be able to execute'
349+ }
350+ }
351+
318352 Context " default executables" {
319353 BeforeAll{
320354 # apt-utils ca-certificates curl wget apt-transport-https locales gnupg2 inetutils-ping git sudo less procps
Original file line number Diff line number Diff line change @@ -142,6 +142,7 @@ function Get-LinuxContainer
142142 SkipPull = $skipPull
143143 OptionalTests = $testArgs.OptionalTests
144144 TestProperties = $testArgs.TestProperties
145+ Channel = $testArgs.Channel
145146 }
146147 }
147148 }
@@ -175,6 +176,9 @@ function Get-WindowsContainer
175176 SkipGssNtlmSspTests = $testArgs.SkipGssNtlmSspTests
176177 ImageName = $testArgs.BuildArgs.IMAGE_NAME
177178 SkipPull = $skipPull
179+ OptionalTests = $testArgs.OptionalTests
180+ TestProperties = $testArgs.TestProperties
181+ Channel = $testArgs.Channel
178182 }
179183 }
180184 }
@@ -429,6 +433,32 @@ function Get-DockerImageSize
429433 return ($size / 1 mb )
430434}
431435
436+ # get the size of an image
437+ function Get-DockerImagePwshPermissions
438+ {
439+ param (
440+ [parameter (Mandatory )]
441+ [string ] $Name ,
442+ [string ] $Path = ' /opt/microsoft/powershell/6/pwsh'
443+ )
444+
445+ $imageTag = ${Name}
446+
447+ $runParams = @ ()
448+ $runParams += ' --rm'
449+
450+ $runParams += $imageTag
451+ $runParams += ' pwsh'
452+ $runParams += ' -nologo'
453+ $runParams += ' -noprofile'
454+ $runParams += ' -c'
455+ $runParams += " ls -l $Path "
456+
457+ $result = Invoke-Docker - Command run - Params $runParams - SuppressHostOutput - PassThru
458+ Write-Verbose $result - Verbose
459+ return ($result ) -split ' ' | select-object - First 1
460+ }
461+
432462# Builds a Docker image
433463function Invoke-DockerBuild
434464{
You can’t perform that action at this time.
0 commit comments