\n"; echo "\n"; echo "\n"; echo ""; echo "
\n"; echo "" . _("Lamdaemon server and path") . " | \n"; if (!isset($_SESSION['config']->scriptServer) || (strlen($_SESSION['config']->scriptServer) < 3)) { echo "" . _("Error") . " | \n"; echo "" . _("No lamdaemon server set, please update your LAM configuration settings.") . " | "; } elseif (!isset($_SESSION['config']->scriptPath) || (strlen($_SESSION['config']->scriptPath) < 10)) { echo "" . _("Error") . " | \n"; echo "" . _("No lamdaemon path set, please update your LAM configuration settings.") . " | "; $stopTest = true; } else { echo "" . _("Ok") . " | \n"; echo "" . sprintf(_("Using %s as lamdaemon remote server."), $_SESSION['config']->scriptServer) . " | "; } echo "
" . _("Unix account") . " | \n"; $credentials = $_SESSION['ldap']->decrypt_login(); $unixOk = false; $sr = @ldap_read($_SESSION['ldap']->server(), $credentials[0], "objectClass=posixAccount", array('uid')); if ($sr) { $entry = @ldap_get_entries($_SESSION['ldap']->server(), $sr); $userName = $entry[0]['uid'][0]; if ($userName) { $unixOk = true; } } if ($unixOk) { echo "" . _("Ok") . " | \n"; echo "" . sprintf(_("Using %s to connect to remote server."), $userName) . " | "; } else { echo "" . _("Error") . " | \n"; echo "" . _("Your LAM admin user must be a valid Unix account to work with lamdaemon!") . " | "; $stopTest = true; } echo "||
" . _("SSH2 module") . " | \n"; if (function_exists("ssh2_connect")) { echo "" . _("Ok") . " | "; echo "" . _("SSH2 module is installed.") . " | "; } else { echo "" . _("Error") . " | \n"; echo "" . _("Please install the SSH2 module for PHP and activate it in your php.ini!") . " | "; $stopTest = true; } echo "||
" . _("SSH connection") . " | \n"; flush(); $sshOk = false; $handle = @ssh2_connect($_SESSION['config']->scriptServer); if ($handle) { if (@ssh2_auth_password($handle, $userName, $credentials[1])) { $sshOk = true; } } if ($sshOk) { echo "" . _("Ok") . " | "; echo "" . _("SSH connection could be established.") . " | "; } else { echo "" . _("Error") . " | \n"; echo "" . _("Unable to connect to remote server!") . " | "; $stopTest = true; } echo "||
" . _("Execute lamdaemon") . " | \n"; flush(); $lamdaemonOk = false; $errorMessage = ""; $shell = ssh2_exec($handle, "sudo " . $_SESSION['config']->scriptPath); $stderr = ssh2_fetch_stream($shell, SSH2_STREAM_STDERR); fwrite($shell, "+ quota get user\n"); $return = array(); $time = time() + 20; while (sizeof($return) < 1) { if ($time < time()) { $lamdaemonOk = false; $errorMessage = _("Timeout while executing lamdaemon commands!"); break; } usleep(100); $read = split("\n", trim(fread($shell, 100000))); if ((sizeof($read) == 1) && (!isset($read[0]) || ($read[0] == ""))) continue; for ($i = 0; $i < sizeof($read); $i++) { $return[] = $read[$i]; } } $errOut = @fread($stderr, 100000); if ((stripos($errOut, "sudoers") !== false) || (stripos($errOut, "sorry") !== false)) { $return[] = "ERROR," . _("Sudo is not setup correctly!") . "," . str_replace(",", " ", $errOut); } if ((sizeof($return) == 1) && (stripos($return[0], "error") === false)) { $lamdaemonOk = true; } if ($lamdaemonOk) { echo "" . _("Ok") . " | "; echo "" . _("Lamdaemon successfully run.") . " | "; } else { echo "" . _("Error") . " | \n"; echo "\n"; for ($i = 0; $i < sizeof($return); $i++) { call_user_func_array('StatusMessage', split(",", $return[$i])); } echo " | \n"; $stopTest = true; } echo "