From e06b295df02bc401349463ba72157ffbdc4f77c8 Mon Sep 17 00:00:00 2001 From: Elton Stoneman Date: Wed, 3 May 2017 15:22:42 +0100 Subject: [PATCH] Change ownership to app pool user for copied files --- Functions/Private/Artifacts/IIS/Generate_IIS.ps1 | 13 ++++++++++++- Image2Docker.psd1 | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Functions/Private/Artifacts/IIS/Generate_IIS.ps1 b/Functions/Private/Artifacts/IIS/Generate_IIS.ps1 index 7a4f003..b894c69 100644 --- a/Functions/Private/Artifacts/IIS/Generate_IIS.ps1 +++ b/Functions/Private/Artifacts/IIS/Generate_IIS.ps1 @@ -41,6 +41,7 @@ function IncludePath([string[]] $pathParts) { function ProcessDirectory([System.Text.StringBuilder] $DirectoryBuilder, [System.Text.StringBuilder] $CopyBuilder, + [System.Text.StringBuilder] $AclBuilder, [string] $SourcePath, [bool] $FirstDirectory) { Write-Verbose "Processing source directory: $SourcePath" @@ -56,6 +57,12 @@ function ProcessDirectory([System.Text.StringBuilder] $DirectoryBuilder, $copy = 'COPY ["{0}", "{1}"]' -f (Split-Path $SourcePath -Leaf),($targetPath -Replace "\\","/") $null = $CopyBuilder.AppendLine($copy) + $null = $AclBuilder.AppendLine('RUN $path=' + "'C:$targetPath'; ``") + $null = $AclBuilder.AppendLine(' $acl = Get-Acl $path; `') + $null = $AclBuilder.AppendLine(' $newOwner = [System.Security.Principal.NTAccount](''BUILTIN\IIS_IUSRS''); `') + $null = $AclBuilder.AppendLine(' $acl.SetOwner($newOwner); `') + $null = $AclBuilder.AppendLine(' dir -r $path | Set-Acl -aclobject $acl') + $fullSourcePath = $SourcePath if ($global:SourceType -eq [SourceType]::Image -or $global:SourceType -eq [SourceType]::Remote) { @@ -127,7 +134,8 @@ if ($Artifact.Status -eq 'Present') { # process the main site path $DirectoryBuilder = New-Object System.Text.StringBuilder $CopyBuilder = New-Object System.Text.StringBuilder - ProcessDirectory -DirectoryBuilder $DirectoryBuilder -CopyBuilder $CopyBuilder -SourcePath $mainVirtualDir.PhysicalPath -FirstDirectory $true + $AclBuilder = New-Object System.Text.StringBuilder + ProcessDirectory -DirectoryBuilder $DirectoryBuilder -CopyBuilder $CopyBuilder -AclBuilder $AclBuilder -SourcePath $mainVirtualDir.PhysicalPath -FirstDirectory $true # creating the website creates the default app & vdir underneath it $sourcePath = $mainVirtualDir.PhysicalPath @@ -200,6 +208,9 @@ if ($Artifact.Status -eq 'Present') { $null = $ResultBuilder.AppendLine($CopyBuilder.ToString().Trim().TrimEnd('``')) $null = $ResultBuilder.AppendLine('') + + $null = $ResultBuilder.AppendLine($AclBuilder.ToString().Trim().TrimEnd('``')) + $null = $ResultBuilder.AppendLine('') } } diff --git a/Image2Docker.psd1 b/Image2Docker.psd1 index 3637089..c20a797 100644 --- a/Image2Docker.psd1 +++ b/Image2Docker.psd1 @@ -12,7 +12,7 @@ RootModule = 'Image2Docker.psm1' # Version number of this module. -ModuleVersion = '1.8.1' +ModuleVersion = '1.8.2' # Supported PSEditions ### NOTE: This module will not work with PowerShell Core.