Skip to content

Commit fd15618

Browse files
committed
don't delete jail if used by php-fpm
1 parent f69b5ab commit fd15618

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function onRunJob() {
7575
// limit the number of jails we update at one time according to time of day
7676
$num_jails_to_update = (date('H') < 6) ? 25 : 3;
7777

78-
$sql = "SELECT domain_id, domain, document_root, jailkit_chroot_app_sections, jailkit_chroot_app_programs, delete_unused_jailkit FROM web_domain WHERE type = 'vhost' AND last_jailkit_update < (NOW() - INTERVAL 24 HOUR) AND server_id = ? ORDER by last_jailkit_update LIMIT ?";
78+
$sql = "SELECT domain_id, domain, document_root, php_fpm_chroot, jailkit_chroot_app_sections, jailkit_chroot_app_programs, delete_unused_jailkit FROM web_domain WHERE type = 'vhost' AND last_jailkit_update < (NOW() - INTERVAL 24 HOUR) AND server_id = ? ORDER by last_jailkit_update LIMIT ?";
7979
$records = $app->db->queryAllRecords($sql, $conf['server_id'], $num_jails_to_update);
8080

8181
foreach($records as $rec) {
@@ -92,7 +92,7 @@ public function onRunJob() {
9292
// check for any cron job using this jail
9393
$cron_inuse = $app->db->queryOneRecord('SELECT id FROM `cron` WHERE `parent_domain_id` = ? AND `type` = ? AND `server_id` = ?', $rec['domain_id'], 'chrooted', $conf['server_id']);
9494

95-
if ($shell_user_inuse || $cron_inuse || $rec['delete_unused_jailkit'] != 'y') {
95+
if ($shell_user_inuse || $cron_inuse || $rec['php_fpm_chroot'] == 'y' || $rec['delete_unused_jailkit'] != 'y') {
9696
$sections = $jailkit_config['jailkit_chroot_app_sections'];
9797
if (isset($web['jailkit_chroot_app_sections']) && $web['jailkit_chroot_app_sections'] != '') {
9898
$sections = $web['jailkit_chroot_app_sections'];
@@ -102,12 +102,10 @@ public function onRunJob() {
102102
$programs = $web['jailkit_chroot_app_programs'];
103103
}
104104
$app->system->update_jailkit_chroot($rec['document_root'], $sections, $programs, $update_options);
105-
} else {
106-
if ($rec['delete_unused_jailkit'] == 'y') {
107-
//$app->log('Removing unused jail: '.$rec['document_root'], LOGLEVEL_DEBUG);
108-
print 'Removing unused jail: '.$rec['document_root']."\n";
109-
$app->system->delete_jailkit_chroot($rec['document_root']);
110-
}
105+
} elseif ($rec['delete_unused_jailkit'] == 'y') {
106+
//$app->log('Removing unused jail: '.$rec['document_root'], LOGLEVEL_DEBUG);
107+
print 'Removing unused jail: '.$rec['document_root']."\n";
108+
$app->system->delete_jailkit_chroot($rec['document_root']);
111109
}
112110

113111
// might need to update master db here? checking....

server/plugins-available/cron_jailkit_plugin.inc.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ private function _delete_jailkit_if_unused($parent_domain_id) {
362362
return;
363363
}
364364

365+
// chroot is used by php-fpm
366+
if (isset($parent_domain['php_fpm_chroot']) && $parent_domain['php_fpm_chroot'] == 'y') {
367+
return;
368+
}
369+
365370
// check for any shell_user using this jail
366371
$inuse = $app->db->queryOneRecord('SELECT shell_user_id FROM `shell_user` WHERE `parent_domain_id` = ? AND `chroot` = ?', $parent_domain_id, 'jailkit');
367372
if($inuse) {

server/plugins-available/shelluser_jailkit_plugin.inc.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,11 @@ private function _delete_jailkit_if_unused($parent_domain_id) {
594594
return;
595595
}
596596

597+
// chroot is used by php-fpm
598+
if (isset($parent_domain['php_fpm_chroot']) && $parent_domain['php_fpm_chroot'] == 'y') {
599+
return;
600+
}
601+
597602
// check for any shell_user using this jail
598603
$inuse = $app->db->queryOneRecord('SELECT shell_user_id FROM `shell_user` WHERE `parent_domain_id` = ? AND `chroot` = ?', $parent_domain_id, 'jailkit');
599604
if($inuse) {

0 commit comments

Comments
 (0)