def _init_default_schemes(): #: pick strongest one for host host_best = None for name in ["bcrypt", "sha256_crypt"]: if registry.has_os_crypt_support(name): host_best = name break # check if we have a bcrypt backend -- otherwise issue warning # XXX: would like to not spam this unless the user *requests* apache 24 bcrypt = "bcrypt" if registry.has_backend("bcrypt") else None _warn_no_bcrypt.clear() if not bcrypt: _warn_no_bcrypt.update([ "portable_apache_24", "host_apache_24", "linux_apache_24", "portable", "host" ]) defaults = dict( # strongest hash builtin to specific apache version portable_apache_24=bcrypt or "apr_md5_crypt", portable_apache_22="apr_md5_crypt", # strongest hash across current host & specific apache version host_apache_24=bcrypt or host_best or "apr_md5_crypt", host_apache_22=host_best or "apr_md5_crypt", # strongest hash on a linux host linux_apache_24=bcrypt or "sha256_crypt", linux_apache_22="sha256_crypt", ) # set latest-apache version aliases # XXX: could check for apache install, and pick correct host 22/24 default? # could reuse _detect_htpasswd() helper in UTs defaults.update( portable=defaults['portable_apache_24'], host=defaults['host_apache_24'], ) return defaults
def _init_default_schemes(): #: pick strongest one for host host_best = None for name in ["bcrypt", "sha256_crypt"]: if registry.has_os_crypt_support(name): host_best = name break # check if we have a bcrypt backend -- otherwise issue warning # XXX: would like to not spam this unless the user *requests* apache 24 bcrypt = "bcrypt" if registry.has_backend("bcrypt") else None _warn_no_bcrypt.clear() if not bcrypt: _warn_no_bcrypt.update(["portable_apache_24", "host_apache_24", "linux_apache_24", "portable", "host"]) defaults = dict( # strongest hash builtin to specific apache version portable_apache_24=bcrypt or "apr_md5_crypt", portable_apache_22="apr_md5_crypt", # strongest hash across current host & specific apache version host_apache_24=bcrypt or host_best or "apr_md5_crypt", host_apache_22=host_best or "apr_md5_crypt", # strongest hash on a linux host linux_apache_24=bcrypt or "sha256_crypt", linux_apache_22="sha256_crypt", ) # set latest-apache version aliases # XXX: could check for apache install, and pick correct host 22/24 default? defaults.update( portable=defaults['portable_apache_24'], host=defaults['host_apache_24'], ) return defaults