MCPcopy Create free account
hub / github.com/ElementsProject/lightning / read_stdin_pass

Function read_stdin_pass

common/hsm_secret.c:428–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426}
427
428const 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
454const char *read_stdin_mnemonic(const tal_t *ctx, enum hsm_secret_error *err)
455{

Callers 5

load_hsm_secretFunction · 0.85
encrypt_hsmFunction · 0.85
generate_hsmFunction · 0.85
check_hsmFunction · 0.85
read_hsm_passphraseFunction · 0.85

Calls 4

disable_echoFunction · 0.85
read_lineFunction · 0.85
restore_echoFunction · 0.85
mlock_tal_memoryFunction · 0.85

Tested by

no test coverage detected