From c23445a2235fec1c8b99d5b2e0eaebfc54e83a03 Mon Sep 17 00:00:00 2001 From: Ilia Rostovtsev Date: Wed, 4 May 2016 14:28:16 +0400 Subject: [PATCH 1/4] Certificates must be editable --- filemin/defaultacl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filemin/defaultacl b/filemin/defaultacl index 2f17e731c..24dd79ec7 100644 --- a/filemin/defaultacl +++ b/filemin/defaultacl @@ -1,3 +1,3 @@ allowed_paths=$HOME work_as_root=1 -allowed_for_edit=application-x-php application-x-ruby application-xml application-javascript application-x-shellscript application-x-perl application-x-yaml application-json +allowed_for_edit=application-x-php application-x-ruby application-xml application-javascript application-x-shellscript application-x-perl application-x-yaml application-json application-x-x509-ca-cert application-pkix-cert From fe6965d1e2106daf72c85776ad21a0ef1e136158 Mon Sep 17 00:00:00 2001 From: Ilia Rostovtsev Date: Wed, 4 May 2016 17:46:10 +0400 Subject: [PATCH 2/4] Support for extracting: .7z, .bz2, .xz, .gz, .rar Commands are checked before they run so no need for last else part which outputted an error message. The rest of the code I will add to -lib file. P.S. Jamie, I tried removing `use File::MimeInfo;` in this file as on current branch and it returned an error!? Please double check. --- filemin/extract.cgi | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/filemin/extract.cgi b/filemin/extract.cgi index a16c9b86c..172cea072 100755 --- a/filemin/extract.cgi +++ b/filemin/extract.cgi @@ -9,16 +9,29 @@ get_paths(); $archive_type = mimetype($cwd.'/'.$in{'file'}); -if ($archive_type eq 'application/zip') { - &backquote_logged("unzip ".quotemeta("$cwd/$in{'file'}"). - " -d ".quotemeta($cwd)); + +if ( index( $archive_type, "x-bzip" ) != -1 ) { + &backquote_logged( "tar xvjfp " . quotemeta("$cwd/$in{'file'}") . " -C " . quotemeta($cwd) ); &redirect("index.cgi?path=$path"); -} elsif (index($archive_type, "tar") != -1) { - &backquote_logged("tar xf ".quotemeta("$cwd/$in{'file'}"). - " -C ".quotemeta($cwd)); - &redirect("index.cgi?path=$path"); -} else { - &ui_print_header(undef, "Filemin", ""); - print "$archive_type $text{'error_archive_type_not_supported'}"; - &ui_print_footer("index.cgi?path=$path", $text{'previous_page'}); } +elsif (index( $archive_type, "x-tar" ) != -1 + || index( $archive_type, "/gzip" ) != -1 + || index( $archive_type, "x-xz" ) != -1 + || index( $archive_type, "x-compressed-tar" ) != -1 ) +{ + &backquote_logged( "tar xfp " . quotemeta("$cwd/$in{'file'}") . " -C " . quotemeta($cwd) ); + &redirect("index.cgi?path=$path"); +} +elsif ( index( $archive_type, "x-7z" ) != -1 ) { + &backquote_logged( "7z x " . quotemeta("$cwd/$in{'file'}") . " -o" . quotemeta($cwd) ); + &redirect("index.cgi?path=$path"); +} +elsif ( index( $archive_type, "/zip" ) != -1 ) { + &backquote_logged( "unzip " . quotemeta("$cwd/$in{'file'}") . " -d " . quotemeta($cwd) ); + &redirect("index.cgi?path=$path"); +} +elsif ( index( $archive_type, "/x-rar" ) != -1 ) { + &backquote_logged( "unrar x -r -y " . quotemeta("$cwd/$in{'file'}") . " " . quotemeta($cwd) ); + &redirect("index.cgi?path=$path"); +} + From b5990ef9fb6f07160097a656654a0042141ece85 Mon Sep 17 00:00:00 2001 From: Ilia Rostovtsev Date: Wed, 4 May 2016 18:01:51 +0400 Subject: [PATCH 3/4] The rest of the code to support new extraction methods Just committed to `extract.cgi`. Command is checked for existence and if found extract button will appear on the interface in all themes. --- filemin/filemin-lib.pl | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/filemin/filemin-lib.pl b/filemin/filemin-lib.pl index 633b0db14..1f96240e4 100644 --- a/filemin/filemin-lib.pl +++ b/filemin/filemin-lib.pl @@ -288,8 +288,25 @@ sub print_interface { ) { $actions = "$actions$edit_icon"; } - if (index($type, "zip") != -1 or index($type, "compressed") != -1) { - $actions = "$actions $extract_icon "; + if ( ( index( $type, "application-zip" ) != -1 && has_command('unzip') ) + || ( index( $type, "application-x-7z-compressed" ) != -1 && has_command('7z') ) + || ( index( $type, "application-x-rar" ) != -1 && has_command('unrar') ) + || (( index( $type, "x-compressed-tar" ) != -1 + || index( $type, "-x-tar" ) != -1 + || ( index( $type, "-x-bzip" ) != -1 && has_command('bzip2') ) + || ( index( $type, "-gzip" ) != -1 && has_command('gzip') ) + || ( index( $type, "-x-xz" ) != -1 && has_command('xz') ) + ) + && has_command('tar') + ) + ) + { + $actions + = "$actions $extract_icon "; } } @row_data = ( From ae15622a574d8bab50ef36c475d015b55a0ccd5c Mon Sep 17 00:00:00 2001 From: Ilia Rostovtsev Date: Thu, 5 May 2016 23:12:24 +0400 Subject: [PATCH 4/4] For search page path could be printed twice in some cases This fix will prevent double printing of the path for searched (found) folders. It doesn't happen always but only if search results contain same value for directory and file. Can be reproduced by going to `/boot/grub` and searching for `grub`. With the current code the folder `grub` (same as the current folder) printed on the results with doubled path on the link and thus doesn't open correctly. The best is to tweak `search.cgi` that filters search results and remove from results same folder as parent. It's more complicated. My fix does it safely, I think. --- filemin/filemin-lib.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/filemin/filemin-lib.pl b/filemin/filemin-lib.pl index 1f96240e4..0414c8ea9 100644 --- a/filemin/filemin-lib.pl +++ b/filemin/filemin-lib.pl @@ -269,8 +269,12 @@ sub print_interface { $actions = "$rename_icon"; - if ($list[$count - 1][15] == 1) { - $href = "index.cgi?path=".&urlize("$path/$link"); + if ( $list[ $count - 1 ][15] == 1 ) { + if ($path eq '/'. $link) { + $href = "index.cgi?path=" . &urlize("$path"); + } else { + $href = "index.cgi?path=" . &urlize("$path/$link"); + } } else { $href = "download.cgi?file=".&urlize($link)."&path=".&urlize($path); if($0 =~ /search.cgi/) {