Skip to content

Commit 1324b80

Browse files
author
Marius Cramer
committed
Merge branch 'master' of /home/git/repositories/florian030/ispconfig3
2 parents f18ff11 + 18f479a commit 1324b80

File tree

11 files changed

+106
-72
lines changed

11 files changed

+106
-72
lines changed

interface/web/dns/dns_dkim_edit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function onShowNew() {
5757
if($_SESSION["s"]["user"]["typ"] == 'user') {
5858

5959
// Get the limits of the client
60-
$client_group_id = $_SESSION["s"]["user"]["default_group"];
60+
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
6161
$client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
6262

6363
// Check if the user may add another record.
@@ -82,7 +82,7 @@ function onSubmit() {
8282
// Check the client limits, if user is not the admin
8383
if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin
8484
// Get the limits of the client
85-
$client_group_id = $_SESSION["s"]["user"]["default_group"];
85+
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
8686
$client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
8787
// Check if the user may add another record.
8888
if($this->id == 0 && $client["limit_dns_record"] >= 0) {

interface/web/dns/dns_soa_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function onShowEnd() {
117117
}
118118
$app->tpl->setVar("client_group_id", $client_select);
119119

120-
}
120+
// }
121121

122122
if($_SESSION["s"]["user"]["typ"] != 'admin')
123123
{

interface/web/dns/dns_wizard.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@
120120
}
121121

122122
if($_SESSION["s"]["user"]["typ"] != 'admin')
123-
{
124-
$client_group_id = $_SESSION["s"]["user"]["default_group"];
123+
124+
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);{
125125
$client_dns = $app->db->queryOneRecord("SELECT dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
126126

127127
$client_dns['dns_servers_ids'] = explode(',', $client_dns['dns_servers']);
@@ -163,7 +163,7 @@
163163

164164
if ($post_server_id)
165165
{
166-
$client_group_id = $_SESSION["s"]["user"]["default_group"];
166+
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
167167
$client = $app->db->queryOneRecord("SELECT dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
168168

169169
$client['dns_servers_ids'] = explode(',', $client['dns_servers']);

interface/web/js/mail_domain_dkim.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ This Javascript is invoked by
6060
else {
6161
document.getElementsByName('dkim_private')[0].value = request.responseXML.getElementsByTagName('privatekey')[0].firstChild.nodeValue;
6262
document.getElementsByName('dkim_public')[0].value = request.responseXML.getElementsByTagName('publickey')[0].firstChild.nodeValue;
63+
document.getElementsByName('dns_record')[0].value = request.responseXML.getElementsByTagName('dns_record')[0].firstChild.nodeValue;
6364
}
6465
break;
6566
default:

interface/web/mail/mail_domain_dkim_create.php

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
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+
*/
3031

31-
This script is invoked by interface/js/mail_domain_dkim.js
32-
to generate or show the DKIM Private-key and to show the Private-key.
33-
returns DKIM Private-Key and DKIM Public-Key
34-
*/
32+
/**
33+
* This script is invoked by interface/js/mail_domain_dkim.js
34+
* to generate or show the DKIM Private-key and to show the Private-key.
35+
* returns DKIM Private-Key and DKIM Public-Key
36+
*/
3537

3638

3739
require_once '../../lib/config.inc.php';
@@ -46,7 +48,6 @@
4648
header('Content-Type: text/xml; charset=utf-8');
4749
header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0');
4850

49-
5051
/**
5152
* This function fix PHP's messing up POST input containing characters space, dot,
5253
* open square bracket and others to be compatible with with the deprecated register_globals
@@ -64,7 +65,6 @@ function getRealPOST() {
6465
return $vars;
6566
}
6667

67-
6868
/**
6969
* This function formats the public-key
7070
* @param array $pubkey
@@ -76,32 +76,39 @@ function pub_key($pubkey) {
7676
return $public_key;
7777
}
7878

79+
function get_public_key($private_key) {
80+
require_once('../../lib/classes/validate_dkim.inc.php');
81+
$validate_dkim=new validate_dkim ();
82+
if($validate_dkim->validate_post('private',$private_key)) { /* validate the $_POST-value */
83+
exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM',$pubkey,$result);
84+
$public_key=pub_key($pubkey);
85+
} else {
86+
$public_key='invalid key';
87+
}
88+
return $public_key;
89+
}
90+
7991
$_POST=getRealPOST();
8092

8193
switch ($_POST['action']) {
82-
case 'create': /* create DKIM Private-key */
83-
exec('openssl rand -out /usr/local/ispconfig/server/temp/random-data.bin 4096', $output, $result);
84-
exec('openssl genrsa -rand /usr/local/ispconfig/server/temp/random-data.bin 1024', $privkey, $result);
85-
unlink("/usr/local/ispconfig/server/temp/random-data.bin");
86-
$private_key='';
87-
foreach($privkey as $values) $private_key=$private_key.$values."\n";
88-
if($validate_dkim->validate_post('private', $private_key)) { /* validate the $_POST-value */
89-
exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM', $pubkey, $result);
90-
$public_key=pub_key($pubkey);
91-
} else { $public_key='invalid key'; }
94+
case 'create': /* create DKIM Private-key */
95+
exec('openssl rand -out /usr/local/ispconfig/server/temp/random-data.bin 4096', $output, $result);
96+
exec('openssl genrsa -rand /usr/local/ispconfig/server/temp/random-data.bin 1024', $privkey, $result);
97+
unlink("/usr/local/ispconfig/server/temp/random-data.bin");
98+
$private_key='';
9299
break;
93-
case 'show': /* show the DNS-Record onLoad */
94-
$private_key=$_POST['pkey'];
95-
if($validate_dkim->validate_post('private', $private_key)) { /* validate the $_POST-value */
96-
/* get the public-key */
97-
exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM', $pubkey, $result);
98-
$public_key=pub_key($pubkey);
99-
} else { $public_key='invalid key'; }
100+
101+
case 'show': /* show the DNS-Record onLoad */
102+
$private_key=$_POST['pkey'];
100103
break;
101104
}
105+
106+
$public_key=get_public_key($private_key);
107+
$dns_record=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$public_key);
102108
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
103109
echo "<formatname>\n";
104110
echo "<privatekey>".$private_key."</privatekey>\n";
105111
echo "<publickey>".$public_key."</publickey>\n";
112+
echo "<dns_record>v=DKIM1; t=s; p=".$dns_record."</dns_record>\n";
106113
echo "</formatname>\n";
107114
?>

interface/web/mail/templates/mail_domain_edit.htm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ <h2><tmpl_var name="list_head_txt"></h2>
9393
</div>
9494
<div class="ctrlHolder">
9595
<textarea name="dkim_public" style="display:none;" id="dkim_public" rows='5' cols='30' readonly>{tmpl_var name='dkim_public'}</textarea>
96-
<!--
97-
<label for="dkim_public">{tmpl_var name='dkim_dns_txt'}</label>
98-
<textarea name="dkim_public" id="dkim_public" rows='5' cols='30' readonly>{tmpl_var name='dkim_public'}</textarea>
99-
-->
96+
</div>
97+
<div class="ctrlHolder">
98+
<label for="dns_record">{tmpl_var name='dkim_dns_txt'}</label>
99+
<textarea name="dns_record" id="dns_record" rows='10' cols='30' readonly>{tmpl_var name='dns_record'}</textarea>
100100
</div>
101101

102102
</div>

interface/web/tools/lib/lang/de_resync.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ $wb['resync_shell_txt'] = 'Shell Benutzer';
77
$wb['resync_cron_txt'] = 'Cronjobs';
88
$wb['resync_db_txt'] = 'Datenbanken';
99
$wb['resync_mailbox_txt'] = 'E-Mail Konten';
10+
$wb['resync_dkim_txt'] = 'DKIM-Keys';
1011
$wb['resync_dns_txt'] = 'DNS Einträge';
1112
$wb['btn_start_txt'] = 'Start';
1213
$wb['btn_cancel_txt'] = 'Zurück';

interface/web/tools/lib/lang/en_resync.lng

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ $wb['resync_shell_txt'] = 'Resync shell users';
77
$wb['resync_cron_txt'] = 'Resync cronjobs';
88
$wb['resync_db_txt'] = 'Resync clientdb config';
99
$wb['resync_mailbox_txt'] = 'Resync Mailboxes';
10+
$wb['resync_dkim_txt'] = 'Resync DKIM-Keys';
1011
$wb['resync_dns_txt'] = 'Resync DNS records';
1112
$wb['btn_start_txt'] = 'Start';
1213
$wb['btn_cancel_txt'] = 'Cancel';
13-
?>
14+
?>

interface/web/tools/resync.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@
146146
}
147147
}
148148

149+
//* Resyncing DKIM-Keys
150+
if(isset($_POST['resync_dkim']) && $_POST['resync_dkim'] == 1) {
151+
$db_table = 'mail_domain';
152+
$index_field = 'domain_id';
153+
$sql = "SELECT * FROM ".$db_table." WHERE active = 'y' AND dkim = 'y'";
154+
$records = $app->db->queryAllRecords($sql);
155+
if(is_array($records)) {
156+
foreach($records as $rec) {
157+
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true);
158+
$msg .= "Resynced DKIM-Key: ".$rec['domain'].'<br />';
159+
}
160+
}
161+
}
162+
149163
//* Resyncing dns zones
150164
if(isset($_POST['resync_dns']) && $_POST['resync_dns'] == 1) {
151165
$zones = $app->db->queryAllRecords("SELECT id,origin,serial FROM dns_soa WHERE active = 'Y'");

interface/web/tools/templates/resync.htm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ <h2><tmpl_var name="head_txt"></h2>
4141
<input id="resync_mailbox" type="checkbox" value="1" name="resync_mailbox" />
4242
</div>
4343
</div>
44+
<div class="ctrlHolder">
45+
<p class="label">{tmpl_var name="resync_dkim_txt"}</p>
46+
<div class="multiField">
47+
<input id="resync_dkim" type="checkbox" value="1" name="resync_dkim" />
48+
</div>
49+
</div>
4450
<div class="ctrlHolder">
4551
<p class="label">{tmpl_var name="resync_dns_txt"}</p>
4652
<div class="multiField">

0 commit comments

Comments
 (0)