|
@ -26,7 +26,11 @@ func EditEncryptedFile(password string, FilePath string) (error) { |
|
|
return errors.New("EDITOR variable cannot be blank") |
|
|
return errors.New("EDITOR variable cannot be blank") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
tmpFilePath = "/tmp/klsadjhflk" |
|
|
|
|
|
|
|
|
tmpFilePath = os.Getenv("TMPDIR") |
|
|
|
|
|
if tmpFilePath == "" { |
|
|
|
|
|
tmpFilePath = "/tmp" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ciphertext, e = ioutil.ReadFile(FilePath) |
|
|
ciphertext, e = ioutil.ReadFile(FilePath) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
return e |
|
|
return e |
|
@ -40,7 +44,7 @@ func EditEncryptedFile(password string, FilePath string) (error) { |
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
tmpFile, e = os.Create(tmpFilePath) |
|
|
|
|
|
|
|
|
tmpFile, e = ioutil.TempFile(tmpFilePath, "") |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
@ -54,7 +58,7 @@ func EditEncryptedFile(password string, FilePath string) (error) { |
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
cmd = exec.Command(editor, tmpFilePath) |
|
|
|
|
|
|
|
|
cmd = exec.Command(editor, tmpFile.Name()) |
|
|
cmd.Stdout = os.Stdout |
|
|
cmd.Stdout = os.Stdout |
|
|
cmd.Stdin = os.Stdin |
|
|
cmd.Stdin = os.Stdin |
|
|
cmd.Stderr = os.Stderr |
|
|
cmd.Stderr = os.Stderr |
|
@ -63,7 +67,7 @@ func EditEncryptedFile(password string, FilePath string) (error) { |
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
plaintext, e = ioutil.ReadFile(tmpFilePath) |
|
|
|
|
|
|
|
|
plaintext, e = ioutil.ReadFile(tmpFile.Name()) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
@ -80,7 +84,7 @@ func EditEncryptedFile(password string, FilePath string) (error) { |
|
|
|
|
|
|
|
|
defer func() { |
|
|
defer func() { |
|
|
encryptedFile.Close() |
|
|
encryptedFile.Close() |
|
|
SecureDelete(tmpFilePath) |
|
|
|
|
|
|
|
|
SecureDelete(tmpFile.Name()) |
|
|
}() |
|
|
}() |
|
|
|
|
|
|
|
|
_, e = io.Copy(encryptedFile, bytes.NewReader(ciphertext)) |
|
|
_, e = io.Copy(encryptedFile, bytes.NewReader(ciphertext)) |
|
|