Skip to content

Commit eea5b6a

Browse files
committed
Merge branch 'develop' into 6501-php-ssh-cron
2 parents 1fd5805 + 5b49c92 commit eea5b6a

File tree

8 files changed

+47
-34
lines changed

8 files changed

+47
-34
lines changed

install/update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
include_once "/usr/local/ispconfig/server/lib/config.inc.php";
112112
$conf_old = $conf;
113113
unset($conf);
114-
define('ISPC_LOG_FILE', $old_conf['ispconfig_log_dir'] . '/update.log');
114+
define('ISPC_LOG_FILE', $conf_old['ispconfig_log_dir'] . '/update.log');
115115

116116
if($dist['id'] == '') die('Linux distribution or version not recognized.');
117117

interface/lib/classes/remote.d/sites.inc.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,10 @@ public function sites_web_domain_add($session_id, $client_id, $params, $readonly
433433
if($params['log_retention'] == '') $params['log_retention'] = 30;
434434

435435
//* Set a few defaults for nginx servers
436-
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1;
437-
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1;
436+
if($params['pm_max_children'] == '') $params['pm_max_children'] = 10;
437+
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 2;
438438
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1;
439-
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1;
439+
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 5;
440440

441441
$domain_id = $this->insertQuery('../sites/form/web_vhost_domain.tform.php', $client_id, $params, 'sites:web_vhost_domain:on_after_insert');
442442
if ($readonly === true)
@@ -455,10 +455,10 @@ public function sites_web_domain_update($session_id, $client_id, $primary_id, $p
455455
if($params['log_retention'] == '') $params['log_retention'] = 30;
456456

457457
//* Set a few defaults for nginx servers
458-
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1;
459-
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1;
458+
if($params['pm_max_children'] == '') $params['pm_max_children'] = 10;
459+
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 2;
460460
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1;
461-
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1;
461+
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 5;
462462

463463
$affected_rows = $this->updateQuery('../sites/form/web_vhost_domain.tform.php', $client_id, $primary_id, $params);
464464
return $affected_rows;
@@ -507,10 +507,10 @@ public function sites_web_vhost_aliasdomain_add($session_id, $client_id, $params
507507
if($params['log_retention'] == '') $params['log_retention'] = 30;
508508

509509
//* Set a few defaults for nginx servers
510-
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1;
511-
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1;
510+
if($params['pm_max_children'] == '') $params['pm_max_children'] = 10;
511+
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 2;
512512
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1;
513-
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1;
513+
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 5;
514514

515515
$domain_id = $this->insertQuery('../sites/form/web_vhost_domain.tform.php', $client_id, $params, 'sites:web_vhost_aliasdomain:on_after_insert');
516516
return $domain_id;
@@ -527,10 +527,10 @@ public function sites_web_vhost_aliasdomain_update($session_id, $client_id, $pri
527527
if($params['log_retention'] == '') $params['log_retention'] = 30;
528528

529529
//* Set a few defaults for nginx servers
530-
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1;
531-
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1;
530+
if($params['pm_max_children'] == '') $params['pm_max_children'] = 10;
531+
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 2;
532532
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1;
533-
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1;
533+
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 5;
534534

535535
$affected_rows = $this->updateQuery('../sites/form/web_vhost_domain.tform.php', $client_id, $primary_id, $params, 'sites:web_vhost_aliasdomain:on_after_insert');
536536
return $affected_rows;
@@ -579,10 +579,10 @@ public function sites_web_vhost_subdomain_add($session_id, $client_id, $params)
579579
if($params['log_retention'] == '') $params['log_retention'] = 30;
580580

581581
//* Set a few defaults for nginx servers
582-
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1;
583-
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1;
582+
if($params['pm_max_children'] == '') $params['pm_max_children'] = 10;
583+
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 2;
584584
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1;
585-
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1;
585+
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 5;
586586

587587
$domain_id = $this->insertQuery('../sites/form/web_vhost_domain.tform.php', $client_id, $params, 'sites:web_vhost_subdomain:on_after_insert');
588588
return $domain_id;
@@ -599,10 +599,10 @@ public function sites_web_vhost_subdomain_update($session_id, $client_id, $prima
599599
if($params['log_retention'] == '') $params['log_retention'] = 30;
600600

601601
//* Set a few defaults for nginx servers
602-
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1;
603-
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1;
602+
if($params['pm_max_children'] == '') $params['pm_max_children'] = 10;
603+
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 2;
604604
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1;
605-
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1;
605+
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 5;
606606

607607
$affected_rows = $this->updateQuery('../sites/form/web_vhost_domain.tform.php', $client_id, $primary_id, $params, 'sites:web_vhost_subdomain:on_after_insert');
608608
return $affected_rows;

interface/lib/classes/validate_cron.inc.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ function command_format($field_name, $field_value, $validator) {
7676
if(preg_match("'^([a-z0-9][a-z0-9\-]{0,62}\.)+([A-Za-z0-9\-]{2,63})$'i", $parsed["host"]) == false) return $this->get_error($validator['errmsg']);
7777

7878

79+
80+
if(strpos($field_value, '\\') !== false) {
81+
return $this->get_error($validator['errmsg']);
82+
}
7983
}
8084

8185
if(strpos($field_value, "\n") !== false || strpos($field_value, "\r") !== false || strpos($field_value, chr(0)) !== false) {

interface/web/mail/form/mail_domain.tform.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@
8787
),
8888
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
8989
'errmsg'=> 'domain_error_empty'),
90-
1 => array ( 'type' => 'UNIQUE',
91-
'errmsg'=> 'domain_error_unique'),
92-
2 => array ( 'type' => 'ISDOMAIN',
90+
1 => array ( 'type' => 'ISDOMAIN',
9391
'errmsg'=> 'domain_error_regex'),
9492
),
9593
'default' => '',

interface/web/mail/mail_domain_edit.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ function onSubmit() {
295295
}
296296
}
297297

298+
// Check uniqueness per server.
299+
$tmp = $app->db->queryOneRecord("SELECT domain_id FROM mail_domain WHERE domain = ? AND server_id = ? AND domain_id != ?", $this->dataRecord['domain'], $this->dataRecord['server_id'], $this->id);
300+
if (!empty($tmp)) {
301+
$app->tform->errorMessage .= $app->tform->lng("domain_error_unique")."<br />";
302+
}
303+
298304
if($_SESSION["s"]["user"]["typ"] != 'admin') {
299305
// Get the limits of the client
300306
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);

server/lib/classes/cron.d/100-mailbox_stats_hourly.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private function update_last_mail_login() {
9696
$matches = [];
9797
// Match pop3/imap logings, or alternately smtp logins.
9898
if (preg_match('/(.*) (imap|pop3)-login: Login: user=\<([\w\.@-]+)\>/', $line, $matches) || preg_match('/(.*) sasl_method=PLAIN, sasl_username=([\w\.@-]+)/', $line, $matches)) {
99-
$user = $matches[3] ?? $matches[2];
99+
$user = isset($matches[3]) ? $matches[3] : $matches[2];
100100
$updatedUsers[] = $user;
101101
}
102102

server/plugins-available/cron_jailkit_plugin.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ function insert($event_name, $data) {
137137

138138
$this->_add_jailkit_user();
139139

140-
//$this->_setup_php_jailkit();
140+
$this->_setup_php_jailkit();
141141

142-
$command .= 'usermod -U ? 2>/dev/null';
142+
$command = 'usermod -U ? 2>/dev/null';
143143
$app->system->exec_safe($command, $parent_domain["system_user"]);
144144

145145
$this->_update_website_security_level();

server/plugins-available/cron_plugin.inc.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ function _write_crontab() {
224224
$cmd_count = 0;
225225
$chr_cmd_count = 0;
226226

227+
// Check if parentDomain array is empty
228+
if(!is_array($this->parent_domain) || count($this->parent_domain) == 0) {
229+
$app->log("Parent domain not found", LOGLEVEL_WARN);
230+
return 0;
231+
}
232+
227233
//* read all active cron jobs from database and write them to file
228234
$cron_jobs = $app->db->queryAllRecords("SELECT c.`id`, c.`run_min`, c.`run_hour`, c.`run_mday`, c.`run_month`, c.`run_wday`, c.`command`, c.`type`, c.`log`, `web_domain`.`domain` as `domain`
229235
FROM `cron` as c
@@ -249,7 +255,11 @@ function _write_crontab() {
249255
$log_wget_target = $log_root . '/cron_wget.log';
250256
}
251257

252-
258+
// Check if command contains invalid chars
259+
if(strpos($job['command'], "\n") !== false || strpos($job['command'], "\r") !== false || strpos($job['command'], chr(0)) !== false) {
260+
$app->log("Insecure Cron job SKIPPED: " . $job['command'], LOGLEVEL_WARN);
261+
continue;
262+
}
253263

254264
$cron_line .= "\t{$this->parent_domain['system_user']}"; //* running as user
255265
if($job['type'] == 'url') {
@@ -259,18 +269,13 @@ function _write_crontab() {
259269

260270
$job['command'] = strtr($job['command'], $trans);
261271

262-
$cron_line .= "\t{$cron_config['wget']} --no-check-certificate --user-agent='Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0' -q -t 1 -T 7200 -O " . $log_wget_target . " " . escapeshellarg($job['command']) . " " . $log_target;
263-
} else {
264-
if(strpos($job['command'], "\n") !== false || strpos($job['command'], "\r") !== false || strpos($job['command'], chr(0)) !== false) {
272+
// Check that command does not contain a backslash
273+
if (strpos($job['command'], '\\') !== false) {
265274
$app->log("Insecure Cron job SKIPPED: " . $job['command'], LOGLEVEL_WARN);
266275
continue;
267276
}
268277

269-
$web_docroot_client = '';
270-
271-
// web folder is hardcoded to /web:
272-
$web_folder = '/web';
273-
278+
$web_root = '';
274279
if($job['type'] == 'chrooted') {
275280
if(substr($job['command'], 0, strlen($this->parent_domain['document_root'])) == $this->parent_domain['document_root']) {
276281
//* delete the unneeded path part

0 commit comments

Comments
 (0)