logo

etc_portage

Unnamed repository; edit this file 'description' to name the repository. git clone https://hacktivis.me/git/etc_portage.git

0001-login-su-Treat-an-empty-passwd-field-as-invalid.patch (1449B)


  1. From 999a428a064222c4fba980baa3b061d39e23ed75 Mon Sep 17 00:00:00 2001
  2. From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
  3. Date: Sun, 14 Mar 2021 19:13:13 +0100
  4. Subject: [PATCH 1/2] login & su: Treat an empty passwd field as invalid
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Otherwise it's treated like the “require no password” clause while it probably
  9. should be treated like a normal su that can't validate anyway.
  10. A similar change should be done for USE_PAM.
  11. ---
  12. src/login.c | 4 ++++
  13. src/su.c | 5 +++++
  14. 2 files changed, 9 insertions(+)
  15. diff --git a/src/login.c b/src/login.c
  16. index 00508cd5..0c0b5c86 100644
  17. --- a/src/login.c
  18. +++ b/src/login.c
  19. @@ -978,6 +978,10 @@ int main (int argc, char **argv)
  20. || ('*' == user_passwd[0])) {
  21. failed = true;
  22. }
  23. + /* Treat empty password field as invalid */
  24. + if (strcmp (user_passwd, "") == 0) {
  25. + failed = true;
  26. + }
  27. }
  28. if (strcmp (user_passwd, SHADOW_PASSWD_STRING) == 0) {
  29. diff --git a/src/su.c b/src/su.c
  30. index fc0e826f..638f533f 100644
  31. --- a/src/su.c
  32. +++ b/src/su.c
  33. @@ -499,6 +499,11 @@ static void check_perms_nopam (const struct passwd *pw)
  34. /*@observer@*/const char *password = pw->pw_passwd;
  35. RETSIGTYPE (*oldsig) (int);
  36. + if (strcmp (pw->pw_passwd, "") == 0) {
  37. + fprintf(stderr, _("Password field is empty, this is invalid.\n"));
  38. + exit(1);
  39. + }
  40. +
  41. if (caller_is_root) {
  42. return;
  43. }
  44. --
  45. 2.26.3