-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provisioner remote-exec > uploaded commands should be wiped out after exec #482
Comments
The issue is that Terraform doesn't know how to delete the file. It uses SCP to upload it and SCP doesn't have a "delete" mode. We can reupload another file to take the place of it, but we can't delete without knowing the system that is there. I think we can just reupload a blank file. |
The blank file seems to meet the (minimal) requirements for me too. |
What about appending a script as last component that deletes itself? |
LGTM Considering the following user provided script $ cat <<EOF >/tmp/script.sh
#!/bin/bash
echo "provisioner remote-exec script : I do something..."
EOF
$ chmod +x /tmp/script.sh
$ ls -l /tmp/script.sh
-rwxrwxr-x 1 frntn frntn 70 Apr 22 14:11 /tmp/script.sh Terraform can append a autodelete command (try shred / fallback to rm) $ cat <<EOF >>/tmp/script.sh
command -v shred >/dev/null && shred -uxz \$(readlink -f \$0) || rm -f \$(readlink -f \$0)
EOF
$ sh -c '/tmp/script.sh'
provisioner remote-exec script : I do something...
$ ls -l /tmp/script.sh
ls: cannot access /tmp/script.sh: No such file or directory |
Prevents residual script contents from remaining on machine. Fixes #482
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
When provisioning a server using
remote-exec
provisioner there is a remaining/tmp/script.sh
which contains either :inline
argument : all the executed commandsscript
argument : the full scriptscripts
argument : the last script of the arrayThis can lead to security issue.
This file should be deleted by default.
The text was updated successfully, but these errors were encountered: