This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, 6.0 has been updated
       via  3a56a5ef092bfd1cbe6e9f6aa88540b8d7ed4f96 (commit)
      from  e3a61c1aac79fe0ba9f812e740e2fbb77964a26a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=3a56a5ef092bfd1cbe6e9f6aa88540b8d7ed4f96

commit 3a56a5ef092bfd1cbe6e9f6aa88540b8d7ed4f96
Author: Franck Villaume <[email protected]>
Date:   Sun Nov 22 13:27:29 2015 +0100

    FRS zip latest migration script: better error handling when database is 
inconsistent

diff --git a/src/CHANGES b/src/CHANGES
index 7550d74..104c716 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -5,6 +5,7 @@ FusionForge 6.0.4:
 * Accounts: passwords hashes: increase md5crypt salt length to 8; fix invalid 
Blowfish salt (Inria)
 * Accounts: passwords hashes: add support for SHA256/SHA512 (Inria)
 * FRS: fix shownotes.php link. Use new url form. view=shownotes (TrivialDev)
+* FRS: frs latest zip migration script hardening (TrivialDev)
 * MTA-Exim4: restart exim4 on install
 * Plugin SCM: fix another race condition when creating project with SCM 
selected (Inria)
 * Plugin SCM Git: improve user matching when computing stats, support git 
.mailmap (Inria)
diff --git a/src/db/20141105-frs-ziplatest.php 
b/src/db/20141105-frs-ziplatest.php
index 778aed5..e845e87 100644
--- a/src/db/20141105-frs-ziplatest.php
+++ b/src/db/20141105-frs-ziplatest.php
@@ -1,7 +1,7 @@
 <?php
 /**
  *
- * Copyright 2014, Franck Villaume - TrivialDev
+ * Copyright 2014,2015, Franck Villaume - TrivialDev
  * http://fusionforge.org/
  *
  * This file is part of FusionForge.
@@ -46,42 +46,52 @@ if (class_exists('ZipArchive')) {
                if (db_numrows($filesRes)) {
                        $zip = new ZipArchive();
                        $zipPath = 
forge_get_config('upload_dir').'/'.$packageArr['guxname'].'/'.$packageArr['pname'].'/'.$packageArr['pname'].'-latest.zip';
-                       if (!is_file($zipPath)) {
-                               if ($zip->open($zipPath, ZIPARCHIVE::CREATE) 
!== true) {
-                                       echo _('Cannot open the file 
archive')._(': ').$zipPath."\n";
-                                       $globalStatus = 1;
-                               } else {
-                                       $filesPath = 
forge_get_config('upload_dir').'/'.$packageArr['guxname'].'/'.$packageArr['pname'].'/'.$releaseArr['rname'];
-                                       while ($fileArr = 
db_fetch_array($filesRes)) {
-                                               $filePath = 
$filesPath.'/'.$fileArr['filename'];
-                                               if ($zip->addFile($filePath, 
$fileArr['filename']) !== true) {
-                                                       echo _('Cannot add file 
to the file archive')._(': ').$filePath.' -> '.$zipPath."\n";
+                       if 
(is_dir(forge_get_config('upload_dir').'/'.$packageArr['guxname'].'/'.$packageArr['pname']))
 {
+                               if (!is_file($zipPath)) {
+                                       if ($zip->open($zipPath, 
ZIPARCHIVE::CREATE) !== true) {
+                                               echo _('ERROR')._(': 
')._('Cannot open the file archive')._(': ').$zipPath."\n";
+                                               $globalStatus = 1;
+                                       } else {
+                                               $filesPath = 
forge_get_config('upload_dir').'/'.$packageArr['guxname'].'/'.$packageArr['pname'].'/'.$releaseArr['rname'];
+                                               while ($fileArr = 
db_fetch_array($filesRes)) {
+                                                       $filePath = 
$filesPath.'/'.$fileArr['filename'];
+                                                       if (is_file($filePath)) 
{
+                                                               if 
($zip->addFile($filePath, $fileArr['filename']) !== true) {
+                                                                       echo 
_('ERROR')._(': ')._('Cannot add file to the file archive')._(': ').$filePath.' 
-> '.$zipPath."\n";
+                                                                       
$globalStatus = 1;
+                                                               }
+                                                       } else {
+                                                               echo 
_('WARNING')._(': ')._('File exists in database but folder does not')._(': 
').$fileArr['filename']."\n";
+                                                               $globalStatus = 
1;
+                                                       }
+                                               }
+                                               db_free_result($filesRes);
+                                               if ($zip->close() !== true) {
+                                                       echo _('ERROR')._(': 
')._('Cannot close the file archive')._(': ').$zipPath."\n";
                                                        $globalStatus = 1;
                                                }
                                        }
-                                       db_free_result($filesRes);
-                                       if ($zip->close() !== true) {
-                                               echo _('Cannot close the file 
archive')._(': ').$zipPath."\n";
+                                       if (!is_file($zipPath)) {
+                                               echo _('ERROR')._(': 
')._('Something went wrong during zip creation, check permission?').' 
'.$zipPath."\n";
                                                $globalStatus = 1;
+                                       } else {
+                                               chown($zipPath, 
forge_get_config('apache_user'));
+                                               chgrp($zipPath, 
forge_get_config('apache_group'));
                                        }
                                }
-                               if (!is_file($zipPath)) {
-                                       echo _('Something went wrong during zip 
creation, check permission?').' '.$zipPath."\n";
-                                       $globalStatus = 1;
-                               } else {
-                                       chown($zipPath, 
forge_get_config('apache_user'));
-                                       chgrp($zipPath, 
forge_get_config('apache_group'));
-                               }
+                       } else {
+                               echo _('WARNING')._(': ')._('Package exists in 
database but folder does not')._(': ').$packageArr['pname']."\n";
+                               $globalStatus = 1;
                        }
                }
                db_free_result($releaseRes);
        }
        db_free_result($packagesRes);
 }
+
 if ($globalStatus) {
-       echo "ERROR\n";
+       echo "ERROR or WARNING during zip latest generation\n";
        exit(1);
 }
-
 echo "SUCCESS\n";
 exit(0);

-----------------------------------------------------------------------

Summary of changes:
 src/CHANGES                       |  1 +
 src/db/20141105-frs-ziplatest.php | 56 +++++++++++++++++++++++----------------
 2 files changed, 34 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to