000-OE-pam-no-innetgr.patch 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. innetgr may not be there so make sure that when innetgr is not present
  2. then we inform about it and not use it.
  3. -Khem
  4. --- a/modules/pam_group/pam_group.c
  5. +++ b/modules/pam_group/pam_group.c
  6. @@ -656,7 +656,11 @@ static int check_account(pam_handle_t *p
  7. }
  8. /* If buffer starts with @, we are using netgroups */
  9. if (buffer[0] == '@')
  10. +#ifdef HAVE_INNETGR
  11. good &= innetgr (&buffer[1], NULL, user, NULL);
  12. +#else
  13. + pam_syslog (pamh, LOG_ERR, "pam_group does not have netgroup support");
  14. +#endif
  15. /* otherwise, if the buffer starts with %, it's a UNIX group */
  16. else if (buffer[0] == '%')
  17. good &= pam_modutil_user_in_group_nam_nam(pamh, user, &buffer[1]);
  18. --- a/modules/pam_time/pam_time.c
  19. +++ b/modules/pam_time/pam_time.c
  20. @@ -555,9 +555,13 @@ check_account(pam_handle_t *pamh, const
  21. }
  22. /* If buffer starts with @, we are using netgroups */
  23. if (buffer[0] == '@')
  24. - good &= innetgr (&buffer[1], NULL, user, NULL);
  25. +#ifdef HAVE_INNETGR
  26. + good &= innetgr (&buffer[1], NULL, user, NULL);
  27. +#else
  28. + pam_syslog (pamh, LOG_ERR, "pam_time does not have netgroup support");
  29. +#endif
  30. else
  31. - good &= logic_field(pamh, user, buffer, count, is_same);
  32. + good &= logic_field(pamh, user, buffer, count, is_same);
  33. D(("with user: %s", good ? "passes":"fails" ));
  34. /* here we get the time field */
  35. --- a/modules/pam_succeed_if/pam_succeed_if.c
  36. +++ b/modules/pam_succeed_if/pam_succeed_if.c
  37. @@ -231,18 +231,27 @@ evaluate_notingroup(pam_handle_t *pamh,
  38. }
  39. /* Return PAM_SUCCESS if the (host,user) is in the netgroup. */
  40. static int
  41. -evaluate_innetgr(const char *host, const char *user, const char *group)
  42. +evaluate_innetgr(const pam_handle_t* pamh, const char *host, const char *user, const char *group)
  43. {
  44. +#ifdef HAVE_INNETGR
  45. if (innetgr(group, host, user, NULL) == 1)
  46. return PAM_SUCCESS;
  47. +#else
  48. + pam_syslog (pamh, LOG_ERR, "pam_succeed_if does not have netgroup support");
  49. +#endif
  50. +
  51. return PAM_AUTH_ERR;
  52. }
  53. /* Return PAM_SUCCESS if the (host,user) is NOT in the netgroup. */
  54. static int
  55. -evaluate_notinnetgr(const char *host, const char *user, const char *group)
  56. +evaluate_notinnetgr(const pam_handle_t* pamh, const char *host, const char *user, const char *group)
  57. {
  58. +#ifdef HAVE_INNETGR
  59. if (innetgr(group, host, user, NULL) == 0)
  60. return PAM_SUCCESS;
  61. +#else
  62. + pam_syslog (pamh, LOG_ERR, "pam_succeed_if does not have netgroup support");
  63. +#endif
  64. return PAM_AUTH_ERR;
  65. }
  66. @@ -387,14 +396,14 @@ evaluate(pam_handle_t *pamh, int debug,
  67. const void *rhost;
  68. if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS)
  69. rhost = NULL;
  70. - return evaluate_innetgr(rhost, user, right);
  71. + return evaluate_innetgr(pamh, rhost, user, right);
  72. }
  73. /* (Rhost, user) is not in this group. */
  74. if (strcasecmp(qual, "notinnetgr") == 0) {
  75. const void *rhost;
  76. if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS)
  77. rhost = NULL;
  78. - return evaluate_notinnetgr(rhost, user, right);
  79. + return evaluate_notinnetgr(pamh, rhost, user, right);
  80. }
  81. /* Fail closed. */
  82. return PAM_SERVICE_ERR;