Skip to main content

mod_mime_magic: invalid type 0 in mconvert()

I remember having these messages in my Apache logs before:

mod_mime_magic: type search/400\t\\\\section\ttext/x-tex invalid
mod_mime_magic: type search/400\t\\\\setlength\ttext/x-tex invalid
[...]
mod_mime_magic: invalid type 0 in mconvert().
....and I even remember setting up a workaround for this one. Now, years later this issue comes up again. Here's a rather ugly, semi-automatic attempt to remediate this (cosmetic) error:
$ awk '/mod_mime_magic:.*invalid$/ {print $9}' /var/log/apache2/error.log | \
   sort -u | \
   sed -e 's/search\/400.*\\\\/search\/400.*/;s/^regex.*tory\\t/regex.*/;\
   s/\//./g'  > /tmp/1
$ mkdir /usr/local/share/file/
$ cp /usr/share/file/magic.mime /usr/local/share/file/
$ for i in `cat /tmp/1`; do
     sed "s/^.*$i/# &/" -i /usr/local/share/file/magic.mime
  done
Now we can point MIMEMagicFile in mime_magic.conf to the new magic file and the errors should go away. Of course, fixing libmagic1 would be cool too :-)