Skip to content

Commit 6a0796e

Browse files
author
Marius Burkard
committed
Merge branch 'stable-3.1'
2 parents 89e4437 + b0f89e5 commit 6a0796e

File tree

255 files changed

+296
-328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+296
-328
lines changed

install/install.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,9 @@
559559

560560
//** Customise the port ISPConfig runs on
561561
$ispconfig_vhost_port = $inst->free_query('ISPConfig Port', '8080','ispconfig_port');
562-
$conf['interface_password'] = $inst->free_query('Admin password', 'admin','ispconfig_admin_password');
563-
if(!AUTOINSTALL && $conf['interface_password'] != 'admin') {
562+
$temp_admin_password = str_shuffle(bin2hex(openssl_random_pseudo_bytes(4)));
563+
$conf['interface_password'] = $inst->free_query('Admin password', $temp_admin_password, 'ispconfig_admin_password');
564+
if($conf['interface_password'] != $temp_admin_password) {
564565
$check = false;
565566
do {
566567
unset($temp_password);
@@ -571,6 +572,7 @@
571572
}
572573
unset($check);
573574
unset($temp_password);
575+
unset($temp_admin_password);
574576
if($conf['apache']['installed'] == true) $conf['apache']['vhost_port'] = $ispconfig_vhost_port;
575577
if($conf['nginx']['installed'] == true) $conf['nginx']['vhost_port'] = $ispconfig_vhost_port;
576578
unset($ispconfig_vhost_port);

install/sql/incremental/upd_dev_collection.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<<<<<<< HEAD
12
ALTER TABLE `mail_mailinglist` ADD `list_type` enum('open','closed') NOT NULL DEFAULT 'open';
23
ALTER TABLE `mail_mailinglist` ADD `subject_prefix` varchar(50) NOT NULL DEFAULT '';
34
ALTER TABLE `mail_mailinglist` ADD `admins` mediumtext;
@@ -86,4 +87,7 @@ INSERT IGNORE INTO `dns_ssl_ca` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_us
8687
(NULL, 1, 1, 'riud', 'riud', '', 'Y', 'WISeKey', 'wisekey.com', 'Y', '', 0),
8788
(NULL, 1, 1, 'riud', 'riud', '', 'Y', 'WoSign', 'wosign.com', 'Y', '', 0);
8889

89-
ALTER TABLE `dns_rr` CHANGE `type` `type` ENUM('A','AAAA','ALIAS','CAA','CNAME','DS','HINFO','LOC','MX','NAPTR','NS','PTR','RP','SRV','TXT','TLSA','DNSKEY') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
90+
ALTER TABLE `dns_rr` CHANGE `type` `type` ENUM('A','AAAA','ALIAS','CAA','CNAME','DS','HINFO','LOC','MX','NAPTR','NS','PTR','RP','SRV','TXT','TLSA','DNSKEY') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
91+
ALTER TABLE `web_domain` ADD COLUMN `ssl_letsencrypt_exclude` enum('n','y') NOT NULL DEFAULT 'n' AFTER `ssl_letsencrypt`;
92+
ALTER TABLE `remote_user` ADD `remote_access` ENUM('y','n') NOT NULL DEFAULT 'y' AFTER `remote_password`;
93+
ALTER TABLE `remote_user` ADD `remote_ips` TEXT AFTER `remote_access`;

install/sql/ispconfig3.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,8 @@ CREATE TABLE `remote_user` (
13301330
`sys_perm_other` varchar(5) default NULL,
13311331
`remote_username` varchar(64) NOT NULL DEFAULT '',
13321332
`remote_password` varchar(64) NOT NULL DEFAULT '',
1333+
`remote_access` enum('y','n') NOT NULL DEFAULT 'y',
1334+
`remote_ips` TEXT,
13331335
`remote_functions` text,
13341336
PRIMARY KEY (`remote_userid`)
13351337
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
@@ -2029,6 +2031,7 @@ CREATE TABLE `web_domain` (
20292031
`rewrite_to_https` ENUM('y','n') NOT NULL DEFAULT 'n',
20302032
`ssl` enum('n','y') NOT NULL default 'n',
20312033
`ssl_letsencrypt` enum('n','y') NOT NULL DEFAULT 'n',
2034+
`ssl_letsencrypt_exclude` enum('n','y') NOT NULL DEFAULT 'n',
20322035
`ssl_state` varchar(255) NULL,
20332036
`ssl_locality` varchar(255) NULL,
20342037
`ssl_organisation` varchar(255) NULL,

interface/lib/classes/listform.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ public function encode($record)
583583
break;
584584

585585
case 'CURRENCY':
586-
$record[$key] = str_replace(',', '.', $record[$key]);
586+
$record[$key] = $app->functions->currency_unformat($record[$key]);
587587
break;
588588

589589
case 'BOOLEAN':

interface/lib/classes/remoting.inc.php

Lines changed: 57 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,30 @@ public function login($username, $password, $client_login = false)
7777
$app->uses('ini_parser,getconf');
7878
$server_config_array = $app->getconf->get_global_config('misc');
7979
if($server_config_array['maintenance_mode'] == 'y'){
80-
throw new SoapFault('maintenance_mode', 'This ISPConfig installation is currently under maintenance. We should be back shortly. Thank you for your patience.');
81-
return false;
82-
}
83-
84-
if(empty($username)) {
85-
$error = array('faultcode' => 'login_username_empty', 'faultstring' => 'The login username is empty.');
86-
}
80+
$error = array('faultcode' => 'maintenance_mode', 'faultstring' => 'This ISPConfig installation is currently under maintenance. We should be back shortly. Thank you for your patience.');
81+
} else {
82+
if(empty($username)) {
83+
$error = array('faultcode' => 'login_username_empty', 'faultstring' => 'The login username is empty.');
84+
}
8785

88-
if(empty($password)) {
89-
$error = array('faultcode' => 'login_password_empty', 'faultstring' => 'The login password is empty.');
90-
}
86+
if(empty($password)) {
87+
$error = array('faultcode' => 'login_password_empty', 'faultstring' => 'The login password is empty.');
88+
}
9189

92-
//* Delete old remoting sessions
93-
$sql = "DELETE FROM remote_session WHERE tstamp < UNIX_TIMESTAMP()";
94-
$app->db->query($sql);
90+
//* Delete old remoting sessions
91+
$sql = "DELETE FROM remote_session WHERE tstamp < UNIX_TIMESTAMP()";
92+
$app->db->query($sql);
9593

96-
$ip = md5($_SERVER['REMOTE_ADDR']);
97-
$sql = "SELECT * FROM `attempts_login` WHERE `ip`= ? AND `login_time` > (NOW() - INTERVAL 1 MINUTE) LIMIT 1";
98-
$alreadyfailed = $app->db->queryOneRecord($sql, $ip);
94+
$ip = md5($_SERVER['REMOTE_ADDR']);
95+
$sql = "SELECT * FROM `attempts_login` WHERE `ip`= ? AND `login_time` > (NOW() - INTERVAL 1 MINUTE) LIMIT 1";
96+
$alreadyfailed = $app->db->queryOneRecord($sql, $ip);
9997

100-
if($alreadyfailed['times'] > 5) {
101-
throw new SoapFault('error_user_too_many_logins', 'Too many failed logins');
102-
return false;
98+
if($alreadyfailed['times'] > 5) {
99+
$error = array('faultcode' => 'error_user_too_many_logins', 'faultstring' => 'Too many failed logins.');
100+
}
103101
}
104102

105103
if (empty($error)) {
106-
107104
if($client_login == true) {
108105
$sql = "SELECT * FROM sys_user WHERE USERNAME = ?";
109106
$user = $app->db->queryOneRecord($sql, $username);
@@ -135,20 +132,50 @@ public function login($username, $password, $client_login = false)
135132
if(!$client || $client['can_use_api'] != 'y') {
136133
$error = array('faultcode' => 'client_login_failed', 'faultstring' => 'The login failed. Client may not use api.');
137134
}
138-
139-
//* Create a remote user session
140-
//srand ((double)microtime()*1000000);
141-
$remote_session = md5(mt_rand().uniqid('ispco'));
142-
$remote_userid = $remote_user['remote_userid'];
143-
$remote_functions = $remote_user['remote_functions'];
144-
$tstamp = time() + $this->session_timeout;
145-
$sql = 'INSERT INTO remote_session (remote_session,remote_userid,remote_functions,tstamp'
146-
.') VALUES (?, ?, ?, ?)';
147-
$app->db->query($sql, $remote_session,$remote_userid,$remote_functions,$tstamp);
148135
} else {
149136
$sql = "SELECT * FROM remote_user WHERE remote_username = ? and remote_password = md5(?)";
150137
$remote_user = $app->db->queryOneRecord($sql, $username, $password);
151138
if($remote_user['remote_userid'] > 0) {
139+
$allowed_ips = explode(',',$remote_user['remote_ips']);
140+
foreach($allowed_ips as $i => $allowed) {
141+
if(!filter_var($allowed, FILTER_VALIDATE_IP)) {
142+
// get the ip for a hostname
143+
unset($allowed_ips[$i]);
144+
$temp=dns_get_record($allowed, DNS_A+DNS_AAAA);
145+
foreach($temp as $t) {
146+
if(isset($t['ip'])) $allowed_ips[] = $t['ip'];
147+
if(isset($t['ipv6'])) $allowed_ips[] = $t['ipv6'];
148+
}
149+
unset($temp);
150+
}
151+
}
152+
$allowed_ips[] = '127.0.0.1';
153+
$allowed_ips[] = '::1';
154+
$allowed_ips=array_unique($allowed_ips);
155+
$ip = $_SERVER['REMOTE_ADDR'];
156+
$remote_allowed = @($ip == '::1' || $ip == '127.0.0.1')?true:false;
157+
if(!$remote_allowed && $remote_user['remote_access'] == 'y') {
158+
if(trim($remote_user['remote_ips']) == '') {
159+
$remote_allowed=true;
160+
} else {
161+
$ip = inet_pton($_SERVER['REMOTE_ADDR']);
162+
foreach($allowed_ips as $allowed) {
163+
if($ip == inet_pton(trim($allowed))) {
164+
$remote_allowed=true;
165+
break;
166+
}
167+
}
168+
}
169+
}
170+
if(!$remote_allowed) {
171+
$error = array('faultcode' => 'login_failed', 'faultstring' => 'The login is not allowed from '.$_SERVER['REMOTE_ADDR']);
172+
}
173+
} else {
174+
$error = array('faultcode' => 'client_login_failed', 'faultstring' => 'The login failed. Username or password wrong.');
175+
}
176+
}
177+
178+
if(empty($error) && isset($remote_user['remote_userid'])) {
152179
//* Create a remote user session
153180
//srand ((double)microtime()*1000000);
154181
$remote_session = md5(mt_rand().uniqid('ispco'));
@@ -158,13 +185,9 @@ public function login($username, $password, $client_login = false)
158185
$sql = 'INSERT INTO remote_session (remote_session,remote_userid,remote_functions,tstamp'
159186
.') VALUES (?, ?, ?, ?)';
160187
$app->db->query($sql, $remote_session,$remote_userid,$remote_functions,$tstamp);
161-
} else {
162-
$error = array('faultcode' => 'login_failed', 'faultstring' => 'The login failed. Username or password wrong.');
163188
}
164189
}
165190

166-
}
167-
168191
if (! empty($error)) {
169192
if(! $alreadyfailed['times']) {
170193
//* user login the first time wrong

interface/lib/classes/tform_base.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ protected function _encode($record, $tab, $dbencode = true, $api = false) {
808808
$new_record[$key] = $record[$key];
809809
break;
810810
case 'CURRENCY':
811-
$new_record[$key] = str_replace(",", ".", $record[$key]);
811+
$new_record[$key] = $app->functions->currency_unformat($record[$key]);
812812
break;
813813

814814
case 'DATETIME':
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2017, Florian Schaal , schaal @it UG
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
class validate_remote_user {
32+
33+
function valid_remote_ip($field_name, $field_value, $validator) {
34+
global $app;
35+
36+
if(trim($field_value) == '') return;
37+
38+
$values = explode(',', $field_value);
39+
$regex = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/';
40+
foreach($values as $cur_value) {
41+
$cur_value = trim($cur_value);
42+
$valid = true;
43+
if(function_exists('filter_var')) {
44+
if(!filter_var($cur_value, FILTER_VALIDATE_IP)) {
45+
$valid = false;
46+
if(preg_match($regex, $cur_value)) $valid = true;
47+
}
48+
} else return "function filter_var missing <br />\r\n";
49+
50+
if($valid == false) {
51+
$errmsg = $validator['errmsg'];
52+
if(isset($app->tform->wordbook[$errmsg])) {
53+
return $app->tform->wordbook[$errmsg]."<br>\r\n";
54+
} else {
55+
return $errmsg."<br>\r\n";
56+
}
57+
}
58+
}
59+
}
60+
61+
}

interface/lib/classes/validate_server.inc.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@ function get_error($errmsg) {
4646
* Validator function for server-ip
4747
*/
4848
function check_server_ip($field_name, $field_value, $validator) {
49-
if($_POST['ip_type'] == 'IPv4') {
49+
global $app;
50+
51+
$type=(isset($app->remoting_lib->dataRecord['ip_type']))?$app->remoting_lib->dataRecord['ip_type']:$_POST['ip_type'];
52+
53+
if($type == 'IPv4') {
5054
if(!filter_var($field_value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
5155
return $this->get_error($validator['errmsg']);
5256
}
53-
} elseif ($_POST['ip_type'] == 'IPv6') {
57+
} elseif ($type == 'IPv6') {
5458
if(!filter_var($field_value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
5559
return $this->get_error($validator['errmsg']);
5660
}

interface/lib/lang/br.lng

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $wb['top_menu_billing'] = 'Faturas';
3939
$wb['top_menu_domain'] = 'Domínios';
4040
$wb['top_menu_dashboard'] = 'Início';
4141
$wb['latest_news_txt'] = 'Últimas notícias';
42-
$wb['top_menu_vm'] = 'VM';
42+
$wb['top_menu_vm'] = 'VPS';
4343
$wb['daynamesmin_su'] = 'Do';
4444
$wb['daynamesmin_mo'] = 'Se';
4545
$wb['daynamesmin_tu'] = 'Te';
@@ -160,4 +160,3 @@ $wb['datalog_status_i_xmpp_user'] = 'Adicionar usuário XMPP';
160160
$wb['datalog_status_u_xmpp_user'] = 'Atualizar usuário XMPP';
161161
$wb['datalog_status_d_xmpp_user'] = 'Remover usuário XMPP';
162162
?>
163-

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,27 @@
115115
'width' => '30',
116116
'maxlength' => '255'
117117
),
118+
'remote_access' => array (
119+
'datatype' => 'VARCHAR',
120+
'formtype' => 'CHECKBOX',
121+
'default' => 'n',
122+
'value' => array(0 => 'n', 1 => 'y')
123+
),
124+
'remote_ips' => array (
125+
'datatype' => 'TEXT',
126+
'formtype' => 'TEXT',
127+
'validators' => array (
128+
0 => array (
129+
'type' => 'CUSTOM',
130+
'class' => 'validate_remote_user',
131+
'function' => 'valid_remote_ip',
132+
'errmsg' => 'remote_user_error_ips'),
133+
),
134+
'default' => '',
135+
'value' => '',
136+
'width' => '60',
137+
'searchable' => 2
138+
),
118139
'remote_functions' => array (
119140
'datatype' => 'TEXT',
120141
'formtype' => 'CHECKBOXARRAY',

0 commit comments

Comments
 (0)