Skip to content

Commit aef2832

Browse files
author
Marius Burkard
committed
Merge branch 'stable-3.1'
2 parents b0f818e + 9ab66a5 commit aef2832

File tree

13 files changed

+115
-52
lines changed

13 files changed

+115
-52
lines changed

install/dist/lib/gentoo.lib.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,6 @@ public function configure_powerdns()
472472
$this->error('Unable to create user for powerdns database Error: '.$this->db->errorMessage);
473473
}
474474

475-
//* Reload database privelages
476-
$this->db->query('FLUSH PRIVILEGES;');
477-
478475
//* load the powerdns databse dump
479476
if($conf['mysql']['admin_password'] == '') {
480477
caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['powerdns']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/powerdns.sql' &> /dev/null",

install/install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
}
209209

210210
//* Initialize the MySQL server connection
211-
if(@mysqli_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, $tmp_mysql_server_database, (int)$tmp_mysql_server_port)) {
211+
if(@mysqli_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, '', (int)$tmp_mysql_server_port)) {
212212
$conf['mysql']['host'] = $tmp_mysql_server_host;
213213
$conf['mysql']['port'] = $tmp_mysql_server_port;
214214
$conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user;

install/lib/installer_base.lib.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,19 +263,15 @@ public function add_database_server_record() {
263263
}
264264

265265
// Delete ISPConfig user in the local database, in case that it exists
266-
$this->db->query("DELETE FROM mysql.user WHERE User = ? AND Host = ?", $conf['mysql']['ispconfig_user'], $from_host);
267-
$this->db->query("DELETE FROM mysql.db WHERE Db = ? AND Host = ?", $conf['mysql']['database'], $from_host);
268-
$this->db->query('FLUSH PRIVILEGES');
266+
$this->db->query("DROP USER ?@?", $conf['mysql']['ispconfig_user'], $from_host);
267+
$this->db->query("DROP DATABASE IF EXISTS ?", $conf['mysql']['database']);
269268

270269
//* Create the ISPConfig database user in the local database
271270
$query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON ?? TO ?@? IDENTIFIED BY ?';
272271
if(!$this->db->query($query, $conf['mysql']['database'] . ".*", $conf['mysql']['ispconfig_user'], $from_host, $conf['mysql']['ispconfig_password'])) {
273272
$this->error('Unable to create database user: '.$conf['mysql']['ispconfig_user'].' Error: '.$this->db->errorMessage);
274273
}
275274

276-
//* Reload database privelages
277-
$this->db->query('FLUSH PRIVILEGES;');
278-
279275
//* Set the database name in the DB library
280276
$this->db->setDBName($conf['mysql']['database']);
281277

@@ -655,10 +651,6 @@ public function grant_master_database_rights($verbose = false) {
655651
}
656652
}
657653

658-
/*
659-
* It is all done. Relod the rights...
660-
*/
661-
$this->dbmaster->query('FLUSH PRIVILEGES');
662654
}
663655

664656
}
@@ -1472,9 +1464,6 @@ public function configure_powerdns() {
14721464
$this->error('Unable to create user for powerdns database Error: '.$this->db->errorMessage);
14731465
}
14741466

