diff --git a/install/dist/lib/centos_base.lib.php b/install/dist/lib/centos_base.lib.php index d6deb7e27a8b8c6515d343fa1ba3e53a7ebc3000..3b204165c8a4103ef72019dcd789a6d4a51a56af 100644 --- a/install/dist/lib/centos_base.lib.php +++ b/install/dist/lib/centos_base.lib.php @@ -48,6 +48,7 @@ class installer_centos extends installer_dist { $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content); $content = str_replace('{hostname}', $conf['hostname'], $content); $content = str_replace('/var/spool/amavisd/clamd.sock', $this->clamav_socket, $content); + $content = str_replace('{amavis_config_dir}', $conf['amavis']['config_dir']); wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content); chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); diff --git a/install/dist/lib/opensuse.lib.php b/install/dist/lib/opensuse.lib.php index d091b3b1bab5449d077aa5ab058652707db0ed11..b9153a021c44b250afe0cb0df719ac478bc85d36 100644 --- a/install/dist/lib/opensuse.lib.php +++ b/install/dist/lib/opensuse.lib.php @@ -507,6 +507,7 @@ class installer_dist extends installer_base { $content = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $content); $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content); $content = str_replace('{hostname}', $conf['hostname'], $content); + $content = str_replace('{amavis_config_dir}', $conf['amavis']['config_dir']); wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content); chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); diff --git a/install/tpl/fedora_amavisd_conf.master b/install/tpl/fedora_amavisd_conf.master index f32530cfabe1b93ec9b41f6b3e59f2bab6b561ee..0258226a82d8c9385253d8a78e8f272d9cc2eac0 100644 --- a/install/tpl/fedora_amavisd_conf.master +++ b/install/tpl/fedora_amavisd_conf.master @@ -711,6 +711,7 @@ $banned_filename_re = new_RE( # package/port of an audio editor. Make sure the correct 'sweep' is found # in the path when enabling. # +w # ### http://www.sophos.com/ - backs up Sophie or SAVI-Perl # ['Sophos Anti Virus (sweep)', 'sweep', # '-nb -f -all -rec -ss -sc -archive -cab -mime -oe -tnef '. @@ -785,6 +786,7 @@ $LOGFILE = "/var/log/amavis.log"; # (defaults to empty, no log) $log_level = 0; # (defaults to 0) +include_config_files('{amavis_config_dir}/60-dkim'); $enable_dkim_verification = 1; $enable_dkim_signing = 1; # load DKIM signing code diff --git a/install/tpl/opensuse_amavisd_conf.master b/install/tpl/opensuse_amavisd_conf.master index 582dd1163130dbe87e2c97c5fb3d2203dbd9e3ca..419eea237c2a81d2bbb939a135ffe0accacfd4c4 100644 --- a/install/tpl/opensuse_amavisd_conf.master +++ b/install/tpl/opensuse_amavisd_conf.master @@ -779,7 +779,7 @@ $DO_SYSLOG = 1; $LOGFILE = "/var/log/amavis.log"; # (defaults to empty, no log) # DKIM - +include_config_files('{amavis_config_dir}/60-dkim'); $enable_dkim_verification = 1; $enable_dkim_signing = 1; # load DKIM signing code $signed_header_fields{'received'} = 0; # turn off signing of Received diff --git a/server/plugins-available/mail_plugin_dkim.inc.php b/server/plugins-available/mail_plugin_dkim.inc.php index 0b840db7d8050607824c85c2ac02e6a977f99c14..6f042e9070c0a53be51d99e7f7029a3558e5e332 100755 --- a/server/plugins-available/mail_plugin_dkim.inc.php +++ b/server/plugins-available/mail_plugin_dkim.inc.php @@ -87,10 +87,11 @@ class mail_plugin_dkim { break; } } - //* If we can use seperate config-files with amavis use 60-dkim - if (substr_compare($amavis_configfile, '50-user', -7) === 0) + if (substr_compare($amavis_configfile, '50-user', -7) === 0) { $amavis_configfile = str_replace('50-user', '60-dkim', $amavis_configfile); - + } else { //* fake 60-dkim on system with a monolithic amavis-config + $amavis_configfile = str_replace('amavisd.conf', '60-dkim', $amavis_configfile); + } return $amavis_configfile; } @@ -109,7 +110,7 @@ class mail_plugin_dkim { /* check for amavis-config */ $amavis_configfile = $this->get_amavis_config(); - //* When we can use 60-dkim for the dkim-keys create the file if it does not exists. + //* Create the file if it does not exists. if (substr_compare($amavis_configfile, '60-dkim', -7) === 0 && !file_exists($amavis_configfile)) $app->system->touch($amavis_configfile); @@ -120,12 +121,7 @@ class mail_plugin_dkim { /* dir for dkim-keys writeable? */ $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); - if ( isset($mail_config['dkim_path']) && - !empty($mail_config['dkim_path']) && -// isset($data['new']['dkim_private']) && -// !empty($data['new']['dkim_private']) && - $mail_config['dkim_path'] != '/' - ) { + if (isset($mail_config['dkim_path']) && !empty($mail_config['dkim_path']) && $mail_config['dkim_path'] != '/') { if (!is_dir($mail_config['dkim_path'])) { $app->log('DKIM Path '.$mail_config['dkim_path'].' not found - (re)created.', LOGLEVEL_DEBUG); if($app->system->is_user('amavis')) { @@ -239,16 +235,18 @@ class mail_plugin_dkim { $search_regex = "/(\n|\r)?dkim_key\(\'".$key_domain."\',\ \'(".$selector."|".$old_selector."){1}?\'.*/"; - //* If we are using seperate config-files with amavis remove existing keys from 50-user to avoid duplicate keys + //* If we are using seperate config-files (no faked 60-dkim) with amavis remove existing keys from 50-user to avoid duplicate keys if (substr_compare($amavis_configfile, '60-dkim', -7) === 0) { $temp_configfile = str_replace('60-dkim', '50-user', $amavis_configfile); - $temp_config = $app->system->file_get_contents($temp_configfile, true); - if (preg_match($search_regex, $temp_config)) { - $temp_config = preg_replace($search_regex, '', $temp_config)."\n"; - $app->system->file_put_contents($temp_configfile, $temp_config, true); + if(file_exists($temp_configfile)) { + $temp_config = $app->system->file_get_contents($temp_configfile, true); + if (preg_match($search_regex, $temp_config)) { + $temp_config = preg_replace($search_regex, '', $temp_config)."\n"; + $app->system->file_put_contents($temp_configfile, $temp_config, true); + } + unset($temp_config); } unset($temp_configfile); - unset($temp_config); } $key_value="dkim_key('".$key_domain."', '".$selector."', '".$mail_config['dkim_path']."/".$key_domain.".private');\n"; @@ -285,17 +283,19 @@ class mail_plugin_dkim { $restart = true; } - //* If we are using seperate config-files with amavis remove existing keys from 50-user, too + //* If we are using seperate config-files (no faked 60-dkim) with amavis remove existing keys from 50-user to avoid duplicate keys if (substr_compare($amavis_configfile, '60-dkim', -7) === 0) { $temp_configfile = str_replace('60-dkim', '50-user', $amavis_configfile); - $temp_config = $app->system->file_get_contents($temp_configfile, true); - if (preg_match($search_regex, $temp_config)) { - $temp_config = preg_replace($search_regex, '', $temp_config); - $app->system->file_put_contents($temp_configfile, $temp_config, true); - $restart = true; + if(file_exists($temp_configfile)) { + $temp_config = $app->system->file_get_contents($temp_configfile, true); + if (preg_match($search_regex, $temp_config)) { + $temp_config = preg_replace($search_regex, '', $temp_config); + $app->system->file_put_contents($temp_configfile, $temp_config, true); + $restart = true; + } + unset($temp_configfile); + unset($temp_config); } - unset($temp_configfile); - unset($temp_config); } return $restart;