Apache2 magic mime file is broken (2.4.52-1ubuntu4.2)

Bug #2003709 reported by Eli Barzilay
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apache2 (Ubuntu)
New
Undecided
Unassigned
Jammy
Triaged
Undecided
Unassigned

Bug Description

The default `/etc/apache2/magic` file that comes with apache2 seems to be broken.

I don't know what exactly is the problem, but here are a few details that demonstrate that it is indeed broken:

* echo -e "<!DOCTYPE HTML>\nblah blah" > /tmp/foo

* file -m /etc/apache2/magic /tmp/foo
  => Shows a bunch of "string modifier `B' invalid" warnings
     and finally: "could not find any valid magic files!"

* Trying to fetch this file via apache for a configuration that has "a2enmod mime_magic" results in no Content-Type header

* Now, get the original magic file from https://raw.githubusercontent.com/apache/httpd/trunk/docs/conf/magic
  drop it in the same place:
  => the `file` command now works as expected,
  => fetching the file via apache has the expected Content-Type header

* Alternatively, modify the original magic file by removing all "B" modifiers
  (on lines 187, 402, 403, 404, 405, 622, 627, 631, 632)
  => both the `file` command and the header from apache work

---

version information:

$ lsb_release -rd
Description: Ubuntu 22.04.1 LTS
Release: 22.04

$ apt-cache policy apache2
apache2:
  Installed: 2.4.52-1ubuntu4.2
  Candidate: 2.4.52-1ubuntu4.2
  Version table:
 *** 2.4.52-1ubuntu4.2 500
        500 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.4.52-1ubuntu4.1 500
        500 http://us.archive.ubuntu.com/ubuntu jammy-security/main amd64 Packages
     2.4.52-1ubuntu4 500
        500 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 Packages

Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Thanks for reporting this bug and trying to make Ubuntu better.

I tried to reproduce what you described in a Ubuntu Jammy container:

root@apache2-jammy:~# dpkg -l apache2
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-=================-============-============================>
ii apache2 2.4.52-1ubuntu4.2 amd64 Apache HTTP Server
root@apache2-jammy:~# cat /tmp/foo
<!DOCTYPE HTML>
blah blah
root@apache2-jammy:~# file -m /etc/apache2/magic /tmp/foo
/etc/apache2/magic, 187: Warning: string modifier `B' invalid
/etc/apache2/magic, 402: Warning: string modifier `B' invalid
/etc/apache2/magic, 619: Warning: string modifier `B' invalid
/etc/apache2/magic, 624: Warning: string modifier `B' invalid
/etc/apache2/magic, 628: Warning: string modifier `B' invalid
/etc/apache2/magic, 629: Warning: string modifier `B' invalid
file: could not find any valid magic files!
root@apache2-jammy:~# wget https://raw.githubusercontent.com/apache/httpd/trunk/docs/conf/magic
--2023-01-24 20:29:34-- https://raw.githubusercontent.com/apache/httpd/trunk/docs/conf/magic
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13064 (13K) [text/plain]
Saving to: ‘magic’

magic 100%[==================>] 12.76K --.-KB/s in 0.001s

2023-01-24 20:29:35 (9.45 MB/s) - ‘magic’ saved [13064/13064]

root@apache2-jammy:~# file -m ./magic /tmp/foo
/tmp/foo: text/html

The file shipped in the Ubuntu package diverges from the upstream one. This requires extra investigation to understand why this was done. Adding this bug to our backlog.

Changed in apache2 (Ubuntu Jammy):
status: New → Triaged
Revision history for this message
Eli Barzilay (elibarzilay) wrote :

Yeah, the file is very different, and also much bigger. I couldn't find which variant of `file` supports those B modifiers...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.