Commit Graph

57 Commits

Author SHA1 Message Date
christos 9cfdbcfd93 Fix the "separate root" test. If we get a permission error check for separate
root. But if we get ENOENT, always succeed. Otherwise if someone removes
the db files or they get corrupted, you can never recreate them.
2014-01-26 01:57:04 +00:00
pooka 4037e69f4e Attempt 2 at fixing DragonFly util.h conflicts: include util.h only for
non-tool builds.
(why does the tool build prefer host headers instead of compat headers?)
2012-11-26 20:13:54 +00:00
plunky 9f61b80465 NULL does not need a cast 2011-08-31 16:24:54 +00:00
joerg bec77c5f43 Use __dead 2011-08-31 13:32:36 +00:00
wiz a148caca6e Fix fd leaks in error cases. Found by cppcheck. 2011-01-04 10:01:51 +00:00
christos d8bfbcfa53 add syslog logging. 2010-08-18 08:06:39 +00:00
snj 34d0fbb3ff Add a missing semicolon. Noted by Tomasz Motyl in PR bin/42603. 2010-01-10 19:04:35 +00:00
joerg 4e2447c901 Don't leak two file descriptors in cp(). From Igor Zinovik.
Explicitly check the close for errors and bail out if needed.
2010-01-10 16:40:00 +00:00
joerg 3e36bb3dce Drop __SCCSID. It is only of archeological interest. 2009-11-06 15:00:31 +00:00
enami fad8f6cbde - The value getdbent() returns when no record is found is not -1 but 1.
Testing if it returns -1 is always false.
- Use the same expression for the size to write and for the size to
  advance a pointer.
2009-08-25 09:27:25 +00:00
christos c08a8944a8 fix typo 2009-06-20 16:19:46 +00:00
christos adee5457b1 don't complain if file does not exist either. 2009-06-20 14:25:47 +00:00
christos 33681fbe60 Fix for unprivileged build. 2009-06-19 16:46:52 +00:00
christos e946d9550c pass lint 2009-06-19 15:23:26 +00:00
christos 2739d569fd allow overwriting the version record. 2009-06-18 22:13:56 +00:00
christos 9dbe62df2a remove duplicated code by merging the insecure and secure database handling.
add warning flag.
2009-06-18 21:59:24 +00:00
christos ed742f5718 support reading and writing both version 0 and version 1 databases using
-V <version>. By default the databases stay in their current version when
rebuilding/updating.
2009-06-18 17:46:24 +00:00
lukem 4780f87772 Fix WARNS=4 issues (-Wsign-compare -Wcast-qual) 2009-04-18 08:08:36 +00:00
apb 09ba0a6ca8 Replace local swap16, swap32, and swap64 inline functions with the
NetBSD conventional bswap16, bswap32, and bswap64 functions or macros.

In a non-tools build, include <sys/types.h> and <machine/bswap.h> to
get definitions of these functions.  In a tools build, rely on the
functions or macros being provided by nbtool_config.h, but don't incluce
<machine/bswap.h> (which might not exist in a cross build).

This should address a problem building on OpenBSD, which has swap16,
swap32, and swap64 macros that conflicted with the local definitions.
The problem was reported by Alexander Bluhm, but this patch is quite
different from the one he suggested.
2009-03-06 19:05:11 +00:00
sketch 7ce9d1c8ea Make 'build.sh tools' work with the Sun Studio compiler, although bugs in
some of the generated tools still prevent building a full release using them.
2009-02-24 22:25:24 +00:00
uebayasi 9281ce080c Make nbpwd_mkdb always generate version 1 by deciding version depending on
sizeof(pw_change).  No objection on tech-userlevel.
2009-02-02 04:24:18 +00:00
jmmv 9b08dc4841 Make sure that the database version is correct if we are updating a single
record; otherwise, bail out early to avoid leaving the database in an
inconsistent state (some old-format records, one new-format record).
2009-01-16 10:42:36 +00:00
christos 5f47ffa430 Oops, forgot to merge this. 2009-01-14 23:18:57 +00:00
lukem 9c1945664c Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
2008-07-21 13:36:57 +00:00
wiz 09cb1d6f1c s/existance/existence/, from Zafer. 2006-11-24 22:52:16 +00:00
sketch e72d64c28d Resolve the second part of PR/19387 from Greg Woods: print error correctly. 2006-09-23 17:38:42 +00:00
sketch 4fea323db6 Add a -c flag to specify the size of cache to use. For very large databases,
increasing this value accordingly gives massive speed improvements.

