From 376cd19fd4fc49c327c905a5e74036abeef0159d Mon Sep 17 00:00:00 2001 From: Alexander Weinhold Date: Fri, 8 Sep 2017 14:38:00 +0200 Subject: [PATCH] pass the name to a password file, don't use pw directly --- unreadMail/unreadMail.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/unreadMail/unreadMail.go b/unreadMail/unreadMail.go index 379d6c5..9100647 100644 --- a/unreadMail/unreadMail.go +++ b/unreadMail/unreadMail.go @@ -5,6 +5,7 @@ package main import ( "flag" "fmt" + "git.gutmet.org/goutil" "git.gutmet.org/libUnreadMail" "os" ) @@ -14,17 +15,24 @@ func main() { portPtr := flag.Int("port", 993, "server port") certPtr := flag.String("cert", "", "PEM cert of server") userPtr := flag.String("user", "", "user login name") - passwdPtr := flag.String("passwd", "", "password for user") + pwFilePtr := flag.String("pwfile", "", "password file for user") flag.Parse() - par := &unreadMail.Parameters{*serverPtr, *portPtr, *certPtr, *userPtr, *passwdPtr} - mails, errs := unreadMail.FetchPlaintext(par) - for _, err := range errs { + passwd, err := goutil.ReadFile(*pwFilePtr) + + if err != nil { fmt.Fprintln(os.Stderr, err) - } - for _, mail := range mails { - fmt.Println(mail) - fmt.Println("\n=*=*=*=*=*=*=*=*=\n") + } else { + par := &unreadMail.Parameters{*serverPtr, *portPtr, *certPtr, *userPtr, passwd} + + mails, errs := unreadMail.FetchPlaintext(par) + for _, err := range errs { + fmt.Fprintln(os.Stderr, err) + } + for _, mail := range mails { + fmt.Println(mail) + fmt.Println("\n=*=*=*=*=*=*=*=*=\n") + } } }