diff --git a/bureau/admin/adm_deactivate.php b/bureau/admin/adm_deactivate.php
index ab71ed3e..a1563d5c 100644
--- a/bureau/admin/adm_deactivate.php
+++ b/bureau/admin/adm_deactivate.php
@@ -126,11 +126,11 @@ foreach ($domains as $key => $domain) {
} else {
# 2.1 keep a copy of where it was, in an SQL request
- $backup .= "UPDATE `sub_domaines` SET `type`='$type', valeur='$dest',web_action='UPDATE' WHERE `domaine`='$domain' AND sub='$sub';\n";
+ $backup .= "UPDATE `sub_domaines` SET `type`='$type', valeur='$dest',web_action='UPDATE' WHERE id=" . $r['sub'][$k]['id'] . ";\n";
# 2.2 change the subdomain to redirect to http://spam.koumbit.org/
$dom->lock();
- if (!$dom->set_sub_domain($domain, $sub, $dom->type_url, $redirect)) {
+ if (! $db->query("UPDATE `sub_domaines` SET `type`='" . $dom->type_url . "', valeur='$redirect',web_action='UPDATE' WHERE id=" . $r['sub'][$k]['id'] . ";\n") ) {
print "-- error in $sub.$domain: " . $err->errstr() . "\n";
}
$dom->unlock();
@@ -141,6 +141,36 @@ foreach ($domains as $key => $domain) {
if (!$confirmed) print '';
}
+$mail_dom = $mail->enum_domains();
+
+if ($confirmed) {
+ print "
";
+ printf(_("-- disabling all the mail passwords\n"));
+}
+if (!$confirmed) print "\n
mailboxes\n";
+reset($mail_dom);
+# 1.3 foreach mail domain, we list the email hashes
+foreach ($mail_dom as $key => $domain) {
+ if (!$confirmed) print '' . $domain['domaine'] . '';
+ $mails = $mail->enum_domain_mails($domain['id']);
+ foreach ($mails as $key => $add) {
+ if ($add['islocal']) {
+ if (!$confirmed) print '- ' . $add['address'] . '@' . $domain['domaine'];
+ $pass = $add['password'];
+ $id = $add['id'];
+ $backup .= $b = "update address set password='$pass' where id=$id;\n";
+ if (!$confirmed) print "
\n";
+ if ($confirmed) {
+ $db->query("update `address` set password='!$pass' where id=$id;\n");
+ }
+ }
+ }
+ if (!$confirmed) print "
";
+}
+
+
+if (!$confirmed) print "
\n";
+
# 3. wrap up (?)
if ($confirmed) {
print "-- The following is a serie of SQL request you can run, as root, to revert the user's domains to their previous state.\n";
diff --git a/bureau/admin/index.php b/bureau/admin/index.php
index d3ca1d8a..af67e474 100644
--- a/bureau/admin/index.php
+++ b/bureau/admin/index.php
@@ -32,6 +32,10 @@ if (!$mem->del_session()) {
}
$H=getenv("HTTP_HOST");
+if (variable_get('https_redirect', false, 'switch users to HTTPS') && !isset($_SERVER['HTTPS'])) {
+ header("Location: https://$H/");
+ exit();
+}
if (!isset($restrictip)) {
$restrictip=1;
@@ -74,7 +78,7 @@ if ( empty($logo) || ! $logo ) {
' . sprintf(_('WARNING: you are trying to access the control panel insecurely, click here to go to secure mode'), $_SERVER["HTTP_HOST"]) . '';
}
?>
diff --git a/bureau/admin/sql_pma_sso.php b/bureau/admin/sql_pma_sso.php
index 0326447c..4fa77891 100644
--- a/bureau/admin/sql_pma_sso.php
+++ b/bureau/admin/sql_pma_sso.php
@@ -32,13 +32,18 @@ require_once("../class/config.php");
if (!$r=$mysql->php_myadmin_connect()) {
$error=$err->errstr();
} else {
+ session_write_close();
// SSO of PhpMyAdmin
+ session_set_cookie_params(0, '/', '', 0);
+ session_name('AlternC_Panel');
+ session_start();
$_SESSION['PMA_single_signon_user'] = $r["login"];
$_SESSION['PMA_single_signon_password'] = $r["pass"];
$_SESSION['PMA_single_signon_host'] = $r["host"]; // pma >= 2.11
+ session_write_close();
// finally redirect to phpMyAdmin :
- header("Location: /alternc-sql/");
+ header("Location: /alternc-sql/index.php?server=1");
exit();
}
diff --git a/bureau/class/db_mysql.php b/bureau/class/db_mysql.php
index 81992ba2..39f29fa5 100644
--- a/bureau/class/db_mysql.php
+++ b/bureau/class/db_mysql.php
@@ -91,9 +91,9 @@ class DB_Sql {
/* establish connection, select database */
if ( 0 == $this->Link_ID ) {
- $this->Link_ID=mysql_pconnect($Host, $User, $Password);
+ $this->Link_ID=mysql_connect($Host, $User, $Password);
if (!$this->Link_ID) {
- $this->halt("pconnect($Host, $User, \$Password) failed.");
+ $this->halt("connect($Host, $User, \$Password) failed.");
return 0;
}
diff --git a/bureau/class/m_bro.php b/bureau/class/m_bro.php
index a90e961b..81c71ffa 100644
--- a/bureau/class/m_bro.php
+++ b/bureau/class/m_bro.php
@@ -111,6 +111,11 @@ class m_bro {
$root_alternc=$root ;
// Passage du root en chemin rel (diffrent avec un lien)
$root=realpath($root) ;
+ if (! $root=realpath($root)) {
+ // Guillaume: it needed to work.. if file doesn't exist it need to crash
+ // gently
+ $root=$root_alternc;
+ }
// separer le chemin entre le repertoire et le fichier
$file=basename($dir);
$dir=dirname($dir);
@@ -556,7 +561,7 @@ class m_bro {
* @return boolean TRUE Si les fichiers ont t renomms, FALSE si une erreur s'est produite.
*/
function ChangePermissions($R,$d,$perm,$verbose=false) {
- global $err;
+ global $err, $action;
$absolute=$this->convertabsolute($R,false);
if (!$absolute) {
$err->raise("bro",_("File or folder name is incorrect"));
@@ -1025,6 +1030,9 @@ class m_bro {
header("Content-Transfer-Encoding: binary");
$d=escapeshellarg(".".$this->convertabsolute($dir,true));
set_time_limit(0);
+ // relacher le lock global sinon ce download va geler alternc pour
+ // tout le monde
+ alternc_shutdown();
passthru("/bin/tar -cZ -C ".getuserpath()."/".$mem->user["login"]."/ $d");
}
@@ -1043,6 +1051,9 @@ class m_bro {
header("Content-Transfer-Encoding: binary");
$d=escapeshellarg(".".$this->convertabsolute($dir,true));
set_time_limit(0);
+ // relacher le lock global sinon ce download va geler alternc pour
+ // tout le monde
+ alternc_shutdown();
passthru("/bin/tar -cz -C ".getuserpath()."/ $d");
}
@@ -1061,6 +1072,9 @@ class m_bro {
header("Content-Transfer-Encoding: binary");
$d=escapeshellarg(".".$this->convertabsolute($dir,true));
set_time_limit(0);
+ // relacher le lock global sinon ce download va geler alternc pour
+ // tout le monde
+ alternc_shutdown();
passthru("/bin/tar -cj -C ".getuserpath()."/ $d");
}
@@ -1172,6 +1186,9 @@ class m_bro {
}
$timestamp=date("H:i:s");
+ // relacher le lock global sinon ce download va geler alternc pour
+ // tout le monde
+ alternc_shutdown();
if(exec("/bin/tar cvf - ".getuserpath()."/ | gzip -9c > ".$dir."/".$mem->user['login']."_html_".$timestamp.".tar.gz")){
$err->log("bro","export_data_succes");
}else{
diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php
index 1c2e533d..3afe4e18 100644
--- a/bureau/class/m_dom.php
+++ b/bureau/class/m_dom.php
@@ -734,7 +734,7 @@ class m_dom {
return false;
}
if ($dns && $v == -3) {
- $err->raise("dom", _("The domain cannot be found in the whois database"));
+ $err->raise("dom", _("The name servers referenced by this domain do not match those referenced by this AlternC instance"));
return false;
}
@@ -996,7 +996,7 @@ class m_dom {
$ligne = preg_replace("/^ *([^ ]*) \(.*\)$/", "\\1", trim($ligne));
if ($found)
$tmp = trim($ligne);
- if ($tmp)
+ if (isset($tmp) && $tmp)
$serveurList[] = $tmp;
if ($ligne == "Nameservers:") {
$state = 1;
diff --git a/bureau/class/m_piwik.php b/bureau/class/m_piwik.php
index 47c996ca..0d3ec976 100644
--- a/bureau/class/m_piwik.php
+++ b/bureau/class/m_piwik.php
@@ -112,6 +112,10 @@ class m_piwik {
$user_creation_date = $user->date_registered;
return $db->query("INSERT INTO piwik_users (uid, login, created_date) VALUES ('$cuid', '$user_login', '$user_creation_date')");
}
+ else {
+ $err->raise('piwik', $api_data->message);
+ return FALSE;
+ }
} else { // api_data = false -> error is already filled
return FALSE;
}
diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php
index ac7ab96d..2b5f38f0 100644
--- a/bureau/class/m_quota.php
+++ b/bureau/class/m_quota.php
@@ -172,7 +172,7 @@ class m_quota {
}
reset($this->disk);
- if (!empty ($this->disk)) { // Check if there are some disk quota to check
+ if ($this->disk_quota_enable && !empty ($this->disk)) { // Check if there are some disk quota to check
// Look if there are some cached value
$disk_cached = $mem->session_tempo_params_get('quota_cache_disk');
diff --git a/debian/alternc-roundcube.postinst b/debian/alternc-roundcube.postinst
index 6dfe23c9..afe52a18 100644
--- a/debian/alternc-roundcube.postinst
+++ b/debian/alternc-roundcube.postinst
@@ -24,13 +24,13 @@ case "$1" in
dpkg-statoverride --list /etc/roundcube/debian-db.php >/dev/null &&
dpkg-statoverride --remove /etc/roundcube/debian-db.php
- chown -R www-data:root /etc/roundcube/debian-db.php
- chmod -R 460 /etc/roundcube/debian-db.php
+ chown root:www-data /etc/roundcube/debian-db.php
+ chmod 640 /etc/roundcube/debian-db.php
dpkg-statoverride --list /etc/roundcube/main.inc.php >/dev/null &&
dpkg-statoverride --remove /etc/roundcube/main.inc.php
- chown -R www-data:root /etc/roundcube/main.inc.php
- chmod -R 460 /etc/roundcube/main.inc.php
+ chown root:www-data /etc/roundcube/main.inc.php
+ chmod 640 /etc/roundcube/main.inc.php
dpkg-statoverride --list /var/log/roundcube >/dev/null &&
dpkg-statoverride --remove /var/log/roundcube
diff --git a/etc/alternc/templates/dovecot/conf.d/95_alternc.conf b/etc/alternc/templates/dovecot/conf.d/95_alternc.conf
index 5dcf7708..5c6839fc 100644
--- a/etc/alternc/templates/dovecot/conf.d/95_alternc.conf
+++ b/etc/alternc/templates/dovecot/conf.d/95_alternc.conf
@@ -192,7 +192,20 @@ protocol imap {
}
service imap {
- executable = /usr/lib/alternc/popimap-log-login.sh /usr/lib/dovecot/imap
+ # tell imap to do post-login lookup using a socket called "imap-postlogin"
+ executable = imap postlogin
+}
+
+# The service name below doesn't actually matter.
+service postlogin {
+ # all post-login scripts are executed via script-login binary
+ 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 postlogin {
+ }
}
@@ -247,7 +260,8 @@ protocol pop3 {
}
service pop3 {
- executable = /usr/lib/alternc/popimap-log-login.sh /usr/lib/dovecot/pop3
+ # tell imap to do post-login lookup using a socket called "imap-postlogin"
+ executable = pop3 postlogin
}
# ----------------------------------------------------------------------------
diff --git a/etc/alternc/templates/postfix/master.cf b/etc/alternc/templates/postfix/master.cf
index a7016407..2e974ba7 100644
--- a/etc/alternc/templates/postfix/master.cf
+++ b/etc/alternc/templates/postfix/master.cf
@@ -114,5 +114,7 @@ mailman unix - n n - - pipe
#dovecot LDA, as explained here: http://wiki.dovecot.org/LDA/Postfix
dovecot unix - n n - 0 pipe
flags=DRhu user=vmail:vmail argv=/usr/bin/sudo /usr/lib/dovecot/deliver -f ${sender} -a ${recipient} -d ${user}@${nexthop}
-
-
+#smtp inet n - n - 1 postscreen
+#smtpd pass - - n - - smtpd
+#dnsblog unix - - n - 0 dnsblog
+#tlsproxy unix - - n - 0 tlsproxy
diff --git a/install/alternc.install b/install/alternc.install
index 8f2d84ba..22f2715a 100644
--- a/install/alternc.install
+++ b/install/alternc.install
@@ -22,6 +22,8 @@
# Purpose of file: Main install script, launch it anytime ;)
# ----------------------------------------------------------------------
+set -e
+
# Somes check before start operations
if [ `id -u` -ne 0 ]; then
echo "must be launched as root"
@@ -528,7 +530,7 @@ tar -zcf "$INSTALLED_CONFIG_TAR" -C / $CONFIG_FILES
# Last touches
#
-find $ALTERNC_HTML -maxdepth 1 -type d -exec setfacl -b -k -m d:g:alterncpanel:rw- -m d:u:alterncpanel:rw- -m u:alterncpanel:rw- -m g:alterncpanel:rw- {} \;
+find $ALTERNC_HTML -maxdepth 1 -type d -exec setfacl -b -k -m d:g:alterncpanel:rwx -m d:u:alterncpanel:rwx -m u:alterncpanel:rwx -m g:alterncpanel:rwx {} \;
#creating log file
if [ ! -e "/var/log/alternc/bureau.log" ]; then
diff --git a/install/upgrades/3.3.1.sql b/install/upgrades/3.3.1.sql
new file mode 100644
index 00000000..f0a82698
--- /dev/null
+++ b/install/upgrades/3.3.1.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `actions` CHANGE `type` `type` ENUM('CREATE_FILE','FIX_USER','CREATE_DIR','DELETE','MOVE','FIX_DIR','FIX_FILE','CHMOD') DEFAULT NULL ;
+
diff --git a/lib/Alternc/Diagnostic/Data.php b/lib/Alternc/Diagnostic/Data.php
index 1ee1e819..1e9078d0 100644
--- a/lib/Alternc/Diagnostic/Data.php
+++ b/lib/Alternc/Diagnostic/Data.php
@@ -24,7 +24,46 @@ class Alternc_Diagnostic_Data {
}
}
-
+
+ // recursive rebuild
+ function buildFromArray( $content ){
+
+ if( ! $this->isValidArrayData( $content ) ) {
+ return $content;
+ }
+ $type = $content["type"];
+ $newInstance = new Alternc_Diagnostic_Data( $type );
+ $newInstance->index = $content["index"];
+ $newInstance->metadata = $content["metadata"];
+ $data = $content["data"];
+ // The content is raw
+ if( $type === self::TYPE_SECTION){
+ $newInstance->data = $data;
+ }
+ // The content is made of services or sections
+ else foreach( $content["data"] as $section_name => $sectionData ){
+ $sectionContent = $this->buildFromArray( $sectionData );
+ $newInstance->addData( $section_name, $sectionContent );
+ }
+ return $newInstance;
+
+ }
+
+ // Make sure we have a valid format result
+ function isValidArrayData( $content ){
+ if(
+ !is_array($content)
+ || !array_key_exists( "type", $content )
+ || !array_key_exists("metadata",$content)
+ || !array_key_exists("index",$content)
+ || !array_key_exists("data",$content)
+ || ! in_array( $content["type"], array(self::TYPE_ROOT,self::TYPE_DOMAIN,self::TYPE_SECTION) ) ){
+
+ return false;
+
+ }
+ return true;
+ }
/**
* Sets
@@ -115,4 +154,4 @@ class Alternc_Diagnostic_Data {
}
-}
\ No newline at end of file
+}
diff --git a/lib/Alternc/Diagnostic/Diff.php b/lib/Alternc/Diagnostic/Diff.php
index 788c2edd..f79b77ef 100644
--- a/lib/Alternc/Diagnostic/Diff.php
+++ b/lib/Alternc/Diagnostic/Diff.php
@@ -1,28 +1,83 @@
-getIndex();
+ $targetIndex = $target->getIndex();
+ // Check diagnostics are same level
+ $source_type = $source->getType();
+ $target_type = $target->getType();
+ if( $source_type != $target_type){
+ throw new \Exception("Invalid type comparison requested: $source_type vs $target_type");
+ }
+ $diffInstance = new Alternc_Diagnostic_Data( $source_type );
+
+#echo "type $source_type\n";
+ // Compare general data
+ if( $source->getMetadata() != $target->getMetadata() ){
+ $diffInstance->setMetadata( array_diff( $source->getMetadata(), $target->getMetadata() ) );
+ }
+
+ if( $source->getIndex() != $target->getIndex() ){
+ $diffInstance->setIndex( array_diff( $source->getIndex(), $target->getIndex() ) );
+ }
+
+ // If section content ie. no subsections
+ if( $source_type == Alternc_Diagnostic_Data::TYPE_SECTION ){
+#echo "Real section\n";
+ if( is_array( $source->getData() ) && is_array( $target->getData() ) ){
+
+ $diff = array_diff( $source->getData(), $target->getData() ) ;
+ if( $diff ){
+ $diffInstance->setData( array_diff( $source->getData(), $target->getData()) );
+ }
+ }else{
+ if( $source->getData() != $target->getData() ){
+ $diffInstance->setData( array("source" => $source->getData(),"target" => $target->getData() ) );
+ }
+ }
+ }else{
+
+ $sourceData = $source->getData();
+ $targetData = $target->getData();
+ $seenSections = array();
+ foreach( $sourceData as $section_name => $sectionData ){
+
+#echo "section_name $section_name\n";
+ $section_data_type = $sectionData->getType();
+ if( ! isset( $targetData[$section_name] ) ) {
+#echo "section_name not in target\n";
+ $tempDataInstance = new Alternc_Diagnostic_Data($section_data_type);
+ $tempDataInstance->setMetadata( array("Not in target") );
+ }else{
+#echo "section_name for diff\n";
+ $tempDataInstance = $this->compare($sectionData, $targetData[$section_name] );
+ }
+ if( ! is_null( $tempDataInstance ) ){
+ $diffInstance->addData( $section_name, $tempDataInstance);
+ }
+
+
+ }
+
+ }
+ if( count( $diffInstance->getData() )
+ || count( $diffInstance->getIndex() )
+ || count( $diffInstance->getMetadata() )
+ ){
+ return $diffInstance;
+ }
+
+ return null;
+
}
- /**
- * Finds a file by reference or name
- *
- * @param string $file_reference
- * @return Alternc_Diagnostic_Data Resulting data
- */
- function resolve( $file_reference){
-
- }
}
diff --git a/lib/Alternc/Diagnostic/Directory.php b/lib/Alternc/Diagnostic/Directory.php
index c89c7e84..7b6048a0 100644
--- a/lib/Alternc/Diagnostic/Directory.php
+++ b/lib/Alternc/Diagnostic/Directory.php
@@ -25,7 +25,17 @@ class Alternc_Diagnostic_Directory {
function getList( $max = null){
$dir = new DirectoryIterator($this->file_path);
-
+ $fileList = array();
+ while($dir->valid()) {
+ if( $dir->isDot() ){
+ $dir->next();
+ continue;
+ }
+ $file_name = $dir->getFilename();
+ $fileList[] = $file_name;
+ $dir->next();
+ }
+ return $fileList;
}
/**
@@ -36,6 +46,35 @@ class Alternc_Diagnostic_Directory {
return $this;
}
+
+ // @todo Confirm usefulness
+ public function getFileContent( $id ) {
+ $fileList = $this->getList();
+ if( array_key_exists( $id, $fileList ) ){
+ return file_get_contents( $this->file_path."/".$fileList[$id]);
+ }
+ if( in_array($id, $fileList)){
+ $key = array_search( $id, $fileList );
+ return file_get_contents( $this->file_path."/".$fileList[$key]);
+ }
+ throw new \Exception("Could not find diagnostic for id : $id");
+ }
+
+ function getFileInfo($id){
+
+ $fileList = $this->getList();
+
+ if( array_key_exists( $id, $fileList ) ){
+ $file_path = $this->file_path."/".$fileList[$id];
+ }
+ if( in_array($id, $fileList)){
+ $key = array_search( $id, $fileList );
+ $file_path = $this->file_path."/".$fileList[$key];
+ }
+ $fileInfos = pathinfo( $file_path );
+ return ($fileInfos);
+ }
+
/**
* @return string
*/
@@ -47,4 +86,4 @@ class Alternc_Diagnostic_Directory {
}
-}
\ No newline at end of file
+}
diff --git a/lib/Alternc/Diagnostic/Format/Abstract.php b/lib/Alternc/Diagnostic/Format/Abstract.php
index 58001499..2557409e 100644
--- a/lib/Alternc/Diagnostic/Format/Abstract.php
+++ b/lib/Alternc/Diagnostic/Format/Abstract.php
@@ -83,6 +83,40 @@ class Alternc_Diagnostic_Format_Abstract {
return $this->directory;
}
+
+ /**
+ * Writes a Data object to file
+ *
+ * @return boolean
+ */
+ public function write( Alternc_Diagnostic_Data $data = null ){
+ if( null == $data ){
+ if( ! $this->data ){
+ throw new \Exception( "A format cannot be written without a Data");
+ }
+ $data = $this->data;
+ }
+ $content = $this->dataToContent( $data );
+ $filename = $this->getFilename();
+ if( ! file_put_contents($filename, $content) ){
+ throw new \Exception("Failed to write in json format to file $filename" );
+ }
+ return true;
+
+ }
+
+ /**
+ *
+ * @param string file_name
+ * @return Alternc_Diagnostic_Data A diagnostic structure
+ */
+ function read( $file_name ){
+
+ $content = $this->directory->getFileContent( $file_name );
+ return $this->contentToData( $content );
+
+ }
+
}
diff --git a/lib/Alternc/Diagnostic/Format/Interface.php b/lib/Alternc/Diagnostic/Format/Interface.php
index 662bcb15..77231a46 100644
--- a/lib/Alternc/Diagnostic/Format/Interface.php
+++ b/lib/Alternc/Diagnostic/Format/Interface.php
@@ -2,20 +2,9 @@
interface Alternc_Diagnostic_Format_Interface{
- /**
- *
- * @param mixed $file_reference
- * Either a number or a string refering to the file
- * @return Alternc_Diagnostic_Data A diagnostic file
- */
- function read( $file_reference );
+ function contentToData( $content );
- /**
- * Writes a Data object to file
- *
- * @return boolean
- */
- function write();
+ function dataToContent();
-}
\ No newline at end of file
+}
diff --git a/lib/Alternc/Diagnostic/Format/Json.php b/lib/Alternc/Diagnostic/Format/Json.php
index ccd77039..cca03791 100644
--- a/lib/Alternc/Diagnostic/Format/Json.php
+++ b/lib/Alternc/Diagnostic/Format/Json.php
@@ -19,29 +19,31 @@ class Alternc_Diagnostic_Format_Json
/**
* @inherit
*/
- function read( $file_reference ){
-
+ function contentToData( $content ){
+
+ $arrayData = json_decode( $content , true);
+ $dataInstance = new Alternc_Diagnostic_Data(Alternc_Diagnostic_Data::TYPE_ROOT);
+ $this->data = $dataInstance->buildFromArray( $arrayData );
+ return $this->data;
+
}
/**
* @inherit
*/
- function write(Alternc_Diagnostic_Data $data = null ){
+ function dataToContent(Alternc_Diagnostic_Data $data = null ){
if( $data ){
$this->setData($data);
}
- $file_content = json_encode($this->getData());
+ $content = json_encode($this->getData());
$filename = $this->getFilename();
if(json_last_error()){
throw new \Exception("Json conversion failed with error #".json_last_error()."for data".serialize($this->getData()));
}
- if( ! file_put_contents($filename, $file_content) ){
- throw new \Exception("Failed to write in json format to file $filename for data".serialize($this->getData()));
- }
- return true;
+ return $content;
}
-}
\ No newline at end of file
+}
diff --git a/lib/Alternc/Diagnostic/Format/Txt.php b/lib/Alternc/Diagnostic/Format/Txt.php
new file mode 100644
index 00000000..407f633b
--- /dev/null
+++ b/lib/Alternc/Diagnostic/Format/Txt.php
@@ -0,0 +1,61 @@
+setExtension("txt");
+ }
+
+ /**
+ * @inherit
+ */
+ function contentToData( $content ){
+
+ // @todo or skip ? Quite a fragile storage
+
+ }
+
+
+ /**
+ * @inherit
+ */
+ function dataToContent(Alternc_Diagnostic_Data $data = null, $depth = 0 ){
+ $d = $this->space_depth($depth);
+ echo $d."Type: ".$data->type."\n";
+ $d .= " ";
+ if( $data->type == Alternc_Diagnostic_Data::TYPE_SECTION ){
+ foreach( $data->data as $key => $value ){
+ if( is_int( $key) ){
+ echo $d.json_encode( $value, true )."\n";
+ }else{
+ echo $d.$key." => ".json_encode( $value, true )."\n";
+ }
+ }
+ return;
+ }
+ foreach( $data->data as $section_name => $sectionData ){
+ echo $d."Section: $section_name\n";
+ $this->dataToContent( $sectionData, $depth+1);
+ }
+ }
+
+ function space_depth( $depth){
+ $buf = "";
+ for( $i=0; $i < $depth; $i++){
+ $buf .= " ";
+ }
+ return $buf;
+ }
+
+
+}
diff --git a/lib/Alternc/Diagnostic/Manager.php b/lib/Alternc/Diagnostic/Manager.php
index e75c03d8..4a41c94d 100644
--- a/lib/Alternc/Diagnostic/Manager.php
+++ b/lib/Alternc/Diagnostic/Manager.php
@@ -55,32 +55,101 @@ class Alternc_Diagnostic_Manager{
* @param Console_CommandLine_Result $options
* @throws \Exception
*/
- function create(Console_CommandLine_Result $options){
+ function c_create(Console_CommandLine_Result $options){
$args = $options->args;
$options = $options->options;
- $diagnosticData = new Alternc_Diagnostic_Data(Alternc_Diagnostic_Data::TYPE_ROOT);
+ $diagnosticdata = new Alternc_Diagnostic_Data(Alternc_Diagnostic_Data::TYPE_ROOT);
- $serviceList = explode(',',$options["services"]);
- foreach ($serviceList as $service) {
+ $servicelist = explode(',',$options["services"]);
+ foreach ($servicelist as $service) {
$class_name = "Alternc_Diagnostic_Service_".trim(ucfirst($service));
if(!class_exists($class_name)){
- throw new \Exception("Invalid service $service");
+ throw new \exception("invalid service $service");
}
- /** @var Alternc_Diagnostic_Service_Interface */
- $serviceAgent = new $class_name( array("service" => $this) );
+ /** @var alternc_diagnostic_service_interface */
+ $serviceagent = new $class_name( array("service" => $this) );
- // Runs the service agent and store the results
- $diagnosticData->addData($serviceAgent->name, $serviceAgent->run());
+ // runs the service agent and store the results
+ $diagnosticdata->addData($serviceagent->name, $serviceagent->run());
}
- $this->formatInstance->setData($diagnosticData)->write();
+ $this->formatInstance->setData($diagnosticdata)->write();
}
- function compare( $options ){}
- function index( $options ){}
- function show( $options ){}
- function delete( $options ){}
+ function c_diff( $options ){
+ $args = $options->args;
+ $options = $options->options;
+ $source = $options["source"];
+ $target = $options["target"];
+ $format = $options['format'];
+ $sourceDiagnostic = $this->getDiagnosticFromId($source);
+ $targetDiagnostic = $this->getDiagnosticFromId($target);
+ $diff = new Alternc_Diagnostic_Diff();
+ $diffData = $diff->compare($sourceDiagnostic,$targetDiagnostic);
+ $formatInstance = $this->getFormatInstance( $format );
+ echo $formatInstance->dataToContent( $diffData);
+ }
+
+ function c_list( $options ){
+
+ $args = $options->args;
+ $options = $options->options;
+ $fileList = $this->directoryInstance->getList();
+ foreach( $fileList as $number => $file ){
+ echo "$number\t$file\n";
+ }
+
+
+
+ }
+ function c_show( $options ){
+
+
+ $args = $options->args;
+ $options = $options->options;
+ $id = $options['id'];
+ $format = $options['format'];
+ $data = $this->getDiagnosticFromId( $id);
+ $formatInstance = $this->getFormatInstance( $format );
+ echo $formatInstance->dataToContent( $data );
+
+
+ }
+ function c_delete( $options ){}
+
+ /**
+ * Finds a file by reference or name
+ *
+ * @param string $file_reference
+ * @return Alternc_Diagnostic_Data Resulting data
+ * @todo add the ability to resolve by filename
+ */
+ protected function getDiagnosticFromId ( $id ) {
+
+ $fileInfo = $this->directoryInstance->getFileInfo( $id ) ;
+ $extension = $fileInfo["extension"];
+ $formatInstance = $this->getFormatInstance( $extension);
+ $formatInstance->read( $fileInfo["basename"] );
+ $data = $formatInstance->getData();
+ return $data;
+
+ }
+
+ protected function getFormatInstance ( $format ){
+ switch( $format ){
+ case "json":
+ $instance = new Alternc_Diagnostic_Format_Json( $this->directoryInstance );
+ break;
+ case "txt":
+ $instance = new Alternc_Diagnostic_Format_Txt( $this->directoryInstance );
+ break;
+ default:
+ throw new \Exception("Invalid format : $format");
+ break;
+ }
+ return $instance;
+ }
}
diff --git a/src/cron_users_doit.sh b/src/cron_users_doit.sh
index 2998a136..005be7c8 100755
--- a/src/cron_users_doit.sh
+++ b/src/cron_users_doit.sh
@@ -23,8 +23,6 @@ for CONFIG_FILE in \
. "$CONFIG_FILE"
done
-from="noreply@$FQDN"
-
if [ "x$url" == "x" ] ; then
echo Missing arguments
exit 0
@@ -62,7 +60,7 @@ echo -e "\n---------- END ----------"
# If there is an email specified, mail it
if [ ! "x$email" == "x" -a ! "$email" == "null" ] ; then
date=$(date +%x\ %X)
- cat "$tmpfile" | mailx -s "AlternC Cron #$id - Report $date" -r "$from" "$(urldecode $email)"
+ mailx -s "AlternC Cron #$id - Report $date" -a "From: noreply@$FQDN" "$(urldecode $email)" < "$tmpfile"
fi
rm -f "$tmpfile"
diff --git a/src/diagnostic.php b/src/diagnostic.php
index 2f05133b..00936055 100644
--- a/src/diagnostic.php
+++ b/src/diagnostic.php
@@ -126,7 +126,7 @@ if(is_file("/usr/share/alternc/panel/class/config_nochk.php")){
-$directoryInstance = new Alternc_Diagnostic_Directory("/tmp/diagnostic");
+$directoryInstance = new Alternc_Diagnostic_Directory("/var/log/alternc/diagnostic");
// instanciation of the diagnosticManager service
@@ -168,9 +168,49 @@ $createCommmand->addOption('format', array(
'help_name' => 'format'
));
-$indexCommmand = $consoleParser->addCommand('index', array('multiple'=>false,"alias"=>"i","description" => "Shows all available diagnostics"));
-$compareCommmand = $consoleParser->addCommand('compare', array('multiple'=>false,"alias"=>"x","description" => "Removes one or more diagnotics"));
-$compareCommmand = $consoleParser->addCommand('show', array('multiple'=>false,"alias"=>"s","description" => "Prints a diagnotic content"));
+$listCommmand = $consoleParser->addCommand('list', array('multiple'=>false,"alias"=>"i","description" => "Shows all available diagnostics"));
+$diffCommmand = $consoleParser->addCommand('diff', array('multiple'=>false,"alias"=>"x","description" => "Removes one or more diagnotics"));
+$diffCommmand->addOption('source', array(
+ 'short_name' => '-s',
+ 'long_name' => '--source',
+ 'action' => 'StoreString',
+ 'default' => '0',
+ 'description' => 'First file to diff, id or basename. Default: 0',
+ 'help_name' => 'source'
+ ));
+$diffCommmand->addOption('target', array(
+ 'short_name' => '-t',
+ 'long_name' => '--target',
+ 'action' => 'StoreString',
+ 'default' => '1',
+ 'description' => 'First file to diff, id or basename. Default: 1',
+ 'help_name' => 'target'
+ ));
+$diffCommmand->addOption('format', array(
+ 'short_name' => '-f',
+ 'long_name' => '--format',
+ 'action' => 'StoreString',
+ 'default' => 'txt',
+ 'description' => 'Sets the format of the diagnostic diff. default: txt',
+ 'help_name' => 'format'
+ ));
+$showCommand = $consoleParser->addCommand('show', array('multiple'=>false,"alias"=>"s","description" => "Prints a diagnotic content"));
+$showCommand->addOption('id', array(
+ 'short_name' => '-i',
+ 'long_name' => '--id',
+ 'action' => 'StoreString',
+ 'default' => '0',
+ 'description' => 'Provides the id or name of a diagnostic to show. Default: 0',
+ 'help_name' => 'id'
+ ));
+$showCommand->addOption('format', array(
+ 'short_name' => '-f',
+ 'long_name' => '--format',
+ 'action' => 'StoreString',
+ 'default' => 'txt',
+ 'description' => 'Sets the format of the output. Default: txt. Other choices : array',
+ 'help_name' => 'format'
+ ));
$deleteCommmand = $consoleParser->addCommand('delete', array('multiple'=>false,"alias"=>"d","description" => "Deletes diagnostic files"));
@@ -179,15 +219,15 @@ $deleteCommmand = $consoleParser->addCommand('delete', a
try {
$result = $consoleParser->parse();
if ($result->command_name){
- $command_name = $result->command_name;
+ $command_name = "c_".$result->command_name;
$command = $result->command;
}else{
- throw new \Exception("Command missing, use -h to learn about available commands.");
+ throw new \Exception("Welcome to AlternC Diagnostics! Use -h to learn about available commands.");
}
if( !method_exists($diagnosticManager, $command_name)){
throw new \Exception("Invalid command : $command");
}
- $diagnosticManager->$command_name($command);
+ $result = $diagnosticManager->$command_name($command);
} catch (\Exception $exc) {
$consoleParser->displayError($exc->getMessage());
}
diff --git a/src/do_actions.php b/src/do_actions.php
index dc01d302..c574a869 100644
--- a/src/do_actions.php
+++ b/src/do_actions.php
@@ -85,12 +85,8 @@ function d($mess){
*/
function mail_it(){
global $errorsList,$L_FQDN;
- // Forces array
- if( !is_array($errorsList)){
- $errorsList = array($errorsList);
- }
// Builds message from array
- $msg = implode("\n", $errorsList);
+ $msg = var_export($errorsList, TRUE);
// Attempts to send email
// @todo log if fails
mail("alterncpanel@$L_FQDN",'Script do_actions.php issues',"\n Errors reporting mail:\n\n$msg");
@@ -264,14 +260,9 @@ while ($rr=$action->get_action()){
}
break;
default :
- $output=array("Fail: Sorry dude, i do not know this type of action");
+ $errorsList[]=array("Fail: Sorry, i do not know this type of action: ". $r['type']);
break;
}
- // Get the error (if exists).
- if(isset($output[0])){
- $return=$output[0];
- $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.
d("Finishing... return value is : $return\n");
if(!$action->finish($r["id"],addslashes($return))){
@@ -290,4 +281,4 @@ if(count($errorsList)) {
unlink(ALTERNC_DO_ACTION_LOCK);
// Exit this script
-exit(0);
\ No newline at end of file
+exit(0);
diff --git a/src/fixperms.sh b/src/fixperms.sh
index 6ae6e505..91912bbe 100755
--- a/src/fixperms.sh
+++ b/src/fixperms.sh
@@ -126,15 +126,15 @@ doone() {
# Set the file readable only for the AlternC User
mkdir -p "$REP"
chown -R $GID:$GID "$REP"
- chmod 2770 -R "$REP"
+ chmod 2750 -R "$REP"
# # Delete existings ACL
# # Set the defaults acl on all the files
# setfacl -b -k -n -R -m d:g:alterncpanel:rwx -m d:u::rwx -m d:g::rwx -m d:u:$GID:rwx -m d:g:$GID:rwx -m d:o::--- -m d:mask:rwx\
# -Rm g:alterncpanel:rwx -m u:$GID:rwx -m g:$GID:rwx -m mask:rwx\
# "$REP"
- setfacl -bknR -m d:u:alterncpanel:rwx -m d:g:alterncpanel:rwx -m u:alterncpanel:rwx -m g:alterncpanel:rwx -m d:o::--- -m o::---\
- -m d:u:$GID:rwx -m d:g:$GID:rwx -m u:$GID:rwx -m g:$GID:rwx -m d:mask:rwx -m mask:rwx "$REP"
+ setfacl -bknR -m d:u:alterncpanel:rwx -m d:g:alterncpanel:r-x -m u:alterncpanel:rwx -m g:alterncpanel:r-x -m d:o::--- -m o::---\
+ -m d:u:$GID:rwx -m d:g:$GID:r-x -m u:$GID:rwx -m g:$GID:r-x -m d:mask:rwx -m mask:rwx "$REP"
fixtmp $GID
read GID LOGIN || true
diff --git a/src/functions_hosting.sh b/src/functions_hosting.sh
index 7c163fb5..409de6e1 100644
--- a/src/functions_hosting.sh
+++ b/src/functions_hosting.sh
@@ -6,7 +6,7 @@ TEMPLATE_DIR="/etc/alternc/templates/apache2"
HOSTING_DIR="/etc/alternc/functions_hosting"
HTML_HOME="$ALTERNC_HTML"
-VHOST_DIR="/var/lib/alternc/apache-vhost"
+VHOST_DIR="/var/lib/alternc/apache-vhost/"
launch_hooks() {
local ACTION=$1
diff --git a/src/mail_add.php b/src/mail_add.php
index 47ff2b9f..e33b59b0 100644
--- a/src/mail_add.php
+++ b/src/mail_add.php
@@ -19,7 +19,7 @@ global $cuid;
// those will be tried in order, the first one to return more than 7
// chars will win
$generators = array('pwqgen', 'pwgen');
-$dryrun = false;
+$dryrun = true;
// 1GB default quota
$default_quotas = 1024; // in MB because using bytes would be too
// precise (try to guess AlternC, just you try)
diff --git a/src/popimap-log-login.sh b/src/popimap-log-login.sh
index 62d0e998..f1679254 100755
--- a/src/popimap-log-login.sh
+++ b/src/popimap-log-login.sh
@@ -15,7 +15,10 @@ if [ ! -r "$ALTERNC_CONFIG_FILE" ]; then
fi
. "$ALTERNC_CONFIG_FILE"
-mysql_query "update address a, domaines d, mailbox m set m.lastlogin=now() where a.domain_id=d.id and m.address_id=a.id and concat_ws('@',a.address,d.domaine) = '$USER';"
+addr=$(echo $USER | sed 's/@.*//')
+dom=$(echo $USER | sed 's/^.*@//')
+
+mysql_query "update address a, domaines d, mailbox m set m.lastlogin=now() where a.domain_id=d.id and m.address_id=a.id and a.address='$addr' and d.domaine='$dom';"
# Now launch the expected binary server
exec "$@"
diff --git a/src/update_domains.sh b/src/update_domains.sh
index 89df3bc6..7961bc56 100755
--- a/src/update_domains.sh
+++ b/src/update_domains.sh
@@ -114,7 +114,7 @@ do
mysql_query "delete from sub_domaines where domaine='$dom'; delete from domaines where domaine='$dom';"
done
-if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then
+if [ ! -z "$(cat "$RELOAD_WEB")" ] || [ "$1" = "force" ]; then
# Just to encourage user to use THIS directory and not another one
test -d "$VHOST_MANUALCONF" || mkdir -p "$VHOST_MANUALCONF"
@@ -132,7 +132,7 @@ if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then
else
echo "Include \"$LOGFORMAT_FILE\""
fi
- find "$VHOST_DIR" -mindepth 2 -type f -iname "*.conf" -print0 | xargs -0 cat
+ 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"
diff --git a/wheezy/95_alternc.conf b/wheezy/95_alternc.conf
index c4d66687..e14ae4f6 100644
--- a/wheezy/95_alternc.conf
+++ b/wheezy/95_alternc.conf
@@ -195,18 +195,22 @@ protocol imap {
}
service imap {
- executable = imap imap-postlogin
+ # tell imap to do post-login lookup using a socket called "postlogin"
+ executable = imap postlogin
vsz_limit = 512M
}
-service imap-postlogin {
- executable = script-login /usr/lib/alternc/popimap-log-login.sh
+# The service name below doesn't actually matter.
+service postlogin {
+ # all post-login scripts are executed via script-login binary
+ 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
+ #user = $default_internal_user
# this UNIX socket listener must use the same name as given to imap executable
- unix_listener imap-postlogin {
+ unix_listener postlogin {
}
-}
+ }
# ----------------------------------------------------------------------------
# 20-managesieve.conf
@@ -259,7 +263,8 @@ protocol pop3 {
}
service pop3 {
- executable = /usr/lib/alternc/popimap-log-login.sh /usr/lib/dovecot/pop3
+ # tell imap to do post-login lookup using a socket called "postlogin"
+ executable = pop3 postlogin
}
# ----------------------------------------------------------------------------