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