Commit Graph

193 Commits

Author SHA1 Message Date
itojun e99b62a1d7 realloc pedant 2003-09-19 06:11:35 +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
wiz 085295fd9c Quote some characters. 2003-06-27 23:21:50 +00:00
lukem 826a14607a Now that <bsd.prog.mk> DTRT if HOSTPROG is defined (i.e, it is a no-op),
there's no need to special-case .include-ing it.
2003-05-18 07:57:31 +00:00
grant f125cd44b3 grammar tweak. 2003-03-31 08:44:22 +00:00
wiz 990562bfef .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
2003-02-25 10:34:36 +00:00
lukem 9e74ffcba8 Change default permissions of newly created directories from
"0700, modified by umask", to "0777, modified by umask".
This matches the behaviour of mkdir(1) and just about every other command...

This change is useful when running with '-W', where the mode of the
new directory won't be changed to what's specified in the specfile.
(I.e, an UNPRIVED build, with a umask of 022).
2003-01-04 13:10:52 +00:00
grant 653b2f1552 File types belong under 'type', not 'uname'. 2002-12-27 06:31:51 +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
lukem 92a480785a correct description of -D 2002-12-09 13:42:08 +00:00
lukem d348d3d723 tweaks for fparseln(3) move from libutil to libc:
- remove #include <util.h> if nothing else needed it
- remove LDFLAGS+=-lutil if nothing else needed it
2002-11-30 03:10:53 +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
lukem 6e980262a4 Remove convoluted code to work around missing lch{flags,mod,own}();
instead, rely upon libnbcompat to provide a workaround (which returns
an error if the target is a symlink).
Should fix another MacOS X build issue due to missing lchown(2).
2002-10-08 00:34:08 +00:00
lukem 64beaeafc8 - Check HAVE_LCHFLAGS for lchflags(2) support, rather than assuming
that HAVE_STRUCT_STAT_ST_FLAGS implies this.
- Set HAVE_LCHFLAGS for native builds
- Clean up {CLEAR,SET,CHANGE}FLAGS macros, and only provide if
  HAVE_STRUCT_STAT_ST_FLAGS is set.

(Fixes compilation as a tool on MacOS X, noted by Allen Briggs.)
2002-10-06 01:36:09 +00:00
lukem 17d72c8a6b use NETBSDSRCDIR as appropriate 2002-09-18 03:54:26 +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
bjh21 dd9c5ed338 Don't use __RCSID unless it's defined. 2002-04-09 19:17:11 +00:00
thorpej 2597d53f5a Use __RCSID(). 2002-04-09 02:35:31 +00:00
lukem 87899d0b72 inotype() only needs to understand S_ types, not the F_ types 2002-02-19 04:54:12 +00:00
lukem b927725af9 support multiple entries for "." and full paths if the types match; the last
listed entry's settings override the existing settings for that node.
2002-02-11 12:43:55 +00:00
tv 3fdf5a9991 Funtion appropriately in the absence of a lchmod call on the host. 2002-02-08 18:15:12 +00:00
lukem daea03f9f5 Support `/unset all', to unset all of the global values set with `/set ...' 2002-02-05 12:15:13 +00:00
lukem f93e02f7db - use lch*() instead of ch*() to change permissions, so that links in
the specfile don't confuse things.  doesn't affect the default
  (physical) operation, and shouldn't affect logical either.
- slightly rework how miss() is implemented so that duplicated code is
  reduced and links may optionally have a mode, uname and/or gname.
2002-02-04 07:17:14 +00:00
lukem 0719c73e2a explicitly chmod(2) newly created devices 2002-02-04 05:16:41 +00:00
tv 9fbd88883c Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
  sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
2002-01-31 22:43:33 +00:00
tv 76834aef57 Protect __RCSID and __COPYRIGHT from being invoked if not defined. 2002-01-31 19:36:47 +00:00
tv a328e34106 Make almost all tools compile and run properly on non-NetBSD hosts. (In
particular, most tools now run correctly on Solaris 7.)
2002-01-29 10:20:28 +00:00
lukem 6dba6d95f7 add <util.h> back in for native builds. 2002-01-29 00:31:37 +00:00
lukem 4e4ee42772 don't bother initialising pwfile[] to _PATH_MASTERPASSWD and grfile[]
to _PATH_GROUP, because the simple_get{pw,gr}*() functions should not
be called by anything before those path arrays are setup by setup_getid().
2002-01-29 00:29:32 +00:00
tv fcae5f73b7 Add hooks to make mtree compilable from src/tools. 2002-01-29 00:07:27 +00:00
lukem 9ca22e1409 Add '-N dbdir', to specify that user & group lookups (via pwcache(3)) are to
be done from dbdir/master.passwd and dbdir/group, using simple text file
parsing routines.
2002-01-24 03:20:11 +00:00
wiz a2d753e3ef Whitespace nits. 2002-01-19 11:44:57 +00:00
jmc adf8bd3435 Ugg...Turn LIST_FOREACH into a while loop around LIST_NEXT...
The *_FOREACH macros got added post 1.5 and were pulled up into 1.5.2. This
makes it impossible to compile mtree local on a 1.5-release box as a cross
toolchain bit for bootstrapping to -current. (and why I never saw this problem
on my 1.5.2 machine)

This whole thing is solved via a compat lib for the tools for all netbsd bits
and/or trimming down a version of mtree to just the bits needed for building
the snapshots.
2001-11-11 05:07:20 +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 9a07d795e3 need <stdio.h> and <time.h> for mtree.h 2001-11-10 07:13:07 +00:00
lukem 17d6712ceb replace <sys/time.h> with <time.h> (for consistency) 2001-11-10 07:11:14 +00:00
lukem 911a933fe1 with local crc.c, don't need usr.bin/cksum in .PATH any more 2001-11-10 07:10:11 +00:00
mycroft 23b6355049 Add a separate version of the CRC routine that listens to sflag. 2001-11-10 05:10:22 +00:00
lukem 704b08b696 Generally don't need the extra byte in MAXPATHLEN sized buffers, because
pathnames are guaranteed by POSIX to be MAXPATHLEN-1 bytes long.
Kindly pointed out by Warner Losh in private email.
2001-11-09 06:55:56 +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 272e588400 - KNF & whitespace cleanup
- use fparseln() instead of fgetln()
2001-11-07 01:36:50 +00:00
lukem e491f8950f Code from FreeBSD to give mtree the ability to exclude items from its traversal 2001-11-07 01:16:00 +00:00
lukem c55aa0f9cb - move "Wflag" global from mtree.c to spec.c, and reinstate the functionality
of tv's previous code, which skips uname or gname parsing if -W is enabled.
- rename "lineno" to "mtree_lineno", to reduce possibility of name
  clashes in code that yanks in spec.c & misc.c (unlikely, but you never know)
2001-11-03 12:51:40 +00:00
tv 70a4e4b481 Revert previous until it's fixed a more generic way ... I didn't realize
this was pulled in via reachover from elsewhere.
2001-11-01 02:15:41 +00:00
tv 8e97329393 Don't try to do uid or gid lookups from a supplied spec file if -W is given;
the numerical IDs won't be used anyway.
2001-10-31 20:41:17 +00:00
lukem 8e9dab2d53 fix potential sparc compiler warning (if DEBUG was defined, that is...) 2001-10-26 16:01:46 +00:00
lukem 1e617f29fb Add -W: don't attempt to change the perms/time/flags on existing entries, nor
set them when creating new directories. (AKA the ``don't whack'' option).
Concept suggested by Todd Vierling.
2001-10-25 14:47:39 +00:00
lukem 68a03bad5d - add lineno field to NODE
- move inotype() prototype into mtree.h from extern.h
2001-10-25 03:00:14 +00:00
lukem 273cdba6ea document requirement about first node being a directory called "." 2001-10-22 07:11:46 +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 dafcb3846f improve enumeration of the different specfile entry types 2001-10-19 02:57:34 +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 0b41840fcb need semicolon between goto label and closing brace 2001-10-18 04:45:41 +00:00
lukem 98df36b3a5 make this mostly WARNS=2 safe 2001-10-18 04:37:56 +00:00
lukem 7f56f49762 convert from strtok() to strsep() 2001-10-17 01:19:17 +00:00
enami a28fcd776c Make mtree a host tool and use it when appropriate. 2001-10-09 05:19:03 +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 09805a42a3 - use "full path" instead of "absolute path"; perry thinks it's less confusing
- clarify the `all' keyword support in -k, -K and -R. should solve [misc/14186]
- use ".sp" instead of ".Pp"  (from FreeBSD).
2001-10-08 00:53:30 +00:00
lukem 8b951d1f0d * Implement support for absolute paths in the specfile. An absolute path
is one that contains a `/' character that is not the first character.
  All parent directories referenced in the path must exist.
* Add copyright for all the work I've done.
* Document the history of various features added since 4.3-Reno.
2001-10-05 15:32:57 +00:00
lukem d8c78c600b - support "all" as a valid keyword for -k, -K and -R.
- parsekey(): support "all" as a keyword which returns a value with all bits
  set that pertain to a valid keyword.
- dump_nodes():
	- only print out a keyword if it's requested AND it's set in the node
	- UNAME falls back to UID if the user name can't be determined
	- GNAME falls back to GID if the group name can't be determined
- rework man page:
	- use Sy instead of Cm
	- use Pq, Dq, Ql, etc instead of ``...''
2001-10-05 13:14:56 +00:00
lukem acd40f8dd4 dump_nodes() fixes:
- in F_GID, print the gid not the uid
- support F_GNAME
2001-10-05 12:44:47 +00:00
lukem 4da22cb499 cleanup tags support;
- create a typedef struct slist_t to hold stuff in (avoid stringlist(3)
  because it's less portable)
- move the tag manipulate stuff into misc.c
- add matchtags(), which returns 0 if the node is explicitly excluded,
  or not included if an include list is given; or 1 otherwise
- in -D, change tags support from files-only to all-non-directories

(xxx; still considering implementing tags support for -c and !-D)
2001-10-05 01:03:24 +00:00
wiz 2cf8bd020e Whitespace fixes, sort sections. 2001-10-04 11:24:05 +00:00
lukem 3f1c463ef7 - skip F_OPT entries (recently added diagnostic detected this)
- put F_TAG parsing in the correct alphabetical position
2001-10-04 05:03:42 +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 a251d86b79 add F_TYPE to KEYDEFAULT.
whilst -c always prints the type (even if removed with -R),
-D wasn't printing it in the default config
2001-10-03 14:33:49 +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
perry 9864f0aae8 Add a -l flag which does "loose" permissions checks, i.e. a mode 444
matches a check for mode 644 (though obviously not the reverse). This
can be used by the nightly security run, making the output1 more useful
by having it contain fewer spurious permissions violations.

Note that I did not make -l work if you have a sgid/suid/sticky bit
set. I don't know how you could cause security trouble with more
stringent settings and a suid file, but I don't want to find out the
hard way.
2001-09-22 03:56:29 +00:00
thorpej 85f032ca45 Fix printf format. 2001-09-11 15:10:45 +00:00
lukem 617a65b6f7 replace home-grown parser with fparseln() 2001-09-10 03:22:24 +00:00
lukem c0e6fdedfc - add parsetype() (a la parsekey()) to parse the "type=xxx" arg. this improves
the error detection for invalid types, as well as shrinking binary size
- implement inotype() using ftype(), rather than duplicating the switch
- change "char *" arguments to "const char *"
2001-07-18 04:51:54 +00:00
christos f69fcce6d5 improve readability of error messages by quoting the string that we
did not understand. Avoids lossage like "unknown group named".
2001-03-25 20:02:01 +00:00
cgd 42bf2daf5b use setprogname 2001-03-21 23:56:35 +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
lukem c2aa46e7c2 use %ll_ instead of the less standard %q_ 2001-01-05 03:27:26 +00:00
lukem ebcd47ebf3 use .Xr 2000-11-07 05:44:50 +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
enami e92c3f2867 - The type of return value of setmode is a void * and getmode takes it,
rather than mode_t *.
- Free the storage allocated by setmode unless it is obvious that program
  exits immediately.
2000-10-10 14:30:40 +00:00
wennmach 36f6fb7e06 mtree uses strsvis, not strvis. 2000-10-05 20:16:02 +00:00
wennmach 914178b225 code.c is no longer used, we use strsvis instead. Removed prototypes
from extern.h
1999-12-07 18:42:06 +00:00
wennmach e1bf4e526c Use strunvis instead of homebrewed "decode" routine 1999-12-01 22:14:46 +00:00
wennmach dff19e227b Now that we have strsvis, use it. 1999-12-01 22:12:52 +00:00
wennmach 5677540edf Add __RCSID() 1999-11-12 14:42:35 +00:00
wennmach 7b5b69d3cb Add RCS tag 1999-11-09 22:41:53 +00:00
drochner 68062ca8dc prototype encode()/decode() 1999-11-09 10:16:55 +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 ac79e98358 fix thinko in mtime stuff. 1999-07-10 19:59:28 +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
mycroft d77575d3c8 Clean up SYNOPSIS formatting. 1999-03-07 11:58:22 +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
jwise 2e6cacfae6 Add an `md5' keyword to mtree, which takes as an argument the MD5 cryptographic
checksum of the file in question, optionally preceeded by `0x'.

This has been tested, and does work, AFAICT.  There is currently no md5 equivalent
of the '-s' flag for use with checksum.
1998-12-06 19:07:53 +00:00
itohy 6b676a3cca getcwd() is not equivalent of getwd() if you want to print an error message. 1998-12-05 03:29:25 +00:00
thorpej 6b7fe574f7 Use getcwd(3) instead of getwd(3). 1998-12-03 23:33:10 +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