public function checkByCrackLib($password)
{
$cl = $this->app->getConfig('cracklib', null);
if ($cl === null) {
if (is_executable($t = '/usr/sbin/cracklib-check')) {
$cl = $t;
} elseif (is_executable($t = '/usr/local/sbin/cracklib-check')) {
$cl = $t;
} else {
$cl = false;
}
}
$password = str_replace("\r", '', $password);
$password = str_replace("\n", '', $password);
if (is_string($cl) && file_exists($cl) && is_executable($cl)) {
/** @type System_ProcessIO $cl */
$cl = $this->add('System_ProcessIO');
$cl->exec($cl)->write_all($password);
$out = trim($cl->read_all());
$out = str_replace($password, '', $out);
$out = preg_replace('/^:\\s*/', '', $out);
if ($out == 'OK') {
return true;
}
return $out;
} else {
if (strlen($password) < 4) {
return 'it is WAY too short';
}
if (strlen($password) < 6) {
return 'it is too short';
}
return true;
}
}