Description: Support local definitions in /etc/magic Author: Michael Piefel , Judit Foglszinger Forwarded: no Last-Update: 2016-06-27 --- a/magic/Header +++ b/magic/Header @@ -1,5 +1,6 @@ # Magic data for file(1) command. -# Format is described in magic(files), where: -# files is 5 on V7 and BSD, 4 on SV, and ?? on SVID. +# Format is described in in magic(5). # Don't edit this file, edit /etc/magic or send your magic improvements -# to the maintainers, at file@astron.com +# to the upstream maintainers, at file@astron.com +# or send your suggested inclusions +# as a wishlist bug against the file package (using the reportbug utility). --- /dev/null +++ b/magic/magic.local @@ -0,0 +1,3 @@ +# Magic local data for file(1) command. +# Insert here your local magic data. Format is described in magic(5). + --- a/src/apprentice.c +++ b/src/apprentice.c @@ -460,7 +460,7 @@ #ifndef COMPILE_ONLY map = apprentice_map(ms, fn); if (map == NULL) { - if (ms->flags & MAGIC_CHECK) + if (ms->flags & MAGIC_CHECK && strcmp("/etc/magic", fn) != 0) file_magwarn(ms, "using regular magic file `%s'", fn); map = apprentice_load(ms, fn, action); if (map == NULL) --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,7 +4,7 @@ bin_PROGRAMS = file -AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"' +AM_CPPFLAGS = -DMAGIC='"/etc/magic:$(MAGIC)"' AM_CFLAGS = $(CFLAG_VISIBILITY) @WARNINGS@ libmagic_la_SOURCES = buffer.c magic.c apprentice.c softmagic.c ascmagic.c \ --- a/src/Makefile.in +++ b/src/Makefile.in @@ -359,7 +359,7 @@ MAGIC = $(pkgdatadir)/magic lib_LTLIBRARIES = libmagic.la nodist_include_HEADERS = magic.h -AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"' +AM_CPPFLAGS = -DMAGIC='"/etc/magic:$(MAGIC)"' AM_CFLAGS = $(CFLAG_VISIBILITY) @WARNINGS@ libmagic_la_SOURCES = buffer.c magic.c apprentice.c softmagic.c ascmagic.c \ encoding.c compress.c is_csv.c is_json.c is_tar.c readelf.c print.c \ --- a/doc/file.man +++ b/doc/file.man @@ -58,7 +58,7 @@ or non-printable). Exceptions are well-known file formats (core files, tar archives) that are known to contain binary data. -When modifying magic files or the program itself, make sure to +When adding local definitions to /etc/magic, make sure to .Em "preserve these keywords" . Users depend on knowing that all the readable files in a directory have the word @@ -102,7 +102,8 @@ has been applied by extension to data files. Any file with some invariant identifier at a small fixed offset into the file can usually be described in this way. -The information identifying these files is read from the compiled +The information identifying these files is read from /etc/magic +and the compiled magic file .Pa __MAGIC__.mgc , or the files in the directory @@ -565,12 +566,6 @@ The order of entries in the magic file is significant. Depending on what system you are using, the order that they are put together may be incorrect. -If your old -.Nm -command uses a magic file, -keep the old magic file around for comparison purposes -(rename it to -.Pa __MAGIC__.orig ) . .Sh HISTORY There has been a .Nm