Marius Cramer
2014-10-31 c28bb43232ab64cd17fc359fc482fc274974822f
Merge branch 'master' of git.ispconfig.org:ispconfig/ispconfig3
11 files modified
126 ■■■■■ changed files
install/dist/lib/debian60.lib.php 2 ●●● patch | view | raw | blame | history
install/dist/lib/fedora.lib.php 2 ●●● patch | view | raw | blame | history
install/dist/lib/gentoo.lib.php 2 ●●● patch | view | raw | blame | history
install/dist/lib/opensuse.lib.php 2 ●●● patch | view | raw | blame | history
install/lib/installer_base.lib.php 2 ●●● patch | view | raw | blame | history
interface/web/js/mail_domain_dkim.js 90 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_domain_dkim_create.php 1 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_domain_edit.php 3 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_domain_edit.htm 9 ●●●● patch | view | raw | blame | history
interface/web/tools/resync_do.php 2 ●●● patch | view | raw | blame | history
server/plugins-available/mail_plugin_dkim.inc.php 11 ●●●● patch | view | raw | blame | history
install/dist/lib/debian60.lib.php
@@ -38,7 +38,7 @@
        
        // check if virtual_transport must be changed
        if ($this->is_update) {
            $tmp = $inst->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
            $tmp = $this->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
            $ini_array = ini_to_array(stripslashes($tmp['config']));
            // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni()
            
install/dist/lib/fedora.lib.php
@@ -385,7 +385,7 @@
        
        // check if virtual_transport must be changed
        if ($this->is_update) {
            $tmp = $inst->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
            $tmp = $this->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
            $ini_array = ini_to_array(stripslashes($tmp['config']));
            // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni()
            
install/dist/lib/gentoo.lib.php
@@ -229,7 +229,7 @@
        
        // check if virtual_transport must be changed
        if ($this->is_update) {
            $tmp = $inst->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
            $tmp = $this->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
            $ini_array = ini_to_array(stripslashes($tmp['config']));
            // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni()
            
install/dist/lib/opensuse.lib.php
@@ -440,7 +440,7 @@
        
        // check if virtual_transport must be changed
        if ($this->is_update) {
            $tmp = $inst->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
            $tmp = $this->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
            $ini_array = ini_to_array(stripslashes($tmp['config']));
            // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni()
            
install/lib/installer_base.lib.php
@@ -961,7 +961,7 @@
        
        // check if virtual_transport must be changed
        if ($this->is_update) {
            $tmp = $inst->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
            $tmp = $this->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
            $ini_array = ini_to_array(stripslashes($tmp['config']));
            // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni()
            
interface/web/js/mail_domain_dkim.js
@@ -31,49 +31,65 @@
This Javascript is invoked by
    * mail/templates/mail_domain_edit.htm to show and/or create the key-pair
*/
var request = false;
$('.subsectiontoggle').on('click', function(){
    $(this).children().toggleClass('showing').end().next().slideToggle();
});
function setRequest(action) {
    if (window.XMLHttpRequest) {
        request = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (e) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e) {}
        }
    }
        var request = false;
    if (!request) {
        alert("Error creating XMLHTTP-instance");
        return false;
    } else {
        // jQuery depends on domain-module active / inactive
        var check = jQuery('#domain_module').val();
        if ( check == "1" ) {
            var skillsSelect = document.getElementById("domain");
            var domain = skillsSelect.options[skillsSelect.selectedIndex].text;
        } else {
            var domain = jQuery('#domain').val();
        }
        var selector=jQuery('#dkim_selector').val();
        var publickey=jQuery('#dkim_public').val();
        var privatekey=encodeURIComponent(document.getElementById("dkim_private").value)
        request.open('POST', 'mail/mail_domain_dkim_create.php', true);
        request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        request.send('domain='+domain+'&action='+action+'&dkim_selector='+selector+'&dkim_public='+publickey+'&dkim_private='+privatekey);
        request.onreadystatechange = interpretRequest;
    }
}
        function setRequest(action,value,privatekey) {
                if (window.XMLHttpRequest) {request = new XMLHttpRequest();}
                else if (window.ActiveXObject) {
                        try {request = new ActiveXObject('Msxml2.XMLHTTP');}
                        catch (e) {
                                try {request = new ActiveXObject('Microsoft.XMLHTTP');}
                                catch (e) {}
                        }
                }
                if (!request) {
                        alert("Error creating XMLHTTP-instance");
                        return false;
                } else {
                        request.open('POST', 'mail/mail_domain_dkim_create.php', true);
                        request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                        request.send('domain='+value+'&action='+action+'&pkey='+privatekey);
                        request.onreadystatechange = interpretRequest;
                }
        }
function interpretRequest() {
    switch (request.readyState) {
        case 4:
            if ( request.status != 200 ) {
                alert("Request done but NOK\nError:"+request.status);
            } else {
                document.getElementsByName('dkim_selector')[0].value = request.responseXML.getElementsByTagName('selector')[0].firstChild.nodeValue;
                document.getElementsByName('dkim_private')[0].value = request.responseXML.getElementsByTagName('privatekey')[0].firstChild.nodeValue;
                document.getElementsByName('dkim_public')[0].value = request.responseXML.getElementsByTagName('publickey')[0].firstChild.nodeValue;
                document.getElementsByName('dns_record')[0].value = request.responseXML.getElementsByTagName('dns_record')[0].firstChild.nodeValue;
            }
        break;
        function interpretRequest() {
                switch (request.readyState) {
                        case 4:
                                if (request.status != 200) {alert("Request done but NOK\nError:"+request.status);}
                                else {
                                        document.getElementsByName('dkim_private')[0].value = request.responseXML.getElementsByTagName('privatekey')[0].firstChild.nodeValue;
                                        document.getElementsByName('dkim_public')[0].value = request.responseXML.getElementsByTagName('publickey')[0].firstChild.nodeValue;
                    document.getElementsByName('dns_record')[0].value = request.responseXML.getElementsByTagName('dns_record')[0].firstChild.nodeValue;
                                }
                                break;
                        default:
                                break;
                }
        }
        default:
        break;
    }
}
var serverType = jQuery('#dkim_private').val();
setRequest('show','{tmpl_var name="domain"}',serverType);
setRequest('show');
interface/web/mail/mail_domain_dkim_create.php
@@ -147,7 +147,6 @@
    break;
    case 'show': /* show the DNS-Record onLoad */
        $_POST=getRealPOST();
        $private_key=$_POST['dkim_private'];
    break;
}
interface/web/mail/mail_domain_edit.php
@@ -176,6 +176,9 @@
                $domain_select .= "<option value=''></option>\r\n";
            }
            $app->tpl->setVar("domain_option", $domain_select);
            $app->tpl->setVar("domain_module", 1);
        } else {
            $app->tpl->setVar("domain_module", 0);
        }
interface/web/mail/templates/mail_domain_edit.htm
@@ -82,6 +82,11 @@
                    {tmpl_var name='active'}
                </div>
            </div>
            <tmpl_if name="domain_module">
                <input type="hidden" name="domain_module" value="1" id="domain_module" />
            <tmpl_else>
                <input type="hidden" name="domain_module" value="0" id="domain_module" />
            </tmpl_if>
            <div class="subsectiontoggle"><span></span>{tmpl_var name='dkim_settings_txt'}<em></em></div>
            <div style="display:none;">
              <div class="ctrlHolder">
@@ -97,11 +102,12 @@
              <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_selector'}')">{tmpl_var name='dkim_generate_txt'}</a>
<a href="javascript:setRequest('create')">{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 class="ctrlHolder">
                <label for="dns_record">{tmpl_var name='dkim_dns_txt'}</label>
                <textarea name="dns_record" id="dns_record" rows='10' cols='30' readonly>{tmpl_var name='dns_record'}</textarea>
@@ -113,7 +119,6 @@
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
        <input type="hidden" name="type" value="local">
        <div class="buttonHolder buttons">
            <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>
interface/web/tools/resync_do.php
@@ -244,7 +244,7 @@
            $index_field = 'mailuser_id';
            $server_type = 'mail';
            $server_id = $app->functions->intval($this->dataRecord['mailbox_server_id']);
            if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type);
            if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1');
            $records = $tmp[0];
            $server_name = $tmp[1];
            unset($tmp);
server/plugins-available/mail_plugin_dkim.inc.php
@@ -117,14 +117,14 @@
            $app->log('Amavis-config not found or not writeable.', LOGLEVEL_ERROR);
            $check=false;
        }
        /* 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'] != '/' &&
                $app->system->checkpath($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);
@@ -148,6 +148,11 @@
            if (!is_writeable($mail_config['dkim_path'])) {
                $app->log('DKIM Path '.$mail_config['dkim_path'].' not writeable.', LOGLEVEL_ERROR);
                $check=false;
            }
            if ( !$app->system->checkpath($mail_config['dkim_path']) ) {
                $app->log('DKIM Path '.$mail_config['dkim_path'].' failed in checkpath.', LOGLEVEL_ERROR);
                $check = false;
            }
        } else {
@@ -184,7 +189,7 @@
     * @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
     * @return bool - true when the private key was written to disk
     */
    function write_dkim_key($key_file, $key_value, $key_domain) {
        global $app, $mailconfig;