Merge branch 'stable-3.1'
Conflicts: bureau/class/m_action.php bureau/class/m_bro.php bureau/class/m_dom.php debian/changelog install/mysql.sql install/upgrades/3.3.0~a.sql
This commit is contained in:
commit
5a31dc9b96
3
Makefile
3
Makefile
|
@ -27,7 +27,6 @@ export VERSION
|
||||||
|
|
||||||
build:
|
build:
|
||||||
# gettext are built at runtime, to be able to MERGE them from CORE + MODULES before msgfmt
|
# gettext are built at runtime, to be able to MERGE them from CORE + MODULES before msgfmt
|
||||||
pod2man --center "" --date "" --release "AlternC" --section=8 man/alternc.install.pod >man/alternc.install.8
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
#install-alternc install-squirrelmail install-roundcube install-upnp install-awstats
|
#install-alternc install-squirrelmail install-roundcube install-upnp install-awstats
|
||||||
|
@ -78,7 +77,7 @@ install-alternc: install-common
|
||||||
|
|
||||||
install-slave: install-common
|
install-slave: install-common
|
||||||
# Man pages
|
# Man pages
|
||||||
install -o root -g root -m 644 man/alternc.install.8 $(DESTDIR)/usr/share/man/man8/
|
pod2man --center "" --date "" --release "AlternC" --section=8 man/alternc.install.pod >$(DESTDIR)/usr/share/man/man8/alternc.install.8
|
||||||
|
|
||||||
|
|
||||||
# Then its modules :
|
# Then its modules :
|
||||||
|
|
|
@ -92,7 +92,7 @@ if (!empty($formu) && $formu) {
|
||||||
<form action="bro_main.php" method="post" name="main" id="main">
|
<form action="bro_main.php" method="post" name="main" id="main">
|
||||||
<input type="hidden" name="formu" value="2" />
|
<input type="hidden" name="formu" value="2" />
|
||||||
<input type="hidden" name="actdel" value="1" />
|
<input type="hidden" name="actdel" value="1" />
|
||||||
<input type="hidden" name="R" value="<?php echo ehe($R)?>" />
|
<input type="hidden" name="R" value="<?php ehe($R)?>" />
|
||||||
<p class="alert alert-warning"><?php __("WARNING: Confirm the deletion of this files"); ?></p>
|
<p class="alert alert-warning"><?php __("WARNING: Confirm the deletion of this files"); ?></p>
|
||||||
<h2><?php echo $mem->user["login"].$R."/"; ?></h2>
|
<h2><?php echo $mem->user["login"].$R."/"; ?></h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -36,9 +36,7 @@ getFields($fields);
|
||||||
|
|
||||||
|
|
||||||
$p=$bro->GetPrefs();
|
$p=$bro->GetPrefs();
|
||||||
// need to release the giant lock, otherwise those downloads will hang
|
|
||||||
// AlternC for all users!
|
|
||||||
alternc_shutdown();
|
|
||||||
switch ($p["downfmt"]) {
|
switch ($p["downfmt"]) {
|
||||||
case 0:
|
case 0:
|
||||||
$bro->DownloadTGZ($dir);
|
$bro->DownloadTGZ($dir);
|
||||||
|
|
|
@ -52,23 +52,6 @@ Merci de revenir plus tard.";
|
||||||
}
|
}
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
/* Toutes les pages du bureau passent ici. On utilise une s<EFBFBD>maphore pour
|
|
||||||
s'assurer que personne ne pourra acc<EFBFBD>der <EFBFBD> 2 pages du bureau en m<EFBFBD>me temps.
|
|
||||||
*/
|
|
||||||
/* * /
|
|
||||||
// 1. Get a semaphore id for the alternc magic number (18577)
|
|
||||||
$alternc_sem = sem_get ( 18577 );
|
|
||||||
// 2. Declare the shutdown function, that release the semaphore
|
|
||||||
function alternc_shutdown() {
|
|
||||||
global $alternc_sem;
|
|
||||||
@sem_release( $alternc_sem );
|
|
||||||
}
|
|
||||||
// 3. Register the shutdown function
|
|
||||||
register_shutdown_function("alternc_shutdown");
|
|
||||||
// 4. Acquire the semaphore : with that process,
|
|
||||||
sem_acquire( $alternc_sem );
|
|
||||||
/* */
|
|
||||||
|
|
||||||
if (ini_get("safe_mode")) {
|
if (ini_get("safe_mode")) {
|
||||||
echo "SAFE MODE IS ENABLED for the web panel ! It's a bug in your php or apache configuration, please fix it !!";
|
echo "SAFE MODE IS ENABLED for the web panel ! It's a bug in your php or apache configuration, please fix it !!";
|
||||||
exit();
|
exit();
|
||||||
|
|
|
@ -69,7 +69,19 @@ class m_action {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plans the cration of a dir
|
* Plans the a chmod on file or dir
|
||||||
|
*
|
||||||
|
* @param string $filename
|
||||||
|
* @param int $perms
|
||||||
|
* @param string $user
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function chmod($filename, $perms, $user = "root") {
|
||||||
|
return $this->set('chmod', $user, array('filename' => $filename,"perms"=>$perms));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plans the creation of a dir
|
||||||
*
|
*
|
||||||
* @param string $dir
|
* @param string $dir
|
||||||
* @param int $user
|
* @param int $user
|
||||||
|
@ -185,18 +197,35 @@ class m_action {
|
||||||
$err->log("action", "set", $type);
|
$err->log("action", "set", $type);
|
||||||
|
|
||||||
$serialized = serialize($parameters);
|
$serialized = serialize($parameters);
|
||||||
$type = strtoupper($type);
|
|
||||||
if (in_array($type, array('CREATE_FILE',
|
switch ($type) {
|
||||||
'CREATE_DIR',
|
case 'chmod':
|
||||||
'MOVE',
|
$query = "insert into actions values ('','CHMOD','$serialized',now(),'','','$user','');";
|
||||||
'FIX_USER',
|
break;
|
||||||
'FIX_FILE',
|
case 'create_file':
|
||||||
'FIX_DIR',
|
$query = "insert into actions values ('','CREATE_FILE','$serialized',now(),'','','$user','');";
|
||||||
'DELETE'))) {
|
break;
|
||||||
$query = "INSERT INTO `actions` (type, parameters, creation, user) VALUES('$type', '$serialized', now(), '$user');";
|
case 'create_dir':
|
||||||
} else {
|
$query = "insert into actions values ('','CREATE_DIR','$serialized',now(),'','','$user','');";
|
||||||
return False;
|
break;
|
||||||
}
|
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 ('','FIX_FILE','$serialized',now(),'','','$user','');";
|
||||||
|
break;
|
||||||
|
case 'fix_dir':
|
||||||
|
$query = "insert into actions values ('','FIX_DIR','$serialized',now(),'','','$user','');";
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
$query = "insert into actions values ('','DELETE','$serialized',now(),'','','$user','');";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!$db->query($query)) {
|
if (!$db->query($query)) {
|
||||||
$err->raise("action", _("Error setting actions"));
|
$err->raise("action", _("Error setting actions"));
|
||||||
return false;
|
return false;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,11 @@ alternc (3.2.1) stable; urgency=low
|
||||||
* Includes a small dovecot patch / dependency for dovecot 2.0 for Wheezy
|
* Includes a small dovecot patch / dependency for dovecot 2.0 for Wheezy
|
||||||
|
|
||||||
-- Benjamin Sonntag <benjamin@sonntag.fr> Thu, 28 Mar 2014 18:19:00 +0200
|
-- Benjamin Sonntag <benjamin@sonntag.fr> Thu, 28 Mar 2014 18:19:00 +0200
|
||||||
|
alternc (3.1.2) oldstable; urgency=low
|
||||||
|
|
||||||
|
* fix a bug when installing (doing patches from 3.1~rc)
|
||||||
|
|
||||||
|
-- Benjamin Sonntag <benjamin@sonntag.fr> Fri, 4 Jul 2014 12:44:12 +0100
|
||||||
|
|
||||||
alternc (3.1.1) oldstable; urgency=low
|
alternc (3.1.1) oldstable; urgency=low
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ if [ ! -r "$CONFIG_FILE" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ `id -u` -ne 0 ]; then
|
if [ `id -u` -ne 0 ]; then
|
||||||
echo "3.0.3~b.sh must be launched as root"
|
echo "$0 must be launched as root"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -28,5 +28,5 @@ test -d /var/alternc/bind/zones/ || exit 0
|
||||||
cp --no-clobber /var/alternc/bind/zones/* /var/lib/alternc/bind/zones/
|
cp --no-clobber /var/alternc/bind/zones/* /var/lib/alternc/bind/zones/
|
||||||
|
|
||||||
# No need to regenerate zone, we are launched by upgrade_check,
|
# No need to regenerate zone, we are launched by upgrade_check,
|
||||||
# launched by alternc.install, and alternc.install regenerate everything
|
# launched by alternc.install, and alternc.install regenerate everything
|
||||||
# when it end
|
# when it end
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
|
|
||||||
#ALTER TABLE variable DROP PRIMARY KEY;
|
|
||||||
# Quick-fix to make setup work again
|
|
||||||
# ALTER TABLE variable ADD id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
|
|
||||||
ALTER TABLE variable ADD strata enum('DEFAULT','GLOBAL','FQDN', 'FQDN_CREATOR', 'CREATOR', 'MEMBER', 'DOMAIN') NOT NULL DEFAULT 'DEFAULT';
|
|
||||||
ALTER TABLE variable ADD strata_id bigint DEFAULT NULL;
|
|
||||||
ALTER TABLE variable ADD type text DEFAULT '';
|
|
||||||
ALTER TABLE variable ADD UNIQUE (name, strata, strata_id);
|
|
||||||
|
|
||||||
ALTER TABLE actions MODIFY COLUMN type enum('CREATE_FILE','FIX_USER','CREATE_DIR','DELETE','MOVE','FIX_DIR','FIX_FILE');
|
|
||||||
|
|
|
@ -69,6 +69,15 @@ class m_actionTest extends AlterncTest {
|
||||||
$this->assertFileExists($L_INOTIFY_DO_ACTION);
|
$this->assertFileExists($L_INOTIFY_DO_ACTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers m_action::chmod
|
||||||
|
*/
|
||||||
|
public function testChmod() {
|
||||||
|
$result = $this->object->chmod(self::TEST_FILE, 0777,"phpunit");
|
||||||
|
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::create_file
|
* @covers m_action::create_file
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,7 +10,7 @@ now=$5
|
||||||
user=$6
|
user=$6
|
||||||
password=$7
|
password=$7
|
||||||
|
|
||||||
timeout=5
|
timeout=3600
|
||||||
|
|
||||||
for CONFIG_FILE in \
|
for CONFIG_FILE in \
|
||||||
/etc/alternc/local.sh \
|
/etc/alternc/local.sh \
|
||||||
|
@ -55,7 +55,7 @@ tmpfile=$(mktemp /tmp/altern-cron-id$id-$$.XXX)
|
||||||
(
|
(
|
||||||
echo -e "Here the report for the scheduled task for the cron #$id in your AlternC configuration (from http://$FQDN)\n\n"
|
echo -e "Here the report for the scheduled task for the cron #$id in your AlternC configuration (from http://$FQDN)\n\n"
|
||||||
echo -e "\n---------- BEGIN ----------"
|
echo -e "\n---------- BEGIN ----------"
|
||||||
bash -c "wget -O - --no-check-certificate --http-user=$(urldecode $user) --http-password=$(urldecode $password) \"$(urldecode $url)\" --timeout=$timeout 2>&1"
|
bash -c "wget --tries=1 -O - --no-check-certificate --http-user=$(urldecode $user) --http-password=$(urldecode $password) \"$(urldecode $url)\" --timeout=$timeout 2>&1"
|
||||||
echo -e "\n---------- END ----------"
|
echo -e "\n---------- END ----------"
|
||||||
) > "$tmpfile"
|
) > "$tmpfile"
|
||||||
|
|
||||||
|
|
|
@ -39,34 +39,69 @@
|
||||||
/*
|
/*
|
||||||
Fixme
|
Fixme
|
||||||
|
|
||||||
- handle error correctly
|
|
||||||
- check all those cases
|
- check all those cases
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
// Put this var to 1 if you want to enable debug prints
|
// Put this var to 1 if you want to enable debug prints
|
||||||
$debug=1;
|
$debug=0;
|
||||||
$error_raise='';
|
|
||||||
|
|
||||||
// Debug function that print infos
|
// Collects errors along execution. If length > 1, an email is sent.
|
||||||
|
$errorsList=array();
|
||||||
|
|
||||||
|
// Bootstraps
|
||||||
|
require_once("/usr/share/alternc/panel/class/config_nochk.php");
|
||||||
|
|
||||||
|
// Script lock through filesystem
|
||||||
|
$admin->stop_if_jobs_locked();
|
||||||
|
|
||||||
|
if( !defined("ALTERNC_DO_ACTION_LOCK")){
|
||||||
|
define("ALTERNC_DO_ACTION_LOCK",'/var/run/alternc/do_actions_cron.lock');
|
||||||
|
}
|
||||||
|
|
||||||
|
$SCRIPT='/usr/bin/php do_actions.php';
|
||||||
|
$MY_PID=getmypid();
|
||||||
|
$FIXPERM='/usr/lib/alternc/fixperms.sh';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Debug function that print infos
|
||||||
|
*
|
||||||
|
* @global int $debug
|
||||||
|
* @param type $mess
|
||||||
|
*/
|
||||||
function d($mess){
|
function d($mess){
|
||||||
global $debug;
|
global $debug;
|
||||||
if ($debug == 1)
|
if ($debug == 1)
|
||||||
echo "$mess\n";
|
echo "$mess\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to mail the panel's administrator if something failed
|
/**
|
||||||
|
* Function to mail the panel's administrator if something failed
|
||||||
|
* @global array $errorsList
|
||||||
|
* @global type $L_FQDN
|
||||||
|
*/
|
||||||
function mail_it(){
|
function mail_it(){
|
||||||
global $error_raise,$L_FQDN;
|
global $errorsList,$L_FQDN;
|
||||||
mail("alterncpanel@$L_FQDN",'Script do_actions.php issues',"\n Errors reporting mail:\n\n$error_raise");
|
// Forces array
|
||||||
|
if( !is_array($errorsList)){
|
||||||
|
$errorsList = array($errorsList);
|
||||||
|
}
|
||||||
|
// Builds message from array
|
||||||
|
$msg = implode("\n", $errorsList);
|
||||||
|
// Attempts to send email
|
||||||
|
// @todo log if fails
|
||||||
|
mail("alterncpanel@$L_FQDN",'Script do_actions.php issues',"\n Errors reporting mail:\n\n$msg");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* $command: the command
|
* Common routine for system calls
|
||||||
* $parameters: of the command (they are going to be protected)
|
*
|
||||||
* return array('output'=>'output of exec', 'return_var'=>'returned integer of exec')
|
* @param type $command the command
|
||||||
|
* @param type $parameters of the command (they are going to be protected)
|
||||||
|
* @return array('output'=>'output of exec', 'return_var'=>'returned integer of exec')
|
||||||
*/
|
*/
|
||||||
function execute_cmd($command, $parameters=array()) {
|
function execute_cmd($command, $parameters=array()) {
|
||||||
$cmd_line = "$command ";
|
$cmd_line = "$command ";
|
||||||
|
@ -84,20 +119,12 @@ function execute_cmd($command, $parameters=array()) {
|
||||||
return array('executed' => $cmd_line, 'output'=>$output, 'return_var'=>$code);
|
return array('executed' => $cmd_line, 'output'=>$output, 'return_var'=>$code);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once("/usr/share/alternc/panel/class/config_nochk.php");
|
|
||||||
|
|
||||||
$admin->stop_if_jobs_locked();
|
|
||||||
|
|
||||||
$LOCK_FILE='/var/run/alternc/do_actions_cron.lock';
|
|
||||||
$SCRIPT='/usr/bin/php do_actions.php';
|
|
||||||
$MY_PID=getmypid();
|
|
||||||
$FIXPERM='/usr/lib/alternc/fixperms.sh';
|
|
||||||
|
|
||||||
// Check if script isn't already running
|
// Check if script isn't already running
|
||||||
if (file_exists($LOCK_FILE) !== false){
|
if (file_exists(ALTERNC_DO_ACTION_LOCK) !== false){
|
||||||
d("Lock file already exists. ");
|
d("Lock file already exists. ");
|
||||||
// Check if file is in process list
|
// Check if file is in process list
|
||||||
$PID=file_get_contents($LOCK_FILE);
|
$PID=file_get_contents(ALTERNC_DO_ACTION_LOCK);
|
||||||
d("My PID is $MY_PID, PID in the lock file is $PID");
|
d("My PID is $MY_PID, PID in the lock file is $PID");
|
||||||
if ($PID == exec("pidof $SCRIPT | tr ' ' '\n' | grep -v $MY_PID")){
|
if ($PID == exec("pidof $SCRIPT | tr ' ' '\n' | grep -v $MY_PID")){
|
||||||
// Previous cron is not finished yet, just exit
|
// Previous cron is not finished yet, just exit
|
||||||
|
@ -105,16 +132,16 @@ if (file_exists($LOCK_FILE) !== false){
|
||||||
exit(0);
|
exit(0);
|
||||||
}else{
|
}else{
|
||||||
// Previous cron failed!
|
// Previous cron failed!
|
||||||
$error_raise.="Lock file already exists. No process with PID $PID found! Previous cron failed...\n";
|
$errorsList[]="Lock file already exists. No process with PID $PID found! Previous cron failed...\n";
|
||||||
|
|
||||||
// No need to remove anything, we're going to recreate it
|
// No need to remove anything, we're going to recreate it
|
||||||
//d("Removing lock file and trying to process the failed action...");
|
//d("Removing lock file and trying to process the failed action...");
|
||||||
// Delete the lock and continue to the next action
|
// Delete the lock and continue to the next action
|
||||||
//unlink($LOCK_FILE);
|
//unlink(ALTERNC_DO_ACTION_LOCK);
|
||||||
|
|
||||||
// Lock with the current script's PID
|
// Lock with the current script's PID
|
||||||
if (file_put_contents($LOCK_FILE,$MY_PID) === false){
|
if (file_put_contents(ALTERNC_DO_ACTION_LOCK,$MY_PID) === false){
|
||||||
$error_raise.="Cannot open/write $LOCK_FILE\n";
|
$errorsList[]="Cannot open/write ALTERNC_DO_ACTION_LOCK\n";
|
||||||
mail_it();
|
mail_it();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -131,9 +158,9 @@ if (file_exists($LOCK_FILE) !== false){
|
||||||
$action->reset_job($c["id"]);
|
$action->reset_job($c["id"]);
|
||||||
}else{
|
}else{
|
||||||
// We can't resume the others types, notify the fail and finish this action
|
// We can't resume the others types, notify the fail and finish this action
|
||||||
$error_raise.="Can't resume the job n°".$c["id"]." action '".$c["type"]."', finishing it with a fail status.\n";
|
$errorsList[]="Can't resume the job n°".$c["id"]." action '".$c["type"]."', finishing it with a fail status.\n";
|
||||||
if(!$action->finish($c["id"],"Fail: Previous script crashed while processing this action, cannot resume it.")){
|
if(!$action->finish($c["id"],"Fail: Previous script crashed while processing this action, cannot resume it.")){
|
||||||
$error_raise.="Cannot finish the action! Error while inserting the error value in the DB for action n°".$c["id"]." : action '".$c["type"]."'\n";
|
$errorsList[]="Cannot finish the action! Error while inserting the error value in the DB for action n°".$c["id"]." : action '".$c["type"]."'\n";
|
||||||
break; // Else we go into an infinite loop... AAAAHHHHHH
|
break; // Else we go into an infinite loop... AAAAHHHHHH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,8 +168,8 @@ if (file_exists($LOCK_FILE) !== false){
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
// Lock with the current script's PID
|
// Lock with the current script's PID
|
||||||
if (file_put_contents($LOCK_FILE,$MY_PID) === false){
|
if (file_put_contents(ALTERNC_DO_ACTION_LOCK,$MY_PID) === false){
|
||||||
$error_raise.="Cannot open/write $LOCK_FILE\n";
|
$errorsList[]="Cannot open/write ALTERNC_DO_ACTION_LOCK\n";
|
||||||
mail_it();
|
mail_it();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -157,7 +184,6 @@ while ($rr=$action->get_action()){
|
||||||
$SU="su ".$r["user"]." 2>&1 ;";
|
$SU="su ".$r["user"]." 2>&1 ;";
|
||||||
else
|
else
|
||||||
$SU="";
|
$SU="";
|
||||||
unset($output);
|
|
||||||
// We lock the action
|
// We lock the action
|
||||||
d("-----------\nBeginning action n°".$r["id"]);
|
d("-----------\nBeginning action n°".$r["id"]);
|
||||||
$action->begin($r["id"]);
|
$action->begin($r["id"]);
|
||||||
|
@ -170,19 +196,36 @@ while ($rr=$action->get_action()){
|
||||||
// Create the directory and make parent directories as needed
|
// Create the directory and make parent directories as needed
|
||||||
#@exec("$FIXPERM -u ".$params["uid"]." 2>&1", $trash, $code);
|
#@exec("$FIXPERM -u ".$params["uid"]." 2>&1", $trash, $code);
|
||||||
$returned = execute_cmd("$FIXPERM -u", $params["uid"]);
|
$returned = execute_cmd("$FIXPERM -u", $params["uid"]);
|
||||||
|
break;
|
||||||
|
case "CHMOD" :
|
||||||
|
$filename=$params["file"];
|
||||||
|
$perms=$params["perms"];
|
||||||
|
// Checks the file or directory exists
|
||||||
|
if( !is_dir($filename) && ! is_file($filename)){
|
||||||
|
$errorsList=array("Fail: cannot create ".$params["dst"]);
|
||||||
|
}
|
||||||
|
// Checks the perms are correct
|
||||||
|
else if ( !is_int( $perms)){
|
||||||
|
$errorsList=array("Fail: cannot create ".$params["dst"]);
|
||||||
|
}
|
||||||
|
// Attempts to change the rights on the file or directory
|
||||||
|
else if( !chmod($filename, $perms)) {
|
||||||
|
$errorsList=array("Fail: cannot create ".$params["dst"]);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "CREATE_FILE" :
|
case "CREATE_FILE" :
|
||||||
if(!file_exists($params["file"])) {
|
if(!file_exists($params["file"])) {
|
||||||
#@exec("$SU touch ".$params["file"]." 2>&1 ; echo '".$params["content"]."' > '".$params["file"]."' 2>&1", $output);
|
#@exec("$SU touch ".$params["file"]." 2>&1 ; echo '".$params["content"]."' > '".$params["file"]."' 2>&1", $output);
|
||||||
if ( file_put_contents($params["file"], $params["content"]) === false ) {
|
if ( file_put_contents($params["file"], $params["content"]) === false ) {
|
||||||
$log_error=array("Fail: can't write into file ".$params["file"]);
|
$errorsList=array("Fail: can't write into file ".$params["file"]);
|
||||||
} else {
|
} else {
|
||||||
if (!chown($params["file"], $r["user"])) {
|
if (!chown($params["file"], $r["user"])) {
|
||||||
$log_error=array("Fail: cannot chown ".$params["file"]);
|
$errorsList=array("Fail: cannot chown ".$params["file"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$log_error=array("Fail: file already exists ".$params["file"]);
|
$errorsList=array("Fail: file already exists ".$params["file"]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "CREATE_DIR" :
|
case "CREATE_DIR" :
|
||||||
|
@ -203,18 +246,22 @@ while ($rr=$action->get_action()){
|
||||||
$returned = execute_cmd("$SU mv -f", array($params["src"], $params["dst"]));
|
$returned = execute_cmd("$SU mv -f", array($params["src"], $params["dst"]));
|
||||||
}
|
}
|
||||||
} else { //is_dir false
|
} else { //is_dir false
|
||||||
$log_error=array("Fail: cannot create ".$params["dst"]);
|
$errorsList=array("Fail: cannot create ".$params["dst"]);
|
||||||
} // is_dir
|
} // is_dir
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "FIX_DIR" :
|
case "FIX_DIR" :
|
||||||
$returned = execute_cmd($FIXPERM, array('-d', $params["dir"]));
|
$returned = execute_cmd($FIXPERM, array('-d', $params["dir"]));
|
||||||
if($returned['return_val'] != 0) $log_error=array("Fixperms.sh failed, returned error code : ".$returned['return_val']);
|
if($returned['return_val'] != 0) {
|
||||||
|
$errorsList=array("Fixperms.sh failed, returned error code : ".$returned['return_val']);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "FIX_FILE" :
|
case "FIX_FILE" :
|
||||||
#@exec("$FIXPERM -f ".$params["file"]." 2>&1", $trash, $code);
|
#@exec("$FIXPERM -f ".$params["file"]." 2>&1", $trash, $code);
|
||||||
$returned = execute_cmd($FIXPERM, array('-f', $params["file"]));
|
$returned = execute_cmd($FIXPERM, array('-f', $params["file"]));
|
||||||
if($returned['return_val'] != 0) $log_error=array("Fixperms.sh failed, returned error code : ".$returned['return_val']);
|
if($returned['return_val'] != 0){
|
||||||
|
$errorsList=array("Fixperms.sh failed, returned error code : ".$returned['return_val']);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
$output=array("Fail: Sorry dude, i do not know this type of action");
|
$output=array("Fail: Sorry dude, i do not know this type of action");
|
||||||
|
@ -223,24 +270,24 @@ while ($rr=$action->get_action()){
|
||||||
// Get the error (if exists).
|
// Get the error (if exists).
|
||||||
if(isset($output[0])){
|
if(isset($output[0])){
|
||||||
$return=$output[0];
|
$return=$output[0];
|
||||||
$error_raise.="\nAction n°".$r["id"]." '".$r["type"]."' failed! With user: ".$r["user"]."\nHere is the complete output:\n".print_r($output);
|
$errorsList[]="\nAction n°".$r["id"]." '".$r["type"]."' failed! With user: ".$r["user"]."\nHere is the complete output:\n".print_r($output);
|
||||||
}
|
}
|
||||||
// We finished the action, notify the DB.
|
// We finished the action, notify the DB.
|
||||||
d("Finishing... return value is : $return\n");
|
d("Finishing... return value is : $return\n");
|
||||||
if(!$action->finish($r["id"],addslashes($return))){
|
if(!$action->finish($r["id"],addslashes($return))){
|
||||||
$error_raise.="Cannot finish the action! Error while inserting the error value in the DB for action n°".$r["id"]." : action '".$r["type"]."'\nReturn value: ".addslashes($return)."\n";
|
$errorsList[]="Cannot finish the action! Error while inserting the error value in the DB for action n°".$r["id"]." : action '".$r["type"]."'\nReturn value: ".addslashes($return)."\n";
|
||||||
break; // Else we go into an infinite loop... AAAAHHHHHH
|
break; // Else we go into an infinite loop... AAAAHHHHHH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If something have failed, notify it to the admin
|
// If an error occured, notify it to the admin
|
||||||
if($error_raise !== '') {
|
if(count($errorsList)) {
|
||||||
mail_it();
|
mail_it();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unlock the script
|
// Unlock the script
|
||||||
unlink($LOCK_FILE);
|
// @todo This could be handled by m_admin
|
||||||
|
unlink(ALTERNC_DO_ACTION_LOCK);
|
||||||
|
|
||||||
// Exit this script
|
// Exit this script
|
||||||
exit(0);
|
exit(0);
|
||||||
?>
|
|
|
@ -1,8 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo Not used anymore
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
. /usr/lib/alternc/functions.sh
|
. /usr/lib/alternc/functions.sh
|
||||||
|
|
||||||
TEMPLATE_DIR="/etc/alternc/templates/apache2"
|
TEMPLATE_DIR="/etc/alternc/templates/apache2"
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
for CONFIG_FILE in \
|
for CONFIG_FILE in \
|
||||||
/etc/alternc/local.sh \
|
/etc/alternc/local.sh \
|
||||||
/usr/lib/alternc/functions.sh \
|
/usr/lib/alternc/functions.sh \
|
||||||
|
/usr/lib/alternc/functions_hosting.sh \
|
||||||
/usr/lib/alternc/functions_dns.sh
|
/usr/lib/alternc/functions_dns.sh
|
||||||
do
|
do
|
||||||
if [ ! -r "$CONFIG_FILE" ]; then
|
if [ ! -r "$CONFIG_FILE" ]; then
|
||||||
|
@ -18,6 +19,13 @@ stop_if_jobs_locked
|
||||||
# Some vars
|
# Some vars
|
||||||
umask 022
|
umask 022
|
||||||
LOCK_FILE="/usr/share/alternc/panel/cron.lock" # FIXME doesn't seem clean to be here
|
LOCK_FILE="/usr/share/alternc/panel/cron.lock" # FIXME doesn't seem clean to be here
|
||||||
|
OLDIFS="$IFS"
|
||||||
|
NEWIFS=" "
|
||||||
|
LOGFORMAT_FILE="/etc/alternc/apache_logformat.conf"
|
||||||
|
RELOAD_WEB="$(mktemp /tmp/alternc_reload_web.XXXX)"
|
||||||
|
B="µµ§§" # Strange letters to make split in query
|
||||||
|
|
||||||
|
echo "" > "$RELOAD_WEB"
|
||||||
|
|
||||||
# Somes check before start operations
|
# Somes check before start operations
|
||||||
if [ `id -u` -ne 0 ]; then
|
if [ `id -u` -ne 0 ]; then
|
||||||
|
@ -45,22 +53,113 @@ echo $$ > "$LOCK_FILE"
|
||||||
# set sub_domaines.web_action = delete where domaines.dns_action = DELETE
|
# set sub_domaines.web_action = delete where domaines.dns_action = DELETE
|
||||||
mysql_query "update sub_domaines sd, domaines d set sd.web_action = 'DELETE' where sd.domaine = d.domaine and sd.compte=d.compte and d.dns_action = 'DELETE';"
|
mysql_query "update sub_domaines sd, domaines d set sd.web_action = 'DELETE' where sd.domaine = d.domaine and sd.compte=d.compte and d.dns_action = 'DELETE';"
|
||||||
|
|
||||||
# Launc apache script. If the script said so, reload apache.
|
# Sub_domaines we want to delete
|
||||||
if [ $(/usr/lib/alternc/generate_apache_conf.php) -gt 0 ] ; then
|
# sub_domaines.web_action = delete
|
||||||
|
for sub in $( mysql_query "select concat_ws('$B',lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine)) from sub_domaines sd where web_action ='DELETE';") ; do
|
||||||
|
host_delete ${sub/$B/ }
|
||||||
|
mysql_query "delete from sub_domaines where concat_ws('$B',lower(type), if(length(sub)>0,concat_ws('.',sub,domaine),domaine)) = '$sub' and web_action ='DELETE';"
|
||||||
|
echo 1 > "$RELOAD_WEB"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Sub domaines we want to update
|
||||||
|
# sub_domaines.web_action = update and sub_domains.only_dns = false
|
||||||
|
IFS="$NEWIFS"
|
||||||
|
mysql_query "
|
||||||
|
select concat_ws('$IFS',sd.id, lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine), concat_ws('@',m.login,v.value), sd.valeur )
|
||||||
|
from sub_domaines sd,membres m,variable v
|
||||||
|
where sd.compte=m.uid and sd.web_action ='UPDATE' and v.name='mailname_bounce'
|
||||||
|
;" | while read sdid type domain mail valeur ; do
|
||||||
|
host_create "$type" "$domain" "$mail" "$valeur"
|
||||||
|
mysql_query "update sub_domaines sd set web_action='OK',web_result='$?' where sd.id = '$sdid' ; "
|
||||||
|
echo 1 > "$RELOAD_WEB"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Domaine to enable
|
||||||
|
mysql_query "select concat_ws('$IFS',sd.id, lower(sd.type),if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),sd.valeur) from sub_domaines sd where sd.enable ='ENABLE' ;"|while read sdid type domain valeur ; do
|
||||||
|
host_enable "$type" "$domain" "$valeur"
|
||||||
|
mysql_query "update sub_domaines sd set enable='ENABLED' where sd.id = '$sdid' ;"
|
||||||
|
echo 1 > "$RELOAD_WEB"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Domains to disable
|
||||||
|
mysql_query "select concat_ws('$IFS', sd.id, lower(sd.type),if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),sd.valeur) from sub_domaines sd where sd.enable ='DISABLE' ;"|while read sdid type domain valeur ; do
|
||||||
|
host_disable "$type" "$domain" "$valeur"
|
||||||
|
mysql_query "update sub_domaines sd set enable='DISABLED' where sd.id = '$sdid' ;"
|
||||||
|
echo 1 > "$RELOAD_WEB"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Domains we do not want to be the DNS serveur anymore :
|
||||||
|
# domaines.dns_action = UPDATE and domaines.gesdns = 0
|
||||||
|
for dom in `mysql_query "select domaine from domaines where dns_action = 'UPDATE' and gesdns = 0;"| tr '\n' ' '`
|
||||||
|
do
|
||||||
|
dns_delete $dom
|
||||||
|
mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Domains we have to update the dns :
|
||||||
|
# domaines.dns_action = UPDATE
|
||||||
|
for dom in `mysql_query "select domaine from domaines where dns_action = 'UPDATE';" | tr '\n' ' '`
|
||||||
|
do
|
||||||
|
echo "dns_regenerate : domain=/$dom/"
|
||||||
|
dns_regenerate $dom
|
||||||
|
mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Domains we want to delete completely, now we do it
|
||||||
|
# domaines.dns_action = DELETE
|
||||||
|
for dom in `mysql_query "select domaine from domaines where dns_action = 'DELETE';" | tr '\n' ' '`
|
||||||
|
do
|
||||||
|
dns_delete $dom
|
||||||
|
# Web configurations have already bean cleaned previously
|
||||||
|
mysql_query "delete from sub_domaines where domaine='$dom'; delete from domaines where domaine='$dom';"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then
|
||||||
|
|
||||||
|
# Just to encourage user to use THIS directory and not another one
|
||||||
|
test -d "$VHOST_MANUALCONF" || mkdir -p "$VHOST_MANUALCONF"
|
||||||
|
|
||||||
|
# Concat the apaches files
|
||||||
|
tempo=$(mktemp "$VHOST_FILE.XXXXX")
|
||||||
|
|
||||||
|
(
|
||||||
|
echo "###BEGIN OF ALTERNC AUTO-GENERATED FILE - DO NOT EDIT MANUALLY###"
|
||||||
|
# If exists and readable, include conf file "apache_logformat.conf"
|
||||||
|
# contain LogFormat and CustomLog directives for our Vhosts)
|
||||||
|
echo "## LogFormat informations"
|
||||||
|
if [ ! -r "$LOGFORMAT_FILE" ] ; then
|
||||||
|
echo "## Warning : Cannot read $LOGFORMAT_FILE"
|
||||||
|
else
|
||||||
|
echo "Include \"$LOGFORMAT_FILE\""
|
||||||
|
fi
|
||||||
|
find "$VHOST_DIR" -mindepth 2 -type f -iname "*.conf" -print0 | xargs -0 cat
|
||||||
|
echo "###END OF ALTERNC AUTO-GENERATED FILE - DO NOT EDIT MANUALLY###"
|
||||||
|
) > "$tempo"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
log_error " web file concatenation failed"
|
||||||
|
fi
|
||||||
|
touch "$VHOST_FILE"
|
||||||
|
if [ ! -w "$VHOST_FILE" ] ; then
|
||||||
|
log_error "cannot write on $VHOST_FILE"
|
||||||
|
fi
|
||||||
|
mv "$tempo" "$VHOST_FILE"
|
||||||
|
|
||||||
# We must reload apache
|
# We must reload apache
|
||||||
# we assume we run apache on the master
|
# we assume we run apache on the master
|
||||||
/usr/lib/alternc/alternc_reload apache || true
|
/usr/lib/alternc/alternc_reload apache || true
|
||||||
|
|
||||||
# Launch hooks for apache reload
|
# Launch hooks for apache reload
|
||||||
# In this directory, you can add you remote web server control
|
|
||||||
run-parts --arg=web_reload /usr/lib/alternc/reload.d
|
run-parts --arg=web_reload /usr/lib/alternc/reload.d
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Do bind updates
|
## FIXME : move the slave part into the /usr/lib/alternc/reload.d directory to be an hook
|
||||||
/usr/lib/alternc/generate_bind_conf.php
|
#for slave in $ALTERNC_SLAVES; do
|
||||||
|
# if [ "$slave" != "localhost" ]; then
|
||||||
|
# ssh alternc@$slave alternc_reload 'apache' || true
|
||||||
|
# fi
|
||||||
|
#done
|
||||||
|
|
||||||
rm -f "$LOCK_FILE" "$RELOAD_ZONES" "$INOTIFY_UPDATE_DOMAIN"
|
rm -f "$LOCK_FILE" "$RELOAD_ZONES" "$RELOAD_WEB" "$INOTIFY_UPDATE_DOMAIN"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
protocols = imap pop3 sieve
|
protocols = imap pop3 sieve
|
||||||
|
|
||||||
|
default_process_limit = 1000
|
||||||
|
|
||||||
## -------------------------------------------------------------------------
|
## -------------------------------------------------------------------------
|
||||||
## 10-auth
|
## 10-auth
|
||||||
|
|
||||||
|
@ -189,12 +191,22 @@ protocol imap {
|
||||||
# list of plugins to load.
|
# list of plugins to load.
|
||||||
mail_plugins = quota imap_quota
|
mail_plugins = quota imap_quota
|
||||||
#mail_plugin_dir = /usr/lib/dovecot/modules/imap
|
#mail_plugin_dir = /usr/lib/dovecot/modules/imap
|
||||||
|
mail_max_userip_connections = 500
|
||||||
}
|
}
|
||||||
|
|
||||||
service imap {
|
service imap {
|
||||||
executable = /usr/lib/alternc/popimap-log-login.sh /usr/lib/dovecot/imap
|
executable = imap imap-postlogin
|
||||||
|
vsz_limit = 512M
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service imap-postlogin {
|
||||||
|
executable = script-login /usr/lib/alternc/popimap-log-login.sh
|
||||||
|
# the script process runs as the user specified here (v2.0.14+):
|
||||||
|
# user = $default_internal_user
|
||||||
|
# this UNIX socket listener must use the same name as given to imap executable
|
||||||
|
unix_listener imap-postlogin {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# 20-managesieve.conf
|
# 20-managesieve.conf
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
--- changelog 2014-06-24 13:42:50.234304438 +0200
|
--- changelog 2014-06-24 13:42:50.234304438 +0200
|
||||||
+++ changelog.wheezy 2014-06-24 13:43:51.978313552 +0200
|
+++ changelog.wheezy 2014-06-24 13:43:51.978313552 +0200
|
||||||
@@ -1,3 +1,10 @@
|
@@ -1,3 +1,10 @@
|
||||||
+alternc (3.2.1) stable; urgency=low
|
+alternc (3.2.2) stable; urgency=low
|
||||||
+
|
+
|
||||||
+ * Version identical to 3.1 for Squeeze
|
+ * Version identical to 3.1 for Squeeze
|
||||||
+ * Includes a small dovecot patch / dependency for dovecot 2.0 for Wheezy
|
+ * Includes a small dovecot patch / dependency for dovecot 2.0 for Wheezy
|
||||||
+
|
+
|
||||||
+ -- Benjamin Sonntag <benjamin@sonntag.fr> Thu, 28 Mar 2014 18:19:00 +0200
|
+ -- Benjamin Sonntag <benjamin@sonntag.fr> Thu, 28 Mar 2014 18:19:00 +0200
|
||||||
+
|
+
|
||||||
alternc (3.1.1) oldstable; urgency=low
|
alternc (3.1.2) oldstable; urgency=low
|
||||||
|
|
||||||
* many bugfixed from 3.1 / 3.2 :
|
* fix a bug when installing (doing patches from 3.1~rc)
|
||||||
|
|
Loading…
Reference in New Issue