Skip to content

Commit 0e32470

Browse files
committed
Update Jailkit/PHP cron placeholders code
1 parent 8b8d315 commit 0e32470

File tree

5 files changed

+46
-28
lines changed

5 files changed

+46
-28
lines changed

interface/web/sites/ajax_get_json.php

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -250,17 +250,27 @@
250250

251251
if($type == 'getcronplaceholders') {
252252

253-
$web_docroot_client = '';
253+
if(is_array($web_id) && !empty($web_id)) {
254254

255-
if($web_id > 0) {
255+
$web_docroot_client = '';
256256

257257
$web = $app->db->queryOneRecord("SELECT wd.sys_groupid, wd.domain, wd.document_root, sp.php_cli_binary
258258
FROM web_domain wd
259259
LEFT JOIN server_php sp ON wd.server_php_id = sp.server_php_id
260260
WHERE wd.domain_id = ?", $web_id);
261261

262-
$php_cli_binary = $web['php_cli_binary'];
263-
$domain = $web['domain'];
262+
if(empty($web['php_cli_binary'])) {
263+
$php_cli_binary = "/usr/bin/php";
264+
} else {
265+
$php_cli_binary = $web['php_cli_binary'];
266+
}
267+
268+
if(empty($web['domain'])) {
269+
$domain = $app->tform->wordbook["domain_not_selected_placeholder_txt"];
270+
} else {
271+
$domain = $web['domain'];
272+
}
273+
264274

265275
$domain_owner = $app->db->queryOneRecord("SELECT limit_cron_type FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $web["sys_groupid"]);
266276

@@ -279,20 +289,18 @@
279289
if($cron_type != 'chrooted') {
280290
$web_docroot_client = $web['document_root'];
281291
}
282-
}
283292

284-
$web_docroot_client .= '/web';
293+
$web_docroot_client .= '/web';
285294

286-
if(empty($web['php_cli_binary'])) {
287-
$php_cli_binary = "/usr/bin/php";
295+
$json = json_encode(array(
296+
'php_cli_binary' => $php_cli_binary,
297+
'docroot_client' => $web_docroot_client,
298+
//'cron_type' => $cron_type,
299+
'domain' => $domain
300+
));
288301
}
289302

290-
$json = json_encode(array(
291-
'php_cli_binary' => $php_cli_binary,
292-
'docroot_client' => $web_docroot_client,
293-
//'cron_type' => $cron_type,
294-
'domain' => $domain
295-
));
303+
296304
}
297305

298306
header('Content-type: application/json');

interface/web/sites/cron_edit.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,23 @@ function onShowEnd() {
8383
LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id
8484
WHERE `domain_id` = ?", $this->dataRecord["parent_domain_id"]);
8585

86-
$php_cli_binary = $parent_domain['php_cli_binary'];
87-
$domain = $parent_domain['domain'];
88-
89-
if($this->dataRecord['type'] != 'chrooted') {
90-
$web_docroot_client = $parent_domain['document_root'];
91-
} else {
92-
$web_docroot_client = '';
93-
}
9486

9587
if(empty($parent_domain['php_cli_binary'])) {
9688
$php_cli_binary = "/usr/bin/php";
89+
} else {
90+
$php_cli_binary = $parent_domain['php_cli_binary'];
9791
}
9892

9993
if(empty($parent_domain['domain'])) {
10094
$domain = $app->tform->wordbook["domain_not_selected_placeholder_txt"];
95+
} else {
96+
$domain = $parent_domain['domain'];
97+
}
98+
99+
if($this->dataRecord['type'] != 'chrooted') {
100+
$web_docroot_client = $parent_domain['document_root'];
101+
} else {
102+
$web_docroot_client = '';
101103
}
102104

103105
// web folder is hardcoded to /web:

server/lib/classes/cron.d/600-jailkit_maintenance.inc.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function onRunJob() {
6868
$sql = "SELECT domain_id, domain, document_root, system_user, system_group, php_fpm_chroot, jailkit_chroot_app_sections, jailkit_chroot_app_programs, delete_unused_jailkit, last_jailkit_hash, `php_cli_binary`
6969
FROM web_domain
7070
LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id
71-
WHERE type = 'vhost' AND (last_jailkit_update IS NULL OR last_jailkit_update < (NOW() - INTERVAL 24 HOUR)) AND web_domain.server_id = ? and domain_id=57
71+
WHERE type = 'vhost' AND (last_jailkit_update IS NULL OR last_jailkit_update < (NOW() - INTERVAL 24 HOUR)) AND web_domain.server_id = ?
7272
ORDER by last_jailkit_update
7373
LIMIT ?";
7474
$records = $app->db->queryAllRecords($sql, $conf['server_id'], $num_jails_to_update);
@@ -80,7 +80,15 @@ public function onRunJob() {
8080
}
8181

8282
$options = $global_options;
83-
$options['php_cli_binary'] = $rec['php_cli_binary'];
83+
84+
$options['domain'] = $rec['domain'];
85+
86+
if(empty($rec['php_cli_binary'])) {
87+
$options['php_cli_binary'] = "/usr/bin/php";
88+
} else {
89+
$options['php_cli_binary'] = $rec['php_cli_binary'];
90+
}
91+
8492

8593
//$app->log('Beginning jailkit maintenance for domain '.$rec['domain'].' at '.$rec['document_root'], LOGLEVEL_DEBUG);
8694
print 'Beginning jailkit maintenance for domain '.$rec['domain'].' at '.$rec['document_root']."\n";

server/lib/classes/system.inc.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,10 +2831,8 @@ public function update_jailkit_chroot($home_dir, $sections = array(), $programs
28312831

28322832
if (!empty($options['php_cli_binary'])) {
28332833
if(!file_exists($home_dir . '/' . $options['php_cli_binary'])) {
2834-
$app->log("The PHP cli binary " . $options['php_cli_binary'] . " is not available in the jail of the web " . $this->web['domain'] . " / SSH/SFTP user: " . $this->username . ". Check your Jailkit setup!", LOGLEVEL_DEBUG);
2835-
$tpl->setVar('use_php_path', false);
2836-
$tpl->setVar('use_php_alias', false);
2837-
if(is_link($home_dir . '/etc/alternatives/php'))
2834+
$app->log("update_jailkit_chroot: The PHP cli binary " . $options['php_cli_binary'] . " is not available in the jail of the web " . $options['domain'], LOGLEVEL_DEBUG);
2835+
if(is_link($home_dir . '/etc/alternatives/php') || is_file($home_dir . '/etc/alternatives/php'))
28382836
{
28392837
unlink($home_dir . '/etc/alternatives/php');
28402838
}

server/plugins-available/shelluser_base_plugin.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class shelluser_base_plugin {
3434
var $class_name = 'shelluser_base_plugin';
3535
var $min_uid = 499;
3636
var $data = array();
37+
var $web = array();
38+
3739

3840
//* This function is called during ispconfig installation to determine
3941
// if a symlink shall be created for this plugin.

0 commit comments

Comments
 (0)