| 426 | } |
| 427 | |
| 428 | const char *read_stdin_pass(const tal_t *ctx, enum hsm_secret_error *err) |
| 429 | { |
| 430 | struct termios saved_term; |
| 431 | bool echo_disabled = disable_echo(&saved_term); |
| 432 | if (isatty(fileno(stdin)) && !echo_disabled) { |
| 433 | *err = HSM_SECRET_ERR_TERMINAL; |
| 434 | return NULL; |
| 435 | } |
| 436 | |
| 437 | const char *input = read_line(ctx); |
| 438 | if (!input) { |
| 439 | if (echo_disabled) |
| 440 | restore_echo(&saved_term); |
| 441 | *err = HSM_SECRET_ERR_INVALID_FORMAT; |
| 442 | return NULL; |
| 443 | } |
| 444 | |
| 445 | mlock_tal_memory(input); |
| 446 | |
| 447 | if (echo_disabled) |
| 448 | restore_echo(&saved_term); |
| 449 | |
| 450 | *err = HSM_SECRET_OK; |
| 451 | return input; |
| 452 | } |
| 453 | |
| 454 | const char *read_stdin_mnemonic(const tal_t *ctx, enum hsm_secret_error *err) |
| 455 | { |
no test coverage detected