From 0023ebaf8362aeb9bd30fcf0e3abf552874688fe Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sun, 10 Oct 2021 18:39:03 +0200 Subject: [PATCH] fixed bug in jsonrpc2-helper script * only look for registered numbers in the signal-cli-config/data folder and do NOT traverse the whole signal-cli-config folder (as there might be other files starting with '+...' --- src/scripts/jsonrpc2-helper.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/scripts/jsonrpc2-helper.go b/src/scripts/jsonrpc2-helper.go index 242ab49..759b371 100644 --- a/src/scripts/jsonrpc2-helper.go +++ b/src/scripts/jsonrpc2-helper.go @@ -33,6 +33,7 @@ numprocs=1 func main() { signalCliConfigDir := flag.String("signal-cli-config-dir", "/home/.local/share/signal-cli/", "Path to signal-cli config directory") + signalCliConfigDataDir := *signalCliConfigDir + "data" jsonRpc2ClientConfig := utils.NewJsonRpc2ClientConfig() @@ -40,9 +41,16 @@ func main() { fifoBasePathName := "/tmp/sigsocket" var ctr int64 = 0 - err := filepath.Walk(*signalCliConfigDir, func(path string, info os.FileInfo, err error) error { - filename := filepath.Base(path) - if strings.HasPrefix(filename, "+") && info.Mode().IsRegular() { + items, err := ioutil.ReadDir(signalCliConfigDataDir) + if err != nil { + log.Fatal("Couldn't read contents of ", signalCliConfigDataDir) + } + for _, item := range items { + if item.IsDir() { + continue + } + filename := filepath.Base(item.Name()) + if strings.HasPrefix(filename, "+") { if utils.IsPhoneNumber(filename) { number := filename fifoPathname := fifoBasePathName + strconv.FormatInt(ctr, 10) @@ -83,8 +91,7 @@ func main() { log.Error("Skipping ", filename, " as it is not a valid phone number!") } } - return nil - }) + } // write jsonrpc.yml config file err = jsonRpc2ClientConfig.Persist(*signalCliConfigDir + "jsonrpc2.yml")