From ec8d8b1344c16db9d3bea95b261f247b1cfac96d Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Thu, 27 Mar 2014 15:04:30 +0000 Subject: [PATCH 1/4] Premier jet pour ROundcube avec l'utilisateur apache normal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Résoud les pb d'upgrade et de cron --- .gitattributes | 1 - roundcube/roundcube-install | 18 +---- roundcube/templates/apache2/roundcube.conf | 70 +++++++++---------- .../templates/logrotate.d/roundcube-core | 15 ---- 4 files changed, 36 insertions(+), 68 deletions(-) delete mode 100644 roundcube/templates/logrotate.d/roundcube-core diff --git a/.gitattributes b/.gitattributes index a57a8bcb..5cdc900d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -615,7 +615,6 @@ roundcube/class/m_roundcube.php -text roundcube/roundcube-install -text roundcube/roundcube_alternc_logo.png -text roundcube/templates/apache2/roundcube.conf -text -roundcube/templates/logrotate.d/roundcube-core -text roundcube/templates/roundcube/main.inc.php -text roundcube/templates/roundcube/plugins/managesieve/config.inc.php -text roundcube/templates/roundcube/plugins/password/config.inc.php -text diff --git a/roundcube/roundcube-install b/roundcube/roundcube-install index f2613a8c..de12c6c9 100644 --- a/roundcube/roundcube-install +++ b/roundcube/roundcube-install @@ -28,7 +28,7 @@ then # cp -f /etc/alternc/templates/roundcube/avelsieve-config.php /etc/alternc/templates/roundcube/apache.conf /etc/roundcube/ # cp -f /etc/alternc/templates/javascript-common/javascript-common.conf /etc/javascript-common/ - LOGIN="2000_roundcube" + LOGIN="0000_roundcube" PASSWORD="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)'`" DESKEY="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..24)'`" @@ -40,7 +40,6 @@ then # Configuration template location TEMPLATE_DIR="/etc/alternc/templates" CONFIG_FILES="etc/roundcube/main.inc.php etc/roundcube/plugins/password/config.inc.php etc/roundcube/plugins/managesieve/config.inc.php" - LOGROTATE_FILES="etc/logrotate.d/roundcube-core" cat > $SED_SCRIPT < /$file - fi - done - echo " Done" . /usr/lib/alternc/functions.sh @@ -99,10 +90,3 @@ EOF fi -#This is necessary because upgrading roundcube from 7.1 to 7.2 changes this setting -if [ "$1" = "end" ]; then - chown alternc-roundcube:root /etc/roundcube/main.inc.php -fi - - - diff --git a/roundcube/templates/apache2/roundcube.conf b/roundcube/templates/apache2/roundcube.conf index 1f6b46a5..cf762418 100644 --- a/roundcube/templates/apache2/roundcube.conf +++ b/roundcube/templates/apache2/roundcube.conf @@ -1,46 +1,46 @@ ServerName %%fqdn%% - AssignUserId alternc-roundcube nogroup - SetEnv LOGIN "%%UID%%-%%LOGIN%%" + AssignUserId www-data www-data + SetEnv LOGIN "0000-roundcube" DocumentRoot /var/lib/roundcube -# Access to tinymce files - - Options Indexes MultiViews FollowSymLinks - AllowOverride None - Order allow,deny - allow from all - - - - Options +FollowSymLinks - # This is needed to parse /var/lib/roundcube/.htaccess. See its - # content before setting AllowOverride to None. - AllowOverride All - order allow,deny - allow from all - - -# Protecting basic directories: - - Options -FollowSymLinks + # Access to tinymce files + + Options Indexes MultiViews FollowSymLinks AllowOverride None - + Order allow,deny + allow from all + - - Options -FollowSymLinks - AllowOverride None - Order allow,deny - Deny from all - + + Options +FollowSymLinks + # This is needed to parse /var/lib/roundcube/.htaccess. See its + # content before setting AllowOverride to None. + AllowOverride All + order allow,deny + allow from all + - - Options -FollowSymLinks - AllowOverride None - Order allow,deny - Deny from all - + # Protecting basic directories: + + Options -FollowSymLinks + AllowOverride None + + + + Options -FollowSymLinks + AllowOverride None + Order allow,deny + Deny from all + + + + Options -FollowSymLinks + AllowOverride None + Order allow,deny + Deny from all + Alias /javascript /usr/share/javascript/ diff --git a/roundcube/templates/logrotate.d/roundcube-core b/roundcube/templates/logrotate.d/roundcube-core deleted file mode 100644 index c5a9e8f6..00000000 --- a/roundcube/templates/logrotate.d/roundcube-core +++ /dev/null @@ -1,15 +0,0 @@ -###### -# Configuration file of Roundcube's logrotate for AlternC -# -# /!\ WARNING /!\ Do not edit this file, edit the one in -# /etc/alternc/templates/logrotate.d/ and launch alternc.install again. -###### - -/var/log/roundcube/password /var/log/roundcube/errors /var/log/roundcube/sendmail /var/log/roundcube/userlogins { - create 0640 alternc-roundcube root - compress - missingok - notifempty - rotate 52 - weekly -} From b2eb4e3016e8caae3024dd63b43380931ccf5907 Mon Sep 17 00:00:00 2001 From: alban Date: Thu, 27 Mar 2014 16:02:52 +0100 Subject: [PATCH 2/4] [fix] adds missing global --- phpunit/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php index df86f135..f9d459c9 100644 --- a/phpunit/bootstrap.php +++ b/phpunit/bootstrap.php @@ -156,4 +156,4 @@ $mem = new \m_mem(); $err = new \m_err(); $authip = new \m_authip(); $hooks = new \m_hooks(); - +$bro = new \m_bro(); From 590223878ebf4a81583428ac61fb6fc9fe3d54b3 Mon Sep 17 00:00:00 2001 From: alban Date: Thu, 27 Mar 2014 16:03:34 +0100 Subject: [PATCH 3/4] [fix] #1545 htaccess files --- bureau/admin/hta_del.php | 9 +++--- phpunit/tests/bureau/class/m_htaTest.php | 35 ++++++++++++++++++++---- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/bureau/admin/hta_del.php b/bureau/admin/hta_del.php index 52ffe975..48a7e9ea 100644 --- a/bureau/admin/hta_del.php +++ b/bureau/admin/hta_del.php @@ -35,11 +35,12 @@ reset($_POST); while (list($key,$val)=each($_POST)) { if (substr($key,0,4)=="del_") { // Effacement du dossier $val - $r=$hta->DelDir($val); - if (!$r) { - $error.=$err->errstr()."
"; +// $r=$hta->DelDir($val); + $return = $hta->DelDir($val); + if (!$return) { + $error.= $err->errstr()."
"; } else { - $error.=sprintf(_("The protected folder %s has been successfully unprotected"),$val)."
"; + $error.= sprintf(_("The protected folder %s has been successfully unprotected"),$val)."
"; } } } diff --git a/phpunit/tests/bureau/class/m_htaTest.php b/phpunit/tests/bureau/class/m_htaTest.php index fe2a6a68..25ecbda6 100644 --- a/phpunit/tests/bureau/class/m_htaTest.php +++ b/phpunit/tests/bureau/class/m_htaTest.php @@ -9,6 +9,9 @@ class m_htaTest extends PHPUnit_Framework_TestCase */ protected $object; + const PATH_HTACCESS = "/tmp/.htaccess"; + const PATH_HTPASSWD = "/tmp/.htpasswd"; + /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -16,6 +19,10 @@ class m_htaTest extends PHPUnit_Framework_TestCase protected function setUp() { parent::setUp(); + touch(self::PATH_HTACCESS); + touch(self::PATH_HTPASSWD); + $file_content = "AuthUserFile \"/tmp/.htpasswd\"\nAuthName \"Restricted area\"\nAuthType Basic\nrequire valid-user\n"; + file_put_contents(self::PATH_HTACCESS,$file_content); $this->object = new m_hta; } @@ -26,6 +33,12 @@ class m_htaTest extends PHPUnit_Framework_TestCase protected function tearDown() { parent::tearDown(); + if(file_exists(self::PATH_HTACCESS)){ + unlink (self::PATH_HTACCESS); + } + if(file_exists(self::PATH_HTPASSWD)){ + unlink (self::PATH_HTPASSWD); + } } /** @@ -114,14 +127,26 @@ class m_htaTest extends PHPUnit_Framework_TestCase /** * @covers m_hta::DelDir - * @todo Implement testDelDir(). */ public function testDelDir() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $result = $this->object->DelDir("/tmp",TRUE); + $this->assertTrue($result); + $this->assertFileNotExists(self::PATH_HTACCESS); + $this->assertFileNotExists(self::PATH_HTPASSWD); + } + + /** + * @covers m_hta::DelDir + */ + public function testDelDirNotEmpty() + { + file_put_contents(self::PATH_HTACCESS, "\nphpunit", FILE_APPEND); + $result = $this->object->DelDir("/tmp",TRUE); + $this->assertTrue($result); + $this->assertFileExists(self::PATH_HTACCESS); + $this->assertFileNotExists(self::PATH_HTPASSWD); + $this->assertTrue("phpunit" == trim(file_get_contents(self::PATH_HTACCESS))); } /** From 0f48d94c04e7e7909ca1c047c573ff0b35bb9443 Mon Sep 17 00:00:00 2001 From: alban Date: Thu, 27 Mar 2014 16:04:21 +0100 Subject: [PATCH 4/4] =?UTF-8?q?[fix]=C2=A0cosmetic=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bureau/class/functions.php | 191 +++++++++----------- bureau/class/m_bro.php | 348 +++++++++++++++++++------------------ bureau/class/m_hta.php | 247 ++++++++++++++++---------- 3 files changed, 421 insertions(+), 365 deletions(-) diff --git a/bureau/class/functions.php b/bureau/class/functions.php index c099c315..892061b2 100644 --- a/bureau/class/functions.php +++ b/bureau/class/functions.php @@ -44,7 +44,7 @@ function fl($str) { return str_replace("<","<",str_replace("\"",""",$str * @param struing $type * @return mixed */ -function variable_get($name, $default = null, $createit_comment = null, $type=null) { +function variable_get($name, $default = null, $createit_comment = null, $type = null) { global $variables; return $variables->variable_get($name, $default, $createit_comment, $type); } @@ -66,16 +66,16 @@ function variable_get($name, $default = null, $createit_comment = null, $type=nu */ function checkhostallow($domain,$dns) { global $L_NS1,$L_NS2,$db,$dom; - $sizefound=0; - $found=""; + $sizefound = 0; + $found = ""; $db->query("SELECT tld,mode FROM tld;"); while ($db->next_record()) { - list($key,$val)=$db->Record; + list($key,$val) = $db->Record; if (substr($domain,-1-strlen($key))==".".$key) { if ($sizefound2) // OK, in the case 3 4 5 return $found; - $n1=false; $n2=false; - for ($i=0;$iquery("SELECT tld,mode FROM tld;"); while ($db->next_record()) { - list($key,$val)=$db->Record; + list($key,$val) = $db->Record; if (substr($domain,-1-strlen($key))==".".$key) { if ($sizefound255) return 1; - $members=explode(".", $fqdn); - if (count($members)>1) $ret=0; else $ret=4; + $members = explode(".", $fqdn); + if (count($members)>1) $ret = 0; else $ret = 4; reset($members); while (list ($key, $val) = each ($members)) { if (strlen($val)>63) @@ -262,10 +262,10 @@ function checkfqdn($fqdn) { */ function checkuserpath($path) { global $mem; - $user=$mem->user["login"]; - $usar=substr($user,0,1); + $user = $mem->user["login"]; + $usar = substr($user,0,1); if (substr($path,0,1)!="/") - $path="/".$path; + $path = "/".$path; $rpath = realpath(ALTERNC_HTML."/$usar/$user$path"); if (!$rpath) { // if file or directory does not exist @@ -310,7 +310,7 @@ function cbox($test, $echo = TRUE) { if ($test) { $return = " checked=\"checked\""; } else { - $return=''; + $return = ''; } if( $echo ){ echo $return; @@ -331,7 +331,7 @@ function selected($bool, $echo = TRUE) { if ($bool) { $return = " selected=\"selected\""; } else { - $return=''; + $return = ''; } if( $echo ){ echo $return; @@ -347,7 +347,7 @@ function selected($bool, $echo = TRUE) { * @param integer $affiche * @return string */ -function ecif($test,$tr,$fa="",$affiche=1) { +function ecif($test,$tr,$fa = "",$affiche = 1) { if ($test){ $retour = $tr; } @@ -375,7 +375,7 @@ function __($str) { * @param string $fa * @return string */ -function ife($test,$tr,$fa="") { +function ife($test,$tr,$fa = "") { if ($test){ return $tr; } @@ -388,33 +388,33 @@ function ife($test,$tr,$fa="") { * @param integer $html * @return string */ -function format_size($size,$html=0) { +function format_size($size,$html = 0) { // Retourne une taille formatt�e en Octets, Kilo-octets, M�ga-octets ou Giga-Octets, avec 2 d�cimales. if ("-" == $size) { return $size; } - $size=(float)$size; + $size = (float)$size; if ($size<1024) { - $r=$size; + $r = $size; if ($size!=1) { $r.=" "._("Bytes"); } else { $r.=" "._("Byte"); } } else { - $size=$size/1024; + $size = $size/1024; if ($size<1024) { - $r=round($size,2)." "._("Kb"); + $r = round($size,2)." "._("Kb"); } else { - $size=$size/1024; + $size = $size/1024; if ($size<1024) { - $r=round($size,2)." "._("Mb"); + $r = round($size,2)." "._("Mb"); } else { - $size=$size/1024; + $size = $size/1024; if ($size<1024) { - $r=round($size,2)." "._("Gb"); + $r = round($size,2)." "._("Gb"); } else { - $r=round($size/1024,2)." "._("Tb"); + $r = round($size/1024,2)." "._("Tb"); } } } @@ -448,17 +448,17 @@ function linkhelp($hid) { * @return string */ function format_date($format,$date) { - $d=substr($date,8,2); - $m=substr($date,5,2); - $y=substr($date,0,4); - $h=substr($date,11,2); - $i=substr($date,14,2); + $d = substr($date,8,2); + $m = substr($date,5,2); + $y = substr($date,0,4); + $h = substr($date,11,2); + $i = substr($date,14,2); if ($h>12) { - $hh=$h-12; - $am="pm"; + $hh = $h-12; + $am = "pm"; } else { - $hh=$h; - $am="am"; + $hh = $h; + $am = "am"; } return sprintf($format,$d,$m,$y,$h,$i,$hh,$am); } @@ -482,13 +482,13 @@ function ssla($str) { * @return string Retourne le mot de passe crypt� * @access private */ - function _md5cr($pass,$salt="") { + function _md5cr($pass,$salt = "") { if (!$salt) { - $chars="./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - for ($i=0;$i<12;$i++) { + $chars = "./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + for ($i = 0;$i<12;$i++) { $salt.=substr($chars,(mt_rand(0,strlen($chars))),1); } - $salt="$1$".$salt; + $salt = "$1$".$salt; } return crypt($pass,$salt); } @@ -536,7 +536,7 @@ function pretty_months($months) { * @return string Code html pour le drop-down * @access private */ -function duration_list($name, $selected=0) { +function duration_list($name, $selected = 0) { $res = "