1994-05-26 05:23:31 +00:00
|
|
|
.\" Copyright (c) 1989, 1990, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the University of
|
|
|
|
.\" California, Berkeley and its contributors.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
1995-02-10 03:12:42 +00:00
|
|
|
.\" From: @(#)mtree.8 8.2 (Berkeley) 12/11/93
|
1999-08-28 01:35:59 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-26 05:23:31 +00:00
|
|
|
.\"
|
2004-06-04 19:25:47 +00:00
|
|
|
.Dd January 11, 2004
|
1994-05-26 05:23:31 +00:00
|
|
|
.Dt MTREE 8
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm mtree
|
|
|
|
.Nd map a directory hierarchy
|
|
|
|
.Sh SYNOPSIS
|
2000-11-20 20:10:44 +00:00
|
|
|
.Nm
|
2004-06-04 19:25:47 +00:00
|
|
|
.Op Fl LPUcdeinqruxw
|
2000-07-14 10:30:36 +00:00
|
|
|
.Bk -words
|
1994-05-26 05:23:31 +00:00
|
|
|
.Op Fl f Ar spec
|
2000-07-14 10:30:36 +00:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
2003-11-05 22:26:08 +00:00
|
|
|
.Op Fl f Ar spec
|
|
|
|
.Ek
|
|
|
|
.Bk -words
|
1994-05-26 05:23:31 +00:00
|
|
|
.Op Fl K Ar keywords
|
2000-07-14 10:30:36 +00:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
1994-05-26 05:23:31 +00:00
|
|
|
.Op Fl k Ar keywords
|
2000-07-14 10:30:36 +00:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
1994-05-26 05:23:31 +00:00
|
|
|
.Op Fl p Ar path
|
2000-07-14 10:30:36 +00:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
1994-05-26 05:23:31 +00:00
|
|
|
.Op Fl s Ar seed
|
2000-07-14 10:30:36 +00:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
2000-05-12 03:03:00 +00:00
|
|
|
.Op Fl X Ar exclude-list
|
2000-07-14 10:30:36 +00:00
|
|
|
.Ek
|
1994-05-26 05:23:31 +00:00
|
|
|
.Sh DESCRIPTION
|
2002-07-14 14:47:15 +00:00
|
|
|
The
|
2000-05-28 15:03:14 +00:00
|
|
|
.Nm
|
2002-07-14 14:47:15 +00:00
|
|
|
utility compares the file hierarchy rooted in the current directory against a
|
1994-05-26 05:23:31 +00:00
|
|
|
specification read from the standard input.
|
|
|
|
Messages are written to the standard output for any files whose
|
|
|
|
characteristics do not match the specifications, or which are
|
|
|
|
missing from either the file hierarchy or the specification.
|
|
|
|
.Pp
|
|
|
|
The options are as follows:
|
|
|
|
.Bl -tag -width flag
|
2000-09-15 08:05:37 +00:00
|
|
|
.It Fl L
|
2000-09-25 16:24:22 +00:00
|
|
|
Follow all symbolic links in the file hierarchy.
|
|
|
|
.It Fl P
|
|
|
|
Don't follow symbolic links in the file hierarchy, instead consider
|
|
|
|
the symbolic link itself in any comparisons. This is the default.
|
2000-07-17 10:59:38 +00:00
|
|
|
.It Fl U
|
2004-06-04 19:25:47 +00:00
|
|
|
Modify the owner, group, permissions, and modification time of existing
|
|
|
|
files to match the specification and create any missing directories or
|
2003-10-31 13:39:19 +00:00
|
|
|
symbolic links.
|
2000-07-17 10:59:38 +00:00
|
|
|
User, group and permissions must all be specified for missing directories
|
|
|
|
to be created.
|
|
|
|
Corrected mismatches are not considered errors.
|
1994-05-26 05:23:31 +00:00
|
|
|
.It Fl c
|
|
|
|
Print a specification for the file hierarchy to the standard output.
|
|
|
|
.It Fl d
|
|
|
|
Ignore everything except directory type files.
|
|
|
|
.It Fl e
|
|
|
|
Don't complain about files that are in the file hierarchy, but not in the
|
|
|
|
specification.
|
1994-09-18 21:17:40 +00:00
|
|
|
.It Fl i
|
1997-10-01 06:30:02 +00:00
|
|
|
Indent the output 4 spaces each time a directory level is descended when
|
1994-09-18 21:17:40 +00:00
|
|
|
create a specification with the
|
|
|
|
.Fl c
|
|
|
|
option.
|
2000-07-17 10:59:38 +00:00
|
|
|
This does not affect either the /set statements or the comment before each
|
1994-09-18 21:17:40 +00:00
|
|
|
directory.
|
2000-07-17 10:59:38 +00:00
|
|
|
It does however affect the comment before the close of each directory.
|
|
|
|
.It Fl n
|
2001-07-15 08:06:20 +00:00
|
|
|
Do not emit pathname comments when creating a specification. Normally
|
2000-07-17 10:59:38 +00:00
|
|
|
a comment is emitted before each directory and before the close of that
|
2001-07-15 08:06:20 +00:00
|
|
|
directory when using the
|
2000-07-17 10:59:38 +00:00
|
|
|
.Fl c
|
|
|
|
option.
|
2000-07-25 19:05:09 +00:00
|
|
|
.It Fl q
|
|
|
|
Quiet mode. Do not complain when a
|
|
|
|
.Dq missing
|
2002-05-10 03:53:00 +00:00
|
|
|
directory cannot be created because it already exists.
|
2000-07-25 19:05:09 +00:00
|
|
|
This occurs when the directory is a symbolic link.
|
2000-07-17 10:59:38 +00:00
|
|
|
.It Fl r
|
|
|
|
Remove any files in the file hierarchy that are not described in the
|
|
|
|
specification.
|
|
|
|
.It Fl u
|
|
|
|
Same as
|
|
|
|
.Fl U
|
|
|
|
except a status of 2 is returned if the file hierarchy did not match
|
|
|
|
the specification.
|
2004-01-11 19:38:48 +00:00
|
|
|
.It Fl w
|
|
|
|
Make some errorconditions non-fatal warnings.
|
2000-07-17 10:59:38 +00:00
|
|
|
.It Fl x
|
|
|
|
Don't descend below mount points in the file hierarchy.
|
|
|
|
.It Fl f Ar file
|
|
|
|
Read the specification from
|
|
|
|
.Ar file ,
|
|
|
|
instead of from the standard input.
|
2003-11-05 22:26:08 +00:00
|
|
|
.Pp
|
|
|
|
If this option is specified twice, the two specifications are compared
|
|
|
|
to each other rather than to the file hierarchy.
|
|
|
|
The specifications be sorted like output generated using
|
|
|
|
.Fl c .
|
|
|
|
The output format in this case is somewhat remniscent of
|
|
|
|
.Xr comm 1 ,
|
|
|
|
having "in first spec only", "in second spec only", and "different"
|
|
|
|
columns, prefixed by zero, one and two TAB characters respectively.
|
|
|
|
Each entry in the "different" column occupies two lines, one from each specfication.
|
1997-10-01 06:30:02 +00:00
|
|
|
.It Fl K Ar keywords
|
|
|
|
Add the specified (whitespace or comma separated)
|
|
|
|
.Ar keywords
|
|
|
|
to the current set of keywords.
|
|
|
|
.It Fl k Ar keywords
|
1994-05-26 05:23:31 +00:00
|
|
|
Use the ``type'' keyword plus the specified (whitespace or comma separated)
|
1997-10-01 06:30:02 +00:00
|
|
|
.Ar keywords
|
|
|
|
instead of the current set of keywords.
|
|
|
|
.It Fl p Ar path
|
1994-05-26 05:23:31 +00:00
|
|
|
Use the file hierarchy rooted in
|
|
|
|
.Ar path ,
|
|
|
|
instead of the current directory.
|
1997-10-01 06:30:02 +00:00
|
|
|
.It Fl s Ar seed
|
1994-05-26 05:23:31 +00:00
|
|
|
Display a single checksum to the standard error output that represents all
|
|
|
|
of the files for which the keyword
|
|
|
|
.Cm cksum
|
|
|
|
was specified.
|
|
|
|
The checksum is seeded with the specified value.
|
2000-05-12 03:03:00 +00:00
|
|
|
.It Fl X Ar exclude-list
|
|
|
|
The specified file contains
|
|
|
|
.Xr fnmatch 3
|
|
|
|
patterns matching files to be excluded from
|
|
|
|
the specification, one to a line.
|
|
|
|
If the pattern contains a
|
|
|
|
.Ql \&/
|
|
|
|
character, it will be matched against entire pathnames (relative to
|
|
|
|
the starting directory); otherwise,
|
|
|
|
it will be matched against basenames only. No comments are allowed in
|
|
|
|
the
|
|
|
|
.Ar exclude-list
|
|
|
|
file.
|
1994-05-26 05:23:31 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2003-09-14 13:41:59 +00:00
|
|
|
Specifications are mostly composed of ``keywords'', i.e. strings
|
1994-05-26 05:23:31 +00:00
|
|
|
that specify values relating to files.
|
|
|
|
No keywords have default values, and if a keyword has no value set, no
|
|
|
|
checks based on it are performed.
|
|
|
|
.Pp
|
|
|
|
Currently supported keywords are as follows:
|
|
|
|
.Bl -tag -width Cm
|
|
|
|
.It Cm cksum
|
|
|
|
The checksum of the file using the default algorithm specified by
|
|
|
|
the
|
|
|
|
.Xr cksum 1
|
|
|
|
utility.
|
1999-12-09 20:38:36 +00:00
|
|
|
.It Cm flags
|
|
|
|
The file flags as a symbolic name. See
|
|
|
|
.Xr chflags 1
|
|
|
|
for information on these names. If no flags are to be set the string
|
|
|
|
.Dq none
|
|
|
|
may be used to override the current default.
|
1994-05-26 05:23:31 +00:00
|
|
|
.It Cm ignore
|
|
|
|
Ignore any file hierarchy below this file.
|
|
|
|
.It Cm gid
|
|
|
|
The file group as a numeric value.
|
|
|
|
.It Cm gname
|
|
|
|
The file group as a symbolic name.
|
1995-02-10 03:12:42 +00:00
|
|
|
.It Cm md5digest
|
|
|
|
The MD5 message digest of the file.
|
1999-02-26 18:44:56 +00:00
|
|
|
.It Cm sha1digest
|
2001-07-15 08:06:20 +00:00
|
|
|
The
|
1999-02-26 18:44:56 +00:00
|
|
|
.Tn FIPS
|
|
|
|
160-1
|
|
|
|
.Pq Dq Tn SHA-1
|
|
|
|
message digest of the file.
|
|
|
|
.It Cm ripemd160digest
|
|
|
|
The
|
|
|
|
.Tn RIPEMD160
|
|
|
|
message digest of the file.
|
1994-05-26 05:23:31 +00:00
|
|
|
.It Cm mode
|
|
|
|
The current file's permissions as a numeric (octal) or symbolic
|
|
|
|
value.
|
|
|
|
.It Cm nlink
|
|
|
|
The number of hard links the file is expected to have.
|
1998-06-10 06:45:08 +00:00
|
|
|
.It Cm nochange
|
|
|
|
Make sure this file or directory exists but otherwise ignore all attributes.
|
1994-05-26 05:23:31 +00:00
|
|
|
.It Cm uid
|
|
|
|
The file owner as a numeric value.
|
|
|
|
.It Cm uname
|
1994-09-03 13:20:05 +00:00
|
|
|
The file owner as a symbolic name.
|
1994-05-26 05:23:31 +00:00
|
|
|
.It Cm size
|
|
|
|
The size, in bytes, of the file.
|
|
|
|
.It Cm link
|
|
|
|
The file the symbolic link is expected to reference.
|
|
|
|
.It Cm time
|
|
|
|
The last modification time of the file.
|
|
|
|
.It Cm type
|
|
|
|
The type of the file; may be set to any one of the following:
|
2000-11-10 17:46:15 +00:00
|
|
|
.Pp
|
1994-05-26 05:23:31 +00:00
|
|
|
.Bl -tag -width Cm -compact
|
|
|
|
.It Cm block
|
|
|
|
block special device
|
|
|
|
.It Cm char
|
|
|
|
character special device
|
|
|
|
.It Cm dir
|
|
|
|
directory
|
|
|
|
.It Cm fifo
|
|
|
|
fifo
|
|
|
|
.It Cm file
|
|
|
|
regular file
|
|
|
|
.It Cm link
|
|
|
|
symbolic link
|
|
|
|
.It Cm socket
|
|
|
|
socket
|
|
|
|
.El
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The default set of keywords are
|
1999-12-09 20:38:36 +00:00
|
|
|
.Cm flags ,
|
1994-05-26 05:23:31 +00:00
|
|
|
.Cm gid ,
|
|
|
|
.Cm mode ,
|
|
|
|
.Cm nlink ,
|
|
|
|
.Cm size ,
|
1994-09-03 13:20:05 +00:00
|
|
|
.Cm link ,
|
1994-05-26 05:23:31 +00:00
|
|
|
.Cm time ,
|
|
|
|
and
|
|
|
|
.Cm uid .
|
|
|
|
.Pp
|
|
|
|
There are four types of lines in a specification.
|
|
|
|
.Pp
|
|
|
|
The first type of line sets a global value for a keyword, and consists of
|
|
|
|
the string ``/set'' followed by whitespace, followed by sets of keyword/value
|
|
|
|
pairs, separated by whitespace.
|
|
|
|
Keyword/value pairs consist of a keyword, followed by an equals sign
|
|
|
|
(``=''), followed by a value, without whitespace characters.
|
|
|
|
Once a keyword has been set, its value remains unchanged until either
|
|
|
|
reset or unset.
|
|
|
|
.Pp
|
|
|
|
The second type of line unsets keywords and consists of the string
|
|
|
|
``/unset'', followed by whitespace, followed by one or more keywords,
|
|
|
|
separated by whitespace.
|
|
|
|
.Pp
|
|
|
|
The third type of line is a file specification and consists of a file
|
|
|
|
name, followed by whitespace, followed by zero or more whitespace
|
|
|
|
separated keyword/value pairs.
|
|
|
|
The file name may be preceded by whitespace characters.
|
|
|
|
The file name may contain any of the standard file name matching
|
|
|
|
characters (``['', ``]'', ``?'' or ``*''), in which case files
|
|
|
|
in the hierarchy will be associated with the first pattern that
|
|
|
|
they match.
|
|
|
|
.Pp
|
|
|
|
Each of the keyword/value pairs consist of a keyword, followed by an
|
|
|
|
equals sign (``=''), followed by the keyword's value, without
|
|
|
|
whitespace characters.
|
|
|
|
These values override, without changing, the global value of the
|
|
|
|
corresponding keyword.
|
|
|
|
.Pp
|
|
|
|
All paths are relative.
|
|
|
|
Specifying a directory will cause subsequent files to be searched
|
|
|
|
for in that directory hierarchy.
|
|
|
|
Which brings us to the last type of line in a specification: a line
|
|
|
|
containing only the string
|
2000-12-27 15:30:30 +00:00
|
|
|
.Dq Pa ..\&
|
1994-05-26 05:23:31 +00:00
|
|
|
causes the current directory
|
|
|
|
path to ascend one level.
|
|
|
|
.Pp
|
|
|
|
Empty lines and lines whose first non-whitespace character is a hash
|
|
|
|
mark (``#'') are ignored.
|
|
|
|
.Pp
|
|
|
|
The
|
1997-10-01 06:30:02 +00:00
|
|
|
.Nm
|
1994-05-26 05:23:31 +00:00
|
|
|
utility exits with a status of 0 on success, 1 if any error occurred,
|
|
|
|
and 2 if the file hierarchy did not match the specification.
|
1994-10-09 20:28:31 +00:00
|
|
|
A status of 2 is converted to a status of 0 if the
|
|
|
|
.Fl U
|
|
|
|
option is used.
|
1994-05-26 05:23:31 +00:00
|
|
|
.Sh EXAMPLES
|
|
|
|
To detect system binaries that have been ``trojan horsed'', it is recommended
|
|
|
|
that
|
1997-10-01 06:30:02 +00:00
|
|
|
.Nm
|
1995-02-10 03:12:42 +00:00
|
|
|
.Fl K
|
1999-02-26 18:44:56 +00:00
|
|
|
.Cm sha1digest
|
2002-12-12 17:26:04 +00:00
|
|
|
be run on the file systems, and a copy of the results stored on a different
|
1994-05-26 05:23:31 +00:00
|
|
|
machine, or, at least, in encrypted form.
|
1995-02-10 03:12:42 +00:00
|
|
|
The output file itself should be digested using the
|
|
|
|
.Xr md5 1
|
|
|
|
utility.
|
1994-05-26 05:23:31 +00:00
|
|
|
Then, periodically,
|
1997-10-01 06:30:02 +00:00
|
|
|
.Nm
|
1995-02-10 03:12:42 +00:00
|
|
|
and
|
|
|
|
.Xr md5 1
|
|
|
|
should be run against the on-line specifications.
|
1994-05-26 05:23:31 +00:00
|
|
|
While it is possible for the bad guys to change the on-line specifications
|
1995-02-10 03:12:42 +00:00
|
|
|
to conform to their modified binaries, it is believed to be
|
|
|
|
impractical for them to create a modified specification which has
|
|
|
|
the same MD5 digest as the original.
|
1994-05-26 05:23:31 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fl d
|
|
|
|
and
|
|
|
|
.Fl u
|
|
|
|
options can be used in combination to create directory hierarchies
|
1995-02-10 03:12:42 +00:00
|
|
|
for distributions and other such things; the files in
|
|
|
|
.Pa /etc/mtree
|
1996-01-30 13:52:50 +00:00
|
|
|
were used to create almost all directories in this
|
2000-05-28 15:03:14 +00:00
|
|
|
.Fx
|
1995-02-10 03:12:42 +00:00
|
|
|
distribution.
|
1994-05-26 05:23:31 +00:00
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width /etc/mtree -compact
|
|
|
|
.It Pa /etc/mtree
|
|
|
|
system specification directory
|
|
|
|
.El
|
2000-07-17 10:59:38 +00:00
|
|
|
.Sh DIAGNOSTICS
|
2001-08-15 09:09:47 +00:00
|
|
|
.Ex -std
|
1994-05-26 05:23:31 +00:00
|
|
|
.Sh SEE ALSO
|
1999-12-09 20:38:36 +00:00
|
|
|
.Xr chflags 1 ,
|
1994-05-26 05:23:31 +00:00
|
|
|
.Xr chgrp 1 ,
|
1997-01-20 00:03:00 +00:00
|
|
|
.Xr chmod 1 ,
|
1994-05-26 05:23:31 +00:00
|
|
|
.Xr cksum 1 ,
|
1995-02-10 03:12:42 +00:00
|
|
|
.Xr md5 1 ,
|
1994-05-26 05:23:31 +00:00
|
|
|
.Xr stat 2 ,
|
|
|
|
.Xr fts 3 ,
|
1996-02-11 22:38:05 +00:00
|
|
|
.Xr md5 3 ,
|
|
|
|
.Xr chown 8
|
1994-05-26 05:23:31 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
1997-10-01 06:30:02 +00:00
|
|
|
.Nm
|
1994-05-26 05:23:31 +00:00
|
|
|
utility appeared in
|
|
|
|
.Bx 4.3 Reno .
|
2001-07-15 08:06:20 +00:00
|
|
|
The
|
1999-02-26 18:44:56 +00:00
|
|
|
.Tn MD5
|
|
|
|
digest capability was added in
|
1997-10-01 06:30:02 +00:00
|
|
|
.Fx 2.1 ,
|
|
|
|
in response to the widespread use of programs which can spoof
|
1995-02-10 03:12:42 +00:00
|
|
|
.Xr cksum 1 .
|
1999-02-26 18:44:56 +00:00
|
|
|
The
|
|
|
|
.Tn SHA-1
|
|
|
|
and
|
|
|
|
.Tn RIPEMD160
|
|
|
|
digests were added in
|
|
|
|
.Fx 4.0 ,
|
|
|
|
as new attacks have demonstrated weaknesses in
|
|
|
|
.Tn MD5 .
|
1999-12-09 20:38:36 +00:00
|
|
|
Support for file flags was added in
|
|
|
|
.Fx 4.0 ,
|
2000-07-17 10:59:38 +00:00
|
|
|
and mostly comes from
|
|
|
|
.Nx .
|