Skip to content

Commit

Permalink
[agroal#424] Improve the invalid master key file error
Browse files Browse the repository at this point in the history
  • Loading branch information
T1t4m1un committed May 6, 2024
1 parent 4d78972 commit 040caf0
Showing 1 changed file with 47 additions and 14 deletions.
61 changes: 47 additions & 14 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,19 @@ main(int argc, char** argv)
#endif
errx(1, "%s (file <%s>)", message, users_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_KO
|| ret == PGAGROAL_CONFIGURATION_STATUS_CANNOT_DECRYPT)
else if (ret == PGAGROAL_CONFIGURATION_STATUS_KO)
{
snprintf(message, MISC_LENGTH, "Invalid USERS configuration file");
#ifdef HAVE_LINUX
sd_notifyf(0, "STATUS=%s: %s", message, users_path);
#endif
errx(1, "%s (file <%s>)", message, users_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_CANNOT_DECRYPT)
{

snprintf(message, MISC_LENGTH, "Invalid master key file");
snprintf(message, MISC_LENGTH, "USERS configuration file cannot decrypt");

#ifdef HAVE_LINUX
sd_notifyf(0, "STATUS=%s: %s", message, users_path);
#endif
Expand Down Expand Up @@ -562,13 +570,21 @@ main(int argc, char** argv)
#endif
errx(1, "%s (file <%s>)", message, frontend_users_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_CANNOT_DECRYPT
|| ret == PGAGROAL_CONFIGURATION_STATUS_KO)
else if (ret == PGAGROAL_CONFIGURATION_STATUS_KO)
{
snprintf(message, MISC_LENGTH, "Invalid master key file");
#ifdef HAVE_LINUX
sd_notifyf(0, "STATUS=%s: %s", message, users_path);
#endif
errx(1, "%s (file <%s>)", message, users_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_CANNOT_DECRYPT)
{
snprintf(message, MISC_LENGTH, "Master key file cannot decrypt");
#ifdef HAVE_LINUX
sd_notify(0, "STATUS=Invalid master key file");
sd_notifyf(0, "STATUS=%s: %s", message, users_path);
#endif
errx(1, "Invalid master key file");
errx(1, "%s (file <%s>)", message, users_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_FILE_TOO_BIG)
{
Expand Down Expand Up @@ -609,13 +625,21 @@ main(int argc, char** argv)
#endif
errx(1, "%s (file <%s>)", message, admins_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_CANNOT_DECRYPT
|| ret == PGAGROAL_CONFIGURATION_STATUS_KO)
else if (ret == PGAGROAL_CONFIGURATION_STATUS_KO)
{
snprintf(message, MISC_LENGTH, "Invalid master key file");
#ifdef HAVE_LINUX
sd_notifyf(0, "STATUS=%s: %s", message, users_path);
#endif
errx(1, "%s (file <%s>)", message, users_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_CANNOT_DECRYPT)
{
snprintf(message, MISC_LENGTH, "Master key file cannot decrypt");
#ifdef HAVE_LINUX
sd_notify(0, "STATUS=Invalid master key file");
sd_notifyf(0, "STATUS=%s: %s", message, users_path);
#endif
errx(1, "Invalid master key file");
errx(1, "%s (file <%s>)", message, users_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_FILE_TOO_BIG)
{
Expand Down Expand Up @@ -653,12 +677,21 @@ main(int argc, char** argv)
#endif
errx(1, "%s (file <%s>)", message, superuser_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_CANNOT_DECRYPT || ret == PGAGROAL_CONFIGURATION_STATUS_KO)
else if (ret == PGAGROAL_CONFIGURATION_STATUS_KO)
{
snprintf(message, MISC_LENGTH, "Invalid master key file");
#ifdef HAVE_LINUX
sd_notify(0, "STATUS=Invalid master key file");
sd_notifyf(0, "STATUS=%s: %s", message, users_path);
#endif
errx(1, "Invalid master key file");
errx(1, "%s (file <%s>)", message, users_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_CANNOT_DECRYPT)
{
snprintf(message, MISC_LENGTH, "Master key file cannot decrypt");
#ifdef HAVE_LINUX
sd_notifyf(0, "STATUS=%s: %s", message, users_path);
#endif
errx(1, "%s (file <%s>)", message, users_path);
}
else if (ret == PGAGROAL_CONFIGURATION_STATUS_FILE_TOO_BIG)
{
Expand Down

0 comments on commit 040caf0

Please sign in to comment.