#!/usr/local/bin/php -f if (file_exists("{$g['varetc_path']}/ipsec/{$modeid}.ca")) { //putenv("LDAPTLS_CACERT={$g['varetc_path']}/ipsec/{$ikeid}.crt"); putenv("LDAPTLS_CACERTDIR={$g['varetc_path']}/ipsec"); putenv("LDAPTLS_REQCERT=never"); } $authenticated = false; if (($strictusercn === true) && ($common_name != $username)) { syslog(LOG_WARNING, "Username does not match certificate common name ({$username} != {$common_name}), access denied.\n"); exit(1); } $attributes = array(); foreach ($authmodes as $authmode) { $authcfg = auth_get_authserver($authmode); if (!$authcfg && $authmode != "local") continue; $authenticated = authenticate_user($username, $password, $authcfg, $attributes); if ($authenticated == true) { if (stristr($authmode, "local")) { $user = getUserEntry($username); if (!is_array($user) || !userHasPrivilege($user, "user-ipsec-xauth-dialin")) { $authenticated = false; syslog(LOG_WARNING, "user '{$username}' cannot authenticate through IPSec since the required privileges are missing.\n"); continue; } } break; } } if ($authenticated == false) { syslog(LOG_WARNING, "user '{$username}' could not authenticate.\n"); exit(-1); } if (file_exists("/etc/inc/ipsec.attributes.php")) include_once("/etc/inc/ipsec.attributes.php"); syslog(LOG_NOTICE, "user '{$username}' authenticated\n"); exit(0); ?>