|
|
@ -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)) |
|
|
|