hashicorp / hashicorp/packer-plugin-docker

file provisioner changes permissions of parent directory when uploading directory

Open
#16 0 comments 0 reactions 0 assignees View on GitHub
bug builder/docker track-internal
Dominant language
Go
Stars
40
Forks
29
PR merge metrics
No merged PRs in 30d

Description

_This issue was originally opened by @GeorgFleig as hashicorp/packer#5955. It was migrated here as a result of the [Packer plugin split](https://github.com/hashicorp/packer/issues/8610#issuecomment-770034737). The original body of the issue is below._


- Packer version from `packer version`
v1.2.1
- Host platform
Debian Buster
- Debug log output from `PACKER_LOG=1 packer build template.json`.
https://gist.github.com/GeorgFleig/39a7e6703429486f41408c8ac677cc50#file-debug_log-txt
- The _simplest example template and scripts_ needed to reproduce the bug.
https://gist.github.com/GeorgFleig/39a7e6703429486f41408c8ac677cc50#file-test-json

When I use the file provisioner to upload files into a Docker container in a folder not owned by root, the permissions of the parent folder of the destination are changed.

Example:
before copy
```
docker: drwxr-xr-x 2 build build 4096 Feb 28 14:57 .
docker: drwxr-xr-x 1 root root 4096 Feb 28 14:57 ..
docker: -rw-r--r-- 1 build build 220 May 15 2017 .bash_logout
docker: -rw-r--r-- 1 build build 3526 May 15 2017 .bashrc
docker: -rw-r--r-- 1 build build 675 May 15 2017 .profile
```
after copy
```
docker: drwxr-xr-x 2 root build 4096 Feb 28 14:57 .
docker: drwxr-xr-x 1 root root 4096 Feb 28 14:57 ..
docker: -rw-r--r-- 1 root build 220 May 15 2017 .bash_logout
docker: -rw-r--r-- 1 root build 3526 May 15 2017 .bashrc
docker: -rw-r--r-- 1 root build 675 May 15 2017 .profile
docker: -rw-r--r-- 1 root build 538 Feb 28 10:20 file1.json
docker: -rwxr-xr-x 1 root build 2704 Feb 28 12:23 file1.json
```
The owner of the parent folder /home/build is changed from build to root.

This happens when I copy a folder or the contents of a folder into that target. When I copy only a single file, the new file is owned by root:root as expected while all other permissions stay untouched.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.