From e6d90608211c7e52038de9f194b663754696d09c Mon Sep 17 00:00:00 2001 From: Josue Hernandez Date: Fri, 29 May 2026 10:40:35 -0600 Subject: [PATCH] Change login error message Login error message shows the line of code where it was called which is not user friendly, This proposal adds better and more human log messages when authentication fails Resolves: #RHEL-180631 Signed-off-by: Josue Hernandez --- 0537-Change-login-error-message.patch | 130 ++++++++++++++++++++++++++ grub.patches | 1 + grub2.spec | 6 +- 3 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 0537-Change-login-error-message.patch diff --git a/0537-Change-login-error-message.patch b/0537-Change-login-error-message.patch new file mode 100644 index 0000000..b20bd4f --- /dev/null +++ b/0537-Change-login-error-message.patch @@ -0,0 +1,130 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Josue Hernandez +Date: Thu, 28 May 2026 16:26:40 -0600 +Subject: [PATCH] Change login error message + +Login error message shows the line of code where it was called +which is not user friendly, This proposal adds better and more +human log messages when authentication fails + +Resolves: #RHEL-180631 + +Signed-off-by: Josue Hernandez +--- + grub-core/commands/password.c | 2 +- + grub-core/commands/password_pbkdf2.c | 2 +- + grub-core/kern/err.c | 14 ++++++++++++++ + grub-core/normal/auth.c | 17 +++++++++++++---- + include/grub/err.h | 2 ++ + 5 files changed, 31 insertions(+), 6 deletions(-) + +diff --git a/grub-core/commands/password.c b/grub-core/commands/password.c +index 6d42c9b02..607ee6435 100644 +--- a/grub-core/commands/password.c ++++ b/grub-core/commands/password.c +@@ -35,7 +35,7 @@ check_password (const char *user, const char *entered, + void *password) + { + if (grub_crypto_memcmp (entered, password, GRUB_AUTH_MAX_PASSLEN) != 0) +- return GRUB_ACCESS_DENIED; ++ grub_user_error(GRUB_ERR_ACCESS_DENIED, N_("Authentication error")); + + grub_auth_authenticate (user); + +diff --git a/grub-core/commands/password_pbkdf2.c b/grub-core/commands/password_pbkdf2.c +index ab845d25e..17dffcd44 100644 +--- a/grub-core/commands/password_pbkdf2.c ++++ b/grub-core/commands/password_pbkdf2.c +@@ -58,7 +58,7 @@ check_password (const char *user, const char *entered, void *pin) + if (err) + ret = grub_crypto_gcry_error (err); + else if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0) +- ret = GRUB_ACCESS_DENIED; ++ ret = grub_user_error(GRUB_ERR_ACCESS_DENIED, N_("Authentication error")); + else + { + grub_auth_authenticate (user); +diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c +index aebfe0cf8..d386e094f 100644 +--- a/grub-core/kern/err.c ++++ b/grub-core/kern/err.c +@@ -37,6 +37,20 @@ static int grub_error_stack_assert; + #undef grub_error + #endif + ++grub_err_t ++grub_user_error (grub_err_t n, const char *fmt, ...) ++{ ++ va_list ap; ++ ++ grub_errno = n; ++ ++ va_start (ap, fmt); ++ grub_vsnprintf (grub_errmsg, sizeof (grub_errmsg), _(fmt), ap); ++ va_end (ap); ++ ++ return n; ++} ++ + grub_err_t + grub_error (grub_err_t n, const char *file, const int line, const char *fmt, ...) + { +diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c +index 075aba452..a7ed80a19 100644 +--- a/grub-core/normal/auth.c ++++ b/grub-core/normal/auth.c +@@ -253,12 +253,18 @@ grub_auth_check_authentication (const char *userlist) + grub_puts_ (N_("Enter username: ")); + + if (!grub_username_get (login, sizeof (login) - 1)) +- goto access_denied; ++ { ++ grub_user_error(GRUB_ERR_ACCESS_DENIED, N_("Error getting user")); ++ goto access_denied; ++ } + + grub_puts_ (N_("Enter password: ")); + + if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN)) +- goto access_denied; ++ { ++ grub_user_error(GRUB_ERR_ACCESS_DENIED, N_("Error getting password")); ++ goto access_denied; ++ } + + FOR_LIST_ELEMENTS (user, users) + { +@@ -267,7 +273,10 @@ grub_auth_check_authentication (const char *userlist) + } + + if (!cur || ! cur->callback) +- goto access_denied; ++ { ++ grub_user_error(GRUB_ERR_ACCESS_DENIED, N_("Authentication error")); ++ goto access_denied; ++ } + + cur->callback (login, entered, cur->arg); + if (is_authenticated (userlist)) +@@ -282,7 +291,7 @@ grub_auth_check_authentication (const char *userlist) + if (punishment_delay < GRUB_ULONG_MAX / 2) + punishment_delay *= 2; + +- return GRUB_ACCESS_DENIED; ++ return GRUB_ERR_ACCESS_DENIED; + } + + static grub_err_t +diff --git a/include/grub/err.h b/include/grub/err.h +index 4703cb33c..547dda478 100644 +--- a/include/grub/err.h ++++ b/include/grub/err.h +@@ -91,6 +91,8 @@ extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG]; + + grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *file, const int line, const char *fmt, ...) + __attribute__ ((format (GNU_PRINTF, 4, 5))); ++grub_err_t EXPORT_FUNC(grub_user_error) (grub_err_t n, const char *fmt, ...) ++ __attribute__ ((format (GNU_PRINTF, 2, 3))); + + #define grub_error(n, fmt, ...) grub_error (n, __FILE__, __LINE__, fmt, ##__VA_ARGS__) + diff --git a/grub.patches b/grub.patches index 72178dc..0535f0b 100644 --- a/grub.patches +++ b/grub.patches @@ -533,3 +533,4 @@ Patch0533: 0533-commands-usbtest-Ensure-string-length-is-sufficient-.patch Patch0534: 0534-util-grub-mkimagexx-Stop-generating-unaligned-append.patch Patch0535: 0535-grub-mkimage-Do-not-generate-empty-SBAT-metadata.patch Patch0536: 0536-kern-efi-mm-Change-grub_efi_mm_add_regions-to-keep-t.patch +Patch0537: 0537-Change-login-error-message.patch diff --git a/grub2.spec b/grub2.spec index e1cf18b..e515856 100644 --- a/grub2.spec +++ b/grub2.spec @@ -16,7 +16,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 126%{?dist} +Release: 127%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -543,6 +543,10 @@ fi %endif %changelog +* Fri May 29 2026 Josue Hernandez 2.06-127 +- Change login error message for more user frienly version +- resolves: #RHEL-180631 + * Mon Mar 09 2026 Josue Hernandez 2.06-126 - kern/efi/mm: Change grub_efi_mm_add_regions() to keep track of map allocation size - Resolves: #RHEL-148310