php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #57473 Be able to use magic-info from package shared-mime-info
Submitted: 2007-01-10 10:52 UTC Modified: 2017-10-11 17:17 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: motin at demomusic dot nu Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.0 RC4 OS: Linux
Private report: No CVE-ID: None
 [2007-01-10 10:52 UTC] motin at demomusic dot nu
Description:
------------
Fileinfo should be able to use not only the magic-file supplied by Apache or the libmagic magic-file but also the magic-info included with the package shared-mime-info from freedesktop.org

The files currently generated by shared-mime-info's update-mime-database are stored in binary form and trying to link to any of these files as the magic file yields the error: 

finfo_open(): Failed to load magic database at '/path/to/updated/files/magic'. in ...

The same error is produced when trying any other of the updated files, as well as trying a copy of "magic" renamed to "magic.mime" (Needed for fileinfo ta accept the /etc/apache2/magic file earlier)

Using the shared-mime-info magic-info would allow fileinfo to detect a lot more mimetypes more exactly. 

http://forums.devshed.com/php-development-5/how-do-i-use-magic-file-from-shared-mime-info-with-fileinfo-415722.html#post1711168

Reproduce code:
---------------
$finfo = finfo_open(FILEINFO_MIME, "/path/to/updated/files/magic");

Expected result:
----------------
No errors, fileinfo object loading successsfully ready to be used.

Actual result:
--------------
finfo_open(): Failed to load magic database at '/path/to/updated/files/magic'. in ...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-04 10:47 UTC] joungkyun at gmail dot com
if /path/to/updated/files/magic is soft link, fix it follow patch. This is clearly bug. :-( I want to fix it.

diff -urNp fileinfo.org/fileinfo.c fileinfo/fileinfo.c
--- fileinfo.org/fileinfo.c 2006-11-08 06:18:51.000000000 +0900
+++ fileinfo/fileinfo.c 2007-10-04 23:22:43.000000000 +0900
@@ -260,12 +260,12 @@ PHP_FUNCTION(finfo_open)
        RETURN_FALSE;
    }

-   if (file_len) { /* user specified filed, perform open_basedir checks */
-       if (!VCWD_REALPATH(file, resolved_path)) {
-           RETURN_FALSE;
-       }
-       file = resolved_path;
+   if (!VCWD_REALPATH(file, resolved_path)) {
+       RETURN_FALSE;
+   }
+   file = resolved_path;

+   if (file_len) { /* user specified filed, perform open_basedir checks */
        if ((PG(safe_mode) && (!php_checkuid(file, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(file TSRMLS_CC)) {
            RETURN_FALSE;
        }
 [2017-07-04 07:23 UTC] motin at demomusic dot nu
Please close this ancient and inaccurate bug report, I've lost the password. 

(This works as it should nowadays and may have worked a decade ago, when I first reported the bug, but was a lot less experienced :) )
 [2017-10-11 17:17 UTC] ab@php.net
-Status: Open +Status: Not a bug -Package: Fileinfo +Package: *General Issues
 [2017-10-11 17:17 UTC] ab@php.net
Closing as per request. But also to mention is - external magic files are versioned, so loading some version not matching current ext version won't work.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 14:01:29 2024 UTC