diff --git a/Encryption/Edit.go b/Encryption/Edit.go index cc7928a..f4ebff5 100644 --- a/Encryption/Edit.go +++ b/Encryption/Edit.go @@ -26,7 +26,11 @@ func EditEncryptedFile(password string, FilePath string) (error) { return errors.New("EDITOR variable cannot be blank") } - tmpFilePath = "/tmp/klsadjhflk" + tmpFilePath = os.Getenv("TMPDIR") + if tmpFilePath == "" { + tmpFilePath = "/tmp" + } + ciphertext, e = ioutil.ReadFile(FilePath) if e != nil { return e @@ -40,7 +44,7 @@ func EditEncryptedFile(password string, FilePath string) (error) { return e } - tmpFile, e = os.Create(tmpFilePath) + tmpFile, e = ioutil.TempFile(tmpFilePath, "") if e != nil { return e } @@ -54,7 +58,7 @@ func EditEncryptedFile(password string, FilePath string) (error) { return e } - cmd = exec.Command(editor, tmpFilePath) + cmd = exec.Command(editor, tmpFile.Name()) cmd.Stdout = os.Stdout cmd.Stdin = os.Stdin cmd.Stderr = os.Stderr @@ -63,7 +67,7 @@ func EditEncryptedFile(password string, FilePath string) (error) { return e } - plaintext, e = ioutil.ReadFile(tmpFilePath) + plaintext, e = ioutil.ReadFile(tmpFile.Name()) if e != nil { return e } @@ -80,7 +84,7 @@ func EditEncryptedFile(password string, FilePath string) (error) { defer func() { encryptedFile.Close() - SecureDelete(tmpFilePath) + SecureDelete(tmpFile.Name()) }() _, e = io.Copy(encryptedFile, bytes.NewReader(ciphertext)) diff --git a/fenc b/fenc index 26917c2..1e95ee4 100755 Binary files a/fenc and b/fenc differ