Add support for the RCW daemon

This commit is contained in:
2025-05-04 19:51:16 -04:00
parent 1180112967
commit 6504bdc8a6
4 changed files with 34 additions and 15 deletions
+4 -2
View File
@@ -5,12 +5,13 @@ go 1.24.2
require ( require (
github.com/Trojan2021/BEAN v0.0.0-20241210230804-8f294833b514 github.com/Trojan2021/BEAN v0.0.0-20241210230804-8f294833b514
github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/glamour v0.7.0
github.com/rwinkhart/libmutton v0.3.2-0.20250504220509-826d94bc4397 github.com/rwinkhart/libmutton v0.3.2-0.20250504234931-3404fc74823c
github.com/rwinkhart/rcw v0.0.0-20250504183741-f176d57b6ba5 github.com/rwinkhart/rcw v0.0.0-20250504233845-9314852f061b
golang.org/x/term v0.31.0 golang.org/x/term v0.31.0
) )
require ( require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/alecthomas/chroma/v2 v2.16.0 // indirect github.com/alecthomas/chroma/v2 v2.16.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect github.com/aymerick/douceur v0.2.0 // indirect
@@ -31,6 +32,7 @@ require (
github.com/pquerna/otp v1.4.1-0.20231130234153-3357de7c0481 // indirect github.com/pquerna/otp v1.4.1-0.20231130234153-3357de7c0481 // indirect
github.com/rivo/uniseg v0.4.7 // indirect github.com/rivo/uniseg v0.4.7 // indirect
github.com/rwinkhart/convertroman v0.2.0 // indirect github.com/rwinkhart/convertroman v0.2.0 // indirect
github.com/rwinkhart/peercred-mini v0.0.0-20250407033241-c09add2eceea // indirect
github.com/stretchr/testify v1.8.4 // indirect github.com/stretchr/testify v1.8.4 // indirect
github.com/yuin/goldmark v1.7.10 // indirect github.com/yuin/goldmark v1.7.10 // indirect
github.com/yuin/goldmark-emoji v1.0.6 // indirect github.com/yuin/goldmark-emoji v1.0.6 // indirect
+8 -4
View File
@@ -59,10 +59,14 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rwinkhart/convertroman v0.2.0 h1:otUm939eXT77q/Lr31mJtMwVWEw0RjEUB71gO65h9OM= github.com/rwinkhart/convertroman v0.2.0 h1:otUm939eXT77q/Lr31mJtMwVWEw0RjEUB71gO65h9OM=
github.com/rwinkhart/convertroman v0.2.0/go.mod h1:Af6HqvX0EIM4Y3HcnNXbbRey1dLasGB7WU0+3Cowgmw= github.com/rwinkhart/convertroman v0.2.0/go.mod h1:Af6HqvX0EIM4Y3HcnNXbbRey1dLasGB7WU0+3Cowgmw=
github.com/rwinkhart/libmutton v0.3.2-0.20250504220509-826d94bc4397 h1:+Zlv62ZB7QTIFDNltMj6rm+7huo05N99BBWhoyVVJQc= github.com/rwinkhart/go-winio-easy-pipe-handles v0.0.0-20250407031321-96994a0e8410 h1:NhHwFM3Pgm6zRUfFKvi0p5ndjfFbVWsRwmmhyFlG4PE=
github.com/rwinkhart/libmutton v0.3.2-0.20250504220509-826d94bc4397/go.mod h1:9a4EYsPTLVI4Je7ql3jsMz7B9JP4PaRZSuTR/BctBIU= github.com/rwinkhart/go-winio-easy-pipe-handles v0.0.0-20250407031321-96994a0e8410/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/rwinkhart/rcw v0.0.0-20250504183741-f176d57b6ba5 h1:BX31d76TLGZqeukYECLFPkLD+SS/CAV12Lkdlc6UuGM= github.com/rwinkhart/libmutton v0.3.2-0.20250504234931-3404fc74823c h1:DzLYC9xNqoJnoFe8rg+/n9XMNX7HOBoUUzlSDqIZZx0=
github.com/rwinkhart/rcw v0.0.0-20250504183741-f176d57b6ba5/go.mod h1:giXrq9o5a7bwMSuMvz+5bb2+qbM+zV4pXaG/SceXfLM= github.com/rwinkhart/libmutton v0.3.2-0.20250504234931-3404fc74823c/go.mod h1:XsXDBz9SQ8QHLkjdzviCcoI/cr7pUnISst+03MB+c8M=
github.com/rwinkhart/peercred-mini v0.0.0-20250407033241-c09add2eceea h1:VE2ti/AE4Y3kgnyK+J5c5hpddE+dKHpsFch3K2R6puQ=
github.com/rwinkhart/peercred-mini v0.0.0-20250407033241-c09add2eceea/go.mod h1:t+YkvAdnTKTrg4d469tw3K+GCUzX/Bja4h8yKjSIsGs=
github.com/rwinkhart/rcw v0.0.0-20250504233845-9314852f061b h1:eWN9ogSzNE8KcFcoIBgrdgMCOUhxnV7m+SJ9Z3SCnPU=
github.com/rwinkhart/rcw v0.0.0-20250504233845-9314852f061b/go.mod h1:giXrq9o5a7bwMSuMvz+5bb2+qbM+zV4pXaG/SceXfLM=
github.com/rwinkhart/sys-freebsd-13-xucred v0.32.0 h1:KRbqimv9Eexf3VB2FrRAQ4v2fGGu7gt3ayMgdT0FNao= github.com/rwinkhart/sys-freebsd-13-xucred v0.32.0 h1:KRbqimv9Eexf3VB2FrRAQ4v2fGGu7gt3ayMgdT0FNao=
github.com/rwinkhart/sys-freebsd-13-xucred v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= github.com/rwinkhart/sys-freebsd-13-xucred v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+2
View File
@@ -158,6 +158,8 @@ func main() {
switch args[1] { switch args[1] {
case "clipclear": case "clipclear":
core.ClipClearArgument() core.ClipClearArgument()
case "startrcwd":
core.RCWDArgument()
case "sync": case "sync":
cli.RunJobWrapper(true) cli.RunJobWrapper(true)
case "init": case "init":
+20 -9
View File
@@ -8,22 +8,33 @@ import (
"github.com/rwinkhart/libmutton/core" "github.com/rwinkhart/libmutton/core"
"github.com/rwinkhart/libmutton/sync" "github.com/rwinkhart/libmutton/sync"
"github.com/rwinkhart/rcw/daemon"
"github.com/rwinkhart/rcw/wrappers" "github.com/rwinkhart/rcw/wrappers"
"golang.org/x/term" "golang.org/x/term"
) )
// GetRCWPassphrase retrieves the RCW passphrase from the user. // GetRCWPassphrase retrieves the RCW passphrase from the most accessible source.
// TODO attempt to retrieve from RCW daemon // It first attempts to retrieve from the RCW daemon, then from user input.
// If it does not find an RCW daemon, it launches one to cache the passphrase.
func GetRCWPassphrase() []byte { func GetRCWPassphrase() []byte {
for { // request passphrase from RCW daemon
passphrase := inputHidden("RCW Passphrase:") passphrase := daemon.CallDaemonIfOpen()
err := wrappers.RunSanityCheck(core.ConfigDir+"/sanity.rcw", passphrase)
if err != nil { // if no passphrase was retrieved, request it from the user
fmt.Println(core.AnsiError + "Failed to encrypt - " + err.Error() + core.AnsiReset) if passphrase == nil {
continue for {
passphrase = inputHidden("RCW Passphrase:")
err := wrappers.RunSanityCheck(core.ConfigDir+"/sanity.rcw", passphrase)
if err != nil {
fmt.Println(core.AnsiError + "Failed to encrypt - " + err.Error() + core.AnsiReset)
continue
}
break
} }
return passphrase // since no daemon was found earlier, start a new one
core.LaunchRCWDProcess(string(passphrase))
} }
return passphrase
} }
// input prompts the user for input and returns the input as a string. // input prompts the user for input and returns the input as a string.