changed way of lamdaemon.pl how to transfer variables

Now ot's possible to set up quotas for
more than one user in one call
Not completly tested yet.

masscreate.php should use this new behavior which
should make creation of many users much faster.
This commit is contained in:
katagia 2003-11-06 10:58:21 +00:00
parent 752f584cee
commit e116aa0893
7 changed files with 393 additions and 267 deletions

View File

@ -193,10 +193,10 @@ function RndInt($Format){
/* Whis function will return the quotas from the specified user If empty only filesystems with enabled quotas are returned /* Whis function will return the quotas from the specified user If empty only filesystems with enabled quotas are returned
* $type = 'user' or 'group' * $type = 'user' or 'group'
* $user = user or groupname. If no user or groupname is defined, * $users = array of users or groupnames. If no user or groupname is defined,
* an array with all quota-enabled partitions will be returned in this case all returned values are 0 exept mointpoint[x][0] * an array with all quota-enabled partitions will be returned in this case all returned values are 0 exept mointpoint[x][0]
*/ */
function getquotas($type,$user='+') { function getquotas($type,$users=array('+')) {
// define new object // define new object
$return = new account(); $return = new account();
// get username and password of the current lam-admin // get username and password of the current lam-admin
@ -205,13 +205,39 @@ function getquotas($type,$user='+') {
* admin-username, admin-password, account with quotas, 'quota', operation='get', type=user|group * admin-username, admin-password, account with quotas, 'quota', operation='get', type=user|group
* use escapeshellarg to make exec() shell-safe * use escapeshellarg to make exec() shell-safe
*/ */
$towrite = escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]).' '.escapeshellarg($user).' quota get '; $towrite = escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".
if ($type=='user') $towrite = $towrite.'u'; escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
else $towrite = $towrite.'g';
/* scriptServer is the IP to remote-host to which lam should connect via ssh /* scriptServer is the IP to remote-host to which lam should connect via ssh
* scriptPath is Path to lamdaemon.pl on remote system * scriptPath is Path to lamdaemon.pl on remote system
*/ */
exec("perl ".escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".$towrite, $vals, $status); $descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stout
2 => array("file", "/dev/null", "a") // sterr
);
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
$descriptorspec,
$pipes);
if (is_resource($process)) {
/* perl-script is running
* $pipes[0] is writeable handle to child stdin
* $pipes[1] is readable handle to child stdout
* any error is send to /dev/null
*/
foreach ($users as $user) {
// put string to trasmit together
$userstring = "$user quota get $type\n";
// Write one output-line for every user
fwrite($pipes[0], $userstring);
}
fclose($pipes[0]);
while (!feof($pipes[1])) {
$output = fgets($pipes[1], 1024);
if ($output!='') $vals5[] = $output;
}
fclose($pipes[1]);
$return_value = proc_close($process);
}
/* $vals is a string which contains a two dimensional array. /* $vals is a string which contains a two dimensional array.
* We have to recreate it with explode * We have to recreate it with explode
* *
@ -220,8 +246,9 @@ function getquotas($type,$user='+') {
* mountpoint, used blocks, soft block limit, hard block limit, grace block period, used inodes, * mountpoint, used blocks, soft block limit, hard block limit, grace block period, used inodes,
* soft inode limit, hard inode limit, grace inode period * soft inode limit, hard inode limit, grace inode period
*/ */
$vals = explode(':', $vals[0]); foreach ($vals5 as $vals3) {
for ($i=0; $i<sizeof($vals); $i++) { $vals = explode(':', $vals3);
for ($i=0; $i<sizeof($vals)-1; $i++) {
$vals2 = explode(',', $vals[$i]); $vals2 = explode(',', $vals[$i]);
for ($j=0; $j<sizeof($vals2); $j++) { for ($j=0; $j<sizeof($vals2); $j++) {
$return->quota[$i][$j] = $vals2[$j]; $return->quota[$i][$j] = $vals2[$j];
@ -231,25 +258,41 @@ function getquotas($type,$user='+') {
if ($return->quota[$i][8]<$time) $return->quota[$i][8] = ''; if ($return->quota[$i][8]<$time) $return->quota[$i][8] = '';
else $return->quota[$i][8] = strval(($return->quota[$i][8]-$time)/3600) .' '. _('hours'); else $return->quota[$i][8] = strval(($return->quota[$i][8]-$time)/3600) .' '. _('hours');
} }
return $return; $return2[] = $return;
}
return $return2;
} }
/* Whis function will set the quotas from the specified user. /* Whis function will set the quotas from the specified user.
* $values = object account with quotas which should be set * $values2 = array of object account with quotas which should be set
* $values_old = object account if set values and values_old will be compared. Quota will only be changed * $values2_old = array of object account if set values and values_old will be compared. Quota will only be changed
* if values differ * if values differ
*/ */
function setquotas($values,$values_old=false) { function setquotas($values2,$values2_old=false) {
// get username and password of the current lam-admin // get username and password of the current lam-admin
$ldap_q = $_SESSION['ldap']->decrypt(); $ldap_q = $_SESSION['ldap']->decrypt();
/* $towrite has the following syntax: /* $towrite has the following syntax:
* admin-username, admin-password, account with quotas, 'quota', operation='set', type=user|group * admin-username, admin-password, account with quotas, 'quota', operation='set', type=user|group
* use escapeshellarg to make exec() shell-safe * use escapeshellarg to make exec() shell-safe
*/ */
$towrite = escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]).' '.escapeshellarg($values->general_username).' quota set '; $towrite = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".escapeshellarg($_SESSION['config']->scriptServer)." ".
if ($values->type=='user') $towrite = $towrite.'u '; escapeshellarg($_SESSION['config']->scriptPath)." ".escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
else $towrite = $towrite.'g '; $descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stout
2 => array("file", "/dev/null", "a") // sterr
);
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
$descriptorspec,
$pipes);
if (is_resource($process)) {
/* perl-script is running
* $pipes[0] is writeable handle to child stdin
* $pipes[1] is readable handle to child stdout
* any error is send to /dev/null
*/
foreach ($values2 as $values) {
$i=0; $i=0;
/* Check wich quotas have changed /* Check wich quotas have changed
* Because we can not send an array to lamdaemon.pl we have to put all * Because we can not send an array to lamdaemon.pl we have to put all
@ -267,54 +310,94 @@ function setquotas($values,$values_old=false) {
} }
$i++; $i++;
} }
$towrite = $towrite . escapeshellarg($quotastring); $userstring = $values->general_username." quota set ".$values->type." ".$quotastring."\n";
/* scriptServer is the IP to remote-host to which lam should connect via ssh // Write to stdin
* scriptPath is Path to lamdaemon.pl on remote system fwrite($pipes[0], $userstring);
* only run lamdaemon.pl if quotas are really set, $i!=0 }
*/ }
if ($i!=0) exec(("perl ".escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".$towrite), $vals); fclose($pipes[0]);
fclose($pipes[1]);
$return_value = proc_close($process);
} }
/* Whis function will remove the quotas from the specified user. /* Whis function will remove the quotas from the specified user.
* $user = username of which quta should be deleted * $user = array of usernames of which quta should be deleted
* $type = user or group * $type = user or group
* Delteing quotas means settings all values to 0 which means no quotas * Delteing quotas means settings all values to 0 which means no quotas
*/ */
function remquotas($user, $type) { function remquotas($users, $type) {
// get username and password of the current lam-admin // get username and password of the current lam-admin
$ldap_q = $_SESSION['ldap']->decrypt(); $ldap_q = $_SESSION['ldap']->decrypt();
/* $towrite has the following syntax: /* $towrite has the following syntax:
* admin-username, admin-password, account with quotas, 'quota', operation='rem', type=user|group * admin-username, admin-password, account with quotas, 'quota', operation='rem', type=user|group
* use escapeshellarg to make exec() shell-safe * use escapeshellarg to make exec() shell-safe
*/ */
$towrite = escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]).' '.escapeshellarg($user).' quota rem '; $towrite = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".escapeshellarg($_SESSION['config']->scriptServer)." ".
if ($type=='user') $towrite = $towrite.'u '; escapeshellarg($_SESSION['config']->scriptPath)." ".escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
else $towrite = $towrite.'g '; $descriptorspec = array(
/* scriptServer is the IP to remote-host to which lam should connect via ssh 0 => array("pipe", "r"), // stdin
* scriptPath is Path to lamdaemon.pl on remote system 1 => array("pipe", "w"), // stout
2 => array("file", "/dev/null", "a") // sterr
);
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
$descriptorspec,
$pipes);
if (is_resource($process)) {
/* perl-script is running
* $pipes[0] is writeable handle to child stdin
* $pipes[1] is readable handle to child stdout
* any error is send to /dev/null
*/ */
exec(("perl ".escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".$towrite), $vals); foreach ($users as $user) {
$userstring = "$user quota rem $type\n";
// Write to stdin
fwrite($pipes[0], $userstring);
}
}
fclose($pipes[0]);
fclose($pipes[1]);
$return_value = proc_close($process);
} }
/* Create Homedirectory /* Create Homedirectory
* lamdaemon.pl uses getpwnam on remote system to get homedir path. * lamdaemon.pl uses getpwnam on remote system to get homedir path.
* Therefore ldap have to be used on remote system for user accounts * Therefore ldap have to be used on remote system for user accounts
* $user = username * $users = array of usernames
*/ */
function addhomedir($user) { function addhomedir($users) {
// get username and password of the current lam-admin // get username and password of the current lam-admin
$ldap_q = $_SESSION['ldap']->decrypt(); $ldap_q = $_SESSION['ldap']->decrypt();
/* $towrite has the following syntax: /* $towrite has the following syntax:
* admin-username, admin-password, owner of homedir, 'home', operation='add' * admin-username, admin-password, owner of homedir, 'home', operation='add'
* use escapeshellarg to make exec() shell-safe * use escapeshellarg to make exec() shell-safe
*/ */
$towrite = escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]).' '.escapeshellarg($user).' home add'; $towrite = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".escapeshellarg($_SESSION['config']->scriptServer)." ".
/* scriptServer is the IP to remote-host to which lam should connect via ssh escapeshellarg($_SESSION['config']->scriptPath)." ".escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
* scriptPath is Path to lamdaemon.pl on remote system $descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stout
2 => array("file", "/dev/null", "a") // sterr
);
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
$descriptorspec,
$pipes);
if (is_resource($process)) {
/* perl-script is running
* $pipes[0] is writeable handle to child stdin
* $pipes[1] is readable handle to child stdout
* any error is send to /dev/null
*/ */
exec(("perl ".escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".$towrite), $vals); foreach ($users as $user) {
$userstring = "$user home add\n";
// Write to stdin
fwrite($pipes[0], $userstring);
}
}
fclose($pipes[0]);
fclose($pipes[1]);
$return_value = proc_close($process);
} }
@ -323,20 +406,40 @@ function addhomedir($user) {
* Therefore ldap have to be used on remote system for user accounts * Therefore ldap have to be used on remote system for user accounts
* This also means you have to remove the homedirectory before the * This also means you have to remove the homedirectory before the
* account is removed from ldap * account is removed from ldap
* $user = username * $users = array of usernames
*/ */
function remhomedir($user) { function remhomedir($user) {
// get username and password of the current lam-admin // get username and password of the current lam-admin
$ldap_q = $_SESSION['ldap']->decrypt(); $ldap_q = $_SESSION['ldap']->decrypt();
/* $towrite has the following syntax: /* $towrite has the following syntax:
* admin-username, admin-password, owner of homedir, 'home', operation='rem' * admin-username, admin-password, owner of homedir, 'home', operation='add'
* use escapeshellarg to make exec() shell-safe * use escapeshellarg to make exec() shell-safe
*/ */
$towrite = escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]).' '.escapeshellarg($user).' home rem'; $towrite = escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".escapeshellarg($_SESSION['config']->scriptServer)." ".
/* scriptServer is the IP to remote-host to which lam should connect via ssh escapeshellarg($_SESSION['config']->scriptPath)." ".escapeshellarg($ldap_q[0]).' '.escapeshellarg($ldap_q[1]);
* scriptPath is Path to lamdaemon.pl on remote system $descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stout
2 => array("file", "/dev/null", "a") // sterr
);
$process = proc_open(escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".$towrite,
$descriptorspec,
$pipes);
if (is_resource($process)) {
/* perl-script is running
* $pipes[0] is writeable handle to child stdin
* $pipes[1] is readable handle to child stdout
* any error is send to /dev/null
*/ */
exec(("perl ".escapeshellarg($_SESSION['lampath']."lib/lamdaemon.pl")." ".escapeshellarg($_SESSION['config']->scriptServer)." ".escapeshellarg($_SESSION['config']->scriptPath)." ".$towrite), $vals); foreach ($users as $user) {
$userstring = "$user home rem\n";
// Write to stdin
fwrite($pipes[0], $userstring);
}
}
fclose($pipes[0]);
fclose($pipes[1]);
$return_value = proc_close($process);
} }
@ -1017,12 +1120,13 @@ function loadgroup($dn) {
/* This function will create a new user acconut in ldap /* This function will create a new user acconut in ldap
* $values is an account-object with all attributes of the user * $values is an account-object with all attributes of the user
* if lamdaemon.pl is false no quotas are set. Usefull for massupload and deletion
* return-value is an integer * return-value is an integer
* 1 == Account has been created * 1 == Account has been created
* 2 == Account already exists at different location * 2 == Account already exists at different location
* 4 == Error while creating Account * 4 == Error while creating Account
*/ */
function createuser($values) { function createuser($values, $uselamdaemon=true) {
// These Objectclasses are needed for an user account // These Objectclasses are needed for an user account
$attr['objectClass'][0] = 'posixAccount'; $attr['objectClass'][0] = 'posixAccount';
$attr['objectClass'][1] = 'shadowAccount'; $attr['objectClass'][1] = 'shadowAccount';
@ -1160,12 +1264,12 @@ function createuser($values) {
// Continue if now error did ocour // Continue if now error did ocour
if (!$success) return 4; if (!$success) return 4;
if ($_SESSION['config']->scriptServer) { if ($_SESSION['config']->scriptServer && $uselamdaemon) {
// lamdaemon.pl should be used // lamdaemon.pl should be used
// Set quotas if quotas are used // Set quotas if quotas are used
if (is_array($values->quota)) setquotas($values); if (is_array($values->quota)) setquotas(array($values));
// Create Homedirectory // Create Homedirectory
addhomedir($values->general_username); addhomedir(array($values->general_username));
} }
// Add User to Additional Groups // Add User to Additional Groups
@ -1193,13 +1297,14 @@ function createuser($values) {
/* This function will modify a user acconut in ldap /* This function will modify a user acconut in ldap
* $values and $values_old are an account-object with all * $values and $values_old are an account-object with all
* attributes of the user. * attributes of the user.
* if lamdaemon.pl is false no quotas are set. Usefull for massupload and deletion
* Only attributes which have changed will be written * Only attributes which have changed will be written
* return-value is an integer * return-value is an integer
* 2 == Account already exists at different location * 2 == Account already exists at different location
* 3 == Account has been modified * 3 == Account has been modified
* 5 == Error while modifying Account * 5 == Error while modifying Account
*/ */
function modifyuser($values,$values_old) { // Will modify the LDAP-Account function modifyuser($values,$values_old,$uselamdaemon=true) { // Will modify the LDAP-Account
// Add missing objectclasses to user // Add missing objectclasses to user
if (!in_array('posixAccount', $values->general_objectClass)) { if (!in_array('posixAccount', $values->general_objectClass)) {
$attr['objectClass'] = $values->general_objectClass; $attr['objectClass'] = $values->general_objectClass;
@ -1631,7 +1736,7 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account
} }
// Change quotas if quotas are set and lamdaemon.pl should be used // Change quotas if quotas are set and lamdaemon.pl should be used
if ($_SESSION['config']->scriptServer && is_array($values->quota) ) setquotas($values,$values_old); if ($_SESSION['config']->scriptServer && is_array($values->quota) && $uselamdaemon) setquotas(array($values),array($values_old));
//make required changes in cache-array //make required changes in cache-array
if ((isset($_SESSION['userDN']))) { if ((isset($_SESSION['userDN']))) {
if ($values->general_dn != $values_old->general_dn) { if ($values->general_dn != $values_old->general_dn) {
@ -1958,12 +2063,13 @@ function modifyhost($values,$values_old) {
/* This function will create a new group acconut in ldap /* This function will create a new group acconut in ldap
* $values is an account-object with all attributes of the group * $values is an account-object with all attributes of the group
* if lamdaemon.pl is false no quotas are set. Usefull for massupload and deletion
* return-value is an integer * return-value is an integer
* 1 == Account has been created * 1 == Account has been created
* 2 == Account already exists at different location * 2 == Account already exists at different location
* 4 == Error while creating Account * 4 == Error while creating Account
*/ */
function creategroup($values) { function creategroup($values, $uselamdaemon=true) {
// These Objectclasses are needed for an user account // These Objectclasses are needed for an user account
$attr['objectClass'][0] = 'posixGroup'; $attr['objectClass'][0] = 'posixGroup';
// Create DN for new user account // Create DN for new user account
@ -1992,7 +2098,7 @@ function creategroup($values) {
// Continue if now error did ocour // Continue if now error did ocour
if (!$success) return 4; if (!$success) return 4;
// lamdaemon.pl should be used. Set quotas if quotas are used // lamdaemon.pl should be used. Set quotas if quotas are used
if ($_SESSION['config']->scriptServer && is_array($values->quota)) setquotas($values); if ($_SESSION['config']->scriptServer && is_array($values->quota) && $uselamdaemon) setquotas(array($values));
// Add new group to cache-array // Add new group to cache-array
if ((isset($_SESSION['groupDN']))) { if ((isset($_SESSION['groupDN']))) {
$_SESSION['groupDN'][$values->general_dn]['cn'] = $values->general_username; $_SESSION['groupDN'][$values->general_dn]['cn'] = $values->general_username;
@ -2005,13 +2111,14 @@ function creategroup($values) {
/* This function will modify a group acconut in ldap /* This function will modify a group acconut in ldap
* $values and $values_old are an account-object with all * $values and $values_old are an account-object with all
* attributes of the group. * attributes of the group.
* if lamdaemon.pl is false no quotas are set. Usefull for massupload and deletion
* Only attributes which have changed will be written * Only attributes which have changed will be written
* return-value is an integer * return-value is an integer
* 2 == Account already exists at different location * 2 == Account already exists at different location
* 3 == Account has been modified * 3 == Account has been modified
* 5 == Error while modifying Account * 5 == Error while modifying Account
*/ */
function modifygroup($values,$values_old) { function modifygroup($values,$values_old, $uselamdaemon=true) {
// Add missing objectclasses to group // Add missing objectclasses to group
if (!in_array('posixGroup', $values->general_objectClass)) { if (!in_array('posixGroup', $values->general_objectClass)) {
$attr['objectClass'] = $values->general_objectClass; $attr['objectClass'] = $values->general_objectClass;
@ -2101,7 +2208,7 @@ function modifygroup($values,$values_old) {
} }
// Change quotas if quotas are set and lamdaemon.pl should be used // Change quotas if quotas are set and lamdaemon.pl should be used
if ($_SESSION['config']->scriptServer && is_array($values->quota)) setquotas($values,$values_old); if ($_SESSION['config']->scriptServer && is_array($values->quota) && $uselamdaemon) setquotas(array($values),array($values_old));
//make required changes in cache-array //make required changes in cache-array
if ((isset($_SESSION['groupDN']))) { if ((isset($_SESSION['groupDN']))) {
if ($values->general_dn != $values_old->general_dn) { if ($values->general_dn != $values_old->general_dn) {

View File

@ -21,14 +21,12 @@
# #
# #
# LDAP Account Manager daemon to create and delete homedirecotries and quotas # LDAP Account Manager daemon to create and delete homedirecotries and quotas
$debug=true; # Show debug messages
#use strict; # Use strict for security reasons #use strict; # Use strict for security reasons
@quota_grp; @quota_grp;
@quota_usr; # Filesystems with enabled userquotas @quota_usr; # Filesystems with enabled userquotas
@vals = @ARGV;
# vals = DN, PAssword, user, home, (add|rem), # vals = DN, PAssword, user, home, (add|rem),
# quota, (set|get),(u|g), (mountpoint,blocksoft,blockhard,filesoft,filehard)+ # quota, (set|get),(u|g), (mountpoint,blocksoft,blockhard,filesoft,filehard)+
# chown options # chown options
@ -67,21 +65,26 @@ sub get_fs { # Load mountpoints from mtab if enabled quotas
} }
# ***************** Check values # ***************** Check values
if ($( == 0 ) { if ($( == 0 ) { # we are root
if ($ARGV[2] eq "*test") { print "sudo set up correctly.\n"; }
if ($ARGV[2] eq "*test") {
print "Perl quota module successfully installed.\n";
use Quota; # Needed to get and set quotas
}
# Drop root Previleges # Drop root Previleges
($<, $>) = ($>, $<); ($<, $>) = ($>, $<);
if ($ARGV[0] eq "*test") {
use Quota; # Needed to get and set quotas
print "Perl quota module successfully installed.\n";
print "IF you haven't seen any errors lamdaemon.pl was set up successfully.\n";
}
else {
# loop for every transmitted user
while (defined($input = <STDIN>)) {
$return = "";
@vals = split (' ', $input);
switch: { switch: {
# Get user information # Get user information
if (($vals[5] eq 'u') || ($vals[3] eq 'home')) { @user = getpwnam($vals[2]); } if (($vals[3] eq 'user') || ($vals[1] eq 'home')) { @user = getpwnam($vals[0]); }
else { @user = getgrnam($vals[2]); } else { @user = getgrnam($vals[0]); }
$vals[3] eq 'home' && do { $vals[1] eq 'home' && do {
switch2: { switch2: {
$vals[4] eq 'add' && do { $vals[2] eq 'add' && do {
# split homedir to set all directories below the last dir. to 755 # split homedir to set all directories below the last dir. to 755
my $path = $user[7]; my $path = $user[7];
$path =~ s,/(?:[^/]*)$,,; $path =~ s,/(?:[^/]*)$,,;
@ -100,7 +103,7 @@ if ($( == 0 ) {
($<, $>) = ($>, $<); # Give up root previleges ($<, $>) = ($>, $<); # Give up root previleges
last switch2; last switch2;
}; };
$vals[4] eq 'rem' && do { $vals[2] eq 'rem' && do {
($<, $>) = ($>, $<); # Get root previliges ($<, $>) = ($>, $<); # Get root previliges
if (-d $user[7]) { if (-d $user[7]) {
system 'rm', '-R', $user[7]; # Delete Homedirectory system 'rm', '-R', $user[7]; # Delete Homedirectory
@ -114,7 +117,7 @@ if ($( == 0 ) {
} }
last switch; last switch;
}; };
$vals[3] eq 'quota' && do { $vals[1] eq 'quota' && do {
use Quota; # Needed to get and set quotas use Quota; # Needed to get and set quotas
get_fs(); # Load list of devices with enabled quotas get_fs(); # Load list of devices with enabled quotas
# Store quota information in array # Store quota information in array
@ -130,12 +133,13 @@ if ($( == 0 ) {
} }
$i++; $i++;
} }
if ($vals[5] eq 'u') { $group=false; } else { if ($vals[3] eq 'user') { $group=false; }
else {
$group=1; $group=1;
@quota_usr = @quota_grp; @quota_usr = @quota_grp;
} }
switch2: { switch2: {
$vals[4] eq 'rem' && do { $vals[2] eq 'rem' && do {
$i=0; $i=0;
($<, $>) = ($>, $<); # Get root privileges ($<, $>) = ($>, $<); # Get root privileges
while ($quota_usr[$i][0]) { while ($quota_usr[$i][0]) {
@ -146,7 +150,7 @@ if ($( == 0 ) {
($<, $>) = ($>, $<); # Give up root previleges ($<, $>) = ($>, $<); # Give up root previleges
last switch2; last switch2;
}; };
$vals[4] eq 'set' && do { $vals[2] eq 'set' && do {
$i=0; $i=0;
($<, $>) = ($>, $<); # Get root privileges ($<, $>) = ($>, $<); # Get root privileges
while ($quota_usr[$i][0]) { while ($quota_usr[$i][0]) {
@ -157,7 +161,7 @@ if ($( == 0 ) {
($<, $>) = ($>, $<); # Give up root previleges ($<, $>) = ($>, $<); # Give up root previleges
last switch2; last switch2;
}; };
$vals[4] eq 'get' && do { $vals[2] eq 'get' && do {
$i=0; $i=0;
($<, $>) = ($>, $<); # Get root privileges ($<, $>) = ($>, $<); # Get root privileges
while ($quota_usr[$i][0]) { while ($quota_usr[$i][0]) {
@ -180,8 +184,9 @@ if ($( == 0 ) {
}; };
last switch; last switch;
}; };
if ($ARGV[2] eq "*test") { print "If you have'nt seen any error lamdaemon.pl should set up successfully.\n"; } print "$return\n";
else { print "$return\n"; } }
}
} }
else { else {
$hostname = shift @ARGV; $hostname = shift @ARGV;
@ -190,10 +195,18 @@ else {
if ($ARGV[2] eq "*test") { print "Net::SSH::Perl successfully installed.\n"; } if ($ARGV[2] eq "*test") { print "Net::SSH::Perl successfully installed.\n"; }
@username = split (',', $ARGV[0]); @username = split (',', $ARGV[0]);
$username[0] =~ s/uid=//; $username[0] =~ s/uid=//;
$password = $ARGV[1];
# Put all transfered lines in one string
if ($ARGV[2] ne "*test") {
while (defined($input = <STDIN>)) {
$string = $string. $input;
}
}
else { $argv = "*test\n"; }
my $ssh = Net::SSH::Perl->new($hostname, options=>[ my $ssh = Net::SSH::Perl->new($hostname, options=>[
"UserKnownHostsFile /dev/null" "UserKnownHostsFile /dev/null"
]); ]);
$ssh->login($username[0], $ARGV[1]); $ssh->login($username[0], $password);
($stdout, $stderr, $exit) = $ssh->cmd("sudo $remotepath @ARGV"); ($stdout, $stderr, $exit) = $ssh->cmd("sudo $remotepath $argv", $string);
print "$stdout"; print "$stdout";
} }

View File

@ -101,16 +101,16 @@ else if (count($_POST)==0) {
while (isset($account_new->quota[$i])) { while (isset($account_new->quota[$i])) {
// search if quotas from profile fit to a real quota // search if quotas from profile fit to a real quota
$found = (-1); $found = (-1);
for ($j=0; $j<count($values->quota); $j++) for ($j=0; $j<count($values[0]->quota); $j++)
if ($values->quota[$j][0]==$account_new->quota[$i][0]) $found = $j; if ($values->quota[$j][0]==$account_new->quota[$i][0]) $found = $j;
// unset quota from profile if quotas (mointpoint) doesn't exists anymore // unset quota from profile if quotas (mointpoint) doesn't exists anymore
if ($found==-1) unset($account_new->quota[$i]); if ($found==-1) unset($account_new->quota[$i]);
else { else {
// Set missing part in quota-array // Set missing part in quota-array
$account_new->quota[$i][1] = $values->quota[$found][1]; $account_new->quota[$i][1] = $values[0]->quota[$found][1];
$account_new->quota[$i][5] = $values->quota[$found][5]; $account_new->quota[$i][5] = $values[0]->quota[$found][5];
$account_new->quota[$i][4] = $values->quota[$found][4]; $account_new->quota[$i][4] = $values[0]->quota[$found][4];
$account_new->quota[$i][8] = $values->quota[$found][8]; $account_new->quota[$i][8] = $values[0]->quota[$found][8];
$i++; $i++;
} }
} }
@ -119,8 +119,8 @@ else if (count($_POST)==0) {
} }
else { // No quotas saved in profile else { // No quotas saved in profile
// Display quotas for new users (Quota set to 0) // Display quotas for new users (Quota set to 0)
if (is_object($values)) { if (is_object($values[0])) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_new->$key = $val; if (isset($val)) $account_new->$key = $val;
} }
} }
@ -162,7 +162,7 @@ switch ($_POST['select']) {
case 'general': case 'general':
if (!$_POST['load']) { if (!$_POST['load']) {
if (($account_new->general_username != $_POST['f_general_username']) && ereg('[A-Z]$', $_POST['f_general_username'])) if (($account_new->general_username != $_POST['f_general_username']) && ereg('[A-Z]$', $_POST['f_general_username']))
$errors[] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because user and uSer could have the same mail-address.')); $errors[] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because not all programs are case-sensitive.'));
// Write all general attributes into $account_new if no profile should be loaded // Write all general attributes into $account_new if no profile should be loaded
$account_new->general_dn = $_POST['f_general_suffix']; $account_new->general_dn = $_POST['f_general_suffix'];
$account_new->general_username = $_POST['f_general_username']; $account_new->general_username = $_POST['f_general_username'];
@ -284,13 +284,13 @@ switch ($_POST['select']) {
if ($_POST['outputpdf']) { if ($_POST['outputpdf']) {
// Load quotas if not yet done because they are needed for the pdf-file // Load quotas if not yet done because they are needed for the pdf-file
if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas
$values = getquotas('group', $account_old->general_username); $values = getquotas('group', array($account_old->general_username));
if (is_object($values)) { if (is_object($values[0])) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_new->$key = $val; if (isset($val)) $account_new->$key = $val;
} }
if (is_object($values) && isset($account_old)) { if (is_object($values[0]) && isset($account_old)) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_old->$key = $val; if (isset($val)) $account_old->$key = $val;
} }
} }
@ -409,16 +409,16 @@ do { // X-Or, only one if() can be true
while (isset($account_new->quota[$i])) { while (isset($account_new->quota[$i])) {
// search if quotas from profile fit to a real quota // search if quotas from profile fit to a real quota
$found = (-1); $found = (-1);
for ($j=0; $j<count($values->quota); $j++) for ($j=0; $j<count($values[0]->quota); $j++)
if ($values->quota[$j][0]==$account_new->quota[$i][0]) $found = $j; if ($values[0]->quota[$j][0]==$account_new->quota[$i][0]) $found = $j;
// unset quota from profile if quotas (mointpoint) doesn't exists anymore // unset quota from profile if quotas (mointpoint) doesn't exists anymore
if ($found==-1) unset($account_new->quota[$i]); if ($found==-1) unset($account_new->quota[$i]);
else { else {
// Set missing part in quota-array // Set missing part in quota-array
$account_new->quota[$i][1] = $values->quota[$found][1]; $account_new->quota[$i][1] = $values[0]->quota[$found][1];
$account_new->quota[$i][5] = $values->quota[$found][5]; $account_new->quota[$i][5] = $values[0]->quota[$found][5];
$account_new->quota[$i][4] = $values->quota[$found][4]; $account_new->quota[$i][4] = $values[0]->quota[$found][4];
$account_new->quota[$i][8] = $values->quota[$found][8]; $account_new->quota[$i][8] = $values[0]->quota[$found][8];
$i++; $i++;
} }
} }
@ -427,8 +427,8 @@ do { // X-Or, only one if() can be true
} }
else { // No quotas saved in profile else { // No quotas saved in profile
// Display quotas for new users (Quota set to 0) // Display quotas for new users (Quota set to 0)
if (is_object($values)) { if (is_object($values[0])) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_new->$key = $val; if (isset($val)) $account_new->$key = $val;
} }
} }
@ -739,13 +739,13 @@ switch ($select_local) {
// Quota Settings // Quota Settings
// Load quotas if not yet done // Load quotas if not yet done
if ($config_intern->scriptServer && !isset($account_new->quota[0]) ) { // load quotas if ($config_intern->scriptServer && !isset($account_new->quota[0]) ) { // load quotas
$values = getquotas('group', $account_new->general_username); $values = getquotas('group', array($account_new->general_username));
if (is_object($values)) { if (is_object($values[0])) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_new->$key = $val; if (isset($val)) $account_new->$key = $val;
} }
if (is_object($values) && isset($account_old)) { if (is_object($values[0]) && isset($account_old)) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_old->$key = $val; if (isset($val)) $account_old->$key = $val;
} }
} }

View File

@ -99,7 +99,7 @@ switch ($_POST['select']) {
case 'general': case 'general':
if (!$_POST['load']) { if (!$_POST['load']) {
if (($account_new->general_username != $_POST['f_general_username']) && ereg('[A-Z]$', $_POST['f_general_username'])) if (($account_new->general_username != $_POST['f_general_username']) && ereg('[A-Z]$', $_POST['f_general_username']))
$errors[] = array('WARN', _('Hostname'), _('You are using a capital letters. This can cause problems because user and uSer could have the same mail-address.')); $errors[] = array('WARN', _('Hostname'), _('You are using a capital letters. This can cause problems because not all programs are case-sensitive.'));
// Write all general values into $account_new if no profile should be loaded // Write all general values into $account_new if no profile should be loaded
$account_new->general_dn = $_POST['f_general_suffix']; $account_new->general_dn = $_POST['f_general_suffix'];
$account_new->general_username = $_POST['f_general_username']; $account_new->general_username = $_POST['f_general_username'];

View File

@ -104,16 +104,16 @@ if (isset($_GET['DN']) && $_GET['DN']!='') {
while (isset($account_new->quota[$i])) { while (isset($account_new->quota[$i])) {
// search if quotas from profile fit to a real quota // search if quotas from profile fit to a real quota
$found = (-1); $found = (-1);
for ($j=0; $j<count($values->quota); $j++) for ($j=0; $j<count($values[0]->quota); $j++)
if ($values->quota[$j][0]==$account_new->quota[$i][0]) $found = $j; if ($values[0]->quota[$j][0]==$account_new->quota[$i][0]) $found = $j;
// unset quota from profile if quotas (mointpoint) doesn't exists anymore // unset quota from profile if quotas (mointpoint) doesn't exists anymore
if ($found==-1) unset($account_new->quota[$i]); if ($found==-1) unset($account_new->quota[$i]);
else { else {
// Set missing part in quota-array // Set missing part in quota-array
$account_new->quota[$i][1] = $values->quota[$found][1]; $account_new->quota[$i][1] = $values[0]->quota[$found][1];
$account_new->quota[$i][5] = $values->quota[$found][5]; $account_new->quota[$i][5] = $values[0]->quota[$found][5];
$account_new->quota[$i][4] = $values->quota[$found][4]; $account_new->quota[$i][4] = $values[0]->quota[$found][4];
$account_new->quota[$i][8] = $values->quota[$found][8]; $account_new->quota[$i][8] = $values[0]->quota[$found][8];
$i++; $i++;
} }
} }
@ -122,8 +122,8 @@ if (isset($_GET['DN']) && $_GET['DN']!='') {
} }
else { // No quotas saved in profile else { // No quotas saved in profile
// Display quotas for new users (Quota set to 0) // Display quotas for new users (Quota set to 0)
if (is_object($values)) { if (is_object($values[0])) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_new->$key = $val; if (isset($val)) $account_new->$key = $val;
} }
} }
@ -500,13 +500,13 @@ switch ($_POST['select']) {
if ($_POST['outputpdf']) { if ($_POST['outputpdf']) {
// Load quotas if not yet done because they are needed for the pdf-file // Load quotas if not yet done because they are needed for the pdf-file
if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas
$values = getquotas('user', $account_old->general_username); $values = getquotas('user', array($account_old->general_username));
if (is_object($values)) { if (is_object($values[0])) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_new->$key = $val; if (isset($val)) $account_new->$key = $val;
} }
if (is_object($values) && isset($account_old)) { if (is_object($values[0]) && isset($account_old)) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_old->$key = $val; if (isset($val)) $account_old->$key = $val;
} }
} }
@ -680,15 +680,15 @@ do { // X-Or, only one if() can be true
// search if quotas from profile fit to a real quota // search if quotas from profile fit to a real quota
$found = (-1); $found = (-1);
for ($j=0; $j<count($values->quota); $j++) for ($j=0; $j<count($values->quota); $j++)
if ($values->quota[$j][0]==$account_new->quota[$i][0]) $found = $j; if ($values[0]->quota[$j][0]==$account_new->quota[$i][0]) $found = $j;
// unset quota from profile if quotas (mointpoint) doesn't exists anymore // unset quota from profile if quotas (mointpoint) doesn't exists anymore
if ($found==-1) unset($account_new->quota[$i]); if ($found==-1) unset($account_new->quota[$i]);
else { else {
// Set missing part in quota-array // Set missing part in quota-array
$account_new->quota[$i][1] = $values->quota[$found][1]; $account_new->quota[$i][1] = $values[0]->quota[$found][1];
$account_new->quota[$i][5] = $values->quota[$found][5]; $account_new->quota[$i][5] = $values[0]->quota[$found][5];
$account_new->quota[$i][4] = $values->quota[$found][4]; $account_new->quota[$i][4] = $values[0]->quota[$found][4];
$account_new->quota[$i][8] = $values->quota[$found][8]; $account_new->quota[$i][8] = $values[0]->quota[$found][8];
$i++; $i++;
} }
} }
@ -697,8 +697,8 @@ do { // X-Or, only one if() can be true
} }
else { // No quotas saved in profile else { // No quotas saved in profile
// Display quotas for new users (Quota set to 0) // Display quotas for new users (Quota set to 0)
if (is_object($values)) { if (is_object($values[0])) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_new->$key = $val; if (isset($val)) $account_new->$key = $val;
} }
} }
@ -753,7 +753,6 @@ if (is_array($errors))
// print_r($account_new); // print_r($account_new);
//print_r($account_old); //print_r($account_old);
switch ($select_local) { switch ($select_local) {
/* Select which part of page should be loaded and check values /* Select which part of page should be loaded and check values
* groups = page with all groups to which user is additional member * groups = page with all groups to which user is additional member
@ -1393,13 +1392,13 @@ switch ($select_local) {
// Quota Settings // Quota Settings
// Load quotas if not yet done // Load quotas if not yet done
if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas
$values = getquotas('user', $account_old->general_username); $values = getquotas('user', array($account_old->general_username));
if (is_object($values)) { if (is_object($values[0])) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_new->$key = $val; if (isset($val)) $account_new->$key = $val;
} }
if (is_object($values) && isset($account_old)) { if (is_object($values[0]) && isset($account_old)) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $account_old->$key = $val; if (isset($val)) $account_old->$key = $val;
} }
} }

View File

@ -151,9 +151,9 @@ if ($_POST['delete_yes']) {
if ($config_intern->scriptServer) { if ($config_intern->scriptServer) {
// Remove homedir if required // Remove homedir if required
if ($_POST['f_rem_home']) remhomedir($username); if ($_POST['f_rem_home']) remhomedir(array($username));
// Remove quotas if lamdaemon.pl is used // Remove quotas if lamdaemon.pl is used
if ($config_intern->scriptServer) remquotas($username, 'user'); if ($config_intern->scriptServer) remquotas(array($username), 'user');
} }
// Search for groups which have memberUid set to username // Search for groups which have memberUid set to username
$result = ldap_search($ldap_intern->server(), $config_intern->get_GroupSuffix(), "(&(objectClass=PosixGroup)(memberUid=$username))", array('')); $result = ldap_search($ldap_intern->server(), $config_intern->get_GroupSuffix(), "(&(objectClass=PosixGroup)(memberUid=$username))", array(''));
@ -189,7 +189,7 @@ if ($_POST['delete_yes']) {
else { else {
// continue if no primary users are in group // continue if no primary users are in group
// Remove quotas if lamdaemon.pl is used // Remove quotas if lamdaemon.pl is used
if ($config_intern->scriptServer) remquotas($groupname, 'group'); if ($config_intern->scriptServer) remquotas(array($groupname), 'group');
// Delete group itself // Delete group itself
$success = ldap_delete($ldap_intern->server(), $dn); $success = ldap_delete($ldap_intern->server(), $dn);
if (!$success) $error = _('Could not delete group:').' '.$dn; if (!$success) $error = _('Could not delete group:').' '.$dn;

View File

@ -174,23 +174,23 @@ switch ($select) {
if ($config_intern->scriptServer) { if ($config_intern->scriptServer) {
// load quotas and check if quotas from profile are valid // load quotas and check if quotas from profile are valid
$values = getquotas('group'); $values = getquotas('group');
if (isset($$group->quota[0])) { if (isset($group->quota[0])) {
// check quotas from profile // check quotas from profile
$i=0; $i=0;
// check quota settings, loop for every partition with quotas // check quota settings, loop for every partition with quotas
while (isset($$group->quota[$i])) { while (isset($group->quota[$i])) {
// search if quotas from profile fit to a real quota // search if quotas from profile fit to a real quota
$found = (-1); $found = (-1);
for ($j=0; $j<count($values->quota); $j++) for ($j=0; $j<count($values[0]->quota); $j++)
if ($values->quota[$j][0]==$group->quota[$i][0]) $found = $j; if ($values[0]->quota[$j][0]==$group->quota[$i][0]) $found = $j;
// unset quota from profile if quotas (mointpoint) doesn't exists anymore // unset quota from profile if quotas (mointpoint) doesn't exists anymore
if ($found==-1) unset($group->quota[$i]); if ($found==-1) unset($group->quota[$i]);
else { else {
// Set missing part in quota-array // Set missing part in quota-array
$group->quota[$i][1] = $values->quota[$found][1]; $group->quota[$i][1] = $values[0]->quota[$found][1];
$group->quota[$i][5] = $values->quota[$found][5]; $group->quota[$i][5] = $values[0]->quota[$found][5];
$group->quota[$i][4] = $values->quota[$found][4]; $group->quota[$i][4] = $values[0]->quota[$found][4];
$group->quota[$i][8] = $values->quota[$found][8]; $group->quota[$i][8] = $values[0]->quota[$found][8];
$i++; $i++;
} }
} }
@ -199,8 +199,8 @@ switch ($select) {
} }
else { // No quotas saved in profile else { // No quotas saved in profile
// Display quotas for new users (Quota set to 0) // Display quotas for new users (Quota set to 0)
if (is_object($values)) { if (is_object($values[0])) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $group->$key = $val; if (isset($val)) $group->$key = $val;
} }
} }
@ -245,7 +245,7 @@ switch ($select) {
$_SESSION['accounts'][$_SESSION['pointer']]->smb_password = $_SESSION['accounts'][$_SESSION['pointer']]->unix_password; $_SESSION['accounts'][$_SESSION['pointer']]->smb_password = $_SESSION['accounts'][$_SESSION['pointer']]->unix_password;
// Only create user if we have at least 5sec time to create the user // Only create user if we have at least 5sec time to create the user
if ( (time()-$time)<(get_cfg_var('max_execution_time')-10)) { if ( (time()-$time)<(get_cfg_var('max_execution_time')-10)) {
$error = createuser($_SESSION['accounts'][$_SESSION['pointer']]); $error = createuser($_SESSION['accounts'][$_SESSION['pointer']], false);
// Show error or success message // Show error or success message
if ($error==1) { if ($error==1) {
$_SESSION['pointer']++; $_SESSION['pointer']++;
@ -271,6 +271,13 @@ switch ($select) {
echo "</fieldset>\n"; echo "</fieldset>\n";
} }
else { else {
// Write homedirs and quotas if needed
if ($_SESSION['config']->scriptServer) {
setquotas ($_SESSION['accounts']);
// Get array with new usernames
foreach ($_SESSION['accounts'] as $account) $users[] = $account->general_username;
addhomedir($users);
}
// Show success-page // Show success-page
echo '<tr><td>'; echo '<tr><td>';
echo _('All Users have been created'); echo _('All Users have been created');
@ -468,16 +475,16 @@ function loadfile() {
while (isset($profile->quota[$i])) { while (isset($profile->quota[$i])) {
// search if quotas from profile fit to a real quota // search if quotas from profile fit to a real quota
$found = (-1); $found = (-1);
for ($j=0; $j<count($values->quota); $j++) for ($j=0; $j<count($values[0]->quota); $j++)
if ($values->quota[$j][0]==$profile->quota[$i][0]) $found = $j; if ($values[0]->quota[$j][0]==$profile->quota[$i][0]) $found = $j;
// unset quota from profile if quotas (mointpoint) doesn't exists anymore // unset quota from profile if quotas (mointpoint) doesn't exists anymore
if ($found==-1) unset($profile->quota[$i]); if ($found==-1) unset($profile->quota[$i]);
else { else {
// Set missing part in quota-array // Set missing part in quota-array
$profile->quota[$i][1] = $values->quota[$found][1]; $profile->quota[$i][1] = $values[0]->quota[$found][1];
$profile->quota[$i][5] = $values->quota[$found][5]; $profile->quota[$i][5] = $values[0]->quota[$found][5];
$profile->quota[$i][4] = $values->quota[$found][4]; $profile->quota[$i][4] = $values[0]->quota[$found][4];
$profile->quota[$i][8] = $values->quota[$found][8]; $profile->quota[$i][8] = $values[0]->quota[$found][8];
$i++; $i++;
} }
} }
@ -486,8 +493,8 @@ function loadfile() {
} }
else { // No quotas saved in profile else { // No quotas saved in profile
// Display quotas for new users (Quota set to 0) // Display quotas for new users (Quota set to 0)
if (is_object($values)) { if (is_object($values[0])) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values[0])) // Set only defined values
if (isset($val)) $profile->$key = $val; if (isset($val)) $profile->$key = $val;
} }
} }