1475-
//* Reload database privelages
1476-
$this->db->query('FLUSH PRIVILEGES');
1477-
14781467
//* load the powerdns databse dump
14791468
if($conf['mysql']['admin_password'] == '') {
14801469
caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['powerdns']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/powerdns.sql' &> /dev/null",

install/sql/incremental/upd_dev_collection.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,7 @@ ALTER TABLE `client` ADD COLUMN `limit_ssl_letsencrypt` enum('n','y') NOT NULL D
216216
ALTER TABLE `client_template` ADD COLUMN `limit_ssl_letsencrypt` enum('n','y') NOT NULL DEFAULT 'n' AFTER `limit_ssl`;
217217
ALTER TABLE `client` ADD COLUMN `limit_directive_snippets` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n' AFTER `limit_backup`;
218218
ALTER TABLE `client_template` ADD COLUMN `limit_directive_snippets` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n' AFTER `limit_backup`;
219+
220+
ALTER TABLE `sys_user`
221+
ADD COLUMN `lost_password_hash` VARCHAR(50) NOT NULL DEFAULT '',
222+
ADD COLUMN `lost_password_reqtime` DATETIME NULL default NULL;

install/sql/ispconfig3.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,8 @@ CREATE TABLE `sys_user` (
17911791
`id_rsa` VARCHAR( 2000 ) NOT NULL default '',
17921792
`ssh_rsa` VARCHAR( 600 ) NOT NULL default '',
17931793
`lost_password_function` tinyint(1) NOT NULL default '1',
1794+
`lost_password_hash` VARCHAR(50) NOT NULL default '',
1795+
`lost_password_reqtime` DATETIME NULL default NULL,
17941796
PRIMARY KEY (`userid`)
17951797
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
17961798

install/update.php

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,28 @@
321321
if($conf['services']['mail']) {
322322

323323
//** Configure postfix
324-
if($inst->reconfigure_app('Postfix', $reconfigure_services_answer)) {
324+
if($inst->reconfigure_app('Postfix and IMAP/POP3', $reconfigure_services_answer)) {
325325
swriteln('Configuring Postfix');
326326
$inst->configure_postfix('dont-create-certs');
327+
328+
if($conf['dovecot']['installed'] == true) {
329+
//* Configure dovecot
330+
swriteln('Configuring Dovecot');
331+
$inst->configure_dovecot();
332+
} elseif ($conf['courier']['installed'] == true) {
333+
//** Configure saslauthd
334+
swriteln('Configuring SASL');
335+
$inst->configure_saslauthd();
336+
337+
//** Configure PAM
338+
swriteln('Configuring PAM');
339+
$inst->configure_pam();
340+
341+
//* Configure courier
342+
swriteln('Configuring Courier');
343+
$inst->configure_courier();
344+
}
345+
327346
}
328347

329348
//** Configure mailman
@@ -332,24 +351,6 @@
332351
$inst->configure_mailman('update');
333352
}
334353

335-
if($conf['dovecot']['installed'] == true && $inst->reconfigure_app('Dovecot', $reconfigure_services_answer)) {
336-
//* Configure dovecot
337-
swriteln('Configuring Dovecot');
338-
$inst->configure_dovecot();
339-
} elseif ($conf['courier']['installed'] == true && $inst->reconfigure_app('Courier', $reconfigure_services_answer)) {
340-
//** Configure saslauthd
341-
swriteln('Configuring SASL');
342-
$inst->configure_saslauthd();
343-
344-
//** Configure PAM
345-
swriteln('Configuring PAM');
346-
$inst->configure_pam();
347-
348-
//* Configure courier
349-
swriteln('Configuring Courier');
350-
$inst->configure_courier();
351-
}
352-
353354
//** Configure Spamasassin
354355
if($inst->reconfigure_app('Spamassassin', $reconfigure_services_answer)) {
355356
swriteln('Configuring Spamassassin');

interface/web/login/lib/lang/de.lng

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ $wb['error_user_blocked'] = 'Benutzer ist gesperrt.';
55
$wb['error_user_too_many_logins'] = 'Zu viele falsche Logins. Bitte warten Sie 15 Minuten.';
66
$wb['pass_reset_txt'] = 'Ein neues Passwort wird generiert und an die E-Mail Adresse, die in ihren Benutzereinstellungen hinterlegt ist, gesendet, wenn Ihre eingegeben E-Mail-Adresse mit der hinterlegten E-Mail-Adresse übereinstimmt.';
77
$wb['pw_reset'] = 'Das Passwort wurde zurückgesetzt und wird per E-Mail an Sie geschickt.';
8+
$wb['pw_reset_act'] = 'Ein Aktivierungslink wurde per E-Mail an Sie geschickt. Bitte bestätigen Sie die Anforderung eines neuen Passwortes.';
89
$wb['pw_error'] = 'Benutzername oder E-Mail Adresse stimmen nicht überein.';
910
$wb['pw_error_noinput'] = 'Bitte geben Sie Ihre E-Mail Adresse und Ihren Benutzernamen ein.';
1011
$wb['pw_reset_mail_msg'] = 'Das Passwort wurde zurückgesetzt. Das neue Passwort lautet: ';
11-
$wb['pw_reset_mail_title'] = 'Ihr Passwort wurde zurückgesetzt.';
12+
$wb['pw_reset_mail_title'] = 'Ihr Passwort wurde zurückgesetzt';
13+
$wb['pw_reset_act_mail_msg'] = 'Bitte bestätigen Sie die Anforderung eines neuen Passworts, indem Sie folgenden Link besuchen: ';
14+
$wb['pw_reset_act_mail_title'] = 'Anforderung zum Zurücksetzen des Passworts';
1215
$wb['user_regex_error'] = 'Benutzername beinhaltet nicht erlaubte Zeichen oder ist länger als 64 Zeichen.';
1316
$wb['pw_error_length'] = 'Die Passwortlänge ist < 1 oder > 64 Zeichen.';
1417
$wb['login_txt'] = 'Anmelden';
@@ -25,4 +28,7 @@ $wb['back_txt'] = 'Zur&uuml;ck';
2528
$wb['stay_logged_in_txt'] = 'Dauerhaft eingeloggt bleiben';
2629
$wb['email_error'] = 'Email contains unallowed characters or has a invalid format.';
2730
$wb['lost_password_function_disabled_txt'] = 'Die Passwort vergessen Funktion steht für diesen Benutzer nicht zur Verfügung.';
31+
$wb['lost_password_function_wait_txt'] = 'Sie können im Moment kein neues Passwort anfordern. Bitte warten Sie einige Minuten.';
32+
$wb['lost_password_function_expired_txt'] = 'Der Passwortlink ist abgelaufen. Bitte fordern Sie einen neuen an.';
33+
$wb['lost_password_function_denied_txt'] = 'Dieser Passwortlink ist ungültig.';
2834
?>

interface/web/login/lib/lang/en.lng

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ $wb['error_user_blocked'] = "User is blocked.";
55
$wb['error_user_too_many_logins'] = "To many wrong login's, Please retry it after 15 minutes";
66
$wb['pass_reset_txt'] = 'A new password will be generated and send to your email address if the email address entered below matches the email address in your client settings.';
77
$wb['pw_reset'] = 'The password has been reset and send to your email address.';
8+
$wb['pw_reset_act'] = 'You have been sent an activation link. Please visit the link to confirm your password request.';
89
$wb['pw_error'] = 'Username or email address does not match.';
910
$wb['pw_error_noinput'] = 'Please enter email address and username.';
1011
$wb['pw_reset_mail_msg'] = 'The password to your ISPConfig 3 control panel account has been reset. The new password is: ';
11-
$wb['pw_reset_mail_title'] = 'ISPConfig 3 Control panel password has been reset.';
12+
$wb['pw_reset_mail_title'] = 'ISPConfig 3 Control panel password has been reset';
13+
$wb['pw_reset_act_mail_title'] = 'Confirm ISPConfig 3 Control panel password reset';
14+
$wb['pw_reset_act_mail_msg'] = 'Please confirm that your want to reset your ISPConfig 3 control panel account password by visiting the following activation link: ';
1215
$wb['user_regex_error'] = 'Username contains unallowed characters or is longer than 64 characters.';
1316
$wb['pw_error_length'] = 'The password length is < 1 or > 64 characters.';
1417
$wb['email_error'] = 'Email contains unallowed characters or has a invalid format.';
@@ -25,4 +28,7 @@ $wb['error_maintenance_mode'] = 'This ISPConfig installation is currently under
2528
$wb['theme_not_compatible'] = 'The chosen theme is not compatible with the current ISPConfig version. Please check for a new version of the theme.<br />The default theme as been activated automatically.';
2629
$wb['stay_logged_in_txt'] = 'Keep me logged in';
2730
$wb['lost_password_function_disabled_txt'] = 'The lost password function is not available for this user.';
31+
$wb['lost_password_function_wait_txt'] = 'You cannot request a new password, yet. Please wait a few minutes.';
32+
$wb['lost_password_function_expired_txt'] = 'This activation link has expired. Please request a new one.';
33+
$wb['lost_password_function_denied_txt'] = 'This activation link is not valid.';
2834
?>

interface/web/login/password_reset.php

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,77 @@
4848
$continue = true;
4949

5050
if(isset($_POST['username']) && $_POST['username'] != '' && $_POST['email'] != '' && $_POST['username'] != 'admin') {
51-
5251
if(!preg_match("/^[\w\.\-\_]{1,64}$/", $_POST['username'])) {
5352
$app->tpl->setVar("error", $wb['user_regex_error']);
5453
$continue = false;
5554
}
56-
if(!preg_match("/^\w+[\w.-]*\w+@\w+[\w.-]*\w+\.[a-z]{2,10}$/i", $_POST['email'])) {
55+
if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
5756
$app->tpl->setVar("error", $wb['email_error']);
5857
$continue = false;
5958
}
6059

6160
$username = $_POST['username'];
6261
$email = $_POST['email'];
6362

64-
$client = $app->db->queryOneRecord("SELECT client.*, sys_user.lost_password_function FROM client,sys_user WHERE client.username = ? AND client.email = ? AND client.client_id = sys_user.client_id", $username, $email);
63+
$client = $app->db->queryOneRecord("SELECT client.*, sys_user.lost_password_function, sys_user.lost_password_hash, IF(sys_user.lost_password_reqtime IS NOT NULL AND DATE_SUB(NOW(), INTERVAL 15 MINUTE) < sys_user.lost_password_reqtime, 1, 0) as `lost_password_wait` FROM client,sys_user WHERE client.username = ? AND client.email = ? AND client.client_id = sys_user.client_id", $username, $email);
64+
65+
if($client['lost_password_function'] == 0) {
66+
$app->tpl->setVar("error", $wb['lost_password_function_disabled_txt']);
67+
} elseif($client['lost_password_wait'] == 1) {
68+
$app->tpl->setVar("error", $wb['lost_password_function_wait_txt']);
69+
} elseif ($continue) {
70+
if($client['client_id'] > 0) {
71+
$username = $client['username'];
72+
$password_hash = sha1(uniqid('ispc_pw'));
73+
$app->db->query("UPDATE sys_user SET lost_password_reqtime = NOW(), lost_password_hash = ? WHERE username = ?", $password_hash, $username);
74+
$app->tpl->setVar("message", $wb['pw_reset_act']);
75+
76+
$server_domain = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']);
77+
if($server_domain == '_') {
78+
$tmp = explode(':',$_SERVER["HTTP_HOST"]);
79+
$server_domain = $tmp[0];
80+
unset($tmp);
81+
}
82+
if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') $server_domain = 'http://' . $server_domain;
83+
else $server_domain = 'https://' . $server_domain;
84+
85+
if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '443') $server_domain .= ':' . $_SERVER['SERVER_PORT'];
86+
87+
$app->uses('getconf,ispcmail');
88+
$mail_config = $server_config_array['mail'];
89+
if($mail_config['smtp_enabled'] == 'y') {
90+
$mail_config['use_smtp'] = true;
91+
$app->ispcmail->setOptions($mail_config);
92+
}
93+
$app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']);
94+
$app->ispcmail->setSubject($wb['pw_reset_act_mail_title']);
95+
$app->ispcmail->setMailText($wb['pw_reset_act_mail_msg'].$server_domain . '/login/password_reset.php?username=' . urlencode($username) . '&hash=' . urlencode($password_hash));
96+
$app->ispcmail->send(array($client['contact_name'] => $client['email']));
97+
$app->ispcmail->finish();
98+
99+
$app->tpl->setVar("msg", $wb['pw_reset_act']);
100+
} else {
101+
$app->tpl->setVar("error", $wb['pw_error']);
102+
}
103+
}
104+
} elseif(isset($_GET['username']) && $_GET['username'] != '' && $_GET['hash'] != '') {
105+
106+
if(!preg_match("/^[\w\.\-\_]{1,64}$/", $_GET['username'])) {
107+
$app->tpl->setVar("error", $wb['user_regex_error']);
108+
$continue = false;
109+
}
110+
111+
$username = $_GET['username'];
112+
$hash = $_GET['hash'];
113+
114+
$client = $app->db->queryOneRecord("SELECT client.*, sys_user.lost_password_function, sys_user.lost_password_hash, IF(sys_user.lost_password_reqtime IS NULL OR DATE_SUB(NOW(), INTERVAL 1 DAY) > sys_user.lost_password_reqtime, 1, 0) as `lost_password_expired` FROM client,sys_user WHERE client.username = ? AND client.client_id = sys_user.client_id", $username);
65115

66116
if($client['lost_password_function'] == 0) {
67117
$app->tpl->setVar("error", $wb['lost_password_function_disabled_txt']);
118+
} elseif($client['lost_password_expired'] == 1) {
119+
$app->tpl->setVar("error", $wb['lost_password_function_expired_txt']);
120+
} elseif($client['lost_password_hash'] != $hash) {
121+
$app->tpl->setVar("error", $wb['lost_password_function_denied_txt']);
68122
} elseif ($continue) {
69123
if($client['client_id'] > 0) {
70124
$server_config_array = $app->getconf->get_global_config();
@@ -75,7 +129,7 @@
75129
$new_password_encrypted = $app->auth->crypt_password($new_password);
76130

77131
$username = $client['username'];
78-
$app->db->query("UPDATE sys_user SET passwort = ? WHERE username = ?", $new_password_encrypted, $username);
132+
$app->db->query("UPDATE sys_user SET passwort = ?, lost_password_hash = '', lost_password_reqtime = NULL WHERE username = ?", $new_password_encrypted, $username);
79133
$app->db->query("UPDATE client SET password = ? WHERE username = ?", $new_password_encrypted, $username);
80134
$app->tpl->setVar("message", $wb['pw_reset']);
81135

server/plugins-available/apache2_plugin.inc.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,10 @@ function update($event_name, $data) {
10521052
}
10531053
}
10541054
}
1055+
1056+
foreach($sub_prefixes as $s) {
1057+
$temp_domains[] = $s . $aliasdomain['domain'];
1058+
}
10551059
}
10561060
}
10571061
}
@@ -1137,6 +1141,7 @@ function update($event_name, $data) {
11371141
$lddomain = $domain;
11381142
$subdomains = null;
11391143
$aliasdomains = null;
1144+
$sub_prefixes = array();
11401145

11411146
//* be sure to have good domain
11421147
if($data['new']['subdomain'] == "www" OR $data['new']['subdomain'] == "*") {
@@ -1148,6 +1153,7 @@ function update($event_name, $data) {
11481153
if(is_array($subdomains)) {
11491154
foreach($subdomains as $subdomain) {
11501155
$temp_domains[] = $subdomain['domain'];
1156+
$sub_prefixes[] = str_replace($domain, "", $subdomain['domain']);
11511157
}
11521158
}
11531159

0 commit comments

Comments
 (0)