Skip to content

Commit

Permalink
fixed: win_copy failure from a VirtualBox share to a local path
Browse files Browse the repository at this point in the history
In the case when a source file/folder is on a VirtualBox share then
win_copy task fails.
E.g.
  - name: Copy file from VirtualBox share
    win_copy:
      src: \\vboxsvr\share\file
      dest: c:\local\path
      remote_src: true

The reason is that .GetAccessControl method fails somehow for a
file/folder on a VirtualBox share.

  PS c:\Users\vboxuser> $file = Get-Item -Path \\vboxsvr\share\file
  PS c:\Users\vboxuser> $file.GetAccessControl();
  Exception calling "GetAccessControl" with "0" argument(s): "Method
  failed with unexpected error code 1."
  ...

<Jordan Borean (jborean93@gmail.com)> (@jborean93) said (see GitHub PR
!33576):

> ... we should just get rid of the ACL stuff in win_copy because;
>
> - There is a bug right now and it isn't actually working
> - When copying a file in Windows manually, it does not bring across the
>   ACL of the source file anyway
> - We can add in a future option that copies the ACL but we should set a
>   flag instead to do this

So, remove the ACL stuff

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Reviewed-by: <Jordan Borean (jborean93@gmail.com)>
  • Loading branch information
ashumkin committed Dec 6, 2017
1 parent aaf2296 commit 185bdeb
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions lib/ansible/modules/windows/win_copy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ Function Copy-File($source, $dest) {
}
$diff += "+$dest`n"

# make sure we set the attributes accordingly
if (-not $check_mode) {
$source_file = Get-Item -Path $source -Force
$dest_file = Get-Item -Path $dest -Force
$dest_file.Attributes = $source_file.Attributes
$dest_file.SetAccessControl($source_file.GetAccessControl())
}

$result.changed = $true
}

Expand All @@ -119,13 +111,6 @@ Function Copy-Folder($source, $dest) {
New-Item -Path $dest -ItemType Container -WhatIf:$check_mode | Out-Null
$diff += "+$dest\`n"
$result.changed = $true

if (-not $check_mode) {
$source_folder = Get-Item -Path $source -Force
$dest_folder = Get-Item -Path $source -Force
$dest_folder.Attributes = $source_folder.Attributes
$dest_folder.SetAccessControl($source_folder.GetAccessControl())
}
}

$child_items = Get-ChildItem -Path $source -Force
Expand Down

0 comments on commit 185bdeb

Please sign in to comment.