Skip to content

Commit

Permalink
Merge pull request #1994 from pi-hole/fix/env_password
Browse files Browse the repository at this point in the history
Check if the newly set password is the same as the old one
  • Loading branch information
DL6ER committed Jun 15, 2024
2 parents 7adda9a + 5a6a212 commit 01c5c56
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/config/password.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,16 @@ int run_performance_test(void)

bool set_and_check_password(struct conf_item *conf_item, const char *password)
{
// Check if the user wants to set an empty password but the password is
// already empty, or if the newly set password is the same as the old
// one
if((strlen(password) == 0 && strlen(config.webserver.api.pwhash.v.s) == 0) ||
verify_password(password, config.webserver.api.pwhash.v.s, false) == PASSWORD_CORRECT)
{
log_debug(DEBUG_CONFIG, "Password unchanged, not updating");
return true;
}

// Get password hash as allocated string (an empty string is hashed to an empty string)
char *pwhash = strlen(password) > 0 ? create_password(password) : strdup("");

Expand Down

0 comments on commit 01c5c56

Please sign in to comment.