Browse Source

NEW Can force the antivirus from conf file or autoprepend ini setup.

Laurent Destailleur 4 years ago
parent
commit
62177edab1

+ 6 - 0
htdocs/admin/security_file.php

@@ -154,6 +154,9 @@ if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
     }
 }
 print '<input type="text" name="MAIN_ANTIVIRUS_COMMAND" class="minwidth500imp" value="'.(!empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_COMMAND) : '').'">';
+if (defined('MAIN_ANTIVIRUS_COMMAND')) {
+	print '<br><span class="opacitymedium">'.$langs->trans("ValueIsForcedBySystem").'</span>';
+}
 print "</td>";
 print '</tr>';
 
@@ -165,6 +168,9 @@ print '<span class="opacitymedium">'.$langs->trans("AntiVirusParamExample").'</s
 print '</td>';
 print '<td>';
 print '<input type="text" name="MAIN_ANTIVIRUS_PARAM" class="minwidth500imp" value="'.(!empty($conf->global->MAIN_ANTIVIRUS_PARAM) ?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_PARAM) : '').'">';
+if (defined('MAIN_ANTIVIRUS_PARAM')) {
+	print '<br><span class="opacitymedium">'.$langs->trans("ValueIsForcedBySystem").'</span>';
+}
 print "</td>";
 print '</tr>';
 

+ 12 - 0
htdocs/conf/conf.php.example

@@ -287,6 +287,18 @@ $dolibarr_cron_allow_cli='0';
 // Examples: '-1' (sending by cli is forbidden)
 // $dolibarr_mailing_limit_sendbycli='0';
 
+// MAIN_ANTIVIRUS_COMMAND (as a constant)
+// Force a value for the antivirus command line tool so setup for admin user interface has no effect.
+// Default value: ''
+// Example: '/usr/bin/clamdscan';
+// define('MAIN_ANTIVIRUS_COMMAND', '/usr/bin/clamdscan');
+
+// MAIN_ANTIVIRUS_PARAM (as a constant)
+// Force a value for the antivirus parameters on command line so setup for admin user interface has no effect.
+// Default value: ''
+// Example: '--fdpass';
+// define('MAIN_ANTIVIRUS_PARAM', '--fdpass');
+
 
 //##################
 // Other

+ 3 - 0
htdocs/core/class/conf.class.php

@@ -684,6 +684,9 @@ class Conf
 		// If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined.
 		if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $this->global->MAIN_FEATURES_LEVEL >= 2) $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1;
 
+		if (defined('MAIN_ANTIVIRUS_COMMAND')) $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
+		if (defined('MAIN_ANTIVIRUS_PARAM')) $this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
+
 		// For backward compatibility
 		if (isset($this->product))   $this->produit = $this->product;
 		if (isset($this->facture))   $this->invoice = $this->facture;

+ 4 - 4
htdocs/core/lib/files.lib.php

@@ -1075,13 +1075,11 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
 		}
 	}
 
-	if ($reshook < 0)	// At least one blocking error returned by one hook
-	{
+	if ($reshook < 0) {	// At least one blocking error returned by one hook
 		$errmsg = join(',', $hookmanager->errors);
 		if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks'; // Should not occurs. Added if hook is bugged and does not set ->errors when there is error.
 		return $errmsg;
-	} elseif (empty($reshook))
-	{
+	} elseif (empty($reshook)) {
 		// The file functions must be in OS filesystem encoding.
 		$src_file_osencoded = dol_osencode($src_file);
 		$file_name_osencoded = dol_osencode($file_name);
@@ -1535,6 +1533,8 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess
 			$nbok = 0;
 			for ($i = 0; $i < $nbfile; $i++)
 			{
+				if (empty($TFile['name'][$i])) continue;		// For example, when submitting a form with no file name
+
 				// Define $destfull (path to file including filename) and $destfile (only filename)
 				$destfull = $upload_dir."/".$TFile['name'][$i];
 				$destfile = $TFile['name'][$i];

+ 2 - 1
htdocs/langs/en_US/admin.lang

@@ -1221,7 +1221,8 @@ RestoreDesc=To restore a Dolibarr backup, two steps are required.
 RestoreDesc2=Restore the backup file (zip file for example) of the "documents" directory to a new Dolibarr installation or into this current documents directory (<b>%s</b>).
 RestoreDesc3=Restore the database structure and data from a backup dump file into the database of the new Dolibarr installation or into the database of this current installation (<b>%s</b>). Warning, once the restore is complete, you must use a login/password, that existed from the backup time/installation to connect again.<br>To restore a backup database into this current installation, you can follow this assistant.
 RestoreMySQL=MySQL import
-ForcedToByAModule= This rule is forced to <b>%s</b> by an activated module
+ForcedToByAModule=This rule is forced to <b>%s</b> by an activated module
+ValueIsForcedBySystem=This value is forced by the system. You can't change it. 
 PreviousDumpFiles=Existing backup files
 PreviousArchiveFiles=Existing archive files
 WeekStartOnDay=First day of the week