[Magic-dev] ~/.magic breaks UNIX 'file' command on OS X
David Fang
fang at csl.cornell.edu
Wed May 18 14:28:35 EDT 2005
Hi Calin,
> This is the first time i hear about it. Since is not documented in file
> man page on OSX it's a bug in file on OSX.
Or just missing documentation.
> On linux I never had that problem. I checked on internet for other
> systems and at least OpenBSD, HP-UX, IRIX, Solaris don't have the
> problem that you describe.
Well not *every* unix variant is structured the same way. Mac OS
X 10.4 (darwin 8) was derived from FreeBSD 5, but not every aspect was
mirrored.
> > % file
> > file: could not find any magic files!
> This is a bug. file on unix systems reads /etc/magic not ~/.magic
According to my man file:
FILES
/usr/share/file/magic.mgc
Default compiled list of magic numbers
/usr/share/file/magic
Default list of magic numbers
/usr/share/file/magic.mime.mgc
Default compiled list of magic numbers, used to output mime
types when the -i option is specified.
/usr/share/file/magic.mime
Default list of magic numbers, used to output mime types when
the -i option is specified.
/etc/magic
Local additions to magic wisdom.
There is no /etc/magic on my system (10.4) nor on 10.3. It's
merely optional for local extensions. One has to create it and put
custom files there. No mention of $HOME/.magic, but my *observation* is
that it somehow overrides the other file-magic paths. Even an empty
.magic file breaks file.
% ls -l /usr/share/file
total 5104
-rw-r--r-- 1 root wheel 358659 Mar 20 19:03 magic
-rw-r--r-- 1 root wheel 2100032 Mar 20 19:03 magic.mgc
-rw-r--r-- 1 root wheel 30287 Mar 20 19:03 magic.mime
-rw-r--r-- 1 root wheel 115104 Mar 20 19:03 magic.mime.mgc
> > then you have a problem. The obvious workaround of course, is to
> > move .magic out of the way during such compiles. Has this been a known
> > problem? Perhaps someone with more knowledge on the subject could
> > offer a better solution?
>
> This has never been a problem. I know magic from about 5 years and
> never heard of such a problem.
Tried using it on Mac OS X? :) I guess the conclusion is that
other unices' `file' command just doesn't use $HOME/.magic, it may be as
simple as that. Perhaps I'll poke around the Darwin newsgroups or look
at the source myself.
> Sidenote: maybe it's an undocumented behaviour if it doesn't have a
> /etc/magic file to look in home directory for a ~/.magic file.
> Do you have a /etc/magic file ?
My feeling is that it's just plain undocumented.
Thanks for the feedback.
David Fang
Computer Systems Laboratory
Electrical & Computer Engineering
Cornell University
http://www.csl.cornell.edu/~fang/ -- *gag* work in progress
More information about the magic-dev
mailing list