Skip to content

Commit b533b41

Browse files
author
Marius Cramer
committed
Merge remote-tracking branch 'florian030/master'
Conflicts: interface/lib/classes/validate_dkim.inc.php interface/web/dns/dns_dkim_edit.php interface/web/dns/dns_dkim_get.php interface/web/dns/dns_wizard.php interface/web/dns/form/dns_dkim.tform.php interface/web/dns/lib/lang/en_dns_dkim.lng interface/web/dns/templates/dns_dkim_edit.htm interface/web/js/dns_dkim.js interface/web/js/mail_domain_dkim.js interface/web/mail/mail_domain_dkim_create.php
2 parents 05beae4 + b9ea02c commit b533b41

File tree

16 files changed

+781
-725
lines changed

16 files changed

+781
-725
lines changed

install/dist/lib/opensuse.lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ function configure_postfix($options = '')
265265
$command = 'chmod 755 /var/run/authdaemon.courier-imap';
266266
caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
267267

268-
//* Changing maildrop lines in posfix master.cf
268+
//* Changing maildrop lines in posfix master.cf
269269
if(is_file($config_dir.'/master.cf')){
270270
copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
271271
}
Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/*
3+
/**
44
Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh
55
Copyright (c) 2013, Florian Schaal, info@schaal-24.de
66
All rights reserved.
@@ -27,6 +27,9 @@
2727
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2828
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2929
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
@author Florian Schaal, info@schaal-24.de
32+
@copyrighth Florian Schaal, info@schaal-24.de
3033
*/
3134

3235
class validate_dkim {
@@ -39,41 +42,52 @@ function get_error($errmsg) {
3942
return $errmsg."<br>\r\n";
4043
}
4144
}
42-
43-
/* Validator function for private DKIM-Key */
45+
46+
/**
47+
* Validator function for private DKIM-Key
48+
*/
4449
function check_private_key($field_name, $field_value, $validator) {
45-
$dkim_enabled=$_POST['dkim'];
46-
if ($dkim_enabled == 'y') {
47-
if (empty($field_value)) return $this->get_error($validator['errmsg']);
48-
exec('echo '.escapeshellarg($field_value).'|openssl rsa -check',$output,$result);
49-
if($result != 0) return $this->get_error($validator['errmsg']);
50-
}
51-
}
50+
$dkim_enabled=$_POST['dkim'];
51+
if ($dkim_enabled == 'y') {
52+
if (empty($field_value)) return $this->get_error($validator['errmsg']);
53+
exec('echo '.escapeshellarg($field_value).'|openssl rsa -check',$output,$result);
54+
if($result != 0) return $this->get_error($validator['errmsg']);
55+
}
56+
}
5257

53-
/* Validator function for DKIM Path */
58+
/**
59+
* Validator function for DKIM Path
60+
* @return boolean - true when the dkim-path exists and is writeable
61+
*/
5462
function check_dkim_path($field_name, $field_value, $validator) {
5563
if(empty($field_value)) return $this->get_error($validator['errmsg']);
5664
if (substr(sprintf('%o', fileperms($field_value)),-3) <= 600)
57-
return $this->get_error($validator['errmsg']);
58-
}
59-
60-
/* Check function for DNS-Template */
61-
function check_template($field_name, $field_value, $validator) {
62-
$dkim=false;
63-
foreach($field_value as $field ) { if($field == 'DKIM') $dkim=true; }
64-
if ($dkim && $field_value[0]!='DOMAIN') return $this->get_error($validator['errmsg']);
65-
}
66-
67-
/* Validator function for $_POST */
68-
function validate_post($key,$value) {
69-
switch ($key) {
70-
case 'public':
71-
if (preg_match("/(^-----BEGIN PUBLIC KEY-----)[a-zA-Z0-9\r\n\/\+=]{1,221}(-----END PUBLIC KEY-----(\n|\r)$)/",$value) === 1) { return true; } else { return false; }
72-
break;
73-
case 'private':
74-
if (preg_match("/(^-----BEGIN RSA PRIVATE KEY-----)[a-zA-Z0-9\r\n\/\+=]{1,850}(-----END RSA PRIVATE KEY-----(\n|\r)$)/",$value) === 1) { return true; } else { return false; }
75-
break;
76-
}
77-
}
78-
}
79-
65+
return $this->get_error($validator['errmsg']);
66+
}
67+
68+
/**
69+
* Check function for DNS-Template
70+
*/
71+
function check_template($field_name, $field_value, $validator) {
72+
$dkim=false;
73+
foreach($field_value as $field ) { if($field == 'DKIM') $dkim=true; }
74+
if ($dkim && $field_value[0]!='DOMAIN') return $this->get_error($validator['errmsg']);
75+
}
76+
77+
/**
78+
* Validator function for $_POST
79+
*
80+
* @return boolean - true if $POST contains a real key-file
81+
*/
82+
function validate_post($key,$value) {
83+
switch ($key) {
84+
case 'public':
85+
if (preg_match("/(^-----BEGIN PUBLIC KEY-----)[a-zA-Z0-9\r\n\/\+=]{1,221}(-----END PUBLIC KEY-----(\n|\r)$)/",$value) === 1) { return true; } else { return false; }
86+
break;
87+
case 'private':
88+
if (preg_match("/(^-----BEGIN RSA PRIVATE KEY-----)[a-zA-Z0-9\r\n\/\+=]{1,850}(-----END RSA PRIVATE KEY-----(\n|\r)$)/",$value) === 1) { return true; } else { return false; }
89+
break;
90+
}
91+
}
92+
}
93+

interface/web/admin/form/server_config.tform.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@
280280
'formtype' => 'TEXT',
281281
'default' => '/var/lib/amavis/dkim',
282282
'validators' => array ( 0 => array ('type' => 'CUSTOM',
283-
'class' => 'validate_dkim',
284-
'function' => 'check_dkim_path',
285-
'errmsg'=> 'dkim_path_error'),
286-
),
283+
'class' => 'validate_dkim',
284+
'function' => 'check_dkim_path',
285+
'errmsg'=> 'dkim_path_error'),
286+
),
287287
'value' => '',
288288
'width' => '40',
289289
'maxlength' => '255'

interface/web/admin/lib/lang/de_server_config.lng

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ $wb['fastcgi_bin_txt'] = 'FastCGI Bin';
1919
$wb['module_txt'] = 'Modul';
2020
$wb['maildir_path_txt'] = 'Maildir Pfad';
2121
$wb['homedir_path_txt'] = 'Homedir Pfad';
22-
$wb["dkim_path_txt"] = 'DKIM Pfad';
23-
$wb["dkim_path_error"] = 'DKIM Pfad nicht gefunden oder nicht beschreibbar.';
22+
$wb['dkim_path_txt'] = 'DKIM Pfad';
23+
$wb['dkim_path_error'] = 'DKIM Pfad nicht gefunden oder nicht beschreibbar.';
2424
$wb['mailuser_uid_txt'] = 'Mailbenutzer UID';
2525
$wb['mailuser_gid_txt'] = 'Mailbenutzer GID';
2626
$wb['mailuser_name_txt'] = 'Mailbenutzer Name';

0 commit comments

Comments
 (0)