Skip to content

Commit 6876a04

Browse files
committed
pass hardlink option to jk_update
1 parent 150aa06 commit 6876a04

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

server/lib/classes/system.inc.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,15 +2433,20 @@ public function update_jailkit_chroot($home_dir, $sections = array(), $programs
24332433
}
24342434

24352435
$opts = array();
2436+
$jk_update_args = '';
2437+
$jk_cp_args = '';
24362438
foreach ($options as $opt) {
24372439
switch ($opt) {
24382440
case '-k':
24392441
case 'hardlink':
24402442
$opts[] = 'hardlink';
2443+
$jk_update_args .= ' -k';
2444+
$jk_cp_args .= ' -k';
24412445
break;
24422446
case '-f':
24432447
case 'force':
24442448
$opts[] = 'force';
2449+
$jk_cp_args .= ' -f';
24452450
break;
24462451
}
24472452
}
@@ -2521,14 +2526,16 @@ public function update_jailkit_chroot($home_dir, $sections = array(), $programs
25212526
unlink($file);
25222527
}
25232528

2524-
$cmd = 'jk_update --jail=?' . $skips;
2529+
$cmd = 'jk_update --jail=?' . $jk_update_args . $skips;
25252530
$this->exec_safe($cmd, $home_dir);
25262531
$app->log('jk_update returned: '.print_r($this->_last_exec_out, true), LOGLEVEL_DEBUG);
25272532
foreach ($this->_last_exec_out as $line) {
25282533
if (substr( $line, 0, 4 ) === "skip") {
25292534
continue;
25302535
}
2531-
if (preg_match('@^(?: [^ ]+){6}(.+)'.preg_quote($home_dir, '@').'$@', $line, $matches)) {
2536+
if (preg_match('/^(WARNING|ERROR)/', $line, $matches)) {
2537+
$app->log("jk_update: $line", LOGLEVEL_DEBUG);
2538+
} elseif (preg_match('@^(?: [^ ]+){6}(.+)'.preg_quote($home_dir, '@').'$@', $line, $matches)) {
25322539
# remove deprecated files that jk_update failed to remove
25332540
if (is_file($matches[1])) {
25342541
$app->log("update_jailkit_chroot: removing deprecated file which jk_update failed to remove: ".$matches[1], LOGLEVEL_DEBUG);
@@ -2583,7 +2590,7 @@ public function update_jailkit_chroot($home_dir, $sections = array(), $programs
25832590
}
25842591
if (is_file($file)) { // file exists in root
25852592
$app->log("update_jailkit_chroot: previously hardlinked file still missing, running jk_cp to restore: $file", LOGLEVEL_DEBUG);
2586-
$cmd = 'jk_cp -j ? ' . escapeshellarg($file);
2593+
$cmd = 'jk_cp -j ? ' . $jk_cp_args . ' ' . escapeshellarg($file);
25872594
$this->exec_safe($cmd, $home_dir);
25882595
} else {
25892596
// not necessarily an error

0 commit comments

Comments
 (0)