From 28a4bef6baf5afc125922534758a5f7c284a45f1 Mon Sep 17 00:00:00 2001 From: Alex Porosanu Date: Thu, 9 Jan 2020 21:58:23 +0200 Subject: [PATCH] fix tar invocation for *BSD platforms "--xform" switch is not supported by tar on BSD platforms i.e. *BSD, MacOS, etc. As such, use "-s" switch on these platforms, with a similar regexp. --- web/skins/classic/includes/export_functions.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/includes/export_functions.php b/web/skins/classic/includes/export_functions.php index 8ce0fba5a..d43c697e3 100644 --- a/web/skins/classic/includes/export_functions.php +++ b/web/skins/classic/includes/export_functions.php @@ -940,6 +940,8 @@ function exportEvents( $archive = ''; if ( $exportFormat == 'tar' ) { $archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.tar'; + $version = shell_exec('tar -v'); + $command = 'tar --create --dereference'; if ( $exportCompressed ) { $archive .= '.gz'; @@ -947,8 +949,11 @@ function exportEvents( $exportFormat .= '.gz'; } if ( $exportStructure == 'flat' ) { - //strip file paths if we - $command .= " --xform='s#^.+/##x'"; + if (preg_match("/BSD/i", $version)) { + $command .= " -s '#^.*/##'"; + } else { + $command .= " --xform='s#^.+/##x'"; + } } $command .= ' --file='.escapeshellarg($archive); } elseif ( $exportFormat == 'zip' ) {