check-setuid.patch 839 B

1234567891011121314151617181920212223242526272829303132
  1. --- a/src/auth_pam.c
  2. +++ b/src/auth_pam.c
  3. @@ -138,7 +138,12 @@
  4. /* we can be installed setuid root to support shadow passwords,
  5. and we don't need root privileges any longer. --marekm */
  6. - setuid(getuid());
  7. + int retval;
  8. + retval = setuid(getuid());
  9. + /* if setuid's return value isn't checked, it's a security issue */
  10. + if (retval != 0) {
  11. + return 0;
  12. + }
  13. return 1;
  14. }
  15. --- a/src/auth_passwd.c
  16. +++ a/src/auth_passwd.c
  17. @@ -68,7 +68,11 @@
  18. /* we can be installed setuid root to support shadow passwords,
  19. and we don't need root privileges any longer. --marekm */
  20. - setuid(getuid());
  21. + int retval;
  22. + retval = setuid(getuid());
  23. + if (retval != 0) {
  24. + return 0;
  25. + }
  26. if (strlen(pwd_entry->pw_passwd) < 13) {
  27. perror("password entry has no pwd\n");