tbrehm
2013-08-22 ec571625a4dee99acff1a2cef75a48aa57df82cb
Updated dkim support. Thanks to Florian for the patch.
16 files modified
2 files added
278 ■■■■■ changed files
install/dist/lib/fedora.lib.php 13 ●●●●● patch | view | raw | blame | history
install/dist/lib/gentoo.lib.php 13 ●●●●● patch | view | raw | blame | history
install/dist/lib/opensuse.lib.php 13 ●●●●● patch | view | raw | blame | history
install/lib/installer_base.lib.php 9 ●●●●● patch | view | raw | blame | history
install/tpl/debian_postfix.conf.master 4 ●●●● patch | view | raw | blame | history
install/tpl/fedora_postfix.conf.master 4 ●●●● patch | view | raw | blame | history
install/tpl/gentoo_postfix.conf.master 4 ●●●● patch | view | raw | blame | history
install/tpl/opensuse_postfix.conf.master 4 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/de_server_config.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/fr_server_config.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/dns/lib/lang/de_dns_dkim.lng 8 ●●●●● patch | view | raw | blame | history
interface/web/dns/lib/lang/de_dns_wizard.lng 1 ●●●● patch | view | raw | blame | history
interface/web/dns/lib/lang/fr_dns_dkim.lng 8 ●●●●● patch | view | raw | blame | history
interface/web/dns/lib/lang/fr_dns_wizard.lng 1 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/de_mail_domain.lng 6 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/fr_mail_domain.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_domain_edit.htm 29 ●●●● patch | view | raw | blame | history
server/plugins-available/mail_plugin_dkim.inc.php 150 ●●●● patch | view | raw | blame | history
install/dist/lib/fedora.lib.php
@@ -152,6 +152,19 @@
        //* mysql-virtual_relayrecipientmaps.cf
        $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf');
    //* postfix-dkim
    $full_file_name=$config_dir.'/tag_as_originating.re';
    if(is_file($full_file_name)) {
        copy($full_file_name, $config_dir.$configfile.'~');
    }
    wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10026');
    $full_file_name=$config_dir.'/tag_as_foreign.re';
    if(is_file($full_file_name)) {
        copy($full_file_name, $config_dir.$configfile.'~');
    }
    wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10024');
        //* Changing mode and group of the new created config files.
        caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
                 __FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed');
