| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  | $Id$ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-27 18:47:12 +00:00
										 |  |  |   This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) | 
					
						
							| 
									
										
										
										
											2010-01-01 17:21:46 +00:00
										 |  |  |   Copyright (C) 2006 - 2010  Roland Gruber | 
					
						
							| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |   it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |   the Free Software Foundation; either version 2 of the License, or | 
					
						
							|  |  |  |   (at your option) any later version. | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |   but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |   GNU General Public License for more details. | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |   along with this program; if not, write to the Free Software | 
					
						
							|  |  |  |   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Tests the lamdaemon script. | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * @author Roland Gruber | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | * @author Thomas Manninger | 
					
						
							| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | * @package tools | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** security functions */ | 
					
						
							|  |  |  | include_once("../../lib/security.inc"); | 
					
						
							|  |  |  | /** access to configuration options */ | 
					
						
							|  |  |  | include_once("../../lib/config.inc"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // start session
 | 
					
						
							|  |  |  | startSecureSession(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-30 13:15:39 +00:00
										 |  |  | // die if no write access
 | 
					
						
							|  |  |  | if (!checkIfWriteAccessIsAllowed()) die(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | setlanguage(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-01 17:21:46 +00:00
										 |  |  | include '../main_header.php'; | 
					
						
							| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-01 17:21:46 +00:00
										 |  |  | echo "<h1>" . _("Lamdaemon test") . "</h1>\n"; | 
					
						
							| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-27 16:12:06 +00:00
										 |  |  | $servers = explode(";", $_SESSION['config']->get_scriptServers()); | 
					
						
							|  |  |  | $serverIDs = array(); | 
					
						
							|  |  |  | $serverTitles = array(); | 
					
						
							|  |  |  | for ($i = 0; $i < sizeof($servers); $i++) { | 
					
						
							|  |  |  | 	$serverParts = explode(":", $servers[$i]); | 
					
						
							|  |  |  | 	$serverName = $serverParts[0]; | 
					
						
							|  |  |  | 	$title = $serverName; | 
					
						
							|  |  |  | 	if (isset($serverParts[1])) { | 
					
						
							|  |  |  | 		$title = $serverParts[1] . " (" . $serverName . ")"; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	$serverIDs[] = $serverName; | 
					
						
							|  |  |  | 	$serverTitles[$serverName] = $title; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (isset($_POST['runTest'])) { | 
					
						
							|  |  |  | 	lamRunLamdaemonTestSuite($_POST['server'], $serverTitles[$_POST['server']] , isset($_POST['checkQuotas'])); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | else if ((sizeof($servers) > 0) && isset($servers[0]) && ($servers[0] != '')) { | 
					
						
							|  |  |  | 	echo "<form action=\"lamdaemonTest.php\" method=\"post\">\n"; | 
					
						
							|  |  |  | 	echo "<fieldset class=\"useredit\"><legend><b>" . _("Lamdaemon test") . "</b></legend><br>\n"; | 
					
						
							|  |  |  | 	echo "<table>\n"; | 
					
						
							|  |  |  | 	echo "<tr>\n"; | 
					
						
							|  |  |  | 		echo "<td>\n"; | 
					
						
							|  |  |  | 			echo _("Server"); | 
					
						
							|  |  |  | 		echo "</td>\n"; | 
					
						
							|  |  |  | 		echo "<td>\n"; | 
					
						
							|  |  |  | 			echo "<select name=\"server\">\n"; | 
					
						
							|  |  |  | 				for ($i = 0; $i < sizeof($servers); $i++) { | 
					
						
							|  |  |  | 					$servers[$i] = explode(":", $servers[$i]); | 
					
						
							|  |  |  | 					$serverName = $servers[$i][0]; | 
					
						
							|  |  |  | 					$title = $serverName; | 
					
						
							|  |  |  | 					if (isset($servers[$i][1])) { | 
					
						
							|  |  |  | 						$title = $servers[$i][1] . " (" . $serverName . ")"; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					echo "<option value=\"$serverName\">$title</option>\n";
 | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			echo "</select>\n"; | 
					
						
							|  |  |  | 		echo "</td>\n"; | 
					
						
							|  |  |  | 	echo "</tr>\n"; | 
					
						
							|  |  |  | 	echo "<tr>\n"; | 
					
						
							|  |  |  | 		echo "<td>\n"; | 
					
						
							|  |  |  | 			echo _("Check quotas"); | 
					
						
							|  |  |  | 		echo "</td>\n"; | 
					
						
							|  |  |  | 		echo "<td>\n"; | 
					
						
							|  |  |  | 			echo "<input type=\"checkbox\" name=\"checkQuotas\">\n"; | 
					
						
							|  |  |  | 		echo "</td>\n"; | 
					
						
							|  |  |  | 	echo "</tr>\n"; | 
					
						
							|  |  |  | 	echo "</table>\n"; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	echo "<br>"; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	echo "<input type=\"submit\" name=\"runTest\" value=\"" . _("Ok") . "\">\n"; | 
					
						
							|  |  |  | 	echo "</fieldset>\n"; | 
					
						
							|  |  |  | 	echo "</form>\n"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | else { | 
					
						
							|  |  |  | 	StatusMessage("ERROR", _('No lamdaemon server set, please update your LAM configuration settings.')); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | include '../main_footer.php'; | 
					
						
							| 
									
										
										
										
											2008-01-27 16:12:06 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-11-05 12:16:07 +00:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Runs a test case of lamdaemon. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param string $command test command | 
					
						
							|  |  |  |  * @param boolean $stopTest specifies if test should be run | 
					
						
							|  |  |  |  * @param connection $handle SSH connection | 
					
						
							|  |  |  |  * @param string $testText describing text | 
					
						
							|  |  |  |  * @return boolean true, if errors occured | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | function lamTestLamdaemon($command, $stopTest, $handle, $testText) { | 
					
						
							| 
									
										
										
										
											2010-05-31 18:10:36 +00:00
										 |  |  | 	$okImage = "<img width=16 height=16 src=\"../../graphics/pass.png\" alt=\"\">\n"; | 
					
						
							|  |  |  | 	$failImage = "<img width=16 height=16 src=\"../../graphics/fail.png\" alt=\"\">\n"; | 
					
						
							| 
									
										
										
										
											2006-11-05 12:16:07 +00:00
										 |  |  | 	// run lamdaemon and get user quotas
 | 
					
						
							|  |  |  | 	if (!$stopTest) { | 
					
						
							| 
									
										
										
										
											2010-07-07 15:22:07 +00:00
										 |  |  | 		echo "<tr class=\"userlist-bright\">\n<td nowrap>" . $testText . "  </td>\n"; | 
					
						
							| 
									
										
										
										
											2006-11-05 12:16:07 +00:00
										 |  |  | 		flush(); | 
					
						
							|  |  |  | 		$lamdaemonOk = false; | 
					
						
							| 
									
										
										
										
											2010-05-23 14:08:46 +00:00
										 |  |  | 		$output = $handle->exec("sudo " . $_SESSION['config']->get_scriptPath() . ' ' . escapeshellarg($command)); | 
					
						
							|  |  |  | 		if ((stripos(strtolower($output), "error") === false) && ((strpos($output, 'INFO,') === 0) || (strpos($output, 'QUOTA_ENTRY') === 0))) { | 
					
						
							| 
									
										
										
										
											2006-11-05 12:16:07 +00:00
										 |  |  | 			$lamdaemonOk = true; | 
					
						
							| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2006-11-05 12:16:07 +00:00
										 |  |  | 		if ($lamdaemonOk) { | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 			echo "<td nowrap>" . $okImage . "  </td>"; | 
					
						
							| 
									
										
										
										
											2007-12-31 13:25:09 +00:00
										 |  |  | 			echo "<td>" . _("Lamdaemon successfully run.") . "</td>"; | 
					
						
							| 
									
										
										
										
											2006-11-05 12:16:07 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 			echo "<td nowrap>" . $failImage . "  </td>\n"; | 
					
						
							| 
									
										
										
										
											2007-12-31 13:25:09 +00:00
										 |  |  | 			echo "<td>\n"; | 
					
						
							| 
									
										
										
										
											2010-05-23 14:08:46 +00:00
										 |  |  | 			if (!(strpos($output, 'ERROR,') === 0) && !(strpos($output, 'WARN,') === 0)) { | 
					
						
							|  |  |  | 				// error messages from console (e.g. sudo)
 | 
					
						
							|  |  |  | 				StatusMessage('ERROR', $output); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							|  |  |  | 				// error messages from lamdaemon
 | 
					
						
							|  |  |  | 				call_user_func_array('StatusMessage', explode(",", $output)); | 
					
						
							| 
									
										
										
										
											2006-11-05 12:16:07 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			echo "</td>\n"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 			$stopTest = true; | 
					
						
							| 
									
										
										
										
											2006-11-05 12:16:07 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		echo "</tr>\n"; | 
					
						
							| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-11-05 12:16:07 +00:00
										 |  |  | 	flush(); | 
					
						
							|  |  |  | 	return $stopTest; | 
					
						
							| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-27 16:12:06 +00:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Runs all tests for a given server. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param String $serverName server ID | 
					
						
							|  |  |  |  * @param String $serverTitle server name | 
					
						
							|  |  |  |  * @param boolean $testQuota true, if Quotas should be checked | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | function lamRunLamdaemonTestSuite($serverName, $serverTitle, $testQuota) { | 
					
						
							| 
									
										
										
										
											2009-12-12 17:22:14 +00:00
										 |  |  | 	$SPLIT_DELIMITER = "###x##y##x###"; | 
					
						
							| 
									
										
										
										
											2010-05-31 18:10:36 +00:00
										 |  |  | 	$okImage = "<img width=16 height=16 src=\"../../graphics/pass.png\" alt=\"\">\n"; | 
					
						
							|  |  |  | 	$failImage = "<img width=16 height=16 src=\"../../graphics/fail.png\" alt=\"\">\n"; | 
					
						
							| 
									
										
										
										
											2008-01-27 16:12:06 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 	echo "<table class=\"userlist\" rules=\"none\">\n"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	flush(); | 
					
						
							|  |  |  | 	$stopTest = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-07 15:22:07 +00:00
										 |  |  | 	echo "<tr class=\"userlist-bright\">\n<td colspan=\"3\" align=\"center\"><b>$serverTitle</b>\n</td>\n</tr>"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// check script server and path
 | 
					
						
							| 
									
										
										
										
											2010-07-07 15:22:07 +00:00
										 |  |  | 	echo "<tr class=\"userlist-bright\">\n<td nowrap>" . _("Lamdaemon server and path") . "  </td>\n"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 	if (!isset($serverName) || (strlen($serverName) < 3)) { | 
					
						
							| 
									
										
										
										
											2007-12-31 13:25:09 +00:00
										 |  |  | 		echo "<td>" . $failImage . "</td>\n"; | 
					
						
							|  |  |  | 		echo "<td>" . _("No lamdaemon server set, please update your LAM configuration settings.") . "</td>"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2007-12-29 18:59:09 +00:00
										 |  |  | 	elseif (($_SESSION['config']->get_scriptPath() == null) || (strlen($_SESSION['config']->get_scriptPath()) < 10)) { | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 		echo "<td nowrap>" . $failImage . "  </td>\n"; | 
					
						
							| 
									
										
										
										
											2007-12-31 13:25:09 +00:00
										 |  |  | 		echo "<td>" . _("No lamdaemon path set, please update your LAM configuration settings.") . "</td>"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 		$stopTest = true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 		echo "<td nowrap>" . $okImage . "  </td>\n"; | 
					
						
							| 
									
										
										
										
											2007-12-31 13:25:09 +00:00
										 |  |  | 		echo "<td>" . sprintf(_("Using %s as lamdaemon remote server."), $serverName) . "</td>"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	echo "</tr>\n"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	flush(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// check Unix account of LAM admin
 | 
					
						
							|  |  |  | 	if (!$stopTest) { | 
					
						
							| 
									
										
										
										
											2010-07-07 15:22:07 +00:00
										 |  |  | 		echo "<tr class=\"userlist-bright\">\n<td nowrap>" . _("Unix account") . "  </td>\n"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 		$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) { | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 			echo "<td nowrap>" . $okImage . "  </td>\n"; | 
					
						
							| 
									
										
										
										
											2007-12-31 13:25:09 +00:00
										 |  |  | 			echo "<td>" . sprintf(_("Using %s to connect to remote server."), $userName) . "</td>"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 			echo "<td nowrap>" . $failImage . "  </td>\n"; | 
					
						
							| 
									
										
										
										
											2007-12-31 13:25:09 +00:00
										 |  |  | 			echo "<td>" . sprintf(_("Your LAM admin user (%s) must be a valid Unix account to work with lamdaemon!"), $credentials[0]) . "</td>"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 			$stopTest = true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		echo "</tr>\n"; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	flush(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// check SSH login
 | 
					
						
							|  |  |  | 	if (!$stopTest) { | 
					
						
							| 
									
										
										
										
											2010-07-07 15:22:07 +00:00
										 |  |  | 		echo "<tr class=\"userlist-bright\">\n<td nowrap>" . _("SSH connection") . "  </td>\n"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 		flush(); | 
					
						
							|  |  |  | 		$sshOk = false; | 
					
						
							| 
									
										
										
										
											2009-12-12 18:21:11 +00:00
										 |  |  | 		$handle = lamTestConnectSSH($serverName); | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 		if ($handle) { | 
					
						
							| 
									
										
										
										
											2010-05-23 14:08:46 +00:00
										 |  |  | 			if ($handle->login($userName, $credentials[1])) { | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 				$sshOk = true; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if ($sshOk) { | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 			echo "<td nowrap>" . $okImage . "  </td>"; | 
					
						
							| 
									
										
										
										
											2007-12-31 13:25:09 +00:00
										 |  |  | 			echo "<td>" . _("SSH connection could be established.") . "</td>"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 			echo "<td nowrap>" . $failImage . "  </td>\n"; | 
					
						
							| 
									
										
										
										
											2007-12-31 13:25:09 +00:00
										 |  |  | 			echo "<td>" . _("Unable to connect to remote server!") . "</td>"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 			$stopTest = true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		echo "</tr>\n"; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	flush(); | 
					
						
							| 
									
										
										
										
											2008-12-18 14:44:42 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-05-14 10:14:19 +00:00
										 |  |  | 	$stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "basic", $stopTest, $handle, _("Execute lamdaemon")); | 
					
						
							| 
									
										
										
										
											2010-01-02 18:40:29 +00:00
										 |  |  | 	$handle = lamTestConnectSSH($serverName); | 
					
						
							| 
									
										
										
										
											2010-05-23 14:08:46 +00:00
										 |  |  | 	@$handle->login($userName, $credentials[1]); | 
					
						
							| 
									
										
										
										
											2010-05-14 10:14:19 +00:00
										 |  |  | 	$stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "nss" . $SPLIT_DELIMITER . "$userName", $stopTest, $handle, _("Lamdaemon: check NSS LDAP")); | 
					
						
							| 
									
										
										
										
											2008-01-27 16:12:06 +00:00
										 |  |  | 	if ($testQuota) { | 
					
						
							| 
									
										
										
										
											2009-12-12 18:21:11 +00:00
										 |  |  | 		$handle = lamTestConnectSSH($serverName); | 
					
						
							| 
									
										
										
										
											2010-05-23 14:08:46 +00:00
										 |  |  | 		@$handle->login($userName, $credentials[1]); | 
					
						
							| 
									
										
										
										
											2010-05-14 10:14:19 +00:00
										 |  |  | 		$stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "quota", $stopTest, $handle, _("Lamdaemon: Quota module installed")); | 
					
						
							| 
									
										
										
										
											2009-12-12 18:21:11 +00:00
										 |  |  | 		$handle = lamTestConnectSSH($serverName); | 
					
						
							| 
									
										
										
										
											2010-05-23 14:08:46 +00:00
										 |  |  | 		@$handle->login($userName, $credentials[1]); | 
					
						
							| 
									
										
										
										
											2010-05-14 10:14:19 +00:00
										 |  |  | 		$stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "quota" . $SPLIT_DELIMITER . "get" . $SPLIT_DELIMITER . "user", $stopTest, $handle, _("Lamdaemon: read quotas")); | 
					
						
							| 
									
										
										
										
											2008-01-27 16:12:06 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-31 13:25:09 +00:00
										 |  |  | 	echo "</table><br>\n"; | 
					
						
							| 
									
										
										
										
											2008-01-27 16:12:06 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	echo "<h2>" . _("Lamdaemon test finished.") . "</h2>\n"; | 
					
						
							| 
									
										
										
										
											2007-02-22 17:38:22 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-12 18:21:11 +00:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Connects to the given SSH server. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param String $server server name (e.g. localhost or localhost,1234) | 
					
						
							|  |  |  |  * @return object handle | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | function lamTestConnectSSH($server) { | 
					
						
							| 
									
										
										
										
											2010-05-23 14:08:46 +00:00
										 |  |  | 	// add phpseclib to include path
 | 
					
						
							|  |  |  | 	set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../../lib/3rdParty/phpseclib'); | 
					
						
							|  |  |  | 	include_once('Net/SSH2.php'); | 
					
						
							| 
									
										
										
										
											2009-12-12 18:21:11 +00:00
										 |  |  | 	$serverNameParts = explode(",", $server); | 
					
						
							|  |  |  | 	if (sizeof($serverNameParts) > 1) { | 
					
						
							| 
									
										
										
										
											2010-05-23 14:08:46 +00:00
										 |  |  | 		return @new Net_SSH2($serverNameParts[0], $serverNameParts[1]); | 
					
						
							| 
									
										
										
										
											2009-12-12 18:21:11 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2010-05-23 14:08:46 +00:00
										 |  |  | 		return @new Net_SSH2($server); | 
					
						
							| 
									
										
										
										
											2009-12-12 18:21:11 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-04 18:12:22 +00:00
										 |  |  | ?>
 |