From 354cb79cb1dde1d81ab33f455283a63e643c4d09 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 23 Jan 2018 15:28:49 +0100 Subject: [PATCH] [users] sample config and stub function for libpwquality --- src/modules/users/CheckPWQuality.cpp | 12 ++++++++++++ src/modules/users/UsersPage.cpp | 2 +- src/modules/users/users.conf | 14 +++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/modules/users/CheckPWQuality.cpp b/src/modules/users/CheckPWQuality.cpp index 4ac84473f..038adf27b 100644 --- a/src/modules/users/CheckPWQuality.cpp +++ b/src/modules/users/CheckPWQuality.cpp @@ -89,6 +89,18 @@ DEFINE_CHECK_FUNC(maxLength) #ifdef HAVE_LIBPWQUALITY DEFINE_CHECK_FUNC(libpwquality) { + if ( !value.canConvert( QVariant::List ) ) + { + cDebug() << "WARNING: libpwquality settings is not a list"; + return; + } + QVariantList l = value.toList(); + unsigned int requirement_count = 0; + for ( const auto& v : l ) + { + cDebug() << " .. " << v.type() << v; + // TODO: pass strings on to libpwquality + } } #endif diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp index ada0fae0f..8ea961662 100644 --- a/src/modules/users/UsersPage.cpp +++ b/src/modules/users/UsersPage.cpp @@ -473,5 +473,5 @@ UsersPage::addPasswordCheck( const QString& key, const QVariant& value ) } #endif else - cDebug() << "WARNING: Unknown password-check key" << '"' << key << '"'; + cDebug() << "WARNING: Unknown password-check key" << key; } diff --git a/src/modules/users/users.conf b/src/modules/users/users.conf index 1f62fc1e5..6111a6e80 100644 --- a/src/modules/users/users.conf +++ b/src/modules/users/users.conf @@ -58,7 +58,19 @@ doReusePassword: true # (e.g. specifying a maximum length less than the minimum length # will annoy users). # -# (additional checks may be implemented in UsersPage.cpp) +# The libpwquality check relies on the (optional) libpwquality library. +# Its value is a list of configuration statements that could also +# be found in pwquality.conf, and these are handed off to the +# libpwquality parser for evaluation. The check is ignored if +# libpwquality is not available at build time (generates a warning in +# the log). The Calamares password check rejects passwords with a +# score of < 40 with the given libpwquality settings. +# +# (additional checks may be implemented in CheckPWQuality.cpp and +# wired into UsersPage.cpp) passwordRequirements: minLength: -1 # Password at least this many characters maxLength: -1 # Password at most this many characters + libpwquality: + - minlen=8 + - minclass=2