Commit fe3148f0 authored by Milan Broz's avatar Milan Broz

Tweak passwdqc use.

parent 5e9c2711
......@@ -115,18 +115,17 @@ fi
dnl ==========================================================================
dnl passwdqc library (cryptsetup CLI only)
AC_ARG_ENABLE([passwdqc],
AS_HELP_STRING([--enable-passwdqc],
[enable password quality checking using passwdqc library]),
AS_HELP_STRING([--enable-passwdqc@<:@=CONFIG_PATH@:>@],
[enable password quality checking using passwdqc library (optionally with CONFIG_PATH)]),
[enable_passwdqc=$enableval],
[enable_passwdqc=no])
case "$enable_passwdqc" in
yes|no) ;;
/*)
AC_DEFINE_UNQUOTED([PASSWDQC_CONFIG_FILE], ["$enable_passwdqc"], [passwdqc library config file])
enable_passwdqc=yes ;;
yes|no) use_passwdqc_config="" ;;
/*) use_passwdqc_config="$enable_passwdqc"; enable_passwdqc=yes ;;
*) AC_MSG_ERROR([Unrecognized --enable-passwdqc parameter.]) ;;
esac
AC_DEFINE_UNQUOTED([PASSWDQC_CONFIG_FILE], ["$use_passwdqc_config"], [passwdqc library config file])
if test "x$enable_passwdqc" = "xyes"; then
AC_DEFINE(ENABLE_PASSWDQC, 1, [Enable password quality checking using passwdqc library])
......
......@@ -24,7 +24,7 @@
int opt_force_password = 0;
#if defined ENABLE_PWQUALITY
# include <pwquality.h>
#include <pwquality.h>
static int tools_check_pwquality(const char *password)
{
......@@ -59,24 +59,24 @@ static int tools_check_pwquality(const char *password)
return r;
}
#elif defined ENABLE_PASSWDQC
# include <passwdqc.h>
#include <passwdqc.h>
static int tools_check_pwquality(const char *password)
{
passwdqc_params_t params;
char *parse_reason;
const char *check_reason;
const char *config = PASSWDQC_CONFIG_FILE;
passwdqc_params_reset(&params);
# ifdef PASSWDQC_CONFIG_FILE
if (passwdqc_params_load(&params, &parse_reason, PASSWDQC_CONFIG_FILE)) {
if (*config && passwdqc_params_load(&params, &parse_reason, config)) {
log_err(_("Cannot check password quality: %s\n"),
(parse_reason ? parse_reason : "Out of memory"));
free(parse_reason);
return -EINVAL;
}
# endif
check_reason = passwdqc_check(&params.qc, password, NULL, NULL);
if (check_reason) {
log_err(_("Password quality check failed: Bad passphrase (%s)\n"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment