install/dist/lib/opensuse.lib.php
interface/lib/classes/validate_dkim.inc.php
@@ -1,6 +1,6 @@ <?php /* /** Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh Copyright (c) 2013, Florian Schaal, info@schaal-24.de All rights reserved. @@ -27,6 +27,9 @@ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @author Florian Schaal, info@schaal-24.de @copyrighth Florian Schaal, info@schaal-24.de */ class validate_dkim { @@ -40,7 +43,9 @@ } } /* Validator function for private DKIM-Key */ /** * Validator function for private DKIM-Key */ function check_private_key($field_name, $field_value, $validator) { $dkim_enabled=$_POST['dkim']; if ($dkim_enabled == 'y') { @@ -50,21 +55,30 @@ } } /* Validator function for DKIM Path */ /** * Validator function for DKIM Path * @return boolean - true when the dkim-path exists and is writeable */ function check_dkim_path($field_name, $field_value, $validator) { if(empty($field_value)) return $this->get_error($validator['errmsg']); if (substr(sprintf('%o', fileperms($field_value)),-3) <= 600) return $this->get_error($validator['errmsg']); } /* Check function for DNS-Template */ /** * Check function for DNS-Template */ function check_template($field_name, $field_value, $validator) { $dkim=false; foreach($field_value as $field ) { if($field == 'DKIM') $dkim=true; } if ($dkim && $field_value[0]!='DOMAIN') return $this->get_error($validator['errmsg']); } /* Validator function for $_POST */ /** * Validator function for $_POST * * @return boolean - true if $POST contains a real key-file */ function validate_post($key,$value) { switch ($key) { case 'public': interface/web/admin/form/server_config.tform.php
interface/web/admin/lib/lang/de_server_config.lng
@@ -19,8 +19,8 @@ $wb['module_txt'] = 'Modul'; $wb['maildir_path_txt'] = 'Maildir Pfad'; $wb['homedir_path_txt'] = 'Homedir Pfad'; $wb["dkim_path_txt"] = 'DKIM Pfad'; $wb["dkim_path_error"] = 'DKIM Pfad nicht gefunden oder nicht beschreibbar.'; $wb['dkim_path_txt'] = 'DKIM Pfad'; $wb['dkim_path_error'] = 'DKIM Pfad nicht gefunden oder nicht beschreibbar.'; $wb['mailuser_uid_txt'] = 'Mailbenutzer UID'; $wb['mailuser_gid_txt'] = 'Mailbenutzer GID'; $wb['mailuser_name_txt'] = 'Mailbenutzer Name'; interface/web/dns/dns_dkim_edit.php
interface/web/dns/dns_dkim_get.php
@@ -1,5 +1,5 @@ <?php /* /** Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh Copyright (c) 2013, Florian Schaal, info@schaal-24.de All rights reserved. @@ -28,11 +28,11 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* This script is invoked by interface/web/dns/templates/dns_dkim_edit.htm when generating the DKIM Private-key. return DKIM Public-Key for the DNS-record /** * This script is invoked by interface/web/dns/templates/dns_dkim_edit.htm * when generating the DKIM Private-key. * * return DKIM Public-Key for the DNS-record */ require_once('../../lib/config.inc.php'); @@ -49,10 +49,12 @@ header('Content-Type: text/xml; charset=utf-8'); header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0'); /* This function fix PHP's messing up POST input containing characters space, dot, open square bracket and others to be compatible with with the deprecated register_globals /** * This function fix PHP's messing up POST input containing characters space, dot, * open square bracket and others to be compatible with with the deprecated register_globals * @return array POST */ function getRealPOST() { $pairs = explode("&", file_get_contents("php://input")); $vars = array(); @@ -64,6 +66,12 @@ } return $vars; } /** * This function formats the public-key * @param array $pubkey * @return string public-key */ function pub_key($pubkey) { $public_key=''; foreach($pubkey as $values) $public_key=$public_key.$values; interface/web/dns/dns_wizard.php
@@ -202,7 +202,6 @@ $tpl_content = str_replace('{DKIM}','TXT|default._domainkey.'.$_POST['domain'].'.|v=DKIM1; t=s; p='.$dns_record,$tpl_content); } } // Parse the template $tpl_rows = explode("\n",$tpl_content); interface/web/dns/form/dns_dkim.tform.php
interface/web/dns/lib/lang/en_dns_dkim.lng
interface/web/dns/lib/lang/en_dns_wizard.lng
interface/web/dns/templates/dns_dkim_edit.htm
interface/web/js/dns_dkim.js
@@ -69,5 +69,3 @@ var serverType = jQuery('#zone').val(); setRequest(serverType); interface/web/js/mail_domain_dkim.js
@@ -69,4 +69,3 @@ var serverType = jQuery('#dkim_private').val(); setRequest('show','{tmpl_var name="domain"}',serverType); interface/web/mail/mail_domain_dkim_create.php
@@ -1,5 +1,6 @@ <?php /* /** Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh Copyright (c) 2013, Florian Schaal, info@schaal-24.de All rights reserved. @@ -26,12 +27,9 @@ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* This script is invoked by interface/web/mail/templates/mail_domain_edit.htm to generate or show the DKIM Private-key. This script is invoked by interface/js/mail_domain_dkim.js to generate or show the DKIM Private-key and to show the Private-key. returns DKIM Private-Key and DKIM Public-Key */ @@ -47,9 +45,10 @@ header('Content-Type: text/xml; charset=utf-8'); header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0'); /* This function fix PHP's messing up POST input containing characters space, dot, open square bracket and others to be compatible with with the deprecated register_globals /** * This function fix PHP's messing up POST input containing characters space, dot, * open square bracket and others to be compatible with with the deprecated register_globals * @return array POST */ function getRealPOST() { $pairs = explode("&", file_get_contents("php://input")); @@ -63,6 +62,11 @@ return $vars; } /** * This function formats the public-key * @param array $pubkey * @return string public-key */ function pub_key($pubkey) { $public_key=''; foreach($pubkey as $values) $public_key=$public_key.$values."\n"; interface/web/mail/templates/mail_domain_edit.htm
@@ -74,6 +74,10 @@ </div> <div class="ctrlHolder"> <textarea name="dkim_public" style="display:none;" id="dkim_public" rows='5' cols='30' readonly>{tmpl_var name='dkim_public'}</textarea> <!-- <label for="dkim_public">{tmpl_var name='dkim_dns_txt'}</label> <textarea name="dkim_public" id="dkim_public" rows='5' cols='30' readonly>{tmpl_var name='dkim_public'}</textarea> --> </div> </div> server/plugins-available/mail_plugin_dkim.inc.php
@@ -1,6 +1,6 @@ <?php /* /** Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh Copyright (c) 2013, Florian Schaal, info@schaal-24.de All rights reserved. @@ -27,6 +27,9 @@ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @author Florian Schaal, info@schaal-24.de @copyrighth Florian Schaal, info@schaal-24.de */ class mail_plugin_dkim { @@ -37,9 +40,9 @@ // private variables var $action = ''; /* This function is called during ispconfig installation to determine if a symlink shall be created for this plugin. /** * This function is called during ispconfig installation to determine * if a symlink shall be created for this plugin. */ function onInstall() { global $conf; @@ -52,8 +55,8 @@ } /* This function is called when the plugin is loaded /** * This function is called when the plugin is loaded */ function onLoad() { global $app,$conf; @@ -65,8 +68,9 @@ $app->plugins->registerEvent('mail_domain_update',$this->plugin_name,'domain_dkim_update'); } /* This function gets the amavisd-config file /** * This function gets the amavisd-config file * @return string path to the amavisd-config for dkim-keys */ function get_amavis_config() { $pos_config=array( @@ -84,9 +88,11 @@ return $amavis_configfile; } /* This function checks the relevant configs and disables dkim for the domain if the directory for dkim is not writeable or does not exist /** * This function checks the relevant configs and disables dkim for the domain * if the directory for dkim is not writeable or does not exist * @param array $data mail-settings * @return boolean - true when the amavis-config and the dkim-dir are writeable */ function check_system($data) { global $app,$mail_config; @@ -105,25 +111,29 @@ $check=false; } } else { $app->log('Unable to write DKIM settings. Check your config!',LOGLEVEL_ERROR); $app->log('Unable to write DKIM settings; Check your config!',LOGLEVEL_ERROR); $check=false; } return $check; } /* This function restarts amavis /** * This function restarts amavis */ function restart_amavis() { global $app,$conf; $initfile=$conf['init_scripts'].'/amavis'; $app->log('Reloading amavis.',LOGLEVEL_DEBUG); exec(escapeshellarg($conf['init_scripts']).escapeshellarg('/amavis').' reload',$output); $app->log('Restarting amavis.',LOGLEVEL_DEBUG); exec(escapeshellarg($conf['init_scripts']).escapeshellarg('/amavis').' restart',$output); foreach($output as $logline) $app->log($logline,LOGLEVEL_DEBUG); } /* This function writes the keyfiles (public and private) /** * This function writes the keyfiles (public and private) * @param string $key_file full path to the key-file * @param string $key_value private-key * @param string $key_domain mail-domain * @return bool - true when the key is written to disk */ function write_dkim_key($key_file,$key_value,$key_domain) { global $app,$mailconfig; @@ -143,8 +153,10 @@ return $success; } /* This function removes the keyfiles /** * This function removes the keyfiles * @param string $key_file full path to the key-file * @param string $key_domain mail-domain */ function remove_dkim_key($key_file,$key_domain) { global $app; @@ -158,8 +170,9 @@ } else $app->log('Unable to delete the DKIM Public-key for '.$key_domain.' (not found).',LOGLEVEL_DEBUG); } /* This function adds the entry to the amavisd-config /** * This function adds the entry to the amavisd-config * @param string $key_domain mail-domain */ function add_to_amavis($key_domain) { global $app,$mail_config; @@ -172,8 +185,9 @@ } } /* This function removes the entry from the amavisd-config /** * This function removes the entry from the amavisd-config * @param string $key_domain mail-domain */ function remove_from_amavis($key_domain) { global $app; @@ -193,11 +207,13 @@ } else $app->log('Unable to delete the DKIM settings from amavis-config for '.$key_domain.'.',LOGLEVEL_ERROR); } /* This function controlls new key-files and amavisd-entries /** * This function controlls new key-files and amavisd-entries * @param array $data mail-settings */ function add_dkim($data) { global $app; if ($data['new']['active'] == 'y') { $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); if ( substr($mail_config['dkim_path'],strlen($mail_config['dkim_path'])-1) == '/' ) $mail_config['dkim_path'] = substr($mail_config['dkim_path'],0,strlen($mail_config['dkim_path'])-1); @@ -207,10 +223,15 @@ $app->log('Error saving the DKIM Private-key for '.$data['new']['domain'].' - DKIM is not enabled for the domain.',LOGLEVEL_ERROR); } } else { $app->log('DKIM for '.$data['new']['domain'].' not written to disk - domain is inactive',LOGLEVEL_DEBUG); } } /* This function controlls the removement of keyfiles (public and private) and the entry in the amavisd-config /** * This function controlls the removement of keyfiles (public and private) * and the entry in the amavisd-config * @param array $data mail-settings */ function remove_dkim($_data) { global $app; @@ -221,19 +242,28 @@ $this->remove_from_amavis($_data['domain']); } /* Functions called by onLoad /** * Function called by onLoad * deletes dkim-keys */ function domain_dkim_delete($event_name,$data) { if (isset($data['old']['dkim']) && $data['old']['dkim'] == 'y') $this->remove_dkim($data['old']); } /** * Function called by onLoad * insert dkim-keys */ function domain_dkim_insert($event_name,$data) { if (isset($data['new']['dkim']) && $data['new']['dkim']=='y' && $this->check_system($data)) { $this->add_dkim($data); } } /** * Function called by onLoad * chang dkim-settings */ function domain_dkim_update($event_name,$data) { global $app; /* get the config */