support users and groups with spaces in their name
This commit is contained in:
parent
9eb33a40a6
commit
eef932eb4d
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
use Sys::Syslog;
|
use Sys::Syslog;
|
||||||
|
|
||||||
|
my $SPLIT_DELIMITER = "###x##y##x###";
|
||||||
|
|
||||||
# set a known path
|
# set a known path
|
||||||
my $path = "";
|
my $path = "";
|
||||||
if (-d "/sbin") {
|
if (-d "/sbin") {
|
||||||
|
@ -108,7 +110,8 @@ while (1) {
|
||||||
my $input = <STDIN>;
|
my $input = <STDIN>;
|
||||||
chop($input);
|
chop($input);
|
||||||
$return = "";
|
$return = "";
|
||||||
@vals = split (' ', $input);
|
logMessage(LOG_ERR, $input);
|
||||||
|
@vals = split ($SPLIT_DELIMITER, $input);
|
||||||
# Get user information
|
# Get user information
|
||||||
if (($vals[3] eq 'user') || ($vals[1] eq 'home')) { @user = getpwnam($vals[0]); }
|
if (($vals[3] eq 'user') || ($vals[1] eq 'home')) { @user = getpwnam($vals[0]); }
|
||||||
else { @user = getgrnam($vals[0]); }
|
else { @user = getgrnam($vals[0]); }
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
class posixAccount extends baseModule implements passwordService {
|
class posixAccount extends baseModule implements passwordService {
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
|
private static $SPLIT_DELIMITER = "###x##y##x###";
|
||||||
|
|
||||||
/* These two variables keep an array of groups the user is also member of. */
|
/* These two variables keep an array of groups the user is also member of. */
|
||||||
private $groups;
|
private $groups;
|
||||||
|
@ -575,7 +576,7 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result = lamdaemon(array($this->attributes['uid'][0] . " home add 0".$_SESSION['config']->get_scriptRights()), $server);
|
$result = lamdaemon(array(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) {
|
foreach ($result as $singleresult) {
|
||||||
|
@ -624,7 +625,7 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
// try to delete directory on all servers
|
// try to delete directory on all servers
|
||||||
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
|
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
|
||||||
$result = lamdaemon(array($this->attributes['uid'][0] . " home rem"), $lamdaemonServers[$i]);
|
$result = lamdaemon(array(implode(posixAccount::$SPLIT_DELIMITER, array($this->attributes['uid'][0], "home", "rem"))), $lamdaemonServers[$i]);
|
||||||
// lamdaemon results
|
// lamdaemon results
|
||||||
if (is_array($result)) {
|
if (is_array($result)) {
|
||||||
foreach ($result as $singleresult) {
|
foreach ($result as $singleresult) {
|
||||||
|
@ -1596,7 +1597,7 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
// create home directories
|
// create home directories
|
||||||
elseif ($temp['counter'] < (sizeof($temp['groups']) + sizeof($temp['createHomes']))) {
|
elseif ($temp['counter'] < (sizeof($temp['groups']) + sizeof($temp['createHomes']))) {
|
||||||
$pos = $temp['createHomes'][$temp['counter'] - sizeof($temp['groups'])];
|
$pos = $temp['createHomes'][$temp['counter'] - sizeof($temp['groups'])];
|
||||||
$result = lamdaemon(array($data[$pos][$ids['posixAccount_userName']] . " home add 0".$_SESSION['config']->get_scriptRights()),
|
$result = lamdaemon(array(implode(posixAccount::$SPLIT_DELIMITER, array($data[$pos][$ids['posixAccount_userName']], "home", "add", "0".$_SESSION['config']->get_scriptRights()))),
|
||||||
$data[$pos][$ids['posixAccount_createHomeDir']]);
|
$data[$pos][$ids['posixAccount_createHomeDir']]);
|
||||||
$errors = array();
|
$errors = array();
|
||||||
if (($result != false) && (sizeof($result) == 1)) {
|
if (($result != false) && (sizeof($result) == 1)) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ $Id$
|
||||||
|
|
||||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||||
Copyright (C) 2003 - 2006 Tilo Lutz
|
Copyright (C) 2003 - 2006 Tilo Lutz
|
||||||
2007 - 2008 Roland Gruber
|
2007 - 2009 Roland Gruber
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -39,6 +39,8 @@ $Id$
|
||||||
*/
|
*/
|
||||||
class quota extends baseModule {
|
class quota extends baseModule {
|
||||||
|
|
||||||
|
private static $SPLIT_DELIMITER = "###x##y##x###";
|
||||||
|
|
||||||
/** this functin fills the error message array with messages
|
/** this functin fills the error message array with messages
|
||||||
**/
|
**/
|
||||||
function load_Messages() {
|
function load_Messages() {
|
||||||
|
@ -174,7 +176,7 @@ class quota extends baseModule {
|
||||||
$temp = explode(":", $lamdaemonServers[$s]);
|
$temp = explode(":", $lamdaemonServers[$s]);
|
||||||
$server = $temp[0];
|
$server = $temp[0];
|
||||||
// get quotas
|
// get quotas
|
||||||
$quotas = lamdaemon(array($userName . " quota get " . $this->get_scope()), $server);
|
$quotas = lamdaemon(array(implode(quota::$SPLIT_DELIMITER, array($userName, "quota", "get", $this->get_scope()))), $server);
|
||||||
$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++) {
|
||||||
|
@ -259,7 +261,7 @@ class quota extends baseModule {
|
||||||
$quotastring = $quotastring . $this->quota[$server][$i][0] . ',' . $this->quota[$server][$i][2] . ',' . $this->quota[$server][$i][3]
|
$quotastring = $quotastring . $this->quota[$server][$i][0] . ',' . $this->quota[$server][$i][2] . ',' . $this->quota[$server][$i][3]
|
||||||
. ',' . $this->quota[$server][$i][6] . ',' . $this->quota[$server][$i][7] . ':';
|
. ',' . $this->quota[$server][$i][6] . ',' . $this->quota[$server][$i][7] . ':';
|
||||||
}
|
}
|
||||||
lamdaemon(array($id . " quota set " . $this->get_scope() . " $quotastring\n"), $server);
|
lamdaemon(array(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n"))), $server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +300,7 @@ class quota extends baseModule {
|
||||||
$quotastring = $quotastring . $this->quota[$server][$i][0] . ',0,0,0,0:';
|
$quotastring = $quotastring . $this->quota[$server][$i][0] . ',0,0,0,0:';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
lamdaemon(array($id . " quota set " . $this->get_scope() . " $quotastring\n"), $server);
|
lamdaemon(array(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n"))), $server);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -456,7 +458,7 @@ class quota extends baseModule {
|
||||||
if (isset($temp[1])) $description = $temp[1];
|
if (isset($temp[1])) $description = $temp[1];
|
||||||
|
|
||||||
// Get quotas
|
// Get quotas
|
||||||
$quotas = lamdaemon(array("+ quota get " . $this->get_scope()), $server);
|
$quotas = lamdaemon(array(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope()))), $server);
|
||||||
$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++) {
|
||||||
|
@ -510,7 +512,7 @@ class quota extends baseModule {
|
||||||
$server = $temp[0];
|
$server = $temp[0];
|
||||||
$id = $this->replaceSpecialChars($server);
|
$id = $this->replaceSpecialChars($server);
|
||||||
// Get quotas
|
// Get quotas
|
||||||
$quotas = lamdaemon(array("+ quota get " . $this->get_scope()), $server);
|
$quotas = lamdaemon(array(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope()))), $server);
|
||||||
$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++) {
|
||||||
|
@ -622,7 +624,7 @@ class quota extends baseModule {
|
||||||
$temp = explode(":", $lamdaemonServers[$s]);
|
$temp = explode(":", $lamdaemonServers[$s]);
|
||||||
$server = $temp[0];
|
$server = $temp[0];
|
||||||
// Get quotas
|
// Get quotas
|
||||||
$quotas = lamdaemon(array("+ quota get " . $this->get_scope()), $server);
|
$quotas = lamdaemon(array(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope()))), $server);
|
||||||
$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++) {
|
||||||
|
@ -740,8 +742,8 @@ class quota extends baseModule {
|
||||||
$mpParts = explode(":", $mountPoints[$m]);
|
$mpParts = explode(":", $mountPoints[$m]);
|
||||||
$server = $mpParts[0];
|
$server = $mpParts[0];
|
||||||
$dir = $mpParts[1];
|
$dir = $mpParts[1];
|
||||||
$quotaString = $name . " quota set " . $this->get_scope() . " " . $dir . ',' .
|
$quotaString = implode(quota::$SPLIT_DELIMITER, array($name, "quota", "set", $this->get_scope(), $dir . ',' .
|
||||||
implode(',', $temp['accounts'][$name][$mountPoints[$m]]) . "\n";
|
implode(',', $temp['accounts'][$name][$mountPoints[$m]]) . "\n"));
|
||||||
$result = lamdaemon(array($quotaString), $server);
|
$result = lamdaemon(array($quotaString), $server);
|
||||||
if (is_array($result)) {
|
if (is_array($result)) {
|
||||||
for ($i = 0; $i < sizeof($result); $i++) {
|
for ($i = 0; $i < sizeof($result); $i++) {
|
||||||
|
|
|
@ -44,7 +44,6 @@ setlanguage();
|
||||||
|
|
||||||
echo $_SESSION['header'];
|
echo $_SESSION['header'];
|
||||||
|
|
||||||
|
|
||||||
echo "<title></title>\n";
|
echo "<title></title>\n";
|
||||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
|
||||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_user.css\">\n";
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_user.css\">\n";
|
||||||
|
@ -200,6 +199,7 @@ function lamTestLamdaemon($command, $stopTest, $handle, $testText) {
|
||||||
* @param boolean $testQuota true, if Quotas should be checked
|
* @param boolean $testQuota true, if Quotas should be checked
|
||||||
*/
|
*/
|
||||||
function lamRunLamdaemonTestSuite($serverName, $serverTitle, $testQuota) {
|
function lamRunLamdaemonTestSuite($serverName, $serverTitle, $testQuota) {
|
||||||
|
$SPLIT_DELIMITER = "###x##y##x###";
|
||||||
$okImage = "<img src=\"../../graphics/pass.png\" alt=\"\">\n";
|
$okImage = "<img src=\"../../graphics/pass.png\" alt=\"\">\n";
|
||||||
$failImage = "<img src=\"../../graphics/fail.png\" alt=\"\">\n";
|
$failImage = "<img src=\"../../graphics/fail.png\" alt=\"\">\n";
|
||||||
|
|
||||||
|
@ -304,14 +304,14 @@ function lamRunLamdaemonTestSuite($serverName, $serverTitle, $testQuota) {
|
||||||
|
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
$stopTest = lamTestLamdaemon("+ test basic\n", $stopTest, $handle, _("Execute lamdaemon"));
|
$stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "basic\n", $stopTest, $handle, _("Execute lamdaemon"));
|
||||||
if ($testQuota) {
|
if ($testQuota) {
|
||||||
$handle = @ssh2_connect($serverName);
|
$handle = @ssh2_connect($serverName);
|
||||||
@ssh2_auth_password($handle, $userName, $credentials[1]);
|
@ssh2_auth_password($handle, $userName, $credentials[1]);
|
||||||
$stopTest = lamTestLamdaemon("+ test quota\n", $stopTest, $handle, _("Lamdaemon: Quota module installed"));
|
$stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "quota\n", $stopTest, $handle, _("Lamdaemon: Quota module installed"));
|
||||||
$handle = @ssh2_connect($serverName);
|
$handle = @ssh2_connect($serverName);
|
||||||
@ssh2_auth_password($handle, $userName, $credentials[1]);
|
@ssh2_auth_password($handle, $userName, $credentials[1]);
|
||||||
$stopTest = lamTestLamdaemon("+ quota get user\n", $stopTest, $handle, _("Lamdaemon: read quotas"));
|
$stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "quota" . $SPLIT_DELIMITER . "get" . $SPLIT_DELIMITER . "user\n", $stopTest, $handle, _("Lamdaemon: read quotas"));
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</table><br>\n";
|
echo "</table><br>\n";
|
||||||
|
|
Loading…
Reference in New Issue