Skip to content

Commit e78fbb4

Browse files
author
Marius Burkard
committed
- re-inserted custom_sendmail_path from !1176
- fixed several issues - fixed variable typos - coding styles
1 parent 8d43ebc commit e78fbb4

File tree

8 files changed

+72
-61
lines changed

8 files changed

+72
-61
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ALTER TABLE `web_domain` ADD `jailkit_chroot_app_sections` mediumtext NULL DEFAULT NULL;
22
ALTER TABLE `web_domain` ADD `jailkit_chroot_app_programs` mediumtext NULL DEFAULT NULL;
33
ALTER TABLE `web_domain` ADD `delete_unused_jailkit` enum('n','y') NOT NULL DEFAULT 'n';
4-
ALTER TABLE `web_domain` ADD `last_jailkit_update` date NOT NULL DEFAULT FROM_UNIXTIME(0);
4+
ALTER TABLE `web_domain` ADD `last_jailkit_update` date NULL DEFAULT NULL;
55
ALTER TABLE `web_domain` ADD `last_jailkit_hash` varchar(255) DEFAULT NULL;

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,19 @@ public function onRunJob() {
5959
if(isset($server_config['migration_mode']) && $server_config['migration_mode'] == 'y') {
6060
//$app->log('Migration mode active, not running Jailkit updates.', LOGLEVEL_DEBUG);
6161
print "Migration mode active, not running Jailkit updates.\n";
62+
63+
return;
6264
}
6365

6466
$jailkit_config = $app->getconf->get_server_config($conf['server_id'], 'jailkit');
6567
if (isset($this->jailkit_config) && isset($this->jailkit_config['jailkit_hardlinks'])) {
6668
if ($this->jailkit_config['jailkit_hardlinks'] == 'yes') {
67-
$update_options = array( 'hardlink', );
69+
$update_options = array('hardlink');
6870
} elseif ($this->jailkit_config['jailkit_hardlinks'] == 'no') {
69-
$update_optiosn = array();
71+
$update_options = array();
7072
}
7173
} else {
72-
$update_options = array( 'allow_hardlink', );
74+
$update_options = array('allow_hardlink');
7375
}
7476

7577
// limit the number of jails we update at one time according to time of day
@@ -80,7 +82,7 @@ public function onRunJob() {
8082

8183
foreach($records as $rec) {
8284
if (!is_dir($rec['document_root']) || !is_dir($rec['document_root'].'/etc/jailkit')) {
83-
return;
85+
continue;
8486
}
8587

8688
//$app->log('Beginning jailkit maintenance for domain '.$rec['domain'].' at '.$rec['document_root'], LOGLEVEL_DEBUG);
@@ -94,12 +96,12 @@ public function onRunJob() {
9496

9597
if ($shell_user_inuse || $cron_inuse || $rec['php_fpm_chroot'] == 'y' || $rec['delete_unused_jailkit'] != 'y') {
9698
$sections = $jailkit_config['jailkit_chroot_app_sections'];
97-
if (isset($web['jailkit_chroot_app_sections']) && $web['jailkit_chroot_app_sections'] != '') {
98-
$sections = $web['jailkit_chroot_app_sections'];
99+
if (isset($rec['jailkit_chroot_app_sections']) && $rec['jailkit_chroot_app_sections'] != '') {
100+
$sections = $rec['jailkit_chroot_app_sections'];
99101
}
100102
$programs = $jailkit_config['jailkit_chroot_app_programs'];
101-
if (isset($web['jailkit_chroot_app_programs']) && $web['jailkit_chroot_app_programs'] != '') {
102-
$programs = $web['jailkit_chroot_app_programs'];
103+
if (isset($rec['jailkit_chroot_app_programs']) && $rec['jailkit_chroot_app_programs'] != '') {
104+
$programs = $rec['jailkit_chroot_app_programs'];
103105
}
104106
$programs .= ' '.$jailkit_config['jailkit_chroot_cron_programs'];
105107

@@ -134,8 +136,6 @@ public function onRunJob() {
134136

135137
/* this function is optional if it contains no custom code */
136138
public function onAfterRun() {
137-
global $app;
138-
139139
parent::onAfterRun();
140140
}
141141

server/lib/classes/system.inc.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ function rmdir($path, $recursive=false) {
954954
foreach ($objects as $object) {
955955
if ($recursive) {
956956
if (is_dir("$path/$object") && !is_link("$path/$object")) {
957-
$this->rmdir("$path/$object", $recursive);
957+
$this->rmdir("$path/$object", $recursive);
958958
} else {
959959
unlink ("$path/$object");
960960
}
@@ -1010,25 +1010,23 @@ public function create_relative_link($f, $t) {
10101010
}
10111011

10121012
function remove_broken_symlinks($path, $recursive=false) {
1013+
global $app;
1014+
10131015
if ($path != '/') {
10141016
$path = rtrim($path, '/');
10151017
}
1016-
global $app;
1017-
#$app->log("remove_broken_symlinks: checking path: $path", LOGLEVEL_DEBUG);
10181018
if (is_dir($path)) {
1019-
#$app->log("remove_broken_symlinks: $path is dir, running scandir", LOGLEVEL_DEBUG);
10201019
$objects = array_diff(scandir($path), array('.', '..'));
10211020
foreach ($objects as $object) {
1022-
#$app->log("remove_broken_symlinks: scandir found $object", LOGLEVEL_DEBUG);
10231021
if (is_dir("$path/$object") && $recursive) {
1024-
$this->remove_broken_symlinks("$path/$object", $recursive);
1022+
$this->remove_broken_symlinks("$path/$object", $recursive);
10251023
} elseif (is_link("$path/$object") && !file_exists("$path/$object")) {
1026-
$app->log("removing broken symlink $path/$object", LOGLEVEL_DEBUG);
1024+
$app->log("removing broken symlink $path/$object", LOGLEVEL_DEBUG);
10271025
unlink ("$path/$object");
10281026
}
10291027
}
10301028
} elseif (is_link("$path") && !file_exists("$path")) {
1031-
$app->log("removing broken symlink $path", LOGLEVEL_DEBUG);
1029+
$app->log("removing broken symlink $path", LOGLEVEL_DEBUG);
10321030
unlink ("$path");
10331031
}
10341032
}
@@ -2525,7 +2523,7 @@ public function update_jailkit_chroot($home_dir, $sections = array(), $programs
25252523
$app->log("update_jailkit_chroot: removing hardlinked file: $file", LOGLEVEL_DEBUG);
25262524
unlink($file);
25272525
}
2528-
2526+
25292527
$cmd = 'jk_update --jail=?' . $jk_update_args . $skips;
25302528
$this->exec_safe($cmd, $home_dir);
25312529
$app->log('jk_update returned: '.print_r($this->_last_exec_out, true), LOGLEVEL_DEBUG);

server/plugins-available/apache2_plugin.inc.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -845,12 +845,12 @@ function update($event_name, $data) {
845845

846846
if (isset($jailkit_config['jailkit_hardlinks'])) {
847847
if ($jailkit_config['jailkit_hardlinks'] == 'yes') {
848-
$options = array( 'hardlink', );
848+
$options = array('hardlink');
849849
} elseif ($jailkit_config['jailkit_hardlinks'] == 'no') {
850850
$options = array();
851851
}
852852
} else {
853-
$options = array( 'allow_hardlink', );
853+
$options = array('allow_hardlink');
854854
}
855855

856856
$options[] = 'force';
@@ -1249,6 +1249,7 @@ function update($event_name, $data) {
12491249
//* Create custom php.ini
12501250
if(trim($data['new']['custom_php_ini']) != '') {
12511251
$has_custom_php_ini = true;
1252+
$custom_sendmail_path = false;
12521253
if(!is_dir($custom_php_ini_dir)) $app->system->mkdirpath($custom_php_ini_dir);
12531254

12541255
$php_ini_content = $this->get_master_php_ini_content($data['new']);
@@ -1273,6 +1274,13 @@ function update($event_name, $data) {
12731274
}
12741275
}
12751276

1277+
$custom_sendmail_path = false;
1278+
$line = strtok($php_ini_content, '\n');
1279+
while ($line !== false) {
1280+
if (strpos($line, 'sendmail_path') === 0) $custom_sendmail_path = true;
1281+
$line = strtok('\n');
1282+
}
1283+
12761284
$app->system->file_put_contents($custom_php_ini_dir.'/php.ini', $php_ini_content);
12771285
} else {
12781286
$has_custom_php_ini = false;
@@ -1317,7 +1325,7 @@ function update($event_name, $data) {
13171325
$trans = array(
13181326
'{DOCROOT}' => $vhost_data['web_document_root_www'],
13191327
'{DOCROOT_CLIENT}' => $vhost_data['web_document_root'],
1320-
'{DOMAIN}' => $vhost_data['domain']
1328+
'{DOMAIN}' => $vhost_data['domain']
13211329
);
13221330
$vhost_data['apache_directives'] = strtr($vhost_data['apache_directives'], $trans);
13231331

@@ -1382,6 +1390,8 @@ function update($event_name, $data) {
13821390
$vhost_data['seo_redirect_enabled'] = 0;
13831391
}
13841392

1393+
$vhost_data['custom_sendmail_path'] = (isset($custom_sendmail_path) && $custom_sendmail_path) ? 'y' : 'n';
1394+
13851395
$tpl->setVar($vhost_data);
13861396
$tpl->setVar('apache_version', $app->system->getapacheversion());
13871397

@@ -1405,13 +1415,13 @@ function update($event_name, $data) {
14051415

14061416
switch($data['new']['subdomain']) {
14071417
case 'www':
1408-
$rewrite_rules[] = array( 'rewrite_domain' => '^'.$this->_rewrite_quote($data['new']['domain']),
1418+
$rewrite_rules[] = array('rewrite_domain' => '^'.$this->_rewrite_quote($data['new']['domain']),
14091419
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']',
14101420
'rewrite_target' => $rewrite_target,
14111421
'rewrite_target_ssl' => $rewrite_target_ssl,
14121422
'rewrite_is_url' => ($this->_is_url($rewrite_target) ? 'y' : 'n'),
14131423
'rewrite_add_path' => (substr($rewrite_target, -1) == '/' ? 'y' : 'n'));
1414-
$rewrite_rules[] = array( 'rewrite_domain' => '^' . $this->_rewrite_quote('www.'.$data['new']['domain']),
1424+
$rewrite_rules[] = array('rewrite_domain' => '^' . $this->_rewrite_quote('www.'.$data['new']['domain']),
14151425
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']',
14161426
'rewrite_target' => $rewrite_target,
14171427
'rewrite_target_ssl' => $rewrite_target_ssl,
@@ -3439,6 +3449,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
34393449
}
34403450

34413451
$custom_session_save_path = false;
3452+
$custom_sendmail_path = false;
34423453
if($custom_php_ini_settings != ''){
34433454
// Make sure we only have Unix linebreaks
34443455
$custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings);
@@ -3456,6 +3467,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
34563467
if($value != ''){
34573468
$key = trim($key);
34583469
if($key == 'session.save_path') $custom_session_save_path = true;
3470+
if($key == 'sendmail_path') $custom_sendmail_path = true;
34593471
switch (strtolower($value)) {
34603472
case '0':
34613473
// PHP-FPM might complain about invalid boolean value if you use 0
@@ -3478,6 +3490,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
34783490
}
34793491

34803492
$tpl->setVar('custom_session_save_path', ($custom_session_save_path ? 'y' : 'n'));
3493+
$tpl->setVar('custom_sendmail_path', ($custom_sendmail_path ? 'y' : 'n'));
34813494

34823495
$tpl->setLoop('custom_php_ini_settings', $final_php_ini_settings);
34833496

@@ -3700,12 +3713,12 @@ function _setup_jailkit_chroot()
37003713

37013714
if (isset($this->jailkit_config) && isset($this->jailkit_config['jailkit_hardlinks'])) {
37023715
if ($this->jailkit_config['jailkit_hardlinks'] == 'yes') {
3703-
$options = array( 'hardlink', );
3716+
$options = array( 'hardlink');
37043717
} elseif ($this->jailkit_config['jailkit_hardlinks'] == 'no') {
37053718
$options = array();
37063719
}
37073720
} else {
3708-
$options = array( 'allow_hardlink', );
3721+
$options = array( 'allow_hardlink');
37093722
}
37103723

37113724
// should move return here if $this->website['new_jailkit_hash'] == $this->website['last_jailkit_hash'] ?

server/plugins-available/cron_jailkit_plugin.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ function _setup_jailkit_chroot()
232232

233233
if (isset($this->jailkit_config) && isset($this->jailkit_config['jailkit_hardlinks'])) {
234234
if ($this->jailkit_config['jailkit_hardlinks'] == 'yes') {
235-
$options = array( 'hardlink', );
235+
$options = array('hardlink');
236236
} elseif ($this->jailkit_config['jailkit_hardlinks'] == 'no') {
237237
$options = array();
238238
}
239239
} else {
240-
$options = array( 'allow_hardlink', );
240+
$options = array('allow_hardlink');
241241
}
242242

243243
$last_updated = preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_app_sections']
@@ -311,7 +311,7 @@ function _add_jailkit_programs($opts=array())
311311
//copy over further programs and its libraries
312312
$app->system->create_jailkit_programs($this->parent_domain['document_root'], $this->jailkit_config['jailkit_chroot_app_programs'], $opts);
313313
$app->log("Added app programs to jailkit chroot", LOGLEVEL_DEBUG);
314-
314+
315315
$app->system->create_jailkit_programs($this->parent_domain['document_root'], $this->jailkit_config['jailkit_chroot_cron_programs'], $opts);
316316
$app->log("Added cron programs to jailkit chroot", LOGLEVEL_DEBUG);
317317
}

server/plugins-available/nginx_plugin.inc.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,12 +684,12 @@ function update($event_name, $data) {
684684

685685
if (isset($jailkit_config['jailkit_hardlinks'])) {
686686
if ($jailkit_config['jailkit_hardlinks'] == 'yes') {
687-
$options = array( 'hardlink', );
687+
$options = array('hardlink');
688688
} elseif ($jailkit_config['jailkit_hardlinks'] == 'no') {
689689
$options = array();
690690
}
691691
} else {
692-
$options = array( 'allow_hardlink', );
692+
$options = array('allow_hardlink');
693693
}
694694

695695
$options[] = 'force';
@@ -3485,12 +3485,12 @@ function _setup_jailkit_chroot()
34853485

34863486
if (isset($this->jailkit_config) && isset($this->jailkit_config['jailkit_hardlinks'])) {
34873487
if ($this->jailkit_config['jailkit_hardlinks'] == 'yes') {
3488-
$options = array( 'hardlink', );
3488+
$options = array( 'hardlink');
34893489
} elseif ($this->jailkit_config['jailkit_hardlinks'] == 'no') {
34903490
$options = array();
34913491
}
34923492
} else {
3493-
$options = array( 'allow_hardlink', );
3493+
$options = array( 'allow_hardlink');
34943494
}
34953495

34963496
// should move return here if $this->website['new_jailkit_hash'] == $this->website['last_jailkit_hash'] ?

0 commit comments

Comments
 (0)