Skip to content

Commit

Permalink
Merge pull request #138 from DopplerHQ/tom_fix_install_temp_dir
Browse files Browse the repository at this point in the history
Use home dir as temp directory
  • Loading branch information
Piccirello authored Oct 12, 2020
2 parents 2e515f5 + 337ebc7 commit 59314ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/utils/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func WriteFile(filename string, data []byte, perm os.FileMode) error {

// WriteTempFile writes data to a unique temp file and returns the file name
func WriteTempFile(name string, data []byte, perm os.FileMode) (string, error) {
tmpFile, err := ioutil.TempFile(os.TempDir(), fmt.Sprintf("%s.", name))
// create hidden file in user's home dir to ensure no other users have write access
tmpFile, err := ioutil.TempFile(HomeDir(), fmt.Sprintf(".%s.", name))
if err != nil {
return "", err
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ url="https://cli.doppler.com/download?os=$os&arch=$arch&format=$format"

# download binary
if [ -x "$(command -v curl)" ] || [ -x "$(command -v wget)" ]; then
tempdir="$(mktemp -d)"
# create hidden temp dir in user's home directory to ensure no other users have write perms
tempdir="$(mktemp -d ~/.tmp.XXXXXXXX)"
log_debug "Using temp directory $tempdir"

echo "Downloading latest release"
Expand Down

0 comments on commit 59314ac

Please sign in to comment.