Prompted by Greg Woods in PR/19387, although mostly taken from FreeBSD.
2006-09-23 17:17:04 +00:00
lukem 90b888928b appease gcc -Wuninitialized 2005-06-02 09:18:14 +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 9f1aac5bb3 Move Jason Downs's code from a 4-clause to a 3-clause licence by
removing the advertising clause.  Diffs provided in PR 22410 by Joel
Baker, confirmed to the board by Jason Downs.

With additional thanks to Jason Thorpe.
2003-10-13 15:36:33 +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
itojun d0f8b66023 strncpy -> strlcpy 2003-05-17 19:18:59 +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 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
ad e13d145336 Speed things up a bit. Parts dredged from OpenBSD/FreeBSD.
- Add -u option, to update one user's records only.
- Add -s option, to update the secure database only.
- Give us roughly 1MB of cache per 50kB of password file, but keep within
  a 2MB minimum and 8MB maximum.
- Tidy a little.
2001-08-18 19:29:31 +00:00
tron f8f9801395 Use empty string as default prefix so that e.g "/etc/spwd.db" is used
instead of "//etc/spwd.db".
2000-11-20 14:09:36 +00:00
ad 4ed69cc393 Remove extraneous M_32_SWAP(). 2000-08-08 12:08:17 +00:00
ad b11d8d3fbf - Move some duplicated code from main() into subroutines. In doing this,
fix -p (it was broken if used in conjunction with either -B or -L).
- const, KNF.
2000-08-07 13:19:27 +00:00
itojun bbef2fbaac errx?/warnx? audit. do not pass variable alone, use %s. idea from openbsd 2000-07-07 15:10:32 +00:00
mycroft c077907823 Add explicit endianness overrides. 2000-01-23 19:59:32 +00:00
mycroft 1f86e5830d const poisoning. 1998-07-27 00:52:00 +00:00
lukem c5b39b1d5a treat single "+" as "+:::::::::" (pw_scan() doesnt like former). minor KNF 1998-06-08 03:23:07 +00:00
lukem 77a05c5b00 clear flags before calling pw_scan() 1998-06-07 14:40:29 +00:00
fair c0ad440bd6 fix my boo-boo documented by PR#5293 1998-04-14 20:20:16 +00:00
fair c85ab8db8e A few more error message changes for better information. 1998-04-14 04:51:19 +00:00
fair dd15ee1ce0 Handle the problem cited in PR#1328 (no checking for I/O errors).
Improve some of the error messages to provide more accurate information.

Repaired a bug by inspection (function pointer reference through a
free'd DB structure!! How did this *ever* work?)
1998-04-13 23:12:45 +00:00
lukem 95ce1aeabe WARNSify, getopt returns -1 not EOF 1997-10-17 12:18:16 +00:00
thorpej a0e4cacd4c Print a warning to stderr if a YP inclusion (`+') specifies a value of
0 for uid or gid.  Based on a patch posted to tech-userlevel by
Paul Kranenburg <pk@NetBSD.ORG>.
1996-11-24 21:13:27 +00:00
lukem 9e8841e359 Implement '-d directory' option, to override the default of '/'.
Useful for building ~ftp/etc/pwd.db without using chroot or unionfs.
Inspired by FreeBSD, closes [bin/2566]
1996-11-22 05:37:29 +00:00