From 8eff004b83dabce2f46327bfad1f7b5d2aaf4533 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 3 Jul 2008 18:42:26 +0000 Subject: [PATCH] allow to specify SSH port --- lam/help/help.inc | 5 +++-- lam/lib/lamdaemon.inc | 8 +++++++- lam/templates/tests/lamdaemonTest.php | 8 +++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lam/help/help.inc b/lam/help/help.inc index 28c4db3b..989cd47b 100644 --- a/lam/help/help.inc +++ b/lam/help/help.inc @@ -106,8 +106,9 @@ $helpArray = array ( "Text" => _("Here you can select which plugins you want to use for account management.") . "

" . _("Account types define which sorts of LDAP entries (e.g. users and groups) should be managed. The account modules define which properties (e.g. Unix and Samba) can be edited.")), "218" => array ("Headline" => _("Configuration wizard") . " - " . _("Script servers"), - "Text" => _("This is a list of the servers where the lamdaemon scripts are stored. LDAP Account Manager will make a SSH connection to the servers with the user name and password provided at login. Multiple servers are separated by semicolons. You can append a descriptive name after a colon.") . "

" - . _("Example") . ": 127.0.0.1:LOCAL;192.168.0.2:Servername;"), + "Text" => _("This is a list of the servers where the lamdaemon scripts are stored. LDAP Account Manager will make a SSH connection to the servers with the user name and password provided at login. Multiple servers are separated by semicolons. You can append a descriptive name after a colon.") . "
" + . _("If your server runs on another port then add a comma and the port number after the server.") . "

" + . _("Example") . ": 127.0.0.1:LOCAL;192.168.0.2,12345:Servername;192.168.0.5"), "219" => array ("Headline" => _("Configuration wizard") . " - " . _("Rights for the home directory"), "Text" => _("This defines the rights for the home directories which are created by lamdaemon.")), "230" => array ("Headline" => _("Profile management") . " - " . _("Add profile"), diff --git a/lam/lib/lamdaemon.inc b/lam/lib/lamdaemon.inc index 7ba84a91..3bf9db9b 100644 --- a/lam/lib/lamdaemon.inc +++ b/lam/lib/lamdaemon.inc @@ -98,7 +98,13 @@ function lamdaemonSSH($commands, $server) { $commands = implode("\n", $commands) . "\n"; // get username and password of the current lam-admin $credentials = $_SESSION['ldap']->decrypt_login(); - $handle = @ssh2_connect($server); + $serverNameParts = explode(",", $server); + if (sizeof($serverNameParts) > 1) { + $handle = @ssh2_connect($serverNameParts[0], $serverNameParts[1]); + } + else { + $handle = @ssh2_connect($server); + } if ($handle) { $sr = @ldap_read($_SESSION['ldap']->server(), $credentials[0], "objectClass=posixAccount", array('uid')); if (!$sr) { diff --git a/lam/templates/tests/lamdaemonTest.php b/lam/templates/tests/lamdaemonTest.php index 5db6a69b..f1ebe752 100644 --- a/lam/templates/tests/lamdaemonTest.php +++ b/lam/templates/tests/lamdaemonTest.php @@ -269,7 +269,13 @@ function lamRunLamdaemonTestSuite($serverName, $serverTitle, $testQuota) { echo "\n" . _("SSH connection") . "  \n"; flush(); $sshOk = false; - $handle = @ssh2_connect($serverName); + $serverNameParts = explode(",", $serverName); + if (sizeof($serverNameParts) > 1) { + $handle = @ssh2_connect($serverNameParts[0], $serverNameParts[1]); + } + else { + $handle = @ssh2_connect($serverName); + } if ($handle) { if (@ssh2_auth_password($handle, $userName, $credentials[1])) { $sshOk = true;