MTREE(8) BSD System Manager's Manual MTREE(8) NNAAMMEE mmttrreeee - map a directory hierarchy SSYYNNOOPPSSIISS mmttrreeee [--ccddeerruuxx] [--ff _s_p_e_c] [--KK _k_e_y_w_o_r_d_s] [--kk _k_e_y_w_o_r_d_s] [--pp _p_a_t_h] [--ss _s_e_e_d] DDEESSCCRRIIPPTTIIOONN The utility mmttrreeee compares the file hierarchy rooted in the current di- rectory against a specification read from the standard input. Messages are written to the standard output for any files whose characteristics do not match the specification's, or which are missing from either the file hierarchy or the specification. The options are as follows: --cc Print a specification for the file hierarchy to the standard out- put. --dd Ignore everything except directory type files. --ee Don't complain about files that are in the file hierarchy, but not in the specification. --ff Read the specification from _f_i_l_e, instead of from the standard in- put. --KK Add the specified (whitespace or comma separated) keywords to the current set of keywords. --kk Use the ``type'' keyword plus the specified (whitespace or comma separated) keywords instead of the current set of keywords. --pp Use the file hierarchy rooted in _p_a_t_h, instead of the current di- rectory. --rr Remove any files in the file hierarchy that are not described in the specification. --ss Display a single checksum to the standard error output that repre- sents all of the files for which the keyword cckkssuumm was specified. The checksum is seeded with the specified value. --uu Modify the owner, group, and permissions of existing files to match the specification and create any missing directories. User, group, and permissions must all be specified for missing directories to be created. --xx Don't descend below mount points in the file hierarchy. Specifications are mostly composed of ``keywords'', i.e. strings that 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. Currently supported keywords are as follows: cckkssuumm The checksum of the file using the default algorithm speci- fied by the cksum(1) utility. iiggnnoorree Ignore any file hierarchy below this file. ggiidd The file group as a numeric value. ggnnaammee The file group as a symbolic name. mmooddee The current file's permissions as a numeric (octal) or sym- bolic value. nnlliinnkk The number of hard links the file is expected to have. uuiidd The file owner as a numeric value. uunnaammee The file group as a symbolic name. ssiizzee The size, in bytes, of the file. lliinnkk The file the symbolic link is expected to reference. ttiimmee The last modification time of the file. ttyyppee The type of the file; may be set to any one of the following: bblloocckk block special device cchhaarr character special device ddiirr directory ffiiffoo fifo ffiillee regular file lliinnkk symbolic link ssoocckkeett socket The default set of keywords are ggiidd, mmooddee, nnlliinnkk, ssiizzee, sslliinnkk, ttiimmee, and uuiidd. There are four types of lines in a specification. 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 key- word/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. The second type of line unsets keywords and consists of the string ``/un- set'', followed by whitespace, followed by one or more keywords, separat- ed by whitespace. The third type of line is a file specification and consists of a file name, followed by whitespace, followed by zero or more whitespace sepa- rated 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. 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. 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 ``....'' causes the current directory path to ascend one level. Empty lines and lines whose first non-whitespace character is a hash mark (``#'') are ignored. The mmttrreeee utility exits with a status of 0 on success, 1 if any error oc- curred, and 2 if the file hierarchy did not match the specification. EEXXAAMMPPLLEESS To detect system binaries that have been ``trojan horsed'', it is recom- mended that mmttrreeee be run on the file systems, and a copy of the results stored on a different machine, or, at least, in encrypted form. The seed for the --ss option should not be an obvious value and the final checksum should not be stored on-line under any circumstances! Then, periodical- ly, mmttrreeee should be run against the on-line specifications and the final checksum compared with the previous value. While it is possible for the bad guys to change the on-line specifications to conform to their modi- fied binaries, it shouldn't be possible for them to make it produce the same final checksum value. If the final checksum value changes, the off- line copies of the specification can be used to detect which of the bina- ries have actually been modified. The --dd and --uu options can be used in combination to create directory hi- erarchies for distributions and other such things. FFIILLEESS /etc/mtree system specification directory SSEEEE AALLSSOO chmod(1), chown(1), chgrp(1), cksum(1), stat(2), fts(3), HHIISSTTOORRYY The mmttrreeee utility appeared in 4.3BSD-Reno. 4.4BSD June 6, 1993 3