From e255d472a601af34043a8b7bf92cebd6dce1662d Mon Sep 17 00:00:00 2001 From: Zack Date: Mon, 20 May 2024 09:46:38 -0700 Subject: [PATCH] fix: shared secret should be read from environmental variable --- src/cli/cli.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/cli/cli.go b/src/cli/cli.go index fd4135a7..412c5654 100644 --- a/src/cli/cli.go +++ b/src/cli/cli.go @@ -321,6 +321,18 @@ func send(c *cli.Context) (err error) { // save the config saveConfig(c, crocOptions) + // if operating system is UNIX, then use environmental variable to set the code + if runtime.GOOS == "linux" { + cr.Options.SharedSecret = os.Getenv("CROC_SECRET") + if cr.Options.SharedSecret == "" { + fmt.Printf(`To use croc you need to set a code phrase using your environmental variables: + +export CROC_SECRET="yourcodephrasetouse" + `) + os.Exit(0) + } + } + err = cr.Send(minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders) return @@ -536,6 +548,18 @@ func receive(c *cli.Context) (err error) { log.Debugf("wrote %s", configFile) } + // if operating system is UNIX, then use environmental variable to set the code + if runtime.GOOS == "linux" { + cr.Options.SharedSecret = os.Getenv("CROC_SECRET") + if cr.Options.SharedSecret == "" { + fmt.Printf(`To use croc you need to set a code phrase using your environmental variables: + + export CROC_SECRET="yourcodephrasetouse" + `) + os.Exit(0) + } + } + err = cr.Receive() return }