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).
This commit is contained in:
1 parent
f33ecad3fb
commit
33494f1b47
1 file changed
+11
-1
+11
-1
@@ -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 = "<elided>"
|
||||
}
|
||||
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)
|
||||
|
||||
Reference in new issue
Block a user