Bugfixing action class rights setting upon member creation.

This commit is contained in:
Steven Mondji-Lerider 2013-08-08 15:56:09 +00:00
parent bb83c728d4
commit 4104c8292c
4 changed files with 16 additions and 3 deletions

View File

@ -49,6 +49,12 @@ class m_action {
return $this->set('create_dir',$user, array('dir'=>$dir));
}
/*
* function to set the perms upon user creation
*/
function fix_user($uid,$user="root") {
return $this->set('fix_user',$user, array('uid'=>$uid));
}
/*
* function to set the cration of a file
*/
@ -115,12 +121,16 @@ class m_action {
case 'move':
$query="insert into actions values ('','MOVE','$serialized',now(),'','','$user','');";
break;
case 'fix_user':
$query="insert into actions values ('','FIX_USER','$serialized',now(),'','','$user','');";
break;
case 'fix_file':
$query="insert into actions values ('','FIXFILE','$serialized',now(),'','','$user','');";
break;
case 'fix_dir':
$query="insert into actions values ('','FIXDIR','$serialized',now(),'','','$user','');";
break;
case 'delete':
$query="insert into actions values ('','DELETE','$serialized',now(),'','','$user','');";
break;
default:

View File

@ -477,7 +477,7 @@ class m_admin {
$this->renew_update($uid, $duration);
#exec("sudo /usr/lib/alternc/mem_add ".$login." ".$uid);
$action->create_dir(getuserpath("$login"));
$action->fix_dir(getuserpath("$login"));
$action->fix_user($uid);
// Triggering hooks
$mem->su($uid);

View File

@ -733,7 +733,7 @@ CREATE TABLE IF NOT EXISTS `vm_history` (
CREATE TABLE IF NOT EXISTS `actions` (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
type enum ('CREATE_FILE','CREATE_DIR','DELETE','MOVE','FIXDIR','FIXFILE'),
type enum ('CREATE_FILE','FIX_USER','CREATE_DIR','DELETE','MOVE','FIXDIR','FIXFILE'),
parameters longtext default NULL,
creation timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
begin timestamp,

View File

@ -104,7 +104,6 @@ if (file_exists($LOCK_FILE) !== false){
}
}else{
// Lock with the current script's PID
d("Lock the script...");
if (file_put_contents($LOCK_FILE,$MY_PID) === false){
$error_raise.="Cannot open/write $LOCK_FILE\n";
mail_it();
@ -130,6 +129,10 @@ while ($rr=$action->get_action()){
// We exec with the specified user
d("Executing action '".$r["type"]."' with user '".$r["user"]."'");
switch ($r["type"]){
case "FIX_USER" :
// Create the directory and make parent directories as needed
@exec("$FIXPERM -u ".$params["uid"]." 2>&1", $trash, $code);
break;
case "CREATE_FILE" :
if(!file_exists($params["file"]))
@exec("$SU touch ".$params["file"]." 2>&1 ; echo '".$params["content"]."' > '".$params["file"]."' 2>&1", $output);