install/dist/lib/gentoo.lib.php
@@ -156,6 +156,19 @@
            $command = 'mkdir '.$cf['vmail_mailbox_base'].'/mailfilters';
            caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        //* postfix-dkim
        $full_file_name=$config_dir.'/tag_as_originating.re';
        if(is_file($full_file_name)) {
            copy($full_file_name, $config_dir.$configfile.'~');
            }
            $this->write_config_file($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10026');
            $full_file_name=$config_dir.'/tag_as_foreign.re';
            if(is_file($full_file_name)) {
                    copy($full_file_name, $config_dir.$configfile.'~');
            }
        $this->write_config_file($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10024');
        
        //* Chmod and chown the .mailfilter file
        $command = 'chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter';
install/dist/lib/opensuse.lib.php
@@ -151,6 +151,19 @@
        //* mysql-virtual_relayrecipientmaps.cf
        $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf');
    //* postfix-dkim
    $full_file_name=$config_dir.'/tag_as_originating.re';
    if(is_file($full_file_name)) {
        copy($full_file_name, $config_dir.$configfile.'~');
    }
    wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10026');
    $full_file_name=$config_dir.'/tag_as_foreign.re';
    if(is_file($full_file_name)) {
        copy($full_file_name, $config_dir.$configfile.'~');
    }
    wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10024');
        //* Changing mode and group of the new created config files.
        caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
                 __FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed');
install/lib/installer_base.lib.php
@@ -665,6 +665,15 @@
        //* mysql-virtual_relayrecipientmaps.cf
        $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf');
        //* postfix-dkim
        $full_file_name=$config_dir.'/tag_as_originating.re';
                if(is_file($full_file_name)) copy($full_file_name, $config_dir.$configfile.'~');
        wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10026');
        $full_file_name=$config_dir.'/tag_as_foreign.re';
                if(is_file($full_file_name)) copy($full_file_name, $config_dir.$configfile.'~');
        wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10024');
        //* Changing mode and group of the new created config files.
        caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
                __FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed');
install/tpl/debian_postfix.conf.master
@@ -20,7 +20,7 @@
relay_domains = mysql:{config_dir}/mysql-virtual_relaydomains.cf
relay_recipient_maps = mysql:{config_dir}/mysql-virtual_relayrecipientmaps.cf
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf
smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf regexp:{config_dir}/tag_as_originating.re, permit_mynetworks, check_sender_access regexp:{config_dir}/tag_as_foreign.re
smtpd_client_restrictions = check_client_access mysql:{config_dir}/mysql-virtual_client.cf
smtpd_client_message_rate_limit = 100
maildrop_destination_concurrency_limit = 1
@@ -30,4 +30,4 @@
mime_header_checks = regexp:{config_dir}/mime_header_checks
nested_header_checks = regexp:{config_dir}/nested_header_checks
body_checks = regexp:{config_dir}/body_checks
owner_request_special = no
owner_request_special = no
install/tpl/fedora_postfix.conf.master
@@ -17,7 +17,7 @@
relay_domains = mysql:{config_dir}/mysql-virtual_relaydomains.cf
relay_recipient_maps = mysql:{config_dir}/mysql-virtual_relayrecipientmaps.cf
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf
smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf regexp:{config_dir}/tag_as_originating.re, permit_mynetworks, check_sender_access regexp:{config_dir}/tag_as_foreign.re
smtpd_client_restrictions = check_client_access mysql:{config_dir}/mysql-virtual_client.cf
smtpd_client_message_rate_limit = 100
maildrop_destination_concurrency_limit = 1
@@ -27,4 +27,4 @@
mime_header_checks = regexp:{config_dir}/mime_header_checks
nested_header_checks = regexp:{config_dir}/nested_header_checks
body_checks = regexp:{config_dir}/body_checks
inet_interfaces = all
inet_interfaces = all
install/tpl/gentoo_postfix.conf.master
@@ -17,7 +17,7 @@
relay_domains = mysql:{config_dir}/mysql-virtual_relaydomains.cf
relay_recipient_maps = mysql:{config_dir}/mysql-virtual_relayrecipientmaps.cf
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf
smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf regexp:{config_dir}/tag_as_originating.re, permit_mynetworks, check_sender_access regexp:{config_dir}/tag_as_foreign.re
smtpd_client_restrictions = check_client_access mysql:{config_dir}/mysql-virtual_client.cf
smtpd_client_message_rate_limit = 100
maildrop_destination_concurrency_limit = 1
@@ -27,4 +27,4 @@
mime_header_checks = regexp:{config_dir}/mime_header_checks
nested_header_checks = regexp:{config_dir}/nested_header_checks
body_checks = regexp:{config_dir}/body_checks
inet_interfaces = all
inet_interfaces = all
install/tpl/opensuse_postfix.conf.master
@@ -17,7 +17,7 @@
relay_domains = mysql:{config_dir}/mysql-virtual_relaydomains.cf
relay_recipient_maps = mysql:{config_dir}/mysql-virtual_relayrecipientmaps.cf
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf
smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf regexp:{config_dir}/tag_as_originating.re, permit_mynetworks, check_sender_access regexp:{config_dir}/tag_as_foreign.re
smtpd_client_restrictions = check_client_access mysql:{config_dir}/mysql-virtual_client.cf
smtpd_client_message_rate_limit = 100
maildrop_destination_concurrency_limit = 1
@@ -27,4 +27,4 @@
mime_header_checks = regexp:{config_dir}/mime_header_checks
nested_header_checks = regexp:{config_dir}/nested_header_checks
body_checks = regexp:{config_dir}/body_checks
inet_interfaces = all
inet_interfaces = all
interface/web/admin/lib/lang/de_server_config.lng
@@ -19,6 +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['mailuser_uid_txt'] = 'Mailbenutzer UID';
$wb['mailuser_gid_txt'] = 'Mailbenutzer GID';
$wb['mailuser_name_txt'] = 'Mailbenutzer Name';
interface/web/admin/lib/lang/fr_server_config.lng
@@ -18,6 +18,8 @@
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Chemin Maildir';
$wb['homedir_path_txt'] = 'Chemin Homedir';
$wb['dkim_path_txt'] = 'Chemin DKIM';
$wb['dkim_path_error'] = 'Le chemin DKIM n\'est pas trouvé ou ne peut être écrit.';
$wb['mailuser_uid_txt'] = 'UID de l\'utilisateur mail';
$wb['mailuser_gid_txt'] = 'GID de l\'utilisateur mail';
$wb['mailuser_name_txt'] = 'Nom d\'utilisateur mail';
interface/web/dns/lib/lang/de_dns_dkim.lng
New file
@@ -0,0 +1,8 @@
<?php
$wb["public_key_txt"] = 'Public-Key';
$wb["ttl_txt"] = 'TTL';
$wb["active_txt"] = 'Aktiv';
$wb["record_exists_txt"] = 'DNS-Eintrag bereits vorhanden';
$wb["limit_dns_record_txt"] = 'Die max. Anzahl von DNS Eintraegen fuer den Account ist erreicht.';
$wb["no_zone_perm"] = 'Fehlende Berechtigung zum Hinzufuegen eines Eintrags zur DNS-Zone.';
?>
interface/web/dns/lib/lang/de_dns_wizard.lng
@@ -9,6 +9,7 @@
$wb['btn_cancel_txt'] = 'Abbrechen';
$wb['domain_txt'] = 'Domain';
$wb['email_txt'] = 'E-Mail Adresse';
$wb['dkim_txt'] = 'DKIM aktiviert';
$wb['ns1_txt'] = 'NS 1';
$wb['ns2_txt'] = 'NS 2';
$wb['ip_txt'] = 'IP Adresse';
interface/web/dns/lib/lang/fr_dns_dkim.lng
New file
@@ -0,0 +1,8 @@
<?php
$wb["public_key_txt"] = 'Clé publiquePublic-Key';
$wb["ttl_txt"] = 'TTL';
$wb["active_txt"] = 'Actif';
$wb["record_exists_txt"] = 'L\'enregistrement DNS exist déjà';
$wb["limit_dns_record_txt"] = 'Le nombre max. d\'enregistrement DNS pour votre compte à été atteint.';
$wb["no_zone_perm"] = 'Vous n\'avez pas la permission d\'ajouter un enregistrement à cette Zone DNS.';
?>
interface/web/dns/lib/lang/fr_dns_wizard.lng
@@ -6,6 +6,7 @@
$wb['btn_cancel_txt'] = 'Annuler';
$wb['domain_txt'] = 'Domaine';
$wb['email_txt'] = 'Email';
$wb['dkim_txt'] = 'DKIM activé';
$wb['ns1_txt'] = 'NS 1';
$wb['ns2_txt'] = 'NS 2';
$wb['ip_txt'] = 'Adresse IP';
interface/web/mail/lib/lang/de_mail_domain.lng
@@ -3,6 +3,12 @@
$wb['domain_txt'] = 'Domain';
$wb['type_txt'] = 'Typ';
$wb['active_txt'] = 'Aktiv';
$wb["dkim_txt"] = 'DKIM aktivieren
$wb["dkim_private_txt"] = 'DKIM Private-key';
$wb["dkim_public_txt"] = 'DKIM Public-key\nfor information only';
$wb["dkim_generate_txt"] = 'erstelle DKIM Private-key';
$wb["dkim_dns_txt"] = 'DNS-Record (TYPE TXT)<br><br>add this record to your DNS';
$wb["dkim_private_key_error"] = 'ungueltiger DKIM-Private key';
$wb['domain_error_empty'] = 'Domain ist leer';
$wb['domain_error_unique'] = 'Doppelte Domain.';
$wb['domain_error_regex'] = 'Ungültiger Domainname.';
interface/web/mail/lib/lang/fr_mail_domain.lng
@@ -3,6 +3,13 @@
$wb['domain_txt'] = 'Domaine';
$wb['type_txt'] = 'Type';
$wb['active_txt'] = 'Actif';
$wb['dkim_txt'] = 'Activer DKIM';
$wb['dkim_private_txt'] = 'Clé privée DKIM';
$wb['dkim_public_txt'] = 'Clé publique DKIM\npour information seulement';
$wb['dkim_generate_txt'] = 'Générer la clé privée DKIM';
$wb['dkim_dns_txt'] = 'Enregistrement DNS (TYPE TXT)<br><br>Ajouter l\'enregistrement à votre DNS';
$wb['dkim_private_key_error'] = 'Clé privée DKIM invalide';
$wb['dkim_settings_txt'] = 'DomainKeys Identified Mail (DKIM)';
$wb['domain_error_empty'] = 'Le domaine est vide.';
$wb['domain_error_unique'] = 'Dupliquer le domaine.';
$wb['domain_error_regex'] = 'Le domaine est invalide.';
interface/web/mail/templates/mail_domain_edit.htm
@@ -69,17 +69,16 @@
              </div>
              <div class="ctrlHolder">
                <label for="dkim_private">{tmpl_var name='dkim_private_txt'}</label>
                <textarea name="dkim_private" id="dkim_private" rows='10' cols='30'>{tmpl_var name='dkim_private'}</textarea>
<a href="javascript:setRequest('create','{tmpl_var name='domain'}')">{tmpl_var name='dkim_generate_txt'}</a>
              </div>
        <div class="ctrlHolder">
                <label for="dkim_public">{tmpl_var name='dkim_public_txt'}</label>
                <textarea name="dkim_public" id="dkim_public" rows='5' cols='30' readonly>{tmpl_var name='dkim_public'}</textarea>
              </div>
            </div>
        </fieldset>
                <textarea name="dkim_private" id="dkim_private" rows='10' cols='30'>{tmpl_var name='dkim_private'}</textarea>
<a href="javascript:setRequest('create','{tmpl_var name='domain'}')">{tmpl_var name='dkim_generate_txt'}</a>
              </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>
              </div>
            </div>
        </fieldset>
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
        <input type="hidden" name="type" value="local">
@@ -87,7 +86,7 @@
            <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onclick="submitForm('pageForm','mail/mail_domain_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
            <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onclick="loadContent('mail/mail_domain_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
        </div>
    </div>
</div>
<script language="JavaScript" type="text/javascript" src="js/mail_domain_dkim.js"></script>
    </div>
</div>
<script language="JavaScript" type="text/javascript" src="js/mail_domain_dkim.js"></script>
server/plugins-available/mail_plugin_dkim.inc.php
@@ -1,9 +1,9 @@
<?php
/*
Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh
Copyright (c) 2013, Florian Schaal, info@schaal-24.de
All rights reserved.
<?php
/*
Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh
Copyright (c) 2013, Florian Schaal, info@schaal-24.de
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -60,22 +60,22 @@
        /*
        Register for the events
        */
        $app->plugins->registerEvent('mail_domain_delete',$this->plugin_name,'domain_dkim_delete');
        $app->plugins->registerEvent('mail_domain_insert',$this->plugin_name,'domain_dkim_insert');
        $app->plugins->registerEvent('mail_domain_update',$this->plugin_name,'domain_dkim_update');
    }
        /*
        $app->plugins->registerEvent('mail_domain_delete',$this->plugin_name,'domain_dkim_delete');
        $app->plugins->registerEvent('mail_domain_insert',$this->plugin_name,'domain_dkim_insert');
        $app->plugins->registerEvent('mail_domain_update',$this->plugin_name,'domain_dkim_update');
    }
        /*
                This function gets the amavisd-config file
        */
    function get_amavis_config() {
        $pos_config=array(
            '/etc/amavisd.conf',
            '/etc/amavisd.conf/50-user',
            '/etc/amavis/conf.d/50-user'
        );
        $amavis_configfile='';
                foreach($pos_config as $conf) {
    function get_amavis_config() {
        $pos_config=array(
            '/etc/amavisd.conf',
            '/etc/amavisd.conf/50-user',
            '/etc/amavis/conf.d/50-user'
        );
        $amavis_configfile='';
                foreach($pos_config as $conf) {
            if (is_file($conf)) {
                $amavis_configfile=$conf;
                break;
@@ -105,58 +105,58 @@
                $check=false;
                       }
        } else {
            $app->log('Unable to write DKIM settings; Check your config!',LOGLEVEL_ERROR);
            $check=false;
        }
        return $check;
    }
            $app->log('Unable to write DKIM settings; Check your config!',LOGLEVEL_ERROR);
            $check=false;
        }
        return $check;
    }
    /*
        This function restarts amavis
    */
    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);
        foreach($output as $logline) $app->log($logline,LOGLEVEL_DEBUG);
    }
    /*
                This function writes the keyfiles (public and private)
        */
    function write_dkim_key($key_file,$key_value,$key_domain) {
                global $app,$mailconfig;
        global $app,$conf;
        $initfile=$conf['init_scripts'].'/amavis';
        $app->log('Reloading amavis.',LOGLEVEL_DEBUG);
        exec(escapeshellarg($conf['init_scripts']).escapeshellarg('/amavis').' reload',$output);
        foreach($output as $logline) $app->log($logline,LOGLEVEL_DEBUG);
    }
    /*
                This function writes the keyfiles (public and private)
        */
    function write_dkim_key($key_file,$key_value,$key_domain) {
                global $app,$mailconfig;
        $success=false;
        if (!file_put_contents($key_file.'.private',$key_value) === false) { 
            $app->log('Saved DKIM Private-key to '.$key_file.'.private',LOGLEVEL_DEBUG);
            $success=true;
            /* now we get the DKIM Public-key */
            exec('cat '.escapeshellarg($key_file.'.private').'|openssl rsa -pubout',$pubkey,$result);
            $public_key='';
            foreach($pubkey as $values) $public_key=$public_key.$values."\n";
            /* 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);
        }
        return $success;
    }
            $app->log('Saved DKIM Private-key to '.$key_file.'.private',LOGLEVEL_DEBUG);
            $success=true;
            /* now we get the DKIM Public-key */
            exec('cat '.escapeshellarg($key_file.'.private').'|openssl rsa -pubout',$pubkey,$result);
            $public_key='';
            foreach($pubkey as $values) $public_key=$public_key.$values."\n";
            /* 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);
        }
        return $success;
    }
    /*
        This function removes the keyfiles
    */
    function remove_dkim_key($key_file,$key_domain) {
        global $app;
        if (file_exists($key_file.'.private')) {
            exec('rm -f '.escapeshellarg($key_file.'.private'));
            $app->log('Deleted the DKIM Private-key for '.$key_domain.'.',LOGLEVEL_DEBUG);
        } else $app->log('Unable to delete the DKIM Private-key for '.$key_domain.' (not found).',LOGLEVEL_DEBUG);
        if (file_exists($key_file.'.public')) {
            exec('rm -f '.escapeshellarg($key_file.'.public'));
            $app->log('Deleted the DKIM Public-key for '.$key_domain.'.',LOGLEVEL_DEBUG);
        } else $app->log('Unable to delete the DKIM Public-key for '.$key_domain.' (not found).',LOGLEVEL_DEBUG);
    }
    function remove_dkim_key($key_file,$key_domain) {
        global $app;
        if (file_exists($key_file.'.private')) {
            exec('rm -f '.escapeshellarg($key_file.'.private'));
            $app->log('Deleted the DKIM Private-key for '.$key_domain.'.',LOGLEVEL_DEBUG);
        } else $app->log('Unable to delete the DKIM Private-key for '.$key_domain.' (not found).',LOGLEVEL_DEBUG);
        if (file_exists($key_file.'.public')) {
            exec('rm -f '.escapeshellarg($key_file.'.public'));
            $app->log('Deleted the DKIM Public-key for '.$key_domain.'.',LOGLEVEL_DEBUG);
        } 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
@@ -201,13 +201,13 @@
                $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);
        if ($this->write_dkim_key($mail_config['dkim_path']."/".$data['new']['domain'],$data['new']['dkim_private'],$data['new']['domain'])) {
                       $this->add_to_amavis($data['new']['domain']);
        } else {
            $app->log('Error saving the DKIM Private-key for '.$data['new']['domain'].' - DKIM is not enabled for the domain.',LOGLEVEL_ERROR);
        }
    }
        if ($this->write_dkim_key($mail_config['dkim_path']."/".$data['new']['domain'],$data['new']['dkim_private'],$data['new']['domain'])) {
                       $this->add_to_amavis($data['new']['domain']);
        } else {
            $app->log('Error saving the DKIM Private-key for '.$data['new']['domain'].' - DKIM is not enabled for the domain.',LOGLEVEL_ERROR);
        }
    }
    /*
        This function controlls the removement of keyfiles (public and private)
        and the entry in the amavisd-config
@@ -227,12 +227,12 @@
    function domain_dkim_delete($event_name,$data) {
        if (isset($data['old']['dkim']) && $data['old']['dkim'] == 'y') $this->remove_dkim($data['old']);
    }
    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 domain_dkim_insert($event_name,$data) {
        if (isset($data['new']['dkim']) && $data['new']['dkim']=='y' && $this->check_system($data)) {
            $this->add_dkim($data);
        }
    }
    function domain_dkim_update($event_name,$data) {
        global $app;