handler = $handler; $_PAM_HANDLERS[$policy][$handler]->importance = strtolower($importance); return true; } return false; } /** * Unregisters a PAM handler. * * @param string $handler The PAM handler function name * @param string $policy The policy type, default is "user" * * @return void * @since 1.7.0 */ function unregister_pam_handler($handler, $policy = "user") { global $_PAM_HANDLERS; unset($_PAM_HANDLERS[$policy][$handler]); } function pam_authenticate($credentials = NULL, $policy = "user") { elgg_deprecated_notice('pam_authenticate has been deprecated for ElggPAM', 1.8); global $_PAM_HANDLERS, $_PAM_HANDLERS_MSG; $_PAM_HANDLERS_MSG = array(); $authenticated = false; foreach ($_PAM_HANDLERS[$policy] as $k => $v) { $handler = $v->handler; $importance = $v->importance; try { // Execute the handler if ($handler($credentials)) { // Explicitly returned true $_PAM_HANDLERS_MSG[$k] = "Authenticated!"; $authenticated = true; } else { $_PAM_HANDLERS_MSG[$k] = "Not Authenticated."; // If this is required then abort. if ($importance == 'required') { return false; } } } catch (Exception $e) { $_PAM_HANDLERS_MSG[$k] = "$e"; // If this is required then abort. if ($importance == 'required') { return false; } } } return $authenticated; }