From b6936b38a36eb325a3e215e44d58f10b6a552400 Mon Sep 17 00:00:00 2001 From: Marius Burkard Date: Fri, 14 Dec 2018 13:02:12 +0100 Subject: [PATCH] - jailkit update cron improvements --- .../lib/classes/cron.d/500-jkupdate.inc.php | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/server/lib/classes/cron.d/500-jkupdate.inc.php b/server/lib/classes/cron.d/500-jkupdate.inc.php index 1fb292347..09ec9c1ed 100644 --- a/server/lib/classes/cron.d/500-jkupdate.inc.php +++ b/server/lib/classes/cron.d/500-jkupdate.inc.php @@ -86,6 +86,7 @@ class cronjob_jkupdate extends cronjob { } if(is_array($jailkit_programs) && !empty($jailkit_programs)) $this->run_jk_cp($site['document_root'], $jailkit_programs); + $this->fix_broken_symlinks($site['document_root']); if($set_php_symlink){ // create symlink from /usr/bin/php to current PHP version @@ -163,6 +164,30 @@ class cronjob_jkupdate extends cronjob { chmod($document_root.'/dev/tty', 0666); } } + + private function fix_broken_symlinks($document_root){ + global $app; + + exec('cd '.escapeshellarg($document_root).' && find . -type l \( ! -name web \) -xtype l', $output, $retval); + + if(is_array($output) && !empty($output)){ + foreach($output as $link){ + $link = trim($link); + if(preg_match('@\.so(\.\d+)*$@',$link)){ + if(substr($link, 0, 1) == '.') $link = substr($link, 1); + //echo $link."\n"; + $path = $document_root.$link; + //if(is_link($path)) echo "Ist Link\n"; + //if(!file_exists($path)) echo "Aber Link ist kaputt!\n"; + if(is_link($path) && !file_exists($path)){ + //echo $path."\n"; + @unlink($path); + $this->run_jk_cp($document_root, array($link)); + } + } + } + } + } private function exec_log($cmd) { global $app; @@ -187,4 +212,4 @@ class cronjob_jkupdate extends cronjob { } -?> \ No newline at end of file +?> -- GitLab