From 33494f1b47d116857d153efcf8cca904998d9fd8 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Fri, 19 Dec 2014 23:56:30 +0000 Subject: [PATCH] do not log password This is trickier than it may first appear. We can't just filter the password from os.Args, since that would require recreating the flag parsing logic, which allows flags to be specified in a wide variety of formats. And there is no API for calling that logic either. So instead we log the results of the flag parsing, eliding the password, and using a straight golang map for formatting (so we don't have to get creative). --- weaver/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/weaver/main.go b/weaver/main.go index 48ab2626..ac1bcb96 100644 --- a/weaver/main.go +++ b/weaver/main.go @@ -22,7 +22,6 @@ func main() { log.SetPrefix(weave.Protocol + " ") log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds) - log.Println(os.Args) procs := runtime.NumCPU() // packet sniffing can block an OS thread, so we need one thread @@ -55,6 +54,17 @@ func main() { flag.Parse() peers = flag.Args() + options := make(map[string]string) + flag.Visit(func (f *flag.Flag) { + value := f.Value.String() + if f.Name == "password" { + value = "" + } + options[f.Name] = value + }) + log.Println("Command line options:", options) + log.Println("Command line peers:", peers) + if ifaceName == "" { fmt.Println("Missing required parameter 'iface'") os.Exit(1)