@@ -2351,15 +2351,15 @@ public function create_jailkit_programs($home_dir, $programs = array(), $options
23512351 # prohibit ill-advised copying paths known to be sensitive/problematic
23522352 # (easy to bypass if needed, eg. use /./etc)
23532353 $ blacklisted_paths_regex = array (
2354- '| ^/$| ' ,
2355- '| ^/proc(/.*)?$| ' ,
2356- '| ^/sys(/.*)?$| ' ,
2357- '| ^/etc/?$| ' ,
2358- '| ^/dev/?$| ' ,
2359- '| ^/tmp/?$| ' ,
2360- '| ^/run/?$| ' ,
2361- '| ^/boot/?$| ' ,
2362- '| ^/var(/?|/backups?/?)?$| ' ,
2354+ '@ ^/$@ ' ,
2355+ '@ ^/proc(/.*)?$@ ' ,
2356+ '@ ^/sys(/.*)?$@ ' ,
2357+ '@ ^/etc/?$@ ' ,
2358+ '@ ^/dev/?$@ ' ,
2359+ '@ ^/tmp/?$@ ' ,
2360+ '@ ^/run/?$@ ' ,
2361+ '@ ^/boot/?$@ ' ,
2362+ '@ ^/var(/?|/backups?/?)?$@ ' ,
23632363 );
23642364
23652365 $ program_args = '' ;
@@ -2460,8 +2460,10 @@ public function update_jailkit_chroot($home_dir, $sections = array(), $programs
24602460 continue ;
24612461 }
24622462
2463+ $ this ->remove_broken_symlinks ($ dir , true );
2464+
24632465 // save list of hardlinked files
2464- if (!in_array ($ opts , 'hardlink ' ) && !in_array ($ options , 'allow_hardlink ' )) {
2466+ if (!in_array ('hardlink ' , $ opts ) && !in_array ('allow_hardlink ' , $ options )) {
24652467 $ find_multiple_links = function ( $ path ) use ( &$ find_multiple_links ) {
24662468 $ found = array ();
24672469 if (is_dir ($ path )) {
@@ -2487,6 +2489,7 @@ public function update_jailkit_chroot($home_dir, $sections = array(), $programs
24872489 }
24882490 }
24892491
2492+ // remove broken symlinks a second time after hardlink cleanup
24902493 $ this ->remove_broken_symlinks ($ dir , true );
24912494 }
24922495
@@ -2497,7 +2500,7 @@ public function update_jailkit_chroot($home_dir, $sections = array(), $programs
24972500 if (substr ( $ line , 0 , 4 ) === "skip " ) {
24982501 continue ;
24992502 }
2500- if (preg_match ('| ^(? [^ ]+){6}(.+)$ ' .preg_quote ($ home_dir , '| ' ).'| ' , $ line , $ matches )) {
2503+ if (preg_match ('@ ^(? [^ ]+){6}(.+) ' .preg_quote ($ home_dir , '@ ' ).'$@ ' , $ line , $ matches )) {
25012504 # remove deprecated files that jk_update failed to remove
25022505 if (is_file ($ matches [1 ])) {
25032506$ app ->log ("removing deprecated file which jk_update failed to remove: " .$ matches [1 ], LOGLEVEL_DEBUG );
@@ -2525,7 +2528,7 @@ public function update_jailkit_chroot($home_dir, $sections = array(), $programs
25252528 }
25262529
25272530 // search for any hardlinked files which are now missing
2528- if (!in_array ($ opts , 'hardlink ' ) && !in_array ($ options , 'allow_hardlink ' )) {
2531+ if (!in_array ('hardlink ' , $ opts ) && !in_array ('allow_hardlink ' , $ options )) {
25292532 foreach ($ multiple_links as $ file ) {
25302533 if (!is_file ($ file )) {
25312534 // strip $home_dir from $file
@@ -2552,7 +2555,7 @@ public function update_jailkit_chroot($home_dir, $sections = array(), $programs
25522555 $ rewrite = false ;
25532556 $ jk_socketd_ini = $ app ->ini_parser ->parse_ini_file ('/etc/jailkit/jk_socketd.ini ' );
25542557 foreach ($ jk_socketd_ini as $ log => $ settings ) {
2555- $ jail = preg_replace ('| /dev/log$| ' , '' , $ log );
2558+ $ jail = preg_replace ('@ /dev/log$@ ' , '' , $ log );
25562559 if ($ jail != $ log && !is_dir ($ jail )) {
25572560 unset($ jk_socketd_ini [$ log ]);
25582561 $ rewrite =true ;
0 commit comments