error handling
This commit is contained in:
parent
3eaeaa6c30
commit
b541460231
|
@ -165,7 +165,6 @@ class quota extends baseModule {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the quota values.
|
* Initializes the quota values.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
function initQuotas() {
|
function initQuotas() {
|
||||||
if (isset($this->quota)) return;
|
if (isset($this->quota)) return;
|
||||||
|
@ -519,6 +518,7 @@ class quota extends baseModule {
|
||||||
$optionsAvailable = false;
|
$optionsAvailable = false;
|
||||||
// get list of lamdaemon servers
|
// get list of lamdaemon servers
|
||||||
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
|
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
|
||||||
|
try {
|
||||||
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
|
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
|
||||||
$temp = explode(":", $lamdaemonServers[$s]);
|
$temp = explode(":", $lamdaemonServers[$s]);
|
||||||
$server = $temp[0];
|
$server = $temp[0];
|
||||||
|
@ -586,6 +586,11 @@ class quota extends baseModule {
|
||||||
$return->addNewLine();
|
$return->addNewLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (LAMException $e) {
|
||||||
|
$return->addElement(new htmlStatusMessage('WARN', $e->getTitle()));
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
if (!$optionsAvailable) {
|
if (!$optionsAvailable) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -640,7 +645,12 @@ class quota extends baseModule {
|
||||||
* @param array $profile hash array with profile values (identifier => value)
|
* @param array $profile hash array with profile values (identifier => value)
|
||||||
*/
|
*/
|
||||||
function load_profile($profile) {
|
function load_profile($profile) {
|
||||||
|
try {
|
||||||
$this->initQuotas();
|
$this->initQuotas();
|
||||||
|
}
|
||||||
|
catch (LAMException $e) {
|
||||||
|
logNewMessage(LOG_ERR, $e->getTitle(), $e->getMessage());
|
||||||
|
}
|
||||||
if (!isset($this->quota) || !is_array($this->quota)) return;
|
if (!isset($this->quota) || !is_array($this->quota)) return;
|
||||||
$servers = array_keys($this->quota);
|
$servers = array_keys($this->quota);
|
||||||
for ($s = 0; $s < sizeof($servers); $s++) {
|
for ($s = 0; $s < sizeof($servers); $s++) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace LAM\REMOTE;
|
namespace LAM\REMOTE;
|
||||||
use \Exception;
|
use \LAMException;
|
||||||
use \phpseclib\Net\SSH2;
|
use \phpseclib\Net\SSH2;
|
||||||
use \phpseclib\Crypt\RSA;
|
use \phpseclib\Crypt\RSA;
|
||||||
/*
|
/*
|
||||||
|
@ -78,7 +78,7 @@ class Remote {
|
||||||
$handle = @new SSH2($server);
|
$handle = @new SSH2($server);
|
||||||
}
|
}
|
||||||
if (!$handle) {
|
if (!$handle) {
|
||||||
throw new Exception(_("Unable to connect to remote server!"));
|
throw new LAMException(_("Unable to connect to remote server!"));
|
||||||
}
|
}
|
||||||
$this->loginSSH($handle);
|
$this->loginSSH($handle);
|
||||||
$this->server = $handle;
|
$this->server = $handle;
|
||||||
|
@ -111,7 +111,7 @@ class Remote {
|
||||||
$username = $entry[0]['uid'][0];
|
$username = $entry[0]['uid'][0];
|
||||||
}
|
}
|
||||||
if (empty($username)) {
|
if (empty($username)) {
|
||||||
throw new Exception(sprintf(_("Your LAM admin user (%s) must be a valid Unix account to work with lamdaemon!"), getAbstractDN($credentials[0])));
|
throw new LAMException(sprintf(_("Your LAM admin user (%s) must be a valid Unix account to work with lamdaemon!"), getAbstractDN($credentials[0])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$password = $credentials[1];
|
$password = $credentials[1];
|
||||||
|
@ -119,7 +119,7 @@ class Remote {
|
||||||
if (!empty($keyPath)) {
|
if (!empty($keyPath)) {
|
||||||
// use key authentication
|
// use key authentication
|
||||||
if (!file_exists($keyPath) || !is_readable($keyPath)) {
|
if (!file_exists($keyPath) || !is_readable($keyPath)) {
|
||||||
throw new Exception(sprintf(_("Unable to read %s."), htmlspecialchars($keyPath)));
|
throw new LAMException(sprintf(_("Unable to read %s."), htmlspecialchars($keyPath)));
|
||||||
}
|
}
|
||||||
$key = file_get_contents($keyPath);
|
$key = file_get_contents($keyPath);
|
||||||
$rsa = new RSA();
|
$rsa = new RSA();
|
||||||
|
@ -128,13 +128,13 @@ class Remote {
|
||||||
$rsa->setPassword($keyPassword);
|
$rsa->setPassword($keyPassword);
|
||||||
}
|
}
|
||||||
if (!$rsa->loadKey($key)) {
|
if (!$rsa->loadKey($key)) {
|
||||||
throw new Exception(sprintf(_("Unable to load key %s."), htmlspecialchars($keyPath)));
|
throw new LAMException(sprintf(_("Unable to load key %s."), htmlspecialchars($keyPath)));
|
||||||
}
|
}
|
||||||
$password = $rsa;
|
$password = $rsa;
|
||||||
}
|
}
|
||||||
$login = @$handle->login($username, $password);
|
$login = @$handle->login($username, $password);
|
||||||
if (!$login) {
|
if (!$login) {
|
||||||
throw new Exception(_("Unable to login to remote server!"));
|
throw new LAMException(_("Unable to login to remote server!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue