()
| 192 | } |
| 193 | |
| 194 | func getPassword() (string, error) { |
| 195 | stdin := int(syscall.Stdin) |
| 196 | initialTermState, err := terminal.GetState(stdin) |
| 197 | if err != nil { |
| 198 | return "", err |
| 199 | } |
| 200 | |
| 201 | c := make(chan os.Signal) |
| 202 | signal.Notify(c, os.Interrupt, syscall.SIGTERM) |
| 203 | go func() { |
| 204 | s := <-c |
| 205 | terminal.Restore(stdin, initialTermState) |
| 206 | switch sig := s.(type) { |
| 207 | case syscall.Signal: |
| 208 | if int(sig) == 2 { |
| 209 | fmt.Println("^C") |
| 210 | } |
| 211 | } |
| 212 | os.Exit(1) |
| 213 | }() |
| 214 | |
| 215 | passBytes, err := terminal.ReadPassword(stdin) |
| 216 | if err != nil { |
| 217 | return "", err |
| 218 | } |
| 219 | |
| 220 | signal.Stop(c) |
| 221 | fmt.Print("\n") |
| 222 | return string(passBytes), nil |
| 223 | } |
| 224 | |
| 225 | func (c *Config) Find(host string) *Host { |
| 226 | for _, h := range c.Hosts { |
no test coverage detected
searching dependent graphs…