ref: b8662330e5a2aed7af1568e6cddb044597857f5c
./eeze.go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
package main import ( "notabug.org/apiote/next-eeze/agent" "notabug.org/apiote/next-eeze/config" "notabug.org/apiote/next-eeze/operation" "notabug.org/apiote/next-eeze/server" "fmt" "log" "os" "golang.org/x/crypto/ssh/terminal" "git.sr.ht/~sircmpwn/getopt" ) func main() { C := getopt.Bool("C", false, "Config") S := getopt.Bool("S", false, "Sync") L := getopt.Bool("L", false, "List") G := getopt.Bool("G", false, "Get") var u string getopt.StringVar(&u, "u", "", "filter Get by username") var l string getopt.StringVar(&l, "l", "", "filter Get by label") var s string getopt.StringVar(&s, "s", "", "filter Get by url (service/server)") f := getopt.Bool("f", false, "show full entry in Get, instead of just username/password") p := getopt.Bool("p", false, "show just password in Get") i := getopt.Bool("i", false, "in Config: set server, username, password (initialise)") r := getopt.Bool("r", false, "in Config: reëncrypt (change master password)") err := getopt.Parse() if err != nil { log.Println("Error parsing opts. ", err) return } masterPassword, err := agent.GetMasterPassword() if err != nil { log.Println("Error getting from agent", err) agent.StartAgent() } if masterPassword == "" || (*C && (*i || *r)) { fmt.Print("Master password: ") // todo memguard masterPass_b, _ := terminal.ReadPassword(int(os.Stdin.Fd())) // todo memguard masterPassword = string(masterPass_b) fmt.Print("\n") agent.GiveMasterPassword(masterPassword) } if *C { if *i { config.Init(masterPassword) } else if *r { // todo memguard newMasterPassword, err := config.Reëncrypt(masterPassword) if err != nil { log.Println("Error reëncrypting. ", err) return } else { agent.GiveMasterPassword(newMasterPassword) } } } else if *S { err = server.Sync(masterPassword) } else if *G { var r string r, err = operation.Get(u, l, s, *f, *p, masterPassword) fmt.Println(r) } else if *L { var r string r, err = operation.List(masterPassword) fmt.Println(r) } else { getopt.Usage() } if err != nil { log.Println("Error. ", err) return } } |