patch-src_auth_password-scheme-crypt_c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. $OpenBSD: patch-src_auth_password-scheme-crypt_c,v 1.4 2016/11/01 14:12:04 sthen Exp $
  2. Dovecot supports various password schemes, e.g. {MD5}, {SHA1},
  3. {SSHA512}, {CRYPT}, etc. This is used in two cases:
  4. 1. Identifying schemes available for 'doveadm pw -s <scheme>' to
  5. generate a hashed password from user input.
  6. 2. Deciding which schemes to allow in a password database.
  7. Entries are stored as {SCHEME}passwordhash; the string from within
  8. brackets is checked against the list of supported schemes.
  9. One common scheme is {CRYPT} which passes to the OS crypt() function and
  10. is often used with LDAP password databases as it's also supported by
  11. OpenLDAP for its own authentication.
  12. After DES was removed from crypt(), 'doveadm pw -s CRYPT' started
  13. segfaulting on OpenBSD. To avoid this Dovecot was changed to
  14. test-encrypt a password and check that it can be verified,
  15. if not then that scheme is knocked out. But as well as stopping
  16. the segfault in case 1, it also prevents it from being used for
  17. case 2 i.e. verifying passwords.
  18. Result:
  19. dovecot: auth: Error: ldap(xyz,11.22.33.44,<asdafasfasdasfsa>): Unknown scheme CRYPT
  20. This patch re-allows CRYPT as a supported scheme. On OpenBSD it will
  21. encrypt as blowfish, on other OS it will encrypt as DES. Verification
  22. will work with whichever password formats are supported by the OS.
  23. --- src/auth/password-scheme-crypt.c.orig Fri Jan 8 01:04:13 2016
  24. +++ src/auth/password-scheme-crypt.c Fri Jan 8 01:23:35 2016
  25. @@ -111,7 +111,12 @@ static const struct {
  26. const char *salt;
  27. const char *expected;
  28. } sample[] = {
  29. +#ifdef __OpenBSD__
  30. + { "08/15!test~4711", "$2a$04$0123456789abcdefABCDEF",
  31. + "$2a$04$0123456789abcdefABCDE.N.drYX5yIAL1LkTaaZotW3yI0hQhZru" },
  32. +#else
  33. { "08/15!test~4711", "JB", "JBOZ0DgmtucwE" },
  34. +#endif
  35. { "08/15!test~4711", "$2a$04$0123456789abcdefABCDEF",
  36. "$2a$04$0123456789abcdefABCDE.N.drYX5yIAL1LkTaaZotW3yI0hQhZru" },
  37. { "08/15!test~4711", "$5$rounds=1000$0123456789abcdef",
  38. @@ -124,8 +129,13 @@ static const struct {
  39. /* keep in sync with the sample struct above */
  40. static const struct password_scheme crypt_schemes[] = {
  41. +#ifdef __OpenBSD__
  42. { "CRYPT", PW_ENCODING_NONE, 0, crypt_verify,
  43. + crypt_generate_blowfisch },
  44. +#else
  45. + { "CRYPT", PW_ENCODING_NONE, 0, crypt_verify,
  46. crypt_generate_des },
  47. +#endif
  48. { "BLF-CRYPT", PW_ENCODING_NONE, 0, crypt_verify,
  49. crypt_generate_blowfisch },
  50. { "SHA256-CRYPT", PW_ENCODING_NONE, 0, crypt_verify,