]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/mtree/mtree.8
This commit was generated by cvs2svn to compensate for changes in r55360,
[FreeBSD/FreeBSD.git] / usr.sbin / mtree / mtree.8
1 .\" Copyright (c) 1989, 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     From: @(#)mtree.8       8.2 (Berkeley) 12/11/93
33 .\" $FreeBSD$
34 .\"
35 .Dd February 26, 1999
36 .Dt MTREE 8
37 .Os
38 .Sh NAME
39 .Nm mtree
40 .Nd map a directory hierarchy
41 .Sh SYNOPSIS
42 .Nm mtree
43 .Op Fl cdeinrUux
44 .Op Fl f Ar spec
45 .Op Fl K Ar keywords
46 .Op Fl k Ar keywords
47 .Op Fl p Ar path
48 .Op Fl s Ar seed
49 .Sh DESCRIPTION
50 The utility
51 .Nm mtree
52 compares the file hierarchy rooted in the current directory against a
53 specification read from the standard input.
54 Messages are written to the standard output for any files whose
55 characteristics do not match the specifications, or which are
56 missing from either the file hierarchy or the specification.
57 .Pp
58 The options are as follows:
59 .Bl -tag -width flag
60 .It Fl c
61 Print a specification for the file hierarchy to the standard output.
62 .It Fl d
63 Ignore everything except directory type files.
64 .It Fl e
65 Don't complain about files that are in the file hierarchy, but not in the
66 specification.
67 .It Fl f Ar file
68 Read the specification from
69 .Ar file  ,
70 instead of from the standard input.
71 .It Fl i
72 Indent the output 4 spaces each time a directory level is descended when
73 create a specification with the
74 .Fl c
75 option.
76 This does not effect either the /set statements or the comment before each
77 directory.
78 It does however effect the comment before the close of each directory.
79 .It Fl K Ar keywords
80 Add the specified (whitespace or comma separated)
81 .Ar keywords
82 to the current set of keywords.
83 .It Fl k Ar keywords
84 Use the ``type'' keyword plus the specified (whitespace or comma separated)
85 .Ar keywords
86 instead of the current set of keywords.
87 .It Fl n
88 Do not emit pathname comments when creating a specification.  Normally 
89 a comment is emitted before each directory and before the close of that
90 directory when using the 
91 .Fl c
92 option.
93 .It Fl p Ar path
94 Use the file hierarchy rooted in
95 .Ar path  ,
96 instead of the current directory.
97 .It Fl r
98 Remove any files in the file hierarchy that are not described in the
99 specification.
100 .It Fl s Ar seed
101 Display a single checksum to the standard error output that represents all
102 of the files for which the keyword
103 .Cm cksum
104 was specified.
105 The checksum is seeded with the specified value.
106 .It Fl U
107 Modify the owner, group, and permissions of existing files to match
108 the specification and create any missing directories.
109 User, group, and permissions must all be specified for missing directories
110 to be created.
111 Exit with a status of 0 on success, 1 if any error occurred,
112 a mismatch is not considered an error if it was corrected.
113 .It Fl u
114 Same as
115 .Fl U
116 except a status of 2 is returned if the file hierarchy did not match
117 the specification.
118 .It Fl x
119 Don't descend below mount points in the file hierarchy.
120 .El
121 .Pp
122 Specifications are mostly composed of ``keywords'', i.e. strings that
123 that specify values relating to files.
124 No keywords have default values, and if a keyword has no value set, no
125 checks based on it are performed.
126 .Pp
127 Currently supported keywords are as follows:
128 .Bl -tag -width Cm
129 .It Cm cksum
130 The checksum of the file using the default algorithm specified by
131 the
132 .Xr cksum 1
133 utility.
134 .It Cm flags
135 The file flags as a symbolic name.  See
136 .Xr chflags 1
137 for information on these names.  If no flags are to be set the string
138 .Dq none
139 may be used to override the current default.
140 .It Cm ignore
141 Ignore any file hierarchy below this file.
142 .It Cm gid
143 The file group as a numeric value.
144 .It Cm gname
145 The file group as a symbolic name.
146 .It Cm md5digest
147 The MD5 message digest of the file.
148 .It Cm sha1digest
149 The 
150 .Tn FIPS
151 160-1
152 .Pq Dq Tn SHA-1
153 message digest of the file.
154 .It Cm ripemd160digest
155 The
156 .Tn RIPEMD160
157 message digest of the file.
158 .It Cm mode
159 The current file's permissions as a numeric (octal) or symbolic
160 value.
161 .It Cm nlink
162 The number of hard links the file is expected to have.
163 .It Cm nochange
164 Make sure this file or directory exists but otherwise ignore all attributes.
165 .It Cm uid
166 The file owner as a numeric value.
167 .It Cm uname
168 The file owner as a symbolic name.
169 .It Cm size
170 The size, in bytes, of the file.
171 .It Cm link
172 The file the symbolic link is expected to reference.
173 .It Cm time
174 The last modification time of the file.
175 .It Cm type
176 The type of the file; may be set to any one of the following:
177 .sp
178 .Bl -tag -width Cm -compact
179 .It Cm block
180 block special device
181 .It Cm char
182 character special device
183 .It Cm dir
184 directory
185 .It Cm fifo
186 fifo
187 .It Cm file
188 regular file
189 .It Cm link
190 symbolic link
191 .It Cm socket
192 socket
193 .El
194 .El
195 .Pp
196 The default set of keywords are
197 .Cm flags ,
198 .Cm gid ,
199 .Cm mode ,
200 .Cm nlink ,
201 .Cm size ,
202 .Cm link ,
203 .Cm time ,
204 and
205 .Cm uid .
206 .Pp
207 There are four types of lines in a specification.
208 .Pp
209 The first type of line sets a global value for a keyword, and consists of
210 the string ``/set'' followed by whitespace, followed by sets of keyword/value
211 pairs, separated by whitespace.
212 Keyword/value pairs consist of a keyword, followed by an equals sign
213 (``=''), followed by a value, without whitespace characters.
214 Once a keyword has been set, its value remains unchanged until either
215 reset or unset.
216 .Pp
217 The second type of line unsets keywords and consists of the string
218 ``/unset'', followed by whitespace, followed by one or more keywords,
219 separated by whitespace.
220 .Pp
221 The third type of line is a file specification and consists of a file
222 name, followed by whitespace, followed by zero or more whitespace
223 separated keyword/value pairs.
224 The file name may be preceded by whitespace characters.
225 The file name may contain any of the standard file name matching
226 characters (``['', ``]'', ``?'' or ``*''), in which case files
227 in the hierarchy will be associated with the first pattern that
228 they match.
229 .Pp
230 Each of the keyword/value pairs consist of a keyword, followed by an
231 equals sign (``=''), followed by the keyword's value, without
232 whitespace characters.
233 These values override, without changing, the global value of the
234 corresponding keyword.
235 .Pp
236 All paths are relative.
237 Specifying a directory will cause subsequent files to be searched
238 for in that directory hierarchy.
239 Which brings us to the last type of line in a specification: a line
240 containing only the string
241 .Dq Nm \&..
242 causes the current directory
243 path to ascend one level.
244 .Pp
245 Empty lines and lines whose first non-whitespace character is a hash
246 mark (``#'') are ignored.
247 .Pp
248 The
249 .Nm
250 utility exits with a status of 0 on success, 1 if any error occurred,
251 and 2 if the file hierarchy did not match the specification.
252 A status of 2 is converted to a status of 0 if the
253 .Fl U
254 option is used.
255 .Sh EXAMPLES
256 To detect system binaries that have been ``trojan horsed'', it is recommended
257 that
258 .Nm
259 .Fl K
260 .Cm sha1digest
261 be run on the file systems, and a copy of the results stored on a different
262 machine, or, at least, in encrypted form.
263 The output file itself should be digested using the
264 .Xr md5 1
265 utility.
266 Then, periodically,
267 .Nm
268 and
269 .Xr md5 1
270 should be run against the on-line specifications.
271 While it is possible for the bad guys to change the on-line specifications
272 to conform to their modified binaries, it is believed to be
273 impractical for them to create a modified specification which has
274 the same MD5 digest as the original.
275 .Pp
276 The
277 .Fl d
278 and
279 .Fl u
280 options can be used in combination to create directory hierarchies
281 for distributions and other such things; the files in
282 .Pa /etc/mtree
283 were used to create almost all directories in this
284 .Tn FreeBSD
285 distribution.
286 .Sh FILES
287 .Bl -tag -width /etc/mtree -compact
288 .It Pa /etc/mtree
289 system specification directory
290 .El
291 .Sh SEE ALSO
292 .Xr chflags 1 ,
293 .Xr chgrp 1 ,
294 .Xr chmod 1 ,
295 .Xr cksum 1 ,
296 .Xr md5 1 ,
297 .Xr stat 2 ,
298 .Xr fts 3 ,
299 .Xr md5 3 ,
300 .Xr chown 8
301 .Sh HISTORY
302 The
303 .Nm
304 utility appeared in
305 .Bx 4.3 Reno .
306 The 
307 .Tn MD5
308 digest capability was added in
309 .Fx 2.1 ,
310 in response to the widespread use of programs which can spoof
311 .Xr cksum 1 .
312 The
313 .Tn SHA-1
314 and
315 .Tn RIPEMD160
316 digests were added in
317 .Fx 4.0 ,
318 as new attacks have demonstrated weaknesses in
319 .Tn MD5 .
320 Support for file flags was added in
321 .Fx 4.0 ,
322 and mostly comes from NetBSD.