1. ## README for file(1) Command and the libmagic(3) library ##
  2. @(#) $File: README,v 1.59 2019/09/19 01:04:01 christos Exp $
  3. Mailing List:
  4. Mailing List archives:
  5. Bug tracker:
  6. E-mail:
  7. Build Status:
  8. Phone: Do not even think of telephoning me about this program. Send cash first!
  9. This is Release 5.x of Ian Darwin's (copyright but distributable)
  10. file(1) command, an implementation of the Unix File(1) command.
  11. It knows the 'magic number' of several thousands of file types.
  12. This version is the standard "file" command for Linux,
  13. *BSD, and other systems. (See "patchlevel.h" for the exact release number).
  14. You can download the latest version of the original sources for file from:
  16. A public read-only git repository of the same sources is available at:
  18. We are continuously being fuzzed by OSS-FUZZ:
  20. The major changes for 5.x are CDF file parsing, indirect magic, name/use
  21. (recursion) and overhaul in mime and ascii encoding handling.
  22. The major feature of 4.x is the refactoring of the code into a library,
  23. and the re-write of the file command in terms of that library. The library
  24. itself, libmagic can be used by 3rd party programs that wish to identify
  25. file types without having to fork() and exec() file. The prime contributor
  26. for 4.0 was Mans Rullgard.
  27. UNIX is a trademark of UNIX System Laboratories.
  28. The prime contributor to Release 3.8 was Guy Harris, who put in megachanges
  29. including byte-order independence.
  30. The prime contributor to Release 3.0 was Christos Zoulas, who put
  31. in hundreds of lines of source code changes, including his own
  32. ANSIfication of the code (I liked my own ANSIfication better, but
  33. his (__P()) is the "Berkeley standard" way of doing it, and I wanted UCB
  34. to include the code...), his HP-like "indirection" (a feature of
  35. the HP file command, I think), and his mods that finally got the
  36. uncompress (-z) mode finished and working.
  37. This release has compiled in numerous environments; see PORTING
  38. for a list and problems.
  39. This fine freeware file(1) follows the USG (System V) model of the file
  40. command, rather than the Research (V7) version or the V7-derived 4.[23]
  41. Berkeley one. That is, the file /etc/magic contains much of the ritual
  42. information that is the source of this program's power. My version
  43. knows a little more magic (including tar archives) than System V; the
  44. /etc/magic parsing seems to be compatible with the (poorly documented)
  45. System V /etc/magic format (with one exception; see the man page).
  46. In addition, the /etc/magic file is built from a subdirectory
  47. for easier(?) maintenance. I will act as a clearinghouse for
  48. magic numbers assigned to all sorts of data files that
  49. are in reasonable circulation. Send your magic numbers,
  50. in magic(5) format please, to the maintainer, Christos Zoulas.
  51. COPYING - read this first.
  52. README - read this second (you are currently reading this file).
  53. INSTALL - read on how to install
  54. src/apprentice.c - parses /etc/magic to learn magic
  55. src/apptype.c - used for OS/2 specific application type magic
  56. src/ascmagic.c - third & last set of tests, based on hardwired assumptions.
  57. src/asctime_r.c - replacement for OS's that don't have it.
  58. src/asprintf.c - replacement for OS's that don't have it.
  59. src/asctime_r.c - replacement for OS's that don't have it.
  60. src/asprintf.c - replacement for OS's that don't have it.
  61. src/buffer.c - buffer handling functions.
  62. src/cdf.[ch] - parser for Microsoft Compound Document Files
  63. src/cdf_time.c - time converter for CDF.
  64. src/compress.c - handles decompressing files to look inside.
  65. src/ctime_r.c - replacement for OS's that don't have it.
  66. src/der.[ch] - parser for Distinguished Encoding Rules
  67. src/dprintf.c - replacement for OS's that don't have it.
  68. src/elfclass.h - common code for elf 32/64.
  69. src/encoding.c - handles unicode encodings
  70. src/file.c - the main program
  71. src/file.h - header file
  72. src/file_opts.h - list of options
  73. src/fmtcheck.c - replacement for OS's that don't have it.
  74. src/fsmagic.c - first set of tests the program runs, based on filesystem info
  75. src/funcs.c - utilility functions
  76. src/getline.c - replacement for OS's that don't have it.
  77. src/getopt_long.c - replacement for OS's that don't have it.
  78. src/gmtime_r.c - replacement for OS's that don't have it.
  79. src/is_csv.c - knows about Comma Separated Value file format (RFC 4180).
  80. src/is_json.c - knows about JavaScript Object Notation format (RFC 8259).
  81. src/is_tar.c, tar.h - knows about Tape ARchive format (courtesy John Gilmore).
  82. src/localtime_r.c - replacement for OS's that don't have it.
  83. src/ - source file for magic.h
  84. src/mygetopt.h - replacement for OS's that don't have it.
  85. src/magic.c - the libmagic api
  86. src/names.h - header file for ascmagic.c
  87. src/pread.c - replacement for OS's that don't have it.
  88. src/print.c - print results, errors, warnings.
  89. src/readcdf.c - CDF wrapper.
  90. src/readelf.[ch] - Stand-alone elf parsing code.
  91. src/softmagic.c - 2nd set of tests, based on /etc/magic
  92. src/mygetopt.h - replacement for OS's that don't have it.
  93. src/strcasestr.c - replacement for OS's that don't have it.
  94. src/strlcat.c - replacement for OS's that don't have it.
  95. src/strlcpy.c - replacement for OS's that don't have it.
  96. src/strndup.c - replacement for OS's that don't have it.
  97. src/tar.h - tar file definitions
  98. src/vasprintf.c - for systems that don't have it.
  99. doc/ - man page for the command
  100. doc/ - man page for the magic file, courtesy Guy Harris.
  101. Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile.
  102. Magdir - directory of /etc/magic pieces
  103. ------------------------------------------------------------------------------
  104. If you submit a new magic entry please make sure you read the following
  105. guidelines:
  106. - Initial match is preferably at least 32 bits long, and is a _unique_ match
  107. - If this is not feasible, use additional check
  108. - Match of <= 16 bits are not accepted
  109. - Delay printing string as much as possible, don't print output too early
  110. - Avoid printf arbitrary byte as string, which can be a source of
  111. crash and buffer overflow
  112. - Provide complete information with entry:
  113. * One line short summary
  114. * Optional long description
  115. * File extension, if applicable
  116. * Full name and contact method (for discussion when entry has problem)
  117. * Further reference, such as documentation of format
  118. ------------------------------------------------------------------------------
  119. gpg for dummies:
  120. $ gpg --verify file-X.YY.tar.gz.asc file-X.YY.tar.gz
  121. gpg: assuming signed data in `file-X.YY.tar.gz'
  122. gpg: Signature made WWW MMM DD HH:MM:SS YYYY ZZZ using DSA key ID KKKKKKKK
  123. To download the key:
  124. $ gpg --keyserver hkp:// --recv-keys KKKKKKKK
  125. ------------------------------------------------------------------------------
  126. Parts of this software were developed at SoftQuad Inc., developers
  127. of SGML/HTML/XML publishing software, in Toronto, Canada.
  128. SoftQuad was swallowed up by Corel in 2002 and does not exist any longer.