php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30492 Invalid magic file, and mime_magic httpd.conf configuration not obeyed
Submitted: 2004-10-20 12:17 UTC Modified: 2005-03-07 22:20 UTC
Votes:8
Avg. Score:4.4 ± 0.9
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:1 (16.7%)
From: Bjorn dot Wiberg at its dot uu dot se Assigned:
Status: Wont fix Package: Unknown/Other Function
PHP Version: 5.0.2 OS: IBM AIX 5.2.0.0 ML4
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-10-20 12:17 UTC] Bjorn dot Wiberg at its dot uu dot se
Description:
------------
Hi!

I have tried using both the /apache/etc/magic file from Apache 2.0.52 and the extras/magic.mime file (from the PHP 5.0.2 for Windows zip archive), but phpinfo() always tells me:

  mime_magic

  mime_magic support	invalid magic file, disabled

  Directive	Local Value	Master Value
  mime_magic.debug	On	Off
  mime_magic.magicfile	/apache/etc/magic	no value

I configured PHP with "--with-mime-magic" but without "--enable-debug", and have set the following in my httpd.conf:

  php_admin_flag display_errors off
  php_admin_flag display_startup_errors on
  php_admin_flag mime_magic.debug on
  php_admin_value mime_magic.magicfile "/apache/etc/magic"

PHP mentions nothing about the erroneous magic file in the Apache error log, however.

I would appreciate if someone could provide me with a known working magic.mime file to try.

Thanks in advance!

Best regards,
Bj?rn

Reproduce code:
---------------
Start Apache, run a PHP script containing phpinfo(), and watch the output.

Expected result:
----------------
That mime_magic was enabled, and that there was nothing wrong with the magic file.

Actual result:
--------------
The mime_magic extension states that the magic file is invalid, but doesn't give any more information.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-11 10:18 UTC] Bjorn dot Wiberg at its dot uu dot se
It seems that the real error behind this is that the PHP mime_magic extension does NOT obey "php_admin_value mime_magic.magicfile" or "php_value mime_magic.magicfile" directives in httpd.conf, although the documentation states that mime_magic.magicfile should be settable from PHP_INI_SYSTEM, i.e., from php.ini and httpd.conf.


Apache 2 httpd.conf:
php_admin_value mime_magic.magicfile "/apache/etc/magic"

Test script:
<?php echo mime_content_type('a'); ?>

Apache 2 error log:
[client 130.238.x.x] PHP Fatal error:  mime_content_type(): mime_magic could not be initialized, magic file  is not avaliable in /apache/htdocs/test/filtyp.php on line 1

Observe the empty file name in the log output! (I did not supply a name along with --with-mime-magic during configuration, and no magic file is available in what mime_magic considers "standard" locations.)


Adding the following to php.ini correctly configures mime_magic (using the Apache 2.0.52-supplied magic file):

[mime_magic]
mime_magic.magicfile = "/etc/apache/magic"

Browser output ('a' is a text file):
text/plain


Furthermore, phpinfo() will SHOW any httpd.conf setting of mime_magic.magicfile that you make, but still not actually USE anything but what you specified in php.ini!

Best regards,
Bj?rn
 [2005-03-07 22:20 UTC] sniper@php.net
See also http://www.php.net/mime_magic
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 05:01:25 2019 UTC