From 1e57661fb7322d52b91dbbc2a826416abb6c4975 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 9 Apr 2011 16:23:19 +0000 Subject: [PATCH] removed old libssh2 code --- lam/lib/lamdaemon.inc | 66 +------------------------------------------ 1 file changed, 1 insertion(+), 65 deletions(-) diff --git a/lam/lib/lamdaemon.inc b/lam/lib/lamdaemon.inc index e2e7757e..597ca218 100644 --- a/lam/lib/lamdaemon.inc +++ b/lam/lib/lamdaemon.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2004 - 2010 Roland Gruber + Copyright (C) 2004 - 2011 Roland Gruber 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 @@ -40,70 +40,6 @@ $Id$ * */ function lamdaemon($command, $server) { - // remove the following line to restore SSH via PHP SSH2 - return lamdaemonSeclib($command, $server); - if (!function_exists('ssh2_connect')) { - return array('ERROR,' . _('This module requires the PHP ssh2 extension.')); - } - // get username and password of the current lam-admin - $credentials = $_SESSION['ldap']->decrypt_login(); - $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'), 0, 0, 0, LDAP_DEREF_NEVER); - if (!$sr) { - $return = array("ERROR," . _("Your LAM admin user must be a valid Unix account to work with lamdaemon!") . ","); - return $return; - } - $entry = @ldap_get_entries($_SESSION['ldap']->server(), $sr); - if (!isset($entry[0]['uid'][0])) { - $return = array("ERROR," . _("Your LAM admin user must be a valid Unix account to work with lamdaemon!") . ","); - return $return; - } - $userName = $entry[0]['uid'][0]; - if (@ssh2_auth_password($handle, $userName, $credentials[1])) { - $shell = ssh2_exec($handle, "sudo " . $_SESSION['config']->get_scriptPath() . ' ' . escapeshellarg($command)); - $return = array(); - $time = time() + 30; - while (sizeof($return) < 1) { - if ($time < time()) { - $return = array("ERROR," . _("Timeout while executing lamdaemon commands!") . ","); - return $return; - } - usleep(100); - $read = explode("\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]; - } - } - return $return; - } - else { - $return = array("ERROR," . _('Unable to connect to remote server!') . "," . $server); - return $return; - } - } - else { - $return = array("ERROR," . _('Unable to connect to remote server!') . "," . $server); - return $return; - } -} - -/** -* Sends commands to lamdaemon script. -* -* @param array $command command to execute -* @param string $server remote server -* @return array Output of lamdaemon -* -*/ -function lamdaemonSeclib($command, $server) { if ($server == '') { return array(); }