Make daemon return decrypted data, not passphrase

This commit is contained in:
2025-05-08 18:47:35 +00:00
parent 949ef622c7
commit e7f041bb0a
9 changed files with 73 additions and 47 deletions
+8 -9
View File
@@ -5,18 +5,17 @@ import (
"net/rpc"
)
// CallDaemonIfOpen returns the passphrase served by the RCW daemon
// (if one is available). If no RCW daemon is accessible, nil is returned.
func CallDaemonIfOpen() []byte {
// CallDaemonIfOpen uses the RCW daemon (if one is available) to
// decrypt and return data. If no RCW daemon is accessible, nil is returned.
func CallDaemonIfOpen(encBytes []byte) []byte {
if daemonIsOpen() {
call()
return call()
return call(encBytes)
}
return nil
}
// call connects to the RPC server and requests the passphrase.
func call() []byte {
func call(encBytes []byte) []byte {
// connect to the UNIX domain socket/Windows named pipe
conn := getConn()
defer conn.Close()
@@ -26,9 +25,9 @@ func call() []byte {
defer client.Close()
// request the passphrase from the RPC server
var reply string
if err := client.Call("RCWService.GetPass", "hi", &reply); err != nil {
log.Fatalf("Error calling RCWService.GetPass: %v", err)
var reply []byte
if err := client.Call("RCWService.DecryptRequest", encBytes, &reply); err != nil {
log.Fatalf("Error calling RCWService.DecryptRequest: %v", err)
}
// return the passphrase