better error handling and no longer depend on ssh2 module
This commit is contained in:
parent
6a31925d00
commit
e3bffe6b7a
|
@ -340,12 +340,12 @@ sub getQuotas {
|
||||||
logMessage(LOG_ERR, "Unable to read quota for $user[0].");
|
logMessage(LOG_ERR, "Unable to read quota for $user[0].");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$return = "$quota_usr[$i][1],$temp[0],$temp[1],$temp[2],$temp[3],$temp[4],$temp[5],$temp[6],$temp[7]:$return";
|
$return = "QUOTA_ENTRY $quota_usr[$i][1],$temp[0],$temp[1],$temp[2],$temp[3],$temp[4],$temp[5],$temp[6],$temp[7]:$return";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { $return = "$quota_usr[$i][1],0,0,0,0,0,0,0,0:$return"; }
|
else { $return = "QUOTA_ENTRY $quota_usr[$i][1],0,0,0,0,0,0,0,0:$return"; }
|
||||||
}
|
}
|
||||||
else { $return = "$quota_usr[$i][1],0,0,0,0,0,0,0,0:$return"; }
|
else { $return = "QUOTA_ENTRY $quota_usr[$i][1],0,0,0,0,0,0,0,0:$return"; }
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
($<, $>) = ($>, $<); # Give up root previleges
|
($<, $>) = ($>, $<); # Give up root previleges
|
||||||
|
|
|
@ -572,13 +572,12 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
$result = lamdaemon(implode(posixAccount::$SPLIT_DELIMITER, array($this->attributes['uid'][0], "home", "add", "0".$_SESSION['config']->get_scriptRights())), $server);
|
$result = lamdaemon(implode(posixAccount::$SPLIT_DELIMITER, array($this->attributes['uid'][0], "home", "add", "0".$_SESSION['config']->get_scriptRights())), $server);
|
||||||
// lamdaemon results
|
// lamdaemon results
|
||||||
if (is_array($result)) {
|
if (is_array($result)) {
|
||||||
foreach ($result as $singleresult) {
|
$singleresult = explode(",", $result[0]);
|
||||||
$singleresult = explode(",", $singleresult);
|
|
||||||
if (is_array($singleresult)) {
|
|
||||||
if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'INFO') || ($singleresult[0] == 'WARN')) {
|
if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'INFO') || ($singleresult[0] == 'WARN')) {
|
||||||
call_user_func_array('StatusMessage', $singleresult);
|
call_user_func_array('StatusMessage', $singleresult);
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
|
StatusMessage('ERROR', $result[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -972,8 +971,7 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
array('kind' => 'input', 'name' => 'homeDirectory', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['homeDirectory'][0]),
|
array('kind' => 'input', 'name' => 'homeDirectory', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['homeDirectory'][0]),
|
||||||
array('kind' => 'help', 'value' => 'homeDirectory'));
|
array('kind' => 'help', 'value' => 'homeDirectory'));
|
||||||
if ($this->getAccountContainer()->isNewAccount && ($_SESSION['config']->get_scriptPath() != null)
|
if ($this->getAccountContainer()->isNewAccount && ($_SESSION['config']->get_scriptPath() != null)
|
||||||
&& ($_SESSION['config']->get_scriptPath() != '')
|
&& ($_SESSION['config']->get_scriptPath() != '')) {
|
||||||
&& extension_loaded('ssh2')) {
|
|
||||||
// get list of lamdaemon servers
|
// get list of lamdaemon servers
|
||||||
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
|
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
|
||||||
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
|
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
|
||||||
|
@ -1019,7 +1017,7 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
* @return meta HTML code
|
* @return meta HTML code
|
||||||
*/
|
*/
|
||||||
function display_html_delete() {
|
function display_html_delete() {
|
||||||
if ($this->get_scope() == 'user' && ($_SESSION['config']->get_scriptPath() != null) && extension_loaded('ssh2')) {
|
if ($this->get_scope() == 'user' && ($_SESSION['config']->get_scriptPath() != null)) {
|
||||||
$return[] = array (
|
$return[] = array (
|
||||||
array('kind' => 'text', 'text' => _('Delete home directory')),
|
array('kind' => 'text', 'text' => _('Delete home directory')),
|
||||||
array('kind' => 'input', 'name' => 'deletehomedir', 'type' => 'checkbox'),
|
array('kind' => 'input', 'name' => 'deletehomedir', 'type' => 'checkbox'),
|
||||||
|
@ -1109,7 +1107,7 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
array('kind' => 'select', 'name' => 'posixAccount_loginShell', 'options' => $shelllist, 'options_selected' => array("/bin/bash")),
|
array('kind' => 'select', 'name' => 'posixAccount_loginShell', 'options' => $shelllist, 'options_selected' => array("/bin/bash")),
|
||||||
array('kind' => 'help', 'value' => 'loginShell', 'scope' => 'user'));
|
array('kind' => 'help', 'value' => 'loginShell', 'scope' => 'user'));
|
||||||
// lamdaemon settings
|
// lamdaemon settings
|
||||||
if (($_SESSION['config']->get_scriptPath() != null) && extension_loaded('ssh2')) {
|
if (($_SESSION['config']->get_scriptPath() != null)) {
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
array('kind' => 'text', 'text' => _('Create home directory') . ": "),
|
array('kind' => 'text', 'text' => _('Create home directory') . ": "),
|
||||||
array('kind' => 'input', 'type' => 'checkbox', 'name' => 'posixAccount_createHomedir'),
|
array('kind' => 'input', 'type' => 'checkbox', 'name' => 'posixAccount_createHomedir'),
|
||||||
|
|
|
@ -41,6 +41,8 @@ class quota extends baseModule {
|
||||||
|
|
||||||
private static $SPLIT_DELIMITER = "###x##y##x###";
|
private static $SPLIT_DELIMITER = "###x##y##x###";
|
||||||
|
|
||||||
|
private static $QUOTA_PREFIX = 'QUOTA_ENTRY ';
|
||||||
|
|
||||||
/** this functin fills the error message array with messages
|
/** this functin fills the error message array with messages
|
||||||
**/
|
**/
|
||||||
function load_Messages() {
|
function load_Messages() {
|
||||||
|
@ -83,8 +85,6 @@ class quota extends baseModule {
|
||||||
// module dependencies
|
// module dependencies
|
||||||
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
|
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
|
||||||
}
|
}
|
||||||
// PHP extensions
|
|
||||||
$return['extensions'] = array('ssh2');
|
|
||||||
// managed attributes
|
// managed attributes
|
||||||
$return['attributes'] = array('uid', 'cn');
|
$return['attributes'] = array('uid', 'cn');
|
||||||
// available PDF fields
|
// available PDF fields
|
||||||
|
@ -157,7 +157,6 @@ class quota extends baseModule {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function initQuotas() {
|
function initQuotas() {
|
||||||
if (!extension_loaded('ssh2')) return;
|
|
||||||
if (isset($this->quota)) return;
|
if (isset($this->quota)) return;
|
||||||
$userName = '+';
|
$userName = '+';
|
||||||
if (($this->getAccountContainer() != null) && !$this->getAccountContainer()->isNewAccount) {
|
if (($this->getAccountContainer() != null) && !$this->getAccountContainer()->isNewAccount) {
|
||||||
|
@ -180,6 +179,8 @@ class quota extends baseModule {
|
||||||
$allQuotas = explode(":", $quotas[0]);
|
$allQuotas = explode(":", $quotas[0]);
|
||||||
array_pop($allQuotas); // remove empty element at the end
|
array_pop($allQuotas); // remove empty element at the end
|
||||||
for ($i = 0; $i < sizeof($allQuotas); $i++) {
|
for ($i = 0; $i < sizeof($allQuotas); $i++) {
|
||||||
|
if (strpos($allQuotas[$i], quota::$QUOTA_PREFIX) !== 0) continue;
|
||||||
|
$allQuotas[$i] = substr($allQuotas[$i], strlen(quota::$QUOTA_PREFIX));
|
||||||
$singleQuota = explode(",", $allQuotas[$i]);
|
$singleQuota = explode(",", $allQuotas[$i]);
|
||||||
$this->quota[$server][$i] = $singleQuota;
|
$this->quota[$server][$i] = $singleQuota;
|
||||||
if ($this->quota[$server][$i][4] < time()) $this->quota[$server][$i][4] = '';
|
if ($this->quota[$server][$i][4] < time()) $this->quota[$server][$i][4] = '';
|
||||||
|
@ -359,11 +360,6 @@ class quota extends baseModule {
|
||||||
* @return array HTML meta data
|
* @return array HTML meta data
|
||||||
*/
|
*/
|
||||||
function display_html_attributes() {
|
function display_html_attributes() {
|
||||||
if (!extension_loaded('ssh2')) {
|
|
||||||
return array(
|
|
||||||
array(array('kind' => 'text', 'text' => _('This module requires the PHP ssh2 extension.'))
|
|
||||||
));
|
|
||||||
}
|
|
||||||
$return = array();
|
$return = array();
|
||||||
$this->initQuotas();
|
$this->initQuotas();
|
||||||
if (!is_array($this->quota)) return $return;
|
if (!is_array($this->quota)) return $return;
|
||||||
|
@ -462,9 +458,16 @@ class quota extends baseModule {
|
||||||
$dirs = explode(":", $quotas[0]);
|
$dirs = explode(":", $quotas[0]);
|
||||||
array_pop($dirs); // remove empty element at the end
|
array_pop($dirs); // remove empty element at the end
|
||||||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||||
|
if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) {
|
||||||
|
unset($dirs[$i]);
|
||||||
|
$i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$dirs[$i] = substr($dirs[$i], strlen(quota::$QUOTA_PREFIX));
|
||||||
$dirs[$i] = explode(",", $dirs[$i]);
|
$dirs[$i] = explode(",", $dirs[$i]);
|
||||||
$dirs[$i] = $dirs[$i][0];
|
$dirs[$i] = $dirs[$i][0];
|
||||||
}
|
}
|
||||||
|
$dirs = array_values($dirs);
|
||||||
if (sizeof($dirs) < 1) continue; // stop if no quota directories were found
|
if (sizeof($dirs) < 1) continue; // stop if no quota directories were found
|
||||||
$fieldContent = array();
|
$fieldContent = array();
|
||||||
$fieldContent[] = array (
|
$fieldContent[] = array (
|
||||||
|
@ -516,9 +519,16 @@ class quota extends baseModule {
|
||||||
$dirs = explode(":", $quotas[0]);
|
$dirs = explode(":", $quotas[0]);
|
||||||
array_pop($dirs); // remove empty element at the end
|
array_pop($dirs); // remove empty element at the end
|
||||||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||||
|
if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) {
|
||||||
|
unset($dirs[$i]);
|
||||||
|
$i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$dirs[$i] = substr($dirs[$i], strlen(quota::$QUOTA_PREFIX));
|
||||||
$dirs[$i] = explode(",", $dirs[$i]);
|
$dirs[$i] = explode(",", $dirs[$i]);
|
||||||
$dirs[$i] = $dirs[$i][0];
|
$dirs[$i] = $dirs[$i][0];
|
||||||
}
|
}
|
||||||
|
$dirs = array_values($dirs);
|
||||||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||||
if (!get_preg($options["quota_softblock_" . $id . "_" . $dirs[$i]][0], 'digit')) $return[] = $this->messages['softblock'][0];
|
if (!get_preg($options["quota_softblock_" . $id . "_" . $dirs[$i]][0], 'digit')) $return[] = $this->messages['softblock'][0];
|
||||||
if (!get_preg($options["quota_hardblock_" . $id . "_" . $dirs[$i]][0], 'digit')) $return[] = $this->messages['hardblock'][0];
|
if (!get_preg($options["quota_hardblock_" . $id . "_" . $dirs[$i]][0], 'digit')) $return[] = $this->messages['hardblock'][0];
|
||||||
|
@ -629,9 +639,16 @@ class quota extends baseModule {
|
||||||
$dirs = explode(":", $quotas[0]);
|
$dirs = explode(":", $quotas[0]);
|
||||||
array_pop($dirs); // remove empty element at the end
|
array_pop($dirs); // remove empty element at the end
|
||||||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||||
|
if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) {
|
||||||
|
unset($dirs[$i]);
|
||||||
|
$i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$dirs[$i] = substr($dirs[$i], strlen(quota::$QUOTA_PREFIX));
|
||||||
$dirs[$i] = explode(",", $dirs[$i]);
|
$dirs[$i] = explode(",", $dirs[$i]);
|
||||||
$dirs[$i] = $dirs[$i][0];
|
$dirs[$i] = $dirs[$i][0];
|
||||||
}
|
}
|
||||||
|
$dirs = array_values($dirs);
|
||||||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
'name' => 'quota_' . $server . ':' . $dirs[$i],
|
'name' => 'quota_' . $server . ':' . $dirs[$i],
|
||||||
|
|
Loading…
Reference in New Issue