Commit Graph

59 Commits

Author SHA1 Message Date
spz b1a40de246 resource leak (Coverity issues 274383 and 274384) 2012-07-15 09:08:29 +00:00
apb 5e464841ab Make "mtree -C" sort its output.
As the input is read from a specfile into a tree of linked lists,
keep each linked list sorted.  The sort order is the same as that
already used by "mtree -c": directories sort after non-directories, but
otherwise names are sorted in the order used by strcmp().
2009-04-03 21:18:59 +00:00
hubertf dde9e1886b When {MD5,RMD160,SHA1,SHA256_,SHA384_,SHA512_}File fail, use errno
to print what's actually wrong
2009-02-01 22:36:24 +00:00
christos ab515b681b fix dev_t formats. 2008-12-28 19:36:30 +00:00
christos 1f093d4259 PR/37482: Malcolm Herbert: mtree does not check for getlogin() returning null
in spec create
2007-12-05 16:55:29 +00:00
rillig f8d3de218d Renamed dsort to dcmp, since it doesn't sort, it only compares. 2007-11-19 08:58:54 +00:00
rillig 50e4f54b4c Even on non-BSD systems, the "-R all" option should disable printing of
the "time" attribute. Noticed by Malcolm Herbert on tech-pkg.
2007-11-19 08:42:24 +00:00
christos 50295fe38d cast to long explicitly for the compat build 2007-10-18 02:28:22 +00:00
elad 3044852cc5 The hashing routines (MD5File() and co.) can do dynamic allocation, so
take advantage of that instead of an ugly hard-coded MAXHASHLEN limit
that needs updating.

I think this was suggested by cube@ years ago.
2007-02-04 08:03:18 +00:00
christos 11c53ad61c kill crypto/rmd160.h and crypto/sha2.h, and instead make symlinks to
/usr/include from /usr/include/sys. This makes all the one way hash
header handling identical.
2006-10-30 20:22:53 +00:00
elad a375b7cdb7 Use crypto/rmd160.h. 2005-09-24 22:40:32 +00:00
elad d05d5cada8 Use MAXHASHLEN here too. 2005-09-02 17:12:38 +00:00
elad aae00d5a54 Add SHA2 support in mtree. 2005-08-24 20:55:41 +00:00
lukem 507e9f7256 strsvis(3) encode & decode the "link=" value (symlink target). 2004-12-01 10:07:56 +00:00
jmc b2f782612f Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
2004-06-20 22:20:14 +00:00
lukem 171d653219 Overhaul how `build.sh tools' are used:
*	Rename "config.h" to "nbtool_config.h" and
	HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
	This makes in more obvious in the source when we're using
	tools/compat/config.h versus "standard autoconf" config.h

    *	Consistently move the inclusion of nbtool_config.h to before
    	<sys/cdefs.h> so that the former can provide __RCSID() (et al),
    	and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
	#if HAVE_NBTOOL_CONFIG_H
	#include "nbtool_config.h"
	#endif
to the top of the source files (for the general case).
2003-10-27 00:12:41 +00:00
agc 326b2259b7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22366, verified by myself.
2003-08-07 11:25:11 +00:00
lukem 3cbfaf0af4 Add -C, which dumps the specification with the full path name first,
and then all the other fields.  (I.e, like -D except with the name
first instead of last).
Consistenly strsvis(3) encode path names (even for -C and -D).
2002-12-23 04:40:19 +00:00
grant 58306652d2 avoid non-constant initializer errors by changing hack to workaround
gcc warning to a slightly different hack.
2002-11-29 02:07:34 +00:00
soren 236006d5dc Remove extraneous \n's in {err,warn}{,x} that used to be printfs. 2002-08-08 13:24:12 +00:00
tv 76834aef57 Protect __RCSID and __COPYRIGHT from being invoked if not defined. 2002-01-31 19:36:47 +00:00
tv fcae5f73b7 Add hooks to make mtree compilable from src/tools. 2002-01-29 00:07:27 +00:00
lukem 7c6d79f87c provide the ability to remove support for generating or checking various
digests by #define-ing NO_MD5, NO_RMD160, or NO_SHA1.  the keywords are
still parsed.
2001-11-10 14:58:20 +00:00
lukem e8b2f3326f User interface changes from (or inspired by) FreeBSD:
- Add -L to walk the tree `logically', by following symbolic links in
  the heirarchy.
- Add -P to walk the tree `physically'. This is the current behaviour,
  and the default.
- Add "-X excludes-file" to give mtree the ability to exclude files and
  directories from its traversal.  excludes-file contains fnmatch(3)
  patterns to exclude from the walk.
- Add "md5digest" synonym for "md5".
- Add "rmd160" keyword for RMD-160 message digest, and "rmd160digest" synonym.
- Add "sha1" keyword for SHA-1 message digest, and "sha1digest" synonym.
- Don't try to compare() other attributes if the type doesn't match;
  it's nothing but trouble, and no use anyway.
- In -c, only emit "/set" records if something has changed since the
  previous one.

User interface changes by me:
- Check a device's parameters before checking uid/gid/mode.
- If updating (-u), modify the following to match the specification:
	- Device type (retaining existing ownership).
	- Symlink target.

Fixes from (or inspired by) FreeBSD:
- Use p->ftslevel instead of own code to keep track of the level ourself.
  The previous code got majorly confused if fts(3) couldn't descend
  into a subdir, resulting in leaf nodes getting attached to the wrong
  directory.
  XXX: This new method is much much more robust, even though it's not 100%
  perfect; it might result in a couple of following entries in the spec
  to be incorrectly tagged as missing.
- Pass a useful pathname to rlink(), so that logical (-L) traversal
  doesn't confuse symlink checking.
- Consistently use MAXPATHLEN+1 sized buffers for pathnames, so that
  there's room for the NUL.
- Use mtree_err() and strerror(p->fts_errno) to report errors during
  the fts(3) walk.

Fixes by me:
- Remove now-unused `const char *name' argument from compare().
- Change crc_total from an int to a u_int32_t, to match usr.bin/cksum/crc.c.
- Remove trailing whitespace.
- Remove unnecessary (void) casts on functions.
- Reorder entries in the getopt() switch.
- Replace strtoq() with strtoll(), and use strtoul() appropriately.
- Renumber F_ flags to be in alphabetical order.
2001-11-07 08:01:51 +00:00
lukem 57566f70f8 - enforce the top-most entry must be "." and must be a directory; avoids
various potential problems when intermixing full and relative paths
- changes to make it much easier to use spec() - the specfile parser - in
  other programs (via .PATHing spec.c and misc.c):
	- move excludetags, includetags and keys from mtree.c to misc.c
	- implement mtree_err() using vwarnx() instead of assuming name is
	  "mtree"
	- move inotype() and nodetype() from compare.c to misc.c
	- add nodetoinode(), to convert from an mtree F_* type to a
	  mode_t S_IF* type
	- clean up #include use; don't assume "mtree.h" pulls in some
	  standard includes
	- change spec() to take a FILE * arg (where the specfile is read from)
2001-10-22 07:07:46 +00:00
lukem f644bd620b complete WARNS=2 cleanup (with a bit of ickiness for the fts_open argv issue) 2001-10-18 05:06:01 +00:00
lukem 98df36b3a5 make this mostly WARNS=2 safe 2001-10-18 04:37:56 +00:00
lukem bc1697fc70 Add "device" keyword, which allows the device number to be specified,
to be later checked and possibly created. Uses parsing and encoding
routines from mknod(8).
2001-10-09 04:50:00 +00:00
lukem 7c30045cef features:
- add a new keyword - "tags" - which is a comma separated list of tags
  associated with that file.
- add "-E tags"; exclude files in -D output with matching tags
- add "-I tags"; only include files in -D output with matching tags
  (default is to list all)

fixes:
- move all extern variable references from individual files into extern.h
- `quote' some more user-specified strings in error messages
- man page: list an options arguments in the description, and sort xrefs.
2001-10-04 04:51:27 +00:00
lukem 0c2c66fb9a - implement -D - dump the specfile out in a manner that's parseable
by various tools
- implement -R key  - remove the given key(s) from the list of keys to print
  (now it's possible with "-k type -R type" to remove all keys :)
- rename ftype() to nodetype(), and make it public
- use pwcache(3) functions instead of get{gr,pw}{nam,uid}(3)
- add dump_nodes(), which provides the guts for -D.
2001-10-01 02:30:40 +00:00
simonb 7cbb4e05a0 ANSIfy, KNF, in preperation for more work. 2001-03-09 03:09:45 +00:00
hubertf 1156c833f6 Remove all the "#ifdef __APPLE__" code, to make this actually
build again on Darwin. The code in question is outdated.

OK'd by Wilfredo Sanchez wsanchez@MIT.EDU.
2001-02-20 19:45:51 +00:00
is 0e32b4bfb3 LP64 format string cleanup. Problem reported by garbled. 2000-10-15 12:27:25 +00:00
is d8302e2d73 More format string cleanups by sommerfeld. 2000-10-11 20:23:46 +00:00
wennmach dff19e227b Now that we have strsvis, use it. 1999-12-01 22:12:52 +00:00
wennmach 7db0eb0492 Encode file names using strvis(3) when creating a specification.
Escape white space characters and `#' characters. Do the inverse
when reading specs.

This is a temporary fix until we have strzouvis(3) (or some such)
which is an improved version of strvis (taking an additional list
of characters to encode).

Fixes PR 5006 and PR 7663
1999-11-07 20:23:01 +00:00
christos 78a99dbab7 portability fixes:
- don't use timespecs in struct stat on non 4.4BSD systems
- don't assume that tv_sec is a time_t
1999-07-06 15:11:14 +00:00
hubertf 657f0ba4f7 Actually generate MD5 checksums, as reported in PR 7928.
Approved by Dr. Lex Wennmacher <wennmach@geo.Uni-Koeln.DE>
1999-07-06 12:59:12 +00:00
mrg f2aaba6db6 - add -m and -i to change file flags more usefully.
- fix bugs in fileflags checking

all of the above from dr. lex wennmacher <wennmach@geo.Uni-Koeln.DE>
with some error fixes from egcs via myself.
1999-02-11 15:32:23 +00:00
christos 62871103f9 Appease gcc-2.8.1, make printf formats more portable. 1998-12-19 15:38:45 +00:00
christos e091e64548 Namespace protection against MAXUID etc. 1998-11-03 15:14:40 +00:00
mrg f2fb63efda add support for 4.4BSD file flags. we take a `flags=xxx' parameter,
using the same style of naming as chflags, ls & xinstall use, plus an
additional `none' to turn off a default setting.
1998-10-10 07:50:27 +00:00
wsanchez c45946d27c Use u_int32_t rather than Sys-V u_long.
Rename err() to mtree_err(), to avoid conflict with libc.
1998-10-08 02:04:55 +00:00
nathanw b757463521 Add braces to satisfy egcs. 1998-08-30 03:20:09 +00:00
ross 5b1f2d4c8c Add {} pairs to shut up egcs. 1998-08-27 18:03:42 +00:00
mrg 32f519716b - use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames
1998-07-06 06:56:06 +00:00
lukem 4eb7653054 WARNSify, getopt returns -1 not EOF 1997-10-17 11:46:30 +00:00
mikel fb325bad88 fix printf() formats, make explicit comparisons to NULL (gcc -Wall) 1997-07-11 07:05:29 +00:00
mycroft e73875ce0a Only record sizes for regular files. 1996-09-05 09:24:19 +00:00
jtc dd05bd5124 Rename struct timespec fields to conform to POSIX.1b 1996-02-01 00:04:52 +00:00