// Copyright: Copyright (C) 2007 Pristine Communications // Referenced subroutines require_once "monica/runcmd.inc.php"; // Only do this when Cracklib extension is not loaded if (!extension_loaded("crack")) { // The last message $_CRACKLIB_LASTMMSG = null; // crack_check: Check password with Cracklib function crack_check($passwd) { // This is faster, but only available with Debian cracklib-runtime if (file_exists("/usr/sbin/crack_testlib")) { $cmd = array("/usr/sbin/crack_testlib"); $out = xruncmd($cmd, "$passwd\n"); $toremove = "enter potential passwords, one per line...\n$passwd: "; if (substr($out, 0, strlen($toremove)) == $toremove) { $out = substr($out, strlen($toremove)); } $out = preg_replace("/\s+$/", "", $out); // This is more portable } else { $cmd = array("/usr/bin/perl", "-e", "use Crypt::Cracklib; print fascist_check();"); $out = xruncmd($cmd, $passwd); } if ($out == "ok") { $GLOBALS["_CRACKLIB_LASTMMSG"] = "strong password"; return true; } else { $GLOBALS["_CRACKLIB_LASTMMSG"] = $out; return false; } } // crack_getlastmessage: Return the last message from Cracklib function crack_getlastmessage() { return $GLOBALS["_CRACKLIB_LASTMMSG"]; } } ?>