| | |
| | | $pos_config=array( |
| | | '/etc/amavisd.conf', |
| | | '/etc/amavisd.conf/50-user', |
| | | '/etc/amavis/conf.d/50-user' |
| | | '/etc/amavis/conf.d/50-user', |
| | | '/etc/amavisd/amavisd.conf' |
| | | ); |
| | | $amavis_configfile=''; |
| | | foreach($pos_config as $conf) { |
| | |
| | | } |
| | | /* dir for dkim-keys writeable? */ |
| | | $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); |
| | | if (isset($mail_config['dkim_path']) && isset($data['new']['dkim_private']) && !empty($data['new']['dkim_private'])) { |
| | | if (isset($mail_config['dkim_path']) && (!empty($mail_config['dkim_path'])) && isset($data['new']['dkim_private']) && !empty($data['new']['dkim_private'])) { |
| | | |
| | | if (!is_dir($mail_config['dkim_path'])) { |
| | | $app->log('DKIM Path '.$mail_config['dkim_path'].' not found - (re)created.', LOGLEVEL_DEBUG); |
| | | mkdir($mail_config['dkim_path'], 0750, true); |
| | | } |
| | | |
| | | if (!is_writeable($mail_config['dkim_path'])) { |
| | | $app->log('DKIM Path '.$mail_config['dkim_path'].' not found or not writeable.', LOGLEVEL_ERROR); |
| | | $app->log('DKIM Path '.$mail_config['dkim_path'].' not writeable.', LOGLEVEL_ERROR); |
| | | $check=false; |
| | | } |
| | | |
| | | } else { |
| | | $app->log('Unable to write DKIM settings; Check your config!', LOGLEVEL_ERROR); |
| | | $check=false; |
| | |
| | | */ |
| | | function restart_amavis() { |
| | | global $app, $conf; |
| | | $initfile=$conf['init_scripts'].'/amavis'; |
| | | $app->log('Restarting amavis.', LOGLEVEL_DEBUG); |
| | | exec(escapeshellarg($conf['init_scripts']).escapeshellarg('/amavis').' restart', $output); |
| | | $pos_init=array( |
| | | $conf['init_scripts'].'/amavis', |
| | | $conf['init_scripts'].'/amavisd' |
| | | ); |
| | | $initfile=''; |
| | | foreach($pos_init as $init) { |
| | | if (is_executable($init)) { |
| | | $initfile=$init; |
| | | break; |
| | | } |
| | | } |
| | | $app->log('Restarting amavis: '.$initfile.'.', LOGLEVEL_DEBUG); |
| | | exec(escapeshellarg($initfile).' restart', $output); |
| | | foreach($output as $logline) $app->log($logline, LOGLEVEL_DEBUG); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * This function writes the keyfiles (public and private) |
| | |
| | | /* save the DKIM Public-key in dkim-dir */ |
| | | if (!file_put_contents($key_file.'.public', $public_key) === false) |
| | | $app->log('Saved DKIM Public to '.$key_domain.'.', LOGLEVEL_DEBUG); |
| | | else $app->log('Unable to save DKIM Public to '.$key_domain.'.', LOGLEVEL_WARNING); |
| | | else $app->log('Unable to save DKIM Public to '.$key_domain.'.', LOGLEVEL_DEBUG); |
| | | } |
| | | return $success; |
| | | } |
| | |
| | | file_put_contents($this->get_amavis_config(), $amavis_config); |
| | | $app->log('Deleted the DKIM settings from amavis-config for '.$key_domain.'.', LOGLEVEL_DEBUG); |
| | | $this->restart_amavis(); |
| | | } else $app->log('Unable to delete the DKIM settings from amavis-config for '.$key_domain.'.', LOGLEVEL_ERROR); |
| | | } else $app->log('Unable to delete the DKIM settings from amavis-config for '.$key_domain.'.', LOGLEVEL_DEBUG); |
| | | } |
| | | |
| | | /** |