Skip to content

Commit

Permalink
Warn the user when a master key cannot be accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
fluca1978 committed Feb 8, 2022
1 parent ce557da commit 5de2957
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ master_key(char* password, bool generate_pwd, int pwd_length)

if (password == NULL)
{
int loops = 0; /* keep track about how many times the user has tried */

if (!generate_pwd)
{
while (!is_valid_key(password))
Expand All @@ -362,9 +364,15 @@ master_key(char* password, bool generate_pwd, int pwd_length)
password = NULL;
}

printf("Master key: ");
// if the user has tried with an invalid
// password, warn her!
if ( loops > 0 )
printf( "Invalid master key, try again\n" );

printf("Master key (will not echo): ");
password = pgagroal_get_password();
printf("\n");
loops++;
}
}
else
Expand Down

0 comments on commit 5de2957

Please sign in to comment.