From 86d719949ed359d8c2227bfc402771f25ee66c77 Mon Sep 17 00:00:00 2001 From: boyska Date: Tue, 28 May 2019 18:42:20 +0200 Subject: [PATCH] FIX #5 safer default paths for sockets: /tmp/ --- cmd/circolog-tail/main.go | 10 +++++----- cmd/circologd/main.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/circolog-tail/main.go b/cmd/circolog-tail/main.go index 74a7a7c..71cacc5 100644 --- a/cmd/circolog-tail/main.go +++ b/cmd/circolog-tail/main.go @@ -54,8 +54,8 @@ func (b *BoolAuto) Set(s string) error { } func main() { - addr := flag.String("addr", "localhost:9080", "http service address") - querySocket := flag.String("socket", "", "Path to a unix domain socket for the HTTP server") + queryAddr := flag.String("addr", "", "http service address") + querySocket := flag.String("socket", "/tmp/circologd-query.sock", "Path to a unix domain socket for the HTTP server") backlogLimit := flag.Int("n", -1, "Limit the backlog length, defaults to no limit (-1)") var format formatter.Format format = formatter.FormatSyslog @@ -75,7 +75,7 @@ func main() { signal.Notify(interrupt, os.Interrupt) var d *websocket.Dialer u := url.URL{Scheme: "ws", - Host: *addr, // ignored in case of -socket; see the Dialer below + Host: *queryAddr, // ignored in case of -socket; see the Dialer below Path: "/ws", } q := u.Query() @@ -84,7 +84,7 @@ func main() { q.Set("l", strconv.Itoa(*backlogLimit)) } u.RawQuery = q.Encode() - if *querySocket != "" { + if *queryAddr == "" { d = &websocket.Dialer{ NetDial: func(network, addr string) (net.Conn, error) { return net.Dial("unix", *querySocket) @@ -95,7 +95,7 @@ func main() { log.Printf("connecting to %s", *querySocket) } else { d = websocket.DefaultDialer - log.Printf("connecting to %s", *addr) + log.Printf("connecting to %s", *queryAddr) } c, _, err := d.Dial(u.String(), nil) diff --git a/cmd/circologd/main.go b/cmd/circologd/main.go index cd49548..d5e5cf7 100644 --- a/cmd/circologd/main.go +++ b/cmd/circologd/main.go @@ -38,8 +38,8 @@ func main() { // dumpSocketPath := flag.String("dump-socket", "/run/buffer.sock", "The socket that user will connect to in order to receive logs") bufsize := flag.Int("buffer-size", 1000, "Number of messages to keep") syslogAddr := flag.String("syslog-addr", "127.0.0.1:9514", "Address:port where to listen for syslog messages") - queryAddr := flag.String("query-addr", "127.0.0.1:9080", "Address:port where to bind the query service") - querySocket := flag.String("query-socket", "", "Path to a unix domain socket for the HTTP server; recommended for security reasons!") + queryAddr := flag.String("query-addr", "", "Address:port where to bind the query service") + querySocket := flag.String("query-socket", "/tmp/circologd-query.sock", "Path to a unix domain socket for the HTTP server; recommended for security reasons!") ctlSocket := flag.String("ctl-socket", "/tmp/circologd-ctl.sock", "Path to a unix domain socket for the control server; leave empty to disable") flag.Var(&logFmt, "log-fmt", "Log messages format. If not set, defaults to automatic choice. Allowed values: rfc3164, rfc5424, auto.") verbose := flag.Bool("verbose", false, "Print more output executing the daemon") @@ -89,7 +89,7 @@ func main() { } httpQueryServer := http.Server{Handler: setupHTTP(hub)} - if *querySocket != "" { + if *queryAddr == "" { fmt.Printf("Binding address `%s` [http]\n", *querySocket) unixListener, err := net.Listen("unix", *querySocket) if err != nil {