Skip to content

Commit

Permalink
lightningd: do not abort while parsing hsm pwd.
Browse files Browse the repository at this point in the history
This is a mistake that I introduced while I implemented the lightningd custom error for hsmd.

In particular, when the command line parser check
if the file is encrypted make an additional check regarding the existence of the file.

This can be a not useful check, but due to the delicate nature of the hsm file, it is better to check if exist and if it doesn't exist an informative line inside the log is emitted that notifies the user that the file does not exist.

This log may return useful while debugging disaster
(that can happen) to understand that there is something strange (eg. the user moves the hsm file somewhere else).

Fixes #5719

Changelog-Fixed: lightningd: do not abort while parsing hsm pwd

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo authored and cdecker committed Nov 30, 2022
1 parent 090facd commit 3579b9d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,15 @@ static char *opt_set_hsm_password(struct lightningd *ld)
int is_encrypted;

is_encrypted = is_hsm_secret_encrypted("hsm_secret");
/* While lightningd is performing the first initialization
* this check is always true because the file does not exist.
*
* Maybe the is_hsm_secret_encrypted is performing a not useful
* check at this stage, but the hsm is a delicate part,
* so it is a good information to have inside the log. */
if (is_encrypted == -1)
return tal_fmt(NULL, "Could not access 'hsm_secret': %s",
strerror(errno));
log_info(ld->log, "'hsm_secret' does not exist (%s)",
strerror(errno));

prompt(ld, "The hsm_secret is encrypted with a password. In order to "
"decrypt it and start the node you must provide the password.");
Expand Down

0 comments on commit 3579b9d

Please sign in to comment.