webmin / authentic-theme

Official theme for the best server management panel of the 21st Century
https://authentic-theme.com
MIT License
947 stars 163 forks source link

No extraction option #839

Closed Keltere closed 7 years ago

Keltere commented 7 years ago

Webmin: 1.850 Authentic-theme: 19

OS:Archlinux 4.13.3-1

I've installed 7z, unrar, zip etc... Everything is updated, i've also installed shared-mime-info and configured MIME on webmin but the extract button won't come out.

I've tried restarting the webmin service, reinstalling, clear cache, different browser (chrome, firefox, edge) nothing seems to work. I can't understand where is the problem.

capture

capture2

iliajie commented 7 years ago

How about unzip? :)

Keltere commented 7 years ago

Ok that was a quite epicfail...

Really really thanks that worked but i still can't use for rar files... any suggestion?

iliajie commented 7 years ago

You want to create rar? if so that is not supported yet.

Keltere commented 7 years ago

Nope, just extract

Keltere commented 7 years ago

I've already installed unrar and rar, but the file is not recognized as archive capture3

iliajie commented 7 years ago

It should work. Looking at this file, I remember I made it work.

https://github.com/qooob/authentic-theme/blob/master/extensions/file-manager/extract.cgi

iliajie commented 7 years ago

If you reload with the circle button in File Manager controls, will you have it? Do you happen to have it in context menu?

Keltere commented 7 years ago

Yes, i also tried to restart the service but nothing. It won't show up.

Keltere commented 7 years ago

tried with 7zip and it's working fine, just rar file has problem

Keltere commented 7 years ago

Talked to my friend with manjaro and he has the same problem, everything works except for rar files.

iliajie commented 7 years ago

I would need to install Archlinux to test it. You most likely would have the same behavior in old themes.

Meanwhile I made a quick test on Debian by installing unrar and here is what I got:

screenshot from 2017-10-03 22-13-03

You need to make sure that you unrar command is on the path. In case you open Command Shell in the theme and execute unrar, what is the output?

iliajie commented 7 years ago

Another possible solution is to manually set MIME Type Program for rar.

Keltere commented 7 years ago

unrarIn the webmin command shell it's working. Also i check the MIME configuration for rar and it's everything ok.

Mime rar config vnd.rar.xml https://pastebin.com/xaB1e9Yf

Keltere commented 7 years ago

Tried to refresh mime database with: update-mime-database /usr/share/mime Still not working

iliajie commented 7 years ago

As you can see on the screenshot, your system doesn't seem to detect MIME type for rar files correctly. Try to rename a file manually typing .rar at the end. Make sure there is no spaces or foreign characters in the string.

In case it's alright and it still doesn't work, go to Webmin/System/MIME Type Program and set it manually.

swelljoe commented 7 years ago

I can add more decompressors to the dependencies in the Virtualmin installer. unzip is already in there, and tar/gz are defaults on all Linux systems regardless, but I can probably add 7z and unrar. Are there any others?

iliajie commented 7 years ago

Yes, you can see all of the dependencies that are checked in extract.cgi file. The other is for making zip archives.

iliajie commented 7 years ago

tar needs to be checked explicitly as it has bzip, xz and other dependencies.

Keltere commented 7 years ago

Maybe i have found out the problem

https://forum.manjaro.org/t/ark-16-08-1-1-regression-with-rar-files-cant-open-or-extract-them/9622

I will try today to find out some solution... anyway not a webmin problem. Thanks for the support and sorry to have bothered you for nothing.

iliajie commented 7 years ago

That's okay.

Keltere commented 7 years ago

Ok the problem is that they changed "application/x-rar" to "application/vnd.rar" I've tried to add this custom MIME to webmin but because of the dot i cannot do it.

iliajie commented 7 years ago

MIME type doesn't need a dot.

https://doxfer.webmin.com/Webmin/MIME_Type_Programs

Keltere commented 7 years ago

Yes but shared-mime-info changed from x-rar to vnd.rar so i need to add support to it. I tried editing those 2 file adding vnd.rar but nothing changed. There are other files i need to edit?

/opt/webmin/authentic-theme/extensions/file-manager/extract.cgi /opt/webmin/filemin/extract.cg

Sorry to bother you.

iliajie commented 7 years ago

Have a look:

Arch Linux - Default applications

File Manager - Internal module used to determine the MIME type of a file

alexbogias commented 6 years ago

Can you please let me know why I still cant unzip zip files with mime type: application-octet-stream. Every zip file i upload has this mime type. Why isnt automatically recognized as a zip? Is why my upload machine OS is windows?

iliajie commented 6 years ago

You upload machine doesn't matter.

Please check System/MIME Type Programs.

alexbogias commented 6 years ago

Can you give me more info on this?

alexbogias commented 6 years ago

I can see that "application/zip" -> "unzip -l %s is enabled! Do I have to add application-octet-stream to unzip -l %s also? Is it safe?

iliajie commented 6 years ago

This is system specific.

Did you make sure that you have unzip installed? I have it displayed as application/zip on Ubuntu.

alexbogias commented 6 years ago

Yup! I am using Debian 8 And it lists on apt list | grep unzip unzip/oldstable,oldstable,now 6.0-16+deb8u3 amd64 [installed]

alexbogias commented 6 years ago

And I think in Debian 8 there is no update-mime-database

update-mime-database /usr/share/mime -bash: update-mime-database: command not found

iliajie commented 6 years ago

@alexbogias Could you follow. It seems related and easily fixable.

https://github.com/webmin/webmin/issues/702#issuecomment-378704623

alexbogias commented 6 years ago

@qooob You mean add application-octet-stream inside those if's ? Isn't application-octet-stream something more general?

iliajie commented 6 years ago

Oh, man, yeah, I forgot it's the wrong type. Okay.

I'll try to reproduce it on my debug machines.

Is it all Debian 8 machines that affected by this bug or only particular one?

alexbogias commented 6 years ago

I just tried in 3x Debian 9 and 1x Debian 8 machine. Everything is application-octet-stream c354dd97-c283-4127-8d1d-1b4f5d8c4bae

alexbogias commented 6 years ago

Files which are created by virtualmin (backups) looks fine in Debian 9 tho

ddffdfgd

alexbogias commented 6 years ago

And files downloaded with wget by github comes like application-octet-stream also gsdgg

iliajie commented 6 years ago

How interesting. I will take a good look tomorrow.

Thank you for reporting.

alexbogias commented 6 years ago

Thank you for making my life easier ;)

iliajie commented 6 years ago

Can you make a screenshot of MIME type module, as well. Just out of curiosity.

I'll do my best to reproduce it.

Do you exclude permission issue? Do you run SELinux?

alexbogias commented 6 years ago

Pemissions? I am on root: sfadfsafsaf I just open console from virtualmin and unzip with unzip hjsplit.zip without a problem...

MIME type module: adadad

SELinux? I am not sure what this does. Firewall? I just use virtualmin's and debian defaults: CSF, IPTables and Fail2Ban on Debian 9

iliajie commented 6 years ago

Okay, I have exactly the same MIME types sets.

I was looking at MimeInfo.pm file and here is what I found:


=head1 METHODS

=item C<mimetype($file)>
If these methods are unsuccessful the file is read and the mimetype defaults
to 'text/plain' or to 'application/octet-stream' when the first ten chars
of the file match ascii control chars (white spaces excluded).
If the file doesn't exist or isn't readable C<undef> is returned.

=item C<default($file)>
This method decides whether a file is binary or plain text by looking at
the first few bytes in the file. Used to decide between "text/plain" and
"application/octet-stream" if all other methods have failed.

Looking further in the code I found:

no warnings; # warnings can be thrown when input not ascii
if ($] < 5.008 or ! utf8::valid($line)) {
    use bytes; # avoid invalid utf8 chars
    $line =~ s/\s//g; # \m, \n and \t are also control chars
    return 'text/plain' unless $line =~ /[\x00-\x1F\x7F]/;
}
else {
    # use perl to do something intelligent for ascii & utf8
    return 'text/plain' unless $line =~ /[^[:print:]\s]/;
}

Now, open console and run:

file -b --mime your_file_name.extension

.. first for files created manually (those that fail, if I understood correctly) and then for those created by Virtualmin scripts (that work correctly).

What is the output? it should be something like:

application/gzip; charset=binary

What is the output of the command below if run it in browser's console?

get_server_data('charset')