summaryrefslogtreecommitdiff
path: root/modules/pam_unix/passverify.c
diff options
context:
space:
mode:
authorBjörn Esser <besser82@fedoraproject.org>2018-11-15 16:57:35 +0100
committerTomáš Mráz <t8m@users.noreply.github.com>2018-11-27 11:43:51 +0100
commitad435b386b22b456724dc5c5b8d9f2d1beffc558 (patch)
tree9062bcb5e33a8038b34437e29cd5c48c4bf823c2 /modules/pam_unix/passverify.c
parent619f19d378529defa5864941caf8c4233aef46f5 (diff)
pam_unix: Add crypt_default method, if supported.
libxcrypt since v4.4.0 supports a default method for its gensalt function on most system configurations. As the default method is to be considered the strongest available hash method, it should be preferred over all other hash methods supported by pam. * modules/pam_unix/pam_unix.8.xml: Documentation for crypt_default. * modules/pam_unix/passverify.c: Add crypt_default method. * modules/pam_unix/support.h: Likewise.
Diffstat (limited to 'modules/pam_unix/passverify.c')
-rw-r--r--modules/pam_unix/passverify.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/pam_unix/passverify.c b/modules/pam_unix/passverify.c
index eb2444bb..0a4c67b4 100644
--- a/modules/pam_unix/passverify.c
+++ b/modules/pam_unix/passverify.c
@@ -395,6 +395,14 @@ PAMH_ARG_DECL(char * create_password_hash,
if (on(UNIX_MD5_PASS, ctrl)) {
/* algoid = "$1" */
return crypt_md5_wrapper(password);
+#if (defined(CRYPT_PREFERRED_METHOD_AVAILABLE) && CRYPT_PREFERRED_METHOD_AVAILABLE)
+ } else if (on(UNIX_CRYPT_DEFAULT_PASS, ctrl)
+ && crypt_preferred_method() != NULL) {
+ algoid = crypt_preferred_method();
+ rounds = 0; /* always use the system preset */
+#endif
+ } else if (on(UNIX_CRYPT_DEFAULT_PASS, ctrl)) {
+ algoid = "*0"; /* never ever a valid method */
} else if (on(UNIX_YESCRYPT_PASS, ctrl)) {
algoid = "$y$";
} else if (on(UNIX_GOST_YESCRYPT_PASS, ctrl)) {
@@ -461,6 +469,7 @@ PAMH_ARG_DECL(char * create_password_hash,
pam_syslog(pamh, LOG_ERR,
"Algo %s not supported by the crypto backend, "
"falling back to MD5\n",
+ on(UNIX_CRYPT_DEFAULT_PASS, ctrl) ? "crypt_default \"" algoid "\"" :
on(UNIX_YESCRYPT_PASS, ctrl) ? "yescrypt" :
on(UNIX_GOST_YESCRYPT_PASS, ctrl) ? "gost_yescrypt" :
on(UNIX_BLOWFISH_PASS, ctrl) ? "blowfish" :