Permission denied when creating packer_to_cdrom inside a chowned and chmod777 temp folder
- Dominant language
- Go
- Stars
- 15.8k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
#### Overview of the Issue
I am running Packer with a non-default TMPDIR (`TMPDIR=/home/myuser/tmp packer build ...`), where `/home/myuser/tmp` is an empty directory I own, with wide-open permissions (chmod 777). However, Packer gives me permission denied when it tries to copy the cd_files to this directory. I have to use `sudo TMPDIR=/home/myuser/tmp packer build ...` in order to make it work.
#### Reproduction Steps
Create a directory in your home directory, have a packer template specifying cd_files, and launch packer with your user.
### Packer version
Packer v1.8.0
### Simplified Packer Template
```
variables {
build_dir = "build/build"
virtio_win_iso_dir = "**REDACTED**/isos/virtio_win"
# ISOs
win10_iso_url = "file:///**REDACTED**/isos/windows_10_enterprise.iso"
win10_cksum = "sha256:69efac1df9ec8066341d8c9b62297ddece0e6b805533fdb6dd66bc8034fba27a"
}
source "qemu" "base_win10" {
accelerator = "kvm"
communicator = "winrm"
cpus = 1
disable_vnc = true
disk_interface = "virtio"
disk_size = "50G"
format = "qcow2"
iso_checksum = "${ var.win10_cksum }"
iso_url = "${ var.win10_iso_url }"
memory = "8192"
# net_bridge = "virbr0"
shutdown_command = "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\""
shutdown_timeout = "30m"
winrm_password = "**REDACTED**"
winrm_username = "lab_admin"
}
build {
source "qemu.base_win10" {
name = "base_image_win10"
output_directory = "${(var.build_dir)}-${(source.name)}"
vm_name = "${(source.name)}.qcow2"
qemuargs = [["-netdev", "bridge,id=user.0,br=virbr0"], ["-device", "virtio-net,netdev=user.0"]]
winrm_host = "192.168.122.10"
# winrm_port = 5985
winrm_use_ssl = false
winrm_insecure = true
winrm_no_proxy = true
floppy_files = ["./autounattend/win10/Autounattend.xml", "./autounattend/win10/configure.ps1"]
cd_files = [
"${ var.virtio_win_iso_dir }/*"
]
}
}
```
### Operating system and Environment details
I am running Debian 11.
### Log Fragments and crash.log files
[Link to the gist](https://gist.github.com/Antoine-Gicquel/108ecedb05b8caea4e1f009237b038ff)
Contributor guide
Research direction
Start by reproducing the build from the issue using Debian 11, a user-owned chmod 777 TMPDIR, and the provided cd_files configuration; review the linked gist for the permission-denied path. Done means Packer can copy the cd_files and complete the build without sudo. No source file or test is named in the report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- build-system, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100