Skip to content

Commit

Permalink
[#481] Add better error message about Invalid master key file (#483)
Browse files Browse the repository at this point in the history
When a users file, (frontend, admins or users files) cannot be
decrypted, a generic `Invalid master key file` was raised.
This commit adds the target file that cannot be decrypted, so that the
user can understand which file has to be adjusted (e.g.,
`pgagroal-admin` usage on such file).

Makes the error messages consistent with those about a missing file.

Close #481
  • Loading branch information
fluca1978 authored Nov 4, 2024
1 parent 0e4c711 commit 7298300
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ main(int argc, char** argv)

snprintf(message, MISC_LENGTH, "Invalid master key file");
#ifdef HAVE_LINUX
sd_notifyf(0, "STATUS=%s: %s", message, users_path);
sd_notifyf(0, "STATUS=%s: <%s>", message, users_path);
#endif
errx(1, "%s (file <%s>)", message, users_path);
}
Expand Down Expand Up @@ -567,9 +567,9 @@ main(int argc, char** argv)
|| ret == PGAGROAL_CONFIGURATION_STATUS_KO)
{
#ifdef HAVE_LINUX
sd_notify(0, "STATUS=Invalid master key file");
sd_notifyf(0, "STATUS=Invalid master key file: <%s>", frontend_users_path);
#endif
errx(1, "Invalid master key file");
errx(1, "%s (file <%s>)", message, frontend_users_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_FILE_TOO_BIG)
{
Expand Down Expand Up @@ -614,9 +614,9 @@ main(int argc, char** argv)
|| ret == PGAGROAL_CONFIGURATION_STATUS_KO)
{
#ifdef HAVE_LINUX
sd_notify(0, "STATUS=Invalid master key file");
sd_notifyf(0, "STATUS=Invalid master key file: <%s>", admins_path);
#endif
errx(1, "Invalid master key file");
errx(1, "Invalid master key file (file <%s>)", admins_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_FILE_TOO_BIG)
{
Expand Down Expand Up @@ -657,9 +657,9 @@ main(int argc, char** argv)
else if (ret == PGAGROAL_CONFIGURATION_STATUS_CANNOT_DECRYPT || ret == PGAGROAL_CONFIGURATION_STATUS_KO)
{
#ifdef HAVE_LINUX
sd_notify(0, "STATUS=Invalid master key file");
sd_notifyf(0, "STATUS=Invalid master key file: <%s>", superuser_path);
#endif
errx(1, "Invalid master key file");
errx(1, "Invalid master key file (file <%s>)", superuser_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_FILE_TOO_BIG)
{
Expand Down

0 comments on commit 7298300

Please sign in to comment.