Home | History | Annotate | only in /src/lib/libutil
History log of /src/lib/libutil
RevisionDateAuthorComments
 1.87 03-Jun-2023  lukem bsd.own.mk: rename GCC_NO_* to CC_WNO_*

Rename compiler-warning-disable variables from
GCC_NO_warning
to
CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.86 28-Mar-2023  rillig lint: warn about extern declarations outside headers

https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html
 1.85 13-Oct-2019  mrg introduce some common variables for use in GCC warning disables:

GCC_NO_FORMAT_TRUNCATION -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints. many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
 1.84 08-Oct-2019  christos -Wstringop-truncation is only gcc.
 1.83 04-Oct-2019  christos Ignore strncpy(foo, bar, sizeof(foo)) for the wtmp fields where we don't
want NUL termination. We can't use pragma's because the old gcc complains
about the new warnings it does not understand.
 1.82 04-Apr-2018  kre branches: 1.82.2;

Document opendisk1() - it has been around long enough.
(pity about the name...)

XXX pullup-8
 1.81 01-Apr-2017  abhinav branches: 1.81.10;
Add man page links for:
EV_SET to kqueue(2)
getmntoptstr, getmntoptnum, freemntopts to getmntopts(3)

Reviewed by wiz@
 1.80 29-Dec-2016  christos branches: 1.80.2;
Make this portable to other OSs
 1.79 10-Apr-2016  roy branches: 1.79.2;
Implement pidfile_lock, pidfile_read and pidfile_clean.

Discussed on tech-net@, ok core@.
 1.78 24-Sep-2015  christos Add kinfo_getvmmap from FreeBSD
 1.77 26-Jul-2015  kamil Add ereallocarr(3) to libutil

ereallocarr(3) wraps reallocarr(3) and embeds return status validation.

Older version reviewed by <riastradh> and <christos>
 1.76 18-Jan-2015  christos add estro{i,u} (Kamil Rytarowski)
 1.75 20-Jun-2013  christos document login_getpwclass(3)
 1.74 02-May-2013  matt Add getbyteorder() call.
 1.73 07-Apr-2012  christos branches: 1.73.2;
- add getdiskrawname.
- exit on error for lint.
 1.72 07-Apr-2012  christos add getfsspecname
 1.71 21-Mar-2012  matt These directories default to WARNS?=5
 1.70 07-Jan-2012  christos - add strspct
- be explicit about string not being NUL terminated if bufsiz == 0
 1.69 13-Nov-2011  christos add manual page
 1.68 21-Oct-2011  christos branches: 1.68.2;
Add proc_compare
 1.67 21-Oct-2011  christos Don't use = to assing SRCS, but += so that we can remove snprintb.c,
which was added elsewhere.
 1.66 30-Aug-2011  bouyer Add getlabelusesmbr(), as proposed in
http://mail-index.netbsd.org/tech-userlevel/2011/08/25/msg005404.html
This is used by disk tools such as disklabel(8) to dynamically decide is
the undelyling platform uses a disklabel-in-mbr-partition or not
(instead of using a compile-time list of ports).
getlabelusesmbr() reads the sysctl kern.labelusesmbr, takes its value from the
machdep #define LABELUSESMBR.
For evbmips, make LABELUSESMBR 1 if the platform uses pmon
as bootloader, and 0 (the previous value) otherwise.
 1.65 29-Aug-2011  jruoho Build libutil(3) as a link to util(3).
 1.64 28-Aug-2011  christos add strpct, requested by joerg
 1.63 27-Jan-2010  drochner retire pw_policy(3) -- it is not found useful, there are other
(more common) ways to enforce a password strength policy
approved by elad
 1.62 20-Jun-2009  christos add a link to pw_copyx; from anon ymous
 1.61 13-May-2009  pgoyette Implement snprintb_m(3) to provide multi-line bit/bit-field decode.
Discussed on tech-kern.
 1.60 18-Jan-2009  lukem branches: 1.60.2;
WARNS=4
 1.59 11-Jan-2009  christos merge christos-time_t
 1.58 26-Dec-2008  christos branches: 1.58.2;
document pw_getpwconf.
 1.57 16-Dec-2008  christos move snprintb to common
 1.56 25-Sep-2007  lukem Add raise_default_signal(3) -- raise the default signal handler.
Can be used by applications that have their own SIGINT (et al)
handlers and want to exit in a manner that correctly
signals to the parent that the process was terminated by a signal.
See http://www.cons.org/cracauer/sigint.html for more info.
Discussed on tech-userlevel@.
 1.55 01-Jul-2007  pooka branches: 1.55.4;
add estrndup()
 1.54 14-Dec-2006  christos moved string_to_flags and flags_to_string from ls to libutil.
 1.53 20-Nov-2006  christos rename getdate to parsedate to avoid conflict with posix function
 1.52 17-Nov-2006  christos add getdate.
 1.51 20-Oct-2006  christos include ecalloc() from our anonymous user.
 1.50 26-Aug-2006  christos Add efun(3)
 1.49 14-Sep-2005  elad Add pw_policy.3.
From Hisashi T Fujinaka, thanks!
 1.48 14-Sep-2005  elad Introduce pw_policy(3), an easily extendable way of defining password
policies and enforcing them in programs.

Man-page written with much help and tips from David Maxwell, Hubert
Feyrer, and Thomas Klausner.

This bumps libutil minor to 7.

XXX: Need default policy to go in /etc/passwd.conf, and integration
into local/yp/PAM password changing code.

PR/10206.
 1.47 11-Dec-2004  christos WARNS=3; fix cast-qual issues.
 1.46 20-Nov-2004  christos Add a manual page.
 1.45 19-Nov-2004  christos Add sockaddr_snprintf; XXX: Needs a man page.
 1.44 11-Nov-2004  dsl Add if_media.c, functions for converting media to/from strings.
(from ifconfig.c)
 1.43 22-Mar-2003  jdolecek branches: 1.43.4;
move getmntopts(3) to libutil, build and install also it's manpage
bump libutil minor
adjust individual mount_*/Makefile to use libutil getmntopts(3)
 1.42 12-Dec-2002  scw Add getlabelsector() and getlabeloffset() as wrappers around the
KERN_LABELSECTOR and KERN_LABELOFFSET sysctls.
 1.41 30-Nov-2002  lukem - Migrate fparseln(3) from libutil to libc, where it should have been in
the first place...
- Bump libutil major (to 7.0) and libc minor (to 12.91).
 1.40 12-Oct-2002  elric Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.39 27-Sep-2002  jdolecek put utmpx/wtmpx routines to separate files, so that programs overriding the
utmp/wtmp routines could still be linked static
fixes e.g. static build of ftpd
 1.38 27-Sep-2002  wiz Add documentation for utmpx and some related functions.
Thanks for some explanations to christos, and for some STANDARDS hints
to Klaus Klein.
 1.37 20-Sep-2002  christos Add snprintb(3) inspired from bitmask_snprintf(9), but made to look like
more like snprintf(3). Discussed with thorpej.
 1.36 22-Aug-2002  abs Move humanize_number(3) from libutil to libc as per discussion on tech-misc
Revert minor number bump on libutil (with note to skip it next update), and
bump libc.
 1.35 19-Aug-2002  lukem Explicitly move setting of NOxxx and USE_SHLIBDIR to the top of the
Makefile (before including <bsd.own.mk>)
 1.34 19-Aug-2002  lukem Use ${NETBSDSRCDIR}/some/path instead of ${.CURDIR}/../../some/path (etc).
(Reduces make output by ~ 20%)
 1.33 08-Aug-2002  abs Add humanize_number.3 from Tomas Svensson in PR lib/15508.
Bump version of libutil
 1.32 28-Dec-2001  lukem branches: 1.32.2;
* Add user-controlled mk.conf variables
- SHLIBDIR Location to install shared libraries if ${USE_SHLIBDIR}
is "yes". Defaults to "/usr/lib".

- USE_SHLIBDIR If "yes", install shared libraries in ${SHLIBDIR}
instead of ${LIBDIR}. Defaults to "no".
Sets ${_LIBSODIR} to the appropriate value.
This may be set by individual Makefiles as well.

- SHLINKDIR Location of shared linker. Defaults to "/usr/libexec".
If != "/usr/libexec", change the dynamic-linker
encoded in shared programs

* Set USE_SHLIBDIR for libraries used by /bin and /sbin:
libc libcrypt libcrypto libedit libipsec libkvm libm libmi387
libtermcap libutil libz

* If ${_LIBSODIR} != ${LIBDIR}, add symlinks from ${LIBDIR}/${LIB}.so*
to ${_LIBSODIR}/${LIB}.so* for compatibility.

* Always install /sbin/init statically (for now)


The net effect of these changes depends on how the variables are set:

1.) If nothing is set or changed, there is no change from the
current behaviour:
- Static /bin, /sbin, and bits of /usr/*
- Dynamic rest
- Shared linker is /usr/libexec/ld*so

2.) If the following make variables are set:
LDSTATIC=
SHLINKDIR=/lib
SHLIBDIR=/lib
Then the behaviour becomes:
- Dynamic tools
- .so libraries used by /bin and /sbin are installed to /lib,
with symlinks from /usr/lib/lib*so to -> /lib/lib*so
where appropriate
- Shared linker is /lib/ld*so

3.) As per 2.), but add the following variable:
USE_SHLIBDIR=yes
This forces all .so's to be instaleld in /lib (with compat
symlinks), not just those tagged by their Makefiles to be.
Again, compat symlinks are installed
 1.31 23-Nov-2001  gmcgarry Add a catch-all man page for libutil.
 1.30 20-Aug-2001  wiz Rename secure_path(3) source file from securepath.c to secure_path.c.
 1.29 06-Apr-2001  wiz Add getbootfile(3) to libutil, and a man page.
Bump libutil version to 5.5.
 1.28 06-Dec-2000  tron Add two new passwd file update functions:
- The pw_setprefix() function defines the root directory used for passwd
file updates. If the prefix is set to /newroot pw_lock() will operate on
/newroot/etc/ptmp afterwards. The default prefix is an empty string.
- The pw_getprefix() function returns the root directory which is currently
used for passwd file updates.
 1.27 07-Jul-2000  itojun rename securepath.3 into secure_path.3, as the function is named secure_path().
it is too hard to guess...
 1.26 06-Jul-2000  ad Documentation for pw_getconf(). From OpenBSD.
 1.25 12-May-2000  mjl branches: 1.25.4;
Correct typos which prevent man pages from being installed.
Fixes PR/10104 by Greg Woods.
 1.24 12-Jan-2000  mjl Add necessary support routines for login.conf.
 1.23 02-Jul-1999  simonb More trailing white space.
 1.22 06-Jun-1999  thorpej Add pidfile(3), which write a pid file in /var/run, and arranges for it
to be removed on normal exit.
 1.21 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.20 14-Oct-1998  kleink Kill __LIBUTIL_BUILD in favor of the newly added _LIBC indicator completely;
suggested by Jason Thorpe.
 1.19 27-Jun-1998  thorpej Put pw_scan() back into libutil and pretent that libutil.so.5.0 never
existed.
 1.18 18-Mar-1998  bouyer Add bswap{16,32,64} functions to libutil. Because of this, bump minor.
 1.17 16-Nov-1997  christos PR/4475: Jason R. Thorpe: there is no common function to parse a continued
line.
 1.16 23-Oct-1997  lukem use CPPFLAGS instead of CFLAGS, remove -Wall et al (WARNS=1 already does this)
 1.15 11-Oct-1997  cjs branches: 1.15.2;
Add pidlock, ttylock, ttyunlock functions.
 1.14 09-Oct-1997  lukem - define WARNS?=1 in the top-level Makefile.inc, and don't define
anywhere else.
- for now, override WARNS=0 in librpcsvc and libwrap, until they're
cleaned up
- rcsid police

lib is now clean (except for librpcsvc and libwrap) on the i386, and
this should motivate the other ports to fix any other minor problems
that their compilers pick up that the i386 version doesn't.
 1.13 09-Oct-1997  lukem WARNSify
 1.12 25-Sep-1997  lukem implement opendisk(3), as discussed with Jason Thorpe
 1.11 29-Jun-1997  christos Add ttymsg.3 to the man pages.
 1.10 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.9 14-Nov-1996  gwr Add ttyaction.3 and ttyaction.c
 1.8 16-May-1996  thorpej Add two functions to libutil:

- getmaxpartitions: get the value of MAXPARTITIONS for the
currently running system

- getrawpartition: get the value of RAW_PART for the
currently running system

These functions are necessary since the value of MAXPARTITIONS might
be different across platforms which are binary compatible (e.g. amiga
and sun3).
 1.7 15-May-1996  jtc Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.6 04-May-1994  cgd minor cleanup; kill unnecessary casts
 1.5 27-Jan-1994  cgd get rid of stuff that doesn't belong here
 1.4 06-Aug-1993  mycroft Add getbsize() from Berkeley, somewhat modified.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 17-Jun-1993  mycroft Don't need -I/sys any more.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Jan-1998  perry import lite-2 onto vendor branch
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.15.2.1 09-Nov-1997  lukem sync with trunk (approved by thorpej)
 1.25.4.2 26-Feb-2002  he Pull up revision 1.26 (via patch, requested by jonathan):
Add support for local MD5-encrypted passwords.
 1.25.4.1 07-Jul-2000  itojun pullup, approved by releng-1-5
rename securepath.3 into secure_path.3, as the function is named secure_path().
it is too hard to guess...

basesrc/distrib/sets/lists/comp/mi 1.243 -> 1.244
basesrc/distrib/sets/lists/comp/obsolete.mi 1.23 -> 1.24
basesrc/lib/libutil/Makefile 1.26 -> 1.27
 1.32.2.1 25-Oct-2003  cyber Pull up revision 1.40 (requested by jmc in ticket #1461):
Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.43.4.1 24-Jul-2005  snj Pull up revision 1.44 (requested by riz in ticket #5518):
Add if_media.c, functions for converting media to/from strings.
(from ifconfig.c)
 1.55.4.1 06-Nov-2007  matt sync with HEAD
 1.58.2.3 29-Dec-2008  christos hide yacc symbols from parsedate. Broke other yacc applications.
 1.58.2.2 28-Dec-2008  christos compat code for libutil.
 1.58.2.1 26-Dec-2008  christos file Makefile was added on branch christos-time_t on 2008-12-28 01:14:32 +0000
 1.60.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.68.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.68.2.1 17-Apr-2012  yamt sync with head
 1.73.2.1 23-Jun-2013  tls resync from head
 1.79.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.79.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.80.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.81.10.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.82.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1 29-Mar-2013  agc branches: 1.1.2;
file Version.map was initially added on branch agc-symver.
 1.1.2.1 29-Mar-2013  agc Add symbol versioning info for libutil
 1.3 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.2 05-May-1998  enami Fix function return value and arguments in SYNOPSIS.
 1.1 18-Mar-1998  bouyer Add bswap{16,32,64} functions to libutil. Because of this, bump minor.
 1.3 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.2 09-Dec-1998  christos Delint
 1.1 18-Mar-1998  bouyer Add bswap{16,32,64} functions to libutil. Because of this, bump minor.
 1.4 27-Jan-1994  mycroft Clean up deleted files.
 1.3 19-Dec-1993  pk Return a well-known constant after becoming a daemon.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8 04-May-2010  jruoho Use .Fn instead of .Nm.
 1.7 30-Apr-2008  martin branches: 1.7.8;
Convert TNF licenses to new 2 clause variant
 1.6 16-May-2005  wiz branches: 1.6.18;
Fix capso in Dd argument.
 1.5 15-May-2005  thorpej u_short -> uint16_t
 1.4 16-Apr-2003  wiz branches: 1.4.2; 1.4.8;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 19-Jan-2003  atatat The next release will be 2.0, not 1.7.
 1.2 12-Oct-2002  wiz Spell out month name in .Dd. Use .Fn instead of .Fo/.Fc and .Fa's.
 1.1 12-Oct-2002  elric Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.4.8.1 19-May-2005  tron Pull up revision 1.5 (requested by thorpej in ticket #309):
u_short -> uint16_t
 1.4.2.2 25-Oct-2003  cyber Pull up revision 1.1 (requested by jmc in ticket #1461):
Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.4.2.1 16-Apr-2003  cyber file disklabel_dkcksum.3 was added on branch netbsd-1-6 on 2003-10-25 03:32:21 +0000
 1.6.18.1 18-May-2008  yamt sync with head.
 1.7.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.7.8.1 30-Apr-2008  martin file disklabel_dkcksum.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.4 15-May-2005  thorpej u_short -> uint16_t
 1.3 25-Oct-2003  christos branches: 1.3.6;
delint pointer casts.
 1.2 07-Aug-2003  agc branches: 1.2.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 12-Oct-2002  elric Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.2.2.2 25-Oct-2003  cyber Pull up revision 1.1 (requested by jmc in ticket #1461):
Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.2.2.1 07-Aug-2003  cyber file disklabel_dkcksum.c was added on branch netbsd-1-6 on 2003-10-25 03:32:21 +0000
 1.3.6.1 19-May-2005  tron Pull up revision 1.4 (requested by thorpej in ticket #309):
u_short -> uint16_t
 1.6 04-May-2010  jruoho Use .Fn instead of .Nm.
 1.5 30-Apr-2008  martin branches: 1.5.8;
Convert TNF licenses to new 2 clause variant
 1.4 16-Apr-2003  wiz branches: 1.4.2; 1.4.32;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 19-Jan-2003  atatat The next release will be 2.0, not 1.7.
 1.2 12-Oct-2002  wiz Spell out month name in .Dd. Use .Fn instead of .Fo/.Fc and .Fa's.
 1.1 12-Oct-2002  elric Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.4.32.1 18-May-2008  yamt sync with head.
 1.4.2.2 25-Oct-2003  cyber Pull up revision 1.1 (requested by jmc in ticket #1461):
Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.4.2.1 16-Apr-2003  cyber file disklabel_scan.3 was added on branch netbsd-1-6 on 2003-10-25 03:32:21 +0000
 1.5.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.5.8.1 30-Apr-2008  martin file disklabel_scan.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.3 18-Jan-2009  lukem fix -Wsign-compare issues
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 12-Oct-2002  elric branches: 1.1.2; 1.1.32;
Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.1.32.1 18-May-2008  yamt sync with head.
 1.1.2.2 25-Oct-2003  cyber Pull up revision 1.1 (requested by jmc in ticket #1461):
Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.1.2.1 12-Oct-2002  cyber file disklabel_scan.c was added on branch netbsd-1-6 on 2003-10-25 03:32:21 +0000
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file disklabel_scan.c was added on branch christos-time_t on 2008-04-28 20:23:03 +0000
 1.14 26-Jul-2015  kamil Bump date for recent changes
 1.13 26-Jul-2015  kamil Sync parameter name with efun.c

This change is non-functional.
 1.12 26-Jul-2015  kamil Add ereallocarr(3) to libutil

ereallocarr(3) wraps reallocarr(3) and embeds return status validation.

Older version reviewed by <riastradh> and <christos>
 1.11 18-Jan-2015  christos add estro{i,u} (Kamil Rytarowski)
 1.10 03-May-2010  jruoho .Nm -> .Fn, and one .Pp.
 1.9 04-May-2009  wiz Sort SEE ALSO.
 1.8 30-Apr-2008  martin branches: 1.8.8; 1.8.10;
Convert TNF licenses to new 2 clause variant
 1.7 23-Feb-2008  oster branches: 1.7.2;
Add the missing 'n' to 'correspoding'.
 1.6 21-Nov-2007  rillig branches: 1.6.4;
The e* functions don't call the error handler in every case, just in
case of an error.

Mentioned the error conditions for the various functions.
 1.5 01-Jul-2007  pooka branches: 1.5.4;
add estrndup()
 1.4 20-Oct-2006  christos typo from our anonymous user.
 1.3 06-Oct-2006  pooka add util.h to SYNOPSIS
 1.2 02-Sep-2006  wiz Slight wording improvement, sort SEE ALSO, remove trailing dot in SEE ALSO.
 1.1 26-Aug-2006  christos Efun source.
 1.5.4.2 23-Mar-2008  matt sync with HEAD
 1.5.4.1 09-Jan-2008  matt sync with HEAD
 1.6.4.1 24-Mar-2008  keiichi sync with head.
 1.7.2.1 18-May-2008  yamt sync with head.
 1.8.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.8.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.8.8.1 30-Apr-2008  martin file efun.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.12 03-Oct-2019  tnn annotate __dead
 1.11 03-Oct-2019  christos provide a default error function instead of trying to cast exit(3).
 1.10 26-Jul-2015  kamil branches: 1.10.16;
Add ereallocarr(3) to libutil

ereallocarr(3) wraps reallocarr(3) and embeds return status validation.

Older version reviewed by <riastradh> and <christos>
 1.9 18-Jan-2015  christos add estro{i,u} (Kamil Rytarowski)
 1.8 30-Dec-2012  dholland Fix failure message for ecalloc.
 1.7 30-Dec-2012  dholland If malloc, calloc, or realloc returns NULL when a size of 0 was
requested, which is allowed by pertinent standards, honor it instead
of bombing.

Do not do this for calloc(x, y) where x != 0 && y != 0 but x*y == 0;
in that case bomb.
 1.6 28-Apr-2008  martin branches: 1.6.4; 1.6.8; 1.6.28;
Remove clause 3 and 4 from TNF licenses
 1.5 01-Jul-2007  pooka branches: 1.5.10;
add estrndup()
 1.4 27-Sep-2006  christos Coverity CID 4159: Don't memset() needlessly.
 1.3 28-Aug-2006  christos make this compilable as a tool.
 1.2 26-Aug-2006  christos Only use __RCSID if we have it.
 1.1 26-Aug-2006  christos Efun source.
 1.5.10.1 18-May-2008  yamt sync with head.
 1.6.28.1 25-Feb-2013  tls resync with head
 1.6.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6.8.1 28-Apr-2008  martin file efun.c was added on branch christos-time_t on 2008-04-28 20:23:03 +0000
 1.6.4.1 23-Jan-2013  yamt sync with head
 1.10.16.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.12 30-Nov-2002  lukem - Migrate fparseln(3) from libutil to libc, where it should have been in
the first place...
- Bump libutil major (to 7.0) and libc minor (to 12.91).
 1.11 02-Oct-2002  wiz dynamically with two l.
 1.10 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 20-Aug-2001  wiz precede, not preceed.
 1.7 02-Jul-1999  simonb More trailing white space.
 1.6 16-Feb-1999  kleink Dv vs. Va police.
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 01-Dec-1997  lukem * add extra arg to fparseln() - int flags - which is a bitmask.
current flags allow the `un-escaping' of escaped arguments (i.e,
don't prefix an escaped argument with the escape char)
* other minor cleanups
 1.3 24-Nov-1997  lukem fix .Nx usage (use 1.0 instead of 0.9a, etc), and other minor cleanups
 1.2 23-Nov-1997  lukem better describe delim[], use ".Nx 1.3a" instead of "1.3A", other minor stuff
 1.1 16-Nov-1997  christos PR/4475: Jason R. Thorpe: there is no common function to parse a continued
line.
 1.12 30-Nov-2002  lukem - Migrate fparseln(3) from libutil to libc, where it should have been in
the first place...
- Bump libutil major (to 7.0) and libc minor (to 12.91).
 1.11 21-Jan-2002  lukem Add hooks for reachover builds from src/tools/compat.
 1.10 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.9 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.8 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.7 02-Jul-1999  simonb More trailing white space.
 1.6 09-Dec-1998  christos Delint
 1.5 01-Dec-1997  lukem * add extra arg to fparseln() - int flags - which is a bitmask.
current flags allow the `un-escaping' of escaped arguments (i.e,
don't prefix an escaped argument with the escape char)
* other minor cleanups
 1.4 24-Nov-1997  lukem * return on empty lines (with len = 0, and a pointer to an empty string),
rather than parsing until non-blank lines. some callers may want to
know when a blank line occurs. fix confirmed with christos.
* enhance test code (which is commented out by default) to use len and
lineno parameters
 1.3 18-Nov-1997  enami Fix typo; update `buf' by return value from realloc(3).
 1.2 16-Nov-1997  christos tyop
 1.1 16-Nov-1997  christos PR/4475: Jason R. Thorpe: there is no common function to parse a continued
line.
 1.9 04-May-2010  jruoho Use .Fn instead of .Nm.
 1.8 22-Mar-2010  joerg Use .In instead of .Aq Pa and variantes for header files.
 1.7 30-Apr-2008  martin branches: 1.7.8;
Convert TNF licenses to new 2 clause variant
 1.6 27-Jun-2003  wiz branches: 1.6.30;
Aq Pa instead of Pa Aq.
 1.5 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.3 07-Feb-2002  ross Generate <>& symbolically.
 1.2 09-Apr-2001  jdolecek Add a note this appeared in NetBSD 1.6. Pointed out on current-users@
by Geoff Wing.
 1.1 06-Apr-2001  wiz Add getbootfile(3) to libutil, and a man page.
Bump libutil version to 5.5.
 1.6.30.1 18-May-2008  yamt sync with head.
 1.7.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.7.8.1 30-Apr-2008  martin file getbootfile.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.6 25-Jan-2016  christos prefer <sys/cpu.h> instead of <machine/cpu.h>
 1.5 28-Apr-2008  martin branches: 1.5.8;
Remove clause 3 and 4 from TNF licenses
 1.4 21-Oct-2003  fvdl branches: 1.4.30;
The last argument to sysctl is a size_t, not a pointer; don't pass NULL.
 1.3 14-Feb-2003  petrov strcmp needs string.h.
 1.2 12-Sep-2002  christos Don't bother calling secure_path() is kernel == _PATH_UNIX. If you are going
to default to it and use it anyway, why do the security check?
 1.1 06-Apr-2001  wiz Add getbootfile(3) to libutil, and a man page.
Bump libutil version to 5.5.
 1.4.30.1 18-May-2008  yamt sync with head.
 1.5.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5.8.1 28-Apr-2008  martin file getbootfile.c was added on branch christos-time_t on 2008-04-28 20:23:03 +0000
 1.4 27-Jan-1994  mycroft Clean up deleted files.
 1.3 25-Jan-1994  cgd kill force.
 1.2 25-Jan-1994  cgd kill the 'prog' arg to getbsize(); it's unneeded. minor rev bump.
 1.1 06-Aug-1993  mycroft Add getbsize() from Berkeley, somewhat modified.
 1.4 18-Mar-2014  riastradh branches: 1.4.4;
Merge riastradh-drm2 to HEAD.
 1.3 22-Jul-2013  njoly Use <major>.<minor> for NetBSD version.
 1.2 03-May-2013  wiz branches: 1.2.2; 1.2.4;
Use more markup.
 1.1 02-May-2013  matt Add getbyteorder() call.
 1.2.4.1 23-Jul-2013  riastradh sync with HEAD
 1.2.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.2.2 23-Jun-2013  tls resync from head
 1.2.2.1 03-May-2013  tls file getbyteorder.3 was added on branch tls-maxphys on 2013-06-23 06:21:09 +0000
 1.4.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.4.1 18-Mar-2014  yamt file getbyteorder.3 was added on branch yamt-pagecache on 2014-05-22 11:37:00 +0000
 1.1 02-May-2013  matt branches: 1.1.2; 1.1.8;
Add getbyteorder() call.
 1.1.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.8.1 02-May-2013  yamt file getbyteorder.c was added on branch yamt-pagecache on 2014-05-22 11:37:00 +0000
 1.1.2.2 23-Jun-2013  tls resync from head
 1.1.2.1 02-May-2013  tls file getbyteorder.c was added on branch tls-maxphys on 2013-06-23 06:21:09 +0000
 1.2 20-Nov-2006  christos rename getdate to parsedate to avoid conflict with posix function
 1.1 17-Nov-2006  christos add getdate.
 1.3 20-Nov-2006  christos rename getdate to parsedate to avoid conflict with posix function
 1.2 17-Nov-2006  christos constify
 1.1 17-Nov-2006  christos add getdate.
 1.4 08-Mar-2019  msaitoh s/ the the / the /
 1.3 30-Mar-2017  abhinav branches: 1.3.12;
Add getdiskcookedname to the NAME section
Fix couple of typos.
 1.2 08-Apr-2012  wiz branches: 1.2.2; 1.2.16; 1.2.20;
End sentence with dot.
 1.1 07-Apr-2012  christos - add getdiskrawname.
- exit on error for lint.
 1.2.20.1 21-Apr-2017  bouyer Sync with HEAD
 1.2.16.1 26-Apr-2017  pgoyette Sync with HEAD
 1.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 08-Apr-2012  yamt file getdiskrawname.3 was added on branch yamt-pagecache on 2012-04-17 00:05:34 +0000
 1.3.12.1 10-Jun-2019  christos Sync with HEAD
 1.6 22-Aug-2019  brad Teach getdiskrawname and getdiskcookedname about zvols.

Reviewed by Christos
 1.5 17-Sep-2014  christos branches: 1.5.16; 1.5.18;
KNF, sign cast.
 1.4 12-Sep-2014  mlelstv use the passed parameter instead of PATH_MAX. Change signedness
of nlen.
 1.3 12-Sep-2014  mlelstv - use a private buffer to resolve symlinks, the previous code was broken
- factored out symlink handling
- handle relative symlinks now
- handle device paths that do not contain a '/'.
 1.2 22-Dec-2013  mlelstv branches: 1.2.4;
Resolve symlinks and cook the targets instead of the symlink names.
 1.1 07-Apr-2012  christos branches: 1.1.2; 1.1.4;
- add getdiskrawname.
- exit on error for lint.
 1.1.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.2.2 17-Apr-2012  yamt sync with head
 1.1.2.1 07-Apr-2012  yamt file getdiskrawname.c was added on branch yamt-pagecache on 2012-04-17 00:05:34 +0000
 1.2.4.1 22-Sep-2014  martin Pull up following revision(s) (requested by mlelstv in ticket #117):
lib/libutil/getdiskrawname.c: revision 1.3
lib/libutil/getdiskrawname.c: revision 1.4
lib/libutil/getdiskrawname.c: revision 1.5
- use a private buffer to resolve symlinks, the previous code was broken
- factored out symlink handling
- handle relative symlinks now
- handle device paths that do not contain a '/'.
use the passed parameter instead of PATH_MAX. Change signedness
of nlen.
KNF, sign cast.
 1.5.18.1 02-Sep-2019  martin Pull up following revision(s) (requested by brad in ticket #110):

libexec/lfs_cleanerd/lfs_cleanerd.c: revision 1.59
libexec/lfs_cleanerd/lfs_cleanerd.8: revision 1.19
sbin/resize_lfs/resize_lfs.c: revision 1.15
usr.sbin/puffs/rump_lfs/rump_lfs.c: revision 1.19
libexec/lfs_cleanerd/lfs_cleanerd.c: revision 1.60
lib/libutil/getdiskrawname.c: revision 1.6
tests/fs/common/fstest_lfs.c: revision 1.7

Use getdiskrawname to find the device name.
Reviewed by Christos

-

Teach getdiskrawname and getdiskcookedname about zvols.
Reviewed by Christos

-

Add support for passing the raw device name separate from the
filesystem. This is useful in the case where the cleaner is compiled
into code, such as rump_lfs and the ATF tests. This helps to fix
bin/54488

-

The cleaner is compiled into rump_lfs and executed as a thread. Pass
in the raw device using the new -J option. This avoids the use of
getdiskrawname which is not particularly rump safe in this context and
insures that the rump container device is used for cleaning, not the
outer device.
 1.5.16.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7 28-Dec-2018  alnsn Document "ROOT." syntax before documenting a generic .
 1.6 06-Oct-2018  jmcneill If fs_spec starts with the special string "ROOT.", replace it with a device
path derived from the value of the kern.root_device sysctl.
 1.5 13-Jun-2015  dholland branches: 1.5.14; 1.5.16;
grammar patrol
 1.4 18-Aug-2014  christos fix param name
 1.3 07-Apr-2012  christos branches: 1.3.2;
fix typo
 1.2 07-Apr-2012  wiz Remove trailing whitespace, add dot.
 1.1 07-Apr-2012  christos add getfsspecname
 1.3.2.2 17-Apr-2012  yamt sync with head
 1.3.2.1 07-Apr-2012  yamt file getfsspecname.3 was added on branch yamt-pagecache on 2012-04-17 00:05:34 +0000
 1.5.16.1 10-Jun-2019  christos Sync with HEAD
 1.5.14.2 18-Jan-2019  pgoyette Synch with HEAD
 1.5.14.1 20-Oct-2018  pgoyette Sync with head
 1.8 27-Dec-2018  alnsn No need to quadruple a buffer because strunvis(3) doesn't expand.
 1.7 06-Oct-2018  christos use the right type.
 1.6 06-Oct-2018  jmcneill If fs_spec starts with the special string "ROOT.", replace it with a device
path derived from the value of the kern.root_device sysctl.
 1.5 25-May-2014  christos branches: 1.5.22; 1.5.24;
In COMPAT_DKWEDGE, attempt to open the label as specified in the NAME= entry.
This works for BSD disklabels, providing full compatibility. Merge some
duplicated code. This means that at least for BSD labels, we can handle
both pre and post- autodiscover kernels with the same fstab.
 1.4 01-Jan-2013  dsl branches: 1.4.6;
Don't rely on something including sys/ioctl.h for us.
 1.3 08-Apr-2012  christos branches: 1.3.2; 1.3.4;
Fix compat code, so if we failed to make raw, return the regular path.
 1.2 07-Apr-2012  christos Add and enable COMPAT_DKWEDGE which let's us autoconfigure wedges and boot
with a non-wedge aware fstab.
 1.1 07-Apr-2012  christos add getfsspecname
 1.3.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.4.1 25-Feb-2013  tls resync with head
 1.3.2.3 23-Jan-2013  yamt sync with head
 1.3.2.2 17-Apr-2012  yamt sync with head
 1.3.2.1 08-Apr-2012  yamt file getfsspecname.c was added on branch yamt-pagecache on 2012-04-17 00:05:34 +0000
 1.4.6.1 10-Aug-2014  tls Rebase.
 1.5.24.1 10-Jun-2019  christos Sync with HEAD
 1.5.22.2 18-Jan-2019  pgoyette Synch with HEAD
 1.5.22.1 20-Oct-2018  pgoyette Sync with head
 1.4 17-Jul-2025  andvar s/partitition/partition/.
 1.3 18-Nov-2011  christos branches: 1.3.4; 1.3.54;
remove clauses 3 and 4
 1.2 13-Nov-2011  wiz Remove trailing dot; slightly improve wording.
 1.1 13-Nov-2011  christos add manual page
 1.3.54.1 02-Aug-2025  perseant Sync with HEAD
 1.3.4.2 17-Apr-2012  yamt sync with head
 1.3.4.1 18-Nov-2011  yamt file getfstypename.3 was added on branch yamt-pagecache on 2012-04-17 00:05:34 +0000
 1.8 14-Sep-2011  njoly Kill empty Dv macro.
 1.7 05-Sep-2011  wiz Fix typo.
 1.6 30-Aug-2011  bouyer Add getlabelusesmbr(), as proposed in
http://mail-index.netbsd.org/tech-userlevel/2011/08/25/msg005404.html
This is used by disk tools such as disklabel(8) to dynamically decide is
the undelyling platform uses a disklabel-in-mbr-partition or not
(instead of using a compile-time list of ports).
getlabelusesmbr() reads the sysctl kern.labelusesmbr, takes its value from the
machdep #define LABELUSESMBR.
For evbmips, make LABELUSESMBR 1 if the platform uses pmon
as bootloader, and 0 (the previous value) otherwise.
 1.5 24-Jun-2009  zafer correct spelling error.
 1.4 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 19-Jan-2003  atatat The next release will be 2.0, not 1.7.
 1.2 18-Dec-2002  wiz Misc fixes.
 1.1 12-Dec-2002  scw Add getlabelsector() and getlabeloffset() as wrappers around the
KERN_LABELSECTOR and KERN_LABELOFFSET sysctls.
 1.5 04-Sep-2011  jmcneill getlabelusesmbr: initialize 'oldlenp' parameter to sysctlbyname
 1.4 30-Aug-2011  bouyer Add getlabelusesmbr(), as proposed in
http://mail-index.netbsd.org/tech-userlevel/2011/08/25/msg005404.html
This is used by disk tools such as disklabel(8) to dynamically decide is
the undelyling platform uses a disklabel-in-mbr-partition or not
(instead of using a compile-time list of ports).
getlabelusesmbr() reads the sysctl kern.labelusesmbr, takes its value from the
machdep #define LABELUSESMBR.
For evbmips, make LABELUSESMBR 1 if the platform uses pmon
as bootloader, and 0 (the previous value) otherwise.
 1.3 17-Sep-2005  elad Lint warnings.
 1.2 24-Jan-2003  fvdl Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
 1.1 12-Dec-2002  scw Add getlabelsector() and getlabeloffset() as wrappers around the
KERN_LABELSECTOR and KERN_LABELOFFSET sysctls.
 1.3 27-Jan-1994  mycroft Clean up deleted files.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3 27-Jan-1994  mycroft Clean up deleted files.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10 04-May-2010  jruoho Use .Fn instead of .Nm.
 1.9 30-Apr-2008  martin branches: 1.9.8;
Convert TNF licenses to new 2 clause variant
 1.8 26-May-2006  drochner branches: 1.8.18;
mention error return value, like getrawpartition(3)
 1.7 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.4 29-Aug-1998  lukem first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.3 05-Feb-1998  perry add LIBRARY section to man page
 1.2 31-Jul-1997  jtc Fix files using old TNF copyright notice
 1.1 16-May-1996  thorpej Add two functions to libutil:

- getmaxpartitions: get the value of MAXPARTITIONS for the
currently running system

- getrawpartition: get the value of RAW_PART for the
currently running system

These functions are necessary since the value of MAXPARTITIONS might
be different across platforms which are binary compatible (e.g. amiga
and sun3).
 1.8.18.1 18-May-2008  yamt sync with head.
 1.9.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.9.8.1 30-Apr-2008  martin file getmaxpartitions.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.6 28-Apr-2008  martin branches: 1.6.8;
Remove clause 3 and 4 from TNF licenses
 1.5 27-Aug-2005  elad branches: 1.5.18;
Lint warnings.
 1.4 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.3 31-Jul-1997  jtc Fix files using old TNF copyright notice
 1.2 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.1 16-May-1996  thorpej Add two functions to libutil:

- getmaxpartitions: get the value of MAXPARTITIONS for the
currently running system

- getrawpartition: get the value of RAW_PART for the
currently running system

These functions are necessary since the value of MAXPARTITIONS might
be different across platforms which are binary compatible (e.g. amiga
and sun3).
 1.5.18.1 18-May-2008  yamt sync with head.
 1.6.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6.8.1 28-Apr-2008  martin file getmaxpartitions.c was added on branch christos-time_t on 2008-04-28 20:23:03 +0000
 1.15 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.14 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.13 30-Mar-2017  abhinav Add getmntoptstr, getmntoptnum, and freemntopts to the NAME section
Fix couple of sentences

getmntoptstr, getmntoptnum, and freemntopts need to be linked to the getmntopts(3)
man page as well. Will do in a later commit after doing a relase build test.
 1.12 24-Aug-2010  christos branches: 1.12.28; 1.12.32;
PR/43795: Guy Harris: describe return values and error handling.
 1.11 04-May-2010  jruoho Rework the example a little.
 1.10 14-Jul-2009  joerg Fix markup.
 1.9 04-May-2009  wiz Sort sections.
 1.8 26-Aug-2007  pooka branches: 1.8.18;
* clarify error behaviour for getmntopts()
* invert getmnt_silent description (a.k.a. "fix it")
 1.7 24-Feb-2004  wiz occured -> occurred. From Peter Postma.
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.5 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 16-Apr-2003  wiz Mostly mdoc improvements, some typos.
 1.3 11-Apr-2003  christos add functions to retrieve option values.
 1.2 22-Mar-2003  wiz Try to get some consistency in the used macros; other minor fixes.
 1.1 22-Mar-2003  jdolecek move getmntopts(3) to libutil, build and install also it's manpage
bump libutil minor
adjust individual mount_*/Makefile to use libutil getmntopts(3)
 1.8.18.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.12.32.1 21-Apr-2017  bouyer Sync with HEAD
 1.12.28.1 26-Apr-2017  pgoyette Sync with HEAD
 1.4 26-Aug-2007  pooka Emulate behaviour described in man page and return NULL if an error occurs.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.2 11-Apr-2003  christos add functions to retrieve option values.
 1.1 22-Mar-2003  jdolecek move getmntopts(3) to libutil, build and install also it's manpage
bump libutil minor
adjust individual mount_*/Makefile to use libutil getmntopts(3)
 1.12 04-Feb-2024  uwe getrawpartition(3): reword to clarify return value, use .Pq

"'a' == 0" is, stricly speaking false, and since 'a' is an int, it's
not immediately clear if it's 'a' or 0 that is returned. Try to
clarify this.
 1.11 04-May-2010  jruoho Use .Fn instead of .Nm.
 1.10 30-Apr-2008  martin branches: 1.10.8;
Convert TNF licenses to new 2 clause variant
 1.9 25-May-2006  wiz branches: 1.9.18;
\- is a minus.
 1.8 25-May-2006  christos Document that this can fail.
 1.7 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.4 29-Aug-1998  lukem first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.3 05-Feb-1998  perry add LIBRARY section to man page
 1.2 31-Jul-1997  jtc Fix files using old TNF copyright notice
 1.1 16-May-1996  thorpej Add two functions to libutil:

- getmaxpartitions: get the value of MAXPARTITIONS for the
currently running system

- getrawpartition: get the value of RAW_PART for the
currently running system

These functions are necessary since the value of MAXPARTITIONS might
be different across platforms which are binary compatible (e.g. amiga
and sun3).
 1.9.18.1 18-May-2008  yamt sync with head.
 1.10.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.10.8.1 30-Apr-2008  martin file getrawpartition.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.7 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.6 28-Apr-2008  martin branches: 1.6.4; 1.6.8;
Remove clause 3 and 4 from TNF licenses
 1.5 27-Aug-2005  elad branches: 1.5.18;
Lint warnings.
 1.4 02-Jul-1999  simonb More trailing white space.
 1.3 31-Jul-1997  jtc Fix files using old TNF copyright notice
 1.2 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.1 16-May-1996  thorpej Add two functions to libutil:

- getmaxpartitions: get the value of MAXPARTITIONS for the
currently running system

- getrawpartition: get the value of RAW_PART for the
currently running system

These functions are necessary since the value of MAXPARTITIONS might
be different across platforms which are binary compatible (e.g. amiga
and sun3).
 1.5.18.1 18-May-2008  yamt sync with head.
 1.6.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6.8.1 28-Apr-2008  martin file getrawpartition.c was added on branch christos-time_t on 2008-04-28 20:23:04 +0000
 1.6.4.1 30-Oct-2012  yamt sync with head
 1.3 22-Aug-2002  abs Move humanize_number(3) from libutil to libc as per discussion on tech-misc
Revert minor number bump on libutil (with note to skip it next update), and
bump libc.
 1.2 08-Aug-2002  wiz Minor cleanup, correct HISTORY.
 1.1 08-Aug-2002  abs Add humanize_number.3 from Tomas Svensson in PR lib/15508.
Bump version of libutil
 1.4 22-Aug-2002  abs Move humanize_number(3) from libutil to libc as per discussion on tech-misc
Revert minor number bump on libutil (with note to skip it next update), and
bump libc.
 1.3 15-Aug-2002  enami Cosmetic changes.
 1.2 12-Aug-2002  martin Do not assume int64_t is printable with %qd - on 64 bit ports it isn't.
Use %lld instead and cast the args to (long long) explicitly.

I'm not sure about our policy vs. the C99 format string macros in
basesrc - should we use those here?
 1.1 08-Aug-2002  abs Add humanize_number.3 from Tomas Svensson in PR lib/15508.
Bump version of libutil
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 11-Nov-2004  dsl branches: 1.1.4; 1.1.26;
Add if_media.c, functions for converting media to/from strings.
(from ifconfig.c)
 1.1.26.1 18-May-2008  yamt sync with head.
 1.1.4.1 24-Jul-2005  snj Pull up revision 1.1 (requested by riz in ticket #5518):
Add if_media.c, functions for converting media to/from strings.
(from ifconfig.c)
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file if_media.c was added on branch christos-time_t on 2008-04-28 20:23:04 +0000
 1.1 24-Sep-2015  christos Add kinfo_getvmmap from FreeBSD
 1.4 14-Jun-2017  kamil Stop including <sys/user.h> in userland libraries

This header in this context is freebsdism.
 1.3 26-Sep-2015  christos need uvm_param.h now.
 1.2 24-Sep-2015  christos Hello lint.
 1.1 24-Sep-2015  christos Add kinfo_getvmmap from FreeBSD
 1.24 27-Jan-1994  mycroft Clean up deleted files.
 1.23 07-Jan-1994  cgd get rid of the awful RSS hack
 1.22 15-Dec-1993  mycroft P[GD]_SHIFT --> P[GD]SHIFT
 1.21 05-Dec-1993  cgd look for m68k, rather than hp300 or amiga
 1.20 13-Oct-1993  mycroft Forgot to initialize `cp' in setsyserr().
 1.19 02-Oct-1993  mycroft Remove code for old VM system. Don't use page tables in kvm_procread().
Change `#if DEBUG' to `#ifdef DEBUG'. Read some symbols from the kernel
only once.
 1.18 16-Aug-1993  mycroft Last change was almost correct, but we have to check that the pager actually
has the page. If not, we go up the shadow chain.
 1.17 15-Aug-1993  mycroft Fix an off-by-one error when scanning the vm map for a page. Also, if the
page is not in core, don't recurse into shadow objects if we've already found
a pager.
 1.16 15-Aug-1993  mycroft Fix a bug in virtual to physical address translation on hp300s, and add support
for Amigas.
 1.15 14-Aug-1993  cgd line 860: use CLSHIFT rather than PGSHIFT.
line 927: fix bogus indentation
also make sure first chars of buffers are null char, just in
case nothing rational is read...
 1.14 14-Aug-1993  cgd implement kvm_procread for the hp300. now things mostly work on
the hp300, in terms of kvm. still minor strangeness re: sendmail...
 1.13 14-Aug-1993  mycroft #include <machine/pte.h>, not <hp300/hp300/pte.h>. Also, make it at least
compile for non-i386 architectures, but exit with an error message (for now).
 1.12 01-Aug-1993  mycroft Add RCS identifiers.
 1.11 19-Jul-1993  mycroft branches: 1.11.2;
Read swap in CLBYTES blocks.
 1.10 15-Jun-1993  deraadt kernel string read function takes much less time. could be optimized further,
by making block reads kernel page aligned. (cgd will make the next optimization
in this file)
 1.9 01-Jun-1993  cgd misc minor changes
 1.8 01-Jun-1993  cgd update kvm.c for the new way of doing things:
(1) add support for new stack format/PS_STRINGS
(2) add support for kvm_getenv
the HP300 support in kvm_procread needs to be looked at/filled in,
from example code in kvm_getu, plus hacks
 1.7 20-May-1993  cgd don't inlude select.h, but keep header cleanups
 1.6 20-May-1993  cgd fix new select stuff
 1.5 11-May-1993  cgd fix problem where kvm_getprocs(), ..., kvm_freeprocs(), kvm_getprocs()
would get no processes.
 1.4 27-Apr-1993  mycroft Fix memory leak.
 1.3 10-Apr-1993  cgd From: pk@cs.few.eur.nl (Paul Kranenburg)

patch which allows ps(1) and w(1) to lay
their hands on process command line arguments.
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.2.2 19-Jul-1993  mycroft Read swap in CLBYTES blocks.
 1.11.2.1 19-Jul-1993  mycroft file kvm.c was added on branch netbsd-0-9 on 1993-07-19 12:37:14 +0000
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.5 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 07-Feb-2002  ross Generate <>& symbolically.
 1.3 05-Feb-1998  perry add LIBRARY section to man page
 1.2 09-Jan-1998  perry RCS Id Police.
 1.1 15-May-1996  jtc Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 27-Sep-2002  jdolecek put utmpx/wtmpx routines to separate files, so that programs overriding the
utmp/wtmp routines could still be linked static
fixes e.g. static build of ftpd
 1.14 27-Jul-2002  christos add utmpx/wtmpx processing routines.
 1.13 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.12 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.11 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.10 12-Jun-1999  christos const poisoning.
 1.9 22-Jan-1998  perry unregisterify
 1.8 25-Aug-1997  kleink Lseek(2) usage cleanup: the use of L_SET/L_INCR/L_XTND is deprecated,
use SEEK_SET/SEEK_CUR/SEEK_END instead.
 1.7 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.6 15-May-1996  jtc Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.5 05-Jun-1995  pk Prototypes (PR#1100).
 1.4 04-May-1994  cgd minor cleanup; kill unnecessary casts
 1.3 01-Apr-1994  cgd off_t
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Jan-1998  perry import lite-2 onto vendor branch
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.24 04-Dec-2022  uwe login_cap(3): Markup fixes
 1.23 23-Jan-2016  wiz unsigned -> unsigned int
 1.22 23-Jan-2016  dholland Update synopses to match u_int/u_long/etc. changes. Do not bump date as
it's not a substantive change.
 1.21 23-Jun-2013  wiz Put code example on its own line, using Dl.
Ok christos
 1.20 21-Jun-2013  wiz Punctuation nit.
(Shouldn't the whole line be .Dl or .Bl -literal instead?)
 1.19 20-Jun-2013  christos document login_getpwclass(3)
 1.18 05-May-2010  wiz branches: 1.18.6; 1.18.12;
Mark up NULL with Dv.
 1.17 13-May-2009  wiz Bump date for previous.
 1.16 06-Oct-2007  christos split LOGIN_SETGROUP -> LOGIN_SETGID|LOGIN_SETGROUPS
 1.15 11-Dec-2004  wiz branches: 1.15.16;
Mmm, API changes without date bumps... bump date for constification.
 1.14 11-Dec-2004  christos Constify; the api was completely broken before.
 1.13 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.12 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.11 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 15-Aug-2001  mjl Fix typo
 1.8 09-Apr-2001  wiz Fix date, whitespace and punctuation.
 1.7 07-Nov-2000  lukem fix up various .Nm abuses:
- keep the case consistent between the actual name and what's referenced.
e.g, if it's `foo', don't use '.Nm Foo' at the start of a sentence.
- remove unnecessary `.Nm foo' after the first occurrence (except for
using `.Nm ""' if there's stuff following, or for the 2nd and so on
occurrences in a SYNOPSIS
- use Sx, Ic, Li, Em, Sq, and Xr as appropriate
 1.6 10-Oct-2000  itojun login_cap.h requires sys/types.h (or should it pull sys/types.h in?)
 1.5 21-Sep-2000  ad Use .{B,Bs,F,N,O}x and fix miscellaneous errors.
 1.4 08-Mar-2000  mjl branches: 1.4.4;
Added details about origin of code (BSD/OS) in history section.
Closes PR/9410 by Peter Seebach.
 1.3 13-Feb-2000  mjl Mention the LOGIN_SETENV flag for setusercontext()
 1.2 13-Jan-2000  mjl Add a history section.
 1.1 12-Jan-2000  mjl Add necessary support routines for login.conf.
 1.4.4.1 16-Oct-2000  tv Pullup 1.6 [itojun]:
login_cap.h requires sys/types.h (or should it pull sys/types.h in?)
 1.15.16.1 06-Nov-2007  matt sync with HEAD
 1.18.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.12.1 23-Jun-2013  tls resync from head
 1.18.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.33 29-Oct-2015  kamil Correct typos in comments

Pointed out by Edgar Fuss and J. Lewis Muir.
 1.32 11-Jul-2015  kamil Clean-up resources (sys/sys/resource.h) usage

Add vmemoryuse to login_cap(3)
Document vmemoryuse in login.conf(5)
Document proc.pid.rlimit.vmemoryuse and proc.pid.rlimit.maxlwp in sysctl(7)
Document SBSIZE, AS, VMEM and NTHR in share/doc/psd/05.sysman/1.6.t

Reviewed by <riastradh>
Approved by <pgoyette>

Tested by Dominik Bialy

Closes PR xsrc/49912
 1.31 29-Jun-2013  yamt branches: 1.31.6;
add "maxthread" tunable to login.conf to adjust RLIMIT_NTHR.
PR/47626
ok'ed by christos
 1.30 07-Apr-2012  christos branches: 1.30.2;
- pass correct types.
- use sizeof(var) instead of sizeof(type)
 1.29 04-Dec-2007  mjf branches: 1.29.30; 1.29.32;
Implement a new magic string for magic symlinks, @ruid, which exapnds to the
real user id of the process and use this magic string for per-user tmp.
This should fix PR/35687

Kernel parts reviewed by wrstuden@
 1.28 06-Oct-2007  christos split LOGIN_SETGROUP -> LOGIN_SETGID|LOGIN_SETGROUPS
 1.27 04-Feb-2007  elad branches: 1.27.4;
Add support for per-user /tmp.

Enabled via per_user_tmp in /etc/rc.conf (default off).

See security(8) and rc.conf(5) for more details.

Lots of input from thorpej@ & christos@, thanks!
 1.26 20-Dec-2006  christos From Anon Ymous:
- add __unused
- remove __GNUC__ hack
 1.25 15-Oct-2006  christos - Instead of wondering if to syslog an error, do so, but in the called
function.
- use snprintf instead of sprintf.
 1.24 14-Oct-2006  christos Allow escaping of the separators using a double backslash
 1.23 20-Dec-2005  christos make setuserenv and setuserpath take an environment setting function and
an environment pointer and expose them.
bump version.
 1.22 27-Aug-2005  elad Lint warnings.
 1.21 13-Apr-2005  drochner Allow for a login.conf file without an explicite "default" class
definition.
The login.conf(5) manpage states that the "default" class is used
*if it exists*.
 1.20 20-Dec-2004  christos Unbreak setuserpath(); from Nick Hudson.
 1.19 11-Dec-2004  christos Constify; the api was completely broken before.
 1.18 09-May-2004  lukem sbsize should be parsed as R_CSIZE so that suffixes work correctly.
Fix from Christian Biere in PR [lib/25504].

(XXX: the R_CSIZE parsing should be changed to using strsuftollx(3))
 1.17 23-Apr-2004  christos sprinkle const
 1.16 18-Apr-2004  matt Add sbsize login capability.
 1.15 25-Oct-2003  christos delint pointer casts.
 1.14 21-Oct-2003  fvdl Don't use NULL to compare against an int.
 1.13 08-Sep-2003  itojun initialize 'res' to NULL
 1.12 08-Sep-2003  itojun plug possible memory leak. from openbsd
 1.11 22-Jul-2001  wiz seperate -> separate
 1.10 03-Jan-2001  lukem sprinkle in _DIAGASSERT() as appropriate
 1.9 12-Oct-2000  itojun /etc/login.conf is optional, so don't return NULL even if
there's none found. addresses part of PR 11150. sync with openbsd.
 1.8 12-Oct-2000  itojun cosmetic; indentation
 1.7 21-Sep-2000  ad - Pull in <util.h> to get secure_path() declared.
- Resolve preprocessor symbol clash.
 1.6 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.5 10-Feb-2000  mjl branches: 1.5.4;
Add a missing free() of a temporary buffer.
Add "unlimited" as synonym for "inf" and "infinity" for the
benefit of FreeBSD users.
Factor out the comparison w/ "infinity" in a isinfinite() function.
 1.4 04-Feb-2000  mjl Add login_getpwclass to libutil as convenience function for
programs originally for FreeBSD.
Add parsing of "setenv" parameter which can be used to set
up an initial environment on login.
 1.3 14-Jan-2000  mjl Make setusercontext() resilient against missing login.conf too.
 1.2 13-Jan-2000  mjl Make login_cap routines resilient to non-existant conf file, and
secure_path() less noisy.
 1.1 12-Jan-2000  mjl Add necessary support routines for login.conf.
 1.5.4.1 18-Oct-2000  tv Pullup 1.6-1.9 [itojun]:
/etc/login.conf is optional, so don't return NULL even if
there's none found. addresses part of PR 11150. sync with openbsd.

[releng: plus some cosmetic changes making 1.6-1.8 necessary]
 1.27.4.2 09-Jan-2008  matt sync with HEAD
 1.27.4.1 06-Nov-2007  matt sync with HEAD
 1.29.32.1 15-Nov-2015  bouyer Pull up following revision(s) (requested by kamil in ticket #1317):
share/man/man5/login.conf.5: revisions 1.29, 1.30, 1.31
lib/libutil/login_cap.c: revision 1.32
Clean-up resources (sys/sys/resource.h) usage
Add vmemoryuse to login_cap(3)
Document vmemoryuse in login.conf(5)
Document proc.pid.rlimit.vmemoryuse and proc.pid.rlimit.maxlwp in
sysctl(7)
Document SBSIZE, AS, VMEM and NTHR in share/doc/psd/05.sysman/1.6.t
Reviewed by <riastradh>
Approved by <pgoyette>
Tested by Dominik Bialy
Closes PR xsrc/49912
Bump date for previous.
Clean-up documentation of login.conf(5)
Remove redundant word "limit" from sentences "Maximum ...".
Note that vmemoryuse might specify both maximum and current limits.
Remove redundant 'in bytes' from the description of vmemoryuse, it's not
ed
in the next section describing the argument type 'size'.
Changes inspired by <riastradh> in PR xsrc/49912
 1.29.30.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.29.30.1 17-Apr-2012  yamt sync with head
 1.30.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.31.6.1 04-Nov-2015  riz Pull up following revision(s) (requested by kamil in ticket #927):
share/man/man5/login.conf.5: revision 1.29
share/man/man7/sysctl.7: revision 1.88
share/man/man5/login.conf.5: revision 1.30
lib/libutil/login_cap.c: revision 1.32
share/man/man5/login.conf.5: revision 1.31
share/doc/psd/05.sysman/1.6.t: revision 1.6
Clean-up resources (sys/sys/resource.h) usage
Add vmemoryuse to login_cap(3)
Document vmemoryuse in login.conf(5)
Reviewed by <riastradh>
Approved by <pgoyette>
Tested by Dominik Bialy
Closes PR xsrc/49912
Bump date for previous.
Clean-up documentation of login.conf(5)
Remove redundant word "limit" from sentences "Maximum ...".
Note that vmemoryuse might specify both maximum and current limits.
Remove redundant 'in bytes' from the description of vmemoryuse, it's not
ed
in the next section describing the argument type 'size'.
Changes inspired by <riastradh> in PR xsrc/49912
 1.13 16-Sep-2011  plunky NULL does not need a cast, here
 1.12 09-Feb-2008  dholland Use STDIN_FILENO and friends instead of magic constants 0/1/2.
Suggested by the patches in PR bin/36551 from Greg A. Woods.
 1.11 07-Aug-2003  agc branches: 1.11.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.9 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.8 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.7 11-Jan-1999  kleink 2 -> STDERR_FILENO
 1.6 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.5 15-May-1996  jtc Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.4 05-Jun-1995  pk Prototypes (PR#1100).
 1.3 04-May-1994  cgd minor cleanup; kill unnecessary casts
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Jan-1998  perry import lite-2 onto vendor branch
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.22.1 23-Mar-2008  matt sync with HEAD
 1.3 30-Apr-2008  martin branches: 1.3.8;
Convert TNF licenses to new 2 clause variant
 1.2 16-Apr-2003  wiz branches: 1.2.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.1 27-Sep-2002  wiz Add documentation for utmpx and some related functions.
Thanks for some explanations to christos, and for some STANDARDS hints
to Klaus Klein.
 1.2.30.1 18-May-2008  yamt sync with head.
 1.3.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.3.8.1 30-Apr-2008  martin file loginx.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 27-Sep-2002  jdolecek put utmpx/wtmpx routines to separate files, so that programs overriding the
utmp/wtmp routines could still be linked static
fixes e.g. static build of ftpd
 1.16 27-Aug-2005  elad Lint warnings.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 27-Sep-2002  jdolecek put utmpx/wtmpx routines to separate files, so that programs overriding the
utmp/wtmp routines could still be linked static
fixes e.g. static build of ftpd
 1.13 27-Jul-2002  christos add utmpx/wtmpx processing routines.
 1.12 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.11 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.10 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.9 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.8 30-Mar-1998  kleink Need <time.h> for time() prototype.
 1.7 25-Aug-1997  kleink Lseek(2) usage cleanup: the use of L_SET/L_INCR/L_XTND is deprecated,
use SEEK_SET/SEEK_CUR/SEEK_END instead.
 1.6 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.5 15-May-1996  jtc Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.4 04-May-1994  cgd minor cleanup; kill unnecessary casts
 1.3 01-Apr-1994  cgd off_t
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Jan-1998  perry import lite-2 onto vendor branch
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 27-Sep-2002  jdolecek put utmpx/wtmpx routines to separate files, so that programs overriding the
utmp/wtmp routines could still be linked static
fixes e.g. static build of ftpd
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 27-Sep-2002  jdolecek put utmpx/wtmpx routines to separate files, so that programs overriding the
utmp/wtmp routines could still be linked static
fixes e.g. static build of ftpd
 1.12 27-Jul-2002  christos add utmpx/wtmpx processing routines.
 1.11 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 09-Dec-1998  christos Delint
 1.7 30-Mar-1998  kleink Need <time.h> for time() prototype.
 1.6 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.5 15-May-1996  jtc Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.4 05-Jun-1995  pk Prototypes (PR#1100).
 1.3 04-May-1994  cgd minor cleanup; kill unnecessary casts
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Jan-1998  perry import lite-2 onto vendor branch
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 27-Sep-2002  jdolecek put utmpx/wtmpx routines to separate files, so that programs overriding the
utmp/wtmp routines could still be linked static
fixes e.g. static build of ftpd
 1.17 13-Oct-2024  rillig lib: sync some manual pages with reality
 1.16 05-Apr-2018  wiz branches: 1.16.14;
Use mdoc macros.
 1.15 04-Apr-2018  kre Document opendisk1() - it has been around long enough.
(pity about the name...)

XXX pullup-8
 1.14 29-Jan-2017  snj branches: 1.14.10;
new lookup order will be in 7.1 before 8.0
 1.13 07-Jun-2016  wiz branches: 1.13.2; 1.13.4;
Fix typo. Sort errors.
 1.12 06-Jun-2016  christos PR/51216: Instead of trying to open files in the current working
directory first for paths that don't contain "/", first try the
/dev paths to avoid confusion with files in the working directory
that happen to match disk names.
 1.11 30-Apr-2008  martin branches: 1.11.8; 1.11.42; 1.11.46;
Convert TNF licenses to new 2 clause variant
 1.10 16-Apr-2003  wiz branches: 1.10.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 10-Dec-2001  lukem remove referenced to raw (block) and cooked (character) devices, since
opendisk(3) doesn't care. the iscooked parameter just changes which
paths in /dev are tried if the supplied one doesn't work.
 1.7 10-Dec-2001  lukem revert previous.
it appears that i misread the intent of the iscooked parameter when
originally designing this feature with jason, and changing it broke
some programs.
 1.6 01-Nov-2001  lukem Enforce is iscooked arg;
if zero, a matching path must be of type S_IFCHR, and
if non-zero, a matching path must be of type S_IFBLK.
 1.5 26-Sep-2001  lukem path variations don't occur if there's a / in the path
 1.4 02-Jul-1999  simonb More trailing white space.
 1.3 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.2 05-Feb-1998  perry add LIBRARY section to man page
 1.1 25-Sep-1997  lukem implement opendisk(3), as discussed with Jason Thorpe
 1.10.30.1 18-May-2008  yamt sync with head.
 1.11.46.1 13-Mar-2017  skrll Sync with netbsd-7-1-RELEASE
 1.11.42.1 29-Jan-2017  snj Pull up following revision(s) (requested by pgoyette in ticket #1349):
lib/libutil/opendisk.c: revision 1.14
lib/libutil/opendisk.3: revision 1.12, 1.13
PR/51216: Instead of trying to open files in the current working
directory first for paths that don't contain "/", first try the
/dev paths to avoid confusion with files in the working directory
that happen to match disk names.
 1.11.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.11.8.1 30-Apr-2008  martin file opendisk.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.13.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.13.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.14.10.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.16.14.1 02-Aug-2025  perseant Sync with HEAD
 1.14 06-Jun-2016  christos PR/51216: Instead of trying to open files in the current working
directory first for paths that don't contain "/", first try the
/dev paths to avoid confusion with files in the working directory
that happen to match disk names.
 1.13 29-Sep-2014  christos toolify opendisk
 1.12 13-Oct-2009  pooka branches: 1.12.24; 1.12.28;
In a furious blaze of *facepalm* / "what was i thinking?", fix the
open routine function pointer prototype of opendisk1() to match
the prototype of open().
 1.11 08-Sep-2009  pooka Add opendisk1(), which functions like opendisk(), but takes a function
pointer to the routine to be used for open().
 1.10 28-Apr-2008  martin branches: 1.10.6; 1.10.8; 1.10.14;
Remove clause 3 and 4 from TNF licenses
 1.9 10-Dec-2001  lukem branches: 1.9.32;
revert previous.
it appears that i misread the intent of the iscooked parameter when
originally designing this feature with jason, and changing it broke
some programs.
 1.8 01-Nov-2001  lukem Enforce is iscooked arg;
if zero, a matching path must be of type S_IFCHR, and
if non-zero, a matching path must be of type S_IFBLK.
 1.7 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.6 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.5 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.4 30-Sep-1997  phil Back out my dumb change.
 1.3 30-Sep-1997  phil Add a prototype for opendisk so it will compile. (Should we have
a libutil.h for collecting all these prototypes?)
 1.2 29-Sep-1997  lukem reorder some checks so that buf is initialised as early as possible
(just after the check for buf != NULL)
 1.1 25-Sep-1997  lukem implement opendisk(3), as discussed with Jason Thorpe
 1.9.32.1 18-May-2008  yamt sync with head.
 1.10.14.1 21-Apr-2010  matt sync to netbsd-5
 1.10.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.10.8.1 28-Apr-2008  martin file opendisk.c was added on branch christos-time_t on 2008-04-28 20:23:04 +0000
 1.10.6.2 14-Oct-2009  sborrill Pull up the following revisions(s) (requested by pooka in ticket #1089):
include/util.h: revision 1.53
lib/libutil/opendisk.c: revision 1.12

Fix the open routine function pointer prototype of opendisk1() to match
the prototype of open().
 1.10.6.1 05-Oct-2009  sborrill Pull up the following revisions(s) (requested by pooka in ticket #1047):
include/util.h: revision 1.52
lib/libutil/opendisk.c: revision 1.11
Add opendisk1(), which functions like opendisk(), but takes a function
pointer to the routine to be used for open().
 1.12.28.1 13-Mar-2017  skrll Sync with netbsd-7-1-RELEASE
 1.12.24.1 29-Jan-2017  snj Pull up following revision(s) (requested by pgoyette in ticket #1349):
lib/libutil/opendisk.c: revision 1.14
lib/libutil/opendisk.3: revision 1.12, 1.13
PR/51216: Instead of trying to open files in the current working
directory first for paths that don't contain "/", first try the
/dev paths to avoid confusion with files in the working directory
that happen to match disk names.
 1.17 27-Jul-2012  christos mention PATH_MAX instead of 16.
 1.16 27-Jul-2012  wiz Remove trailing whitespace.
 1.15 23-Jul-2012  christos Mention how big the name can be.
 1.14 28-Nov-2008  dholland branches: 1.14.2; 1.14.10;
Clarify that the "amaster" argument of forkpty() is only defined upon
return in the parent process, but the tty name is available to both
the parent and child. Bump date.
 1.13 18-Jun-2004  christos Don't allow openpty to succeed if the caller is non-superuser.
XXX: we cross-reference ptm 4 which does not exist (yet)
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 06-May-2003  agc Minor grammatical correction.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.8 30-May-2002  simonb Correct the list of pseudo-terminals in the FILES section.
 1.7 20-Feb-2002  wiz branches: 1.7.2;
Sort sections.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 11-Jul-2000  ad PCVT hack is gone.
 1.4 05-Feb-1998  perry branches: 1.4.10;
add LIBRARY section to man page
 1.3 09-Jan-1998  perry RCS Id Police.
 1.2 03-Nov-1996  lukem - fix retval of openpty()
- correct two .Fn references to forkpty()
- describe retval of forkpty(); it can return PID as well
- add xref to fork(2)
 1.1 15-May-1996  jtc Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.4.10.1 26-Jul-2000  ad Pull up revision 1.5 (approved by releng):
PCVT is dead.
 1.7.2.1 30-May-2002  lukem Pull up revision 1.8 (requested by simonb):
Correct the list of pseudo-terminals in the FILES section.
--
 1.14.10.1 30-Oct-2012  yamt sync with head
 1.14.2.2 28-Nov-2008  dholland Clarify that the "amaster" argument of forkpty() is only defined upon
return in the parent process, but the tty name is available to both
the parent and child. Bump date.
 1.14.2.1 28-Nov-2008  dholland file openpty.3 was added on branch christos-time_t on 2008-11-28 07:17:18 +0000
 1.27 02-May-2024  rillig parsedate.3: resolve contradictory values for 'next'
 1.26 16-May-2021  kre PR bin/56042

Fix typos (2nd acst should have been acdt), 0550 for ist should be 0530
(5.5 hours is not 5 hours and 50 minutes...).

Comment out the zp4 zp5 and zp6 zone names. They are supposedly supported
by the source (they're in the table) but cannot work, as the parsedate
lexer doesn't allow a "word" to start with an alpha and also contain
digits. Maybe (just maybe) that could be fixed sometime, but since these
have never worked, and no-one has ever seemed to miss them, and they're the
only words which are of that form, for now, just stop pretending they work.
 1.25 19-Oct-2020  kre branches: 1.25.2;
Catch the parsedate man page up with recent updates, ans also include
some general improvements I've had kicking around for a long time, but
never got around to committing.
 1.24 22-Mar-2017  kre parsedate.y: meaningless KNF of a comment (no code changes)
parsedate.3: add an item in BUGS noting the weirdness of "next"

The real purpose of this commit is to supply the following message
which should be used for the immediately previous commit, replacing
its commit message (the two are similar, but definitely not the
same). With thanks to gdt@ for pointing out one of the (many) errors
in the previous message (and noting others I had already seen).

----

Make parsedate handle "12 noon" and "12 midnight" (including when the
time given is "12:00" or "12:00:00") - but only for exactly 12 o'clock.
"12:00:01" is am or pm, not noon or midnight.

"12 am" remains as an alias for "12 midnight", and "12 pm" for noon,
though both are strictly (pedanticly) invalid (and meaningless.)

Note that "12 midnight" (or "12 am") means 00:00:00 (ie: midnight at
the start of the day, not at the end.)
 1.23 22-Mar-2017  kre Make parsedate handle "12 noon" and "12 midnight" (including when
the time is "12:00" or "12:00:00) - but only for exactly 12 o'clock.
"12:00:01" is am or pm, not noon or midnight.

"12 am" remains as an alias for "12 midnight", and "12 pm" for midnight,
though both are strictly invalid (and meaningless.)

Note that "12 pm" means 00:00:00 (ie: midnight at the start of the
day, not at the end.)
 1.22 23-Dec-2016  abhinav branches: 1.22.2;
Complete a sentence
and replace full stop with a comma at one place as the sentence wasn't finished
 1.21 26-Jun-2016  kre branches: 1.21.2;

Remove dawn/sunup/sunset/sundown (sunrise was never there...)
If 06:00 or 18:00 are wanted, just say "06:00" (etc). If these
are ever added back, they really should determine location, and
calculate actual sunrise/sunset times for the location and date.
That's not likely to happen...
 1.20 10-Dec-2015  wiz Markup improvements.
 1.19 08-Dec-2015  christos more changes I forgot to commit
 1.18 07-Dec-2015  christos - Add support for "midnight" "noon", dawn etc.
- Add validation to date/time strings by checking that mktime did not change
the fields of struct tm from the ones requested
- Allow the format "year monthname day".
From kre
 1.17 26-Nov-2015  wiz Sort sections. Mark up NULL. End Bl with El.
 1.16 26-Nov-2015  christos Fix documentation inconsistencies, and add some clarifications (from kre)
 1.15 08-Oct-2014  wiz Drop trailing whitespace.
 1.14 08-Oct-2014  apb The tzoff argument is in minutes (behind/west of UTC), not seconds.

While here, also say that time = NULL and tzoff = NULL are independent.
The code doesn't yet implement that, but it will soon.
 1.13 07-Oct-2014  apb Document that years in ISO 8601 dates are taken literally.
"69-09-10" is in the year 69, not 2069.
 1.12 19-Jan-2013  apb branches: 1.12.8;
Document that errno may be used to distinguish between a
non-error result of -1 and an error.
 1.11 06-Apr-2012  wiz branches: 1.11.2;
Fix capitalization and typo, from Bug Hunting.
 1.10 22-Dec-2010  wiz branches: 1.10.6; 1.10.8;
Remove trailing whitespace.
 1.9 21-Dec-2010  christos - document limitations
- add extra number name parsing
 1.8 28-Aug-2010  wiz Fix Dd argument, sort sections.
 1.7 28-Aug-2010  tron Mention recent enhancement and not that this function is neither
re-entrant nor thread-safe.
 1.6 04-May-2010  jruoho Use .Fn instead of .Nm.
 1.5 10-Mar-2009  joerg Specify width for tag list
 1.4 30-Apr-2008  martin branches: 1.4.6; 1.4.8; 1.4.10;
Convert TNF licenses to new 2 clause variant
 1.3 23-Dec-2006  wiz branches: 1.3.10;
Quote - when used as minus; uppercase Dt argument; remove dot at end
of SEE ALSO; new sentence, new line.
 1.2 23-Dec-2006  wiz Remove trailing whitespace.
 1.1 20-Nov-2006  christos rename getdate to parsedate to avoid conflict with posix function
 1.3.10.1 18-May-2008  yamt sync with head.
 1.4.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.4.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.4.8.1 30-Apr-2008  martin file parsedate.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.4.6.1 21-Nov-2010  riz Pull up following revision(s) (requested by tron in ticket #1443):
lib/libutil/parsedate.3: revision 1.7
lib/libutil/parsedate.y: revision 1.5
Add support for parsing the data format "@<seconds since epoch>" e.g.
"@735275209" for "Tue Apr 20 03:06:49 UTC 1993". This change was inspired
by coreutil's "date" utility.
Mention recent enhancement and not that this function is neither
re-entrant nor thread-safe.
 1.10.8.1 17-Apr-2015  msaitoh Pull up following revision(s) (requested by nonaka in ticket #1291):
tests/lib/libutil/t_parsedate.c: revision 1.4-1.13
lib/libutil/parsedate.y: revision 1.14-1.20
lib/libutil/parsedate.3: revision 1.11-1.14
Distinguish between a non-error result of (time_t)-1 and an error result.
Modernise the test code inside #ifdef TEST.
add rcsid
fix timezone bugs in rev.1.11 and rev.1.13. PR/47916.
Some years don't need the "maybe add 1900 or 2000" adjustment
that was designed for handling two-digit abbreviated years.
For example, "1/2/70" still refers to the year 1970, as before,
but "70-01-02" now refers to the year 70.
* Add a new yyHaveFullYear member to struct dateinfo, to record whether
or not the year needs to be adjusted.
* Code that parses years sets yyHaveFullYear=1 if they know that the
year should not be adjusted (as is the case for ISO 8601 dates), or if
they perform their own adjustment (as is the case for CVS timestamps).
* Move the year adjustment code into a new function, AdjustYear,
instead of inline in Convert().
* Make Convert() assume the year doesn't need to be adjusted,
and make Convert's callers first call AdjustYear() if appropriate.
A time like HH:MM:SS.sss says nothing about whether DST is on or off.
Add a new non-terminal "time_numericzone" for a time with
a numeric timezone. Move some productions from "time" to "time_numericzone".
Increment yyHaveZone when encountering one of these.
Previously, input of the form "HH:MM:SS +ZZZZ" would not have set the
yyhaveZone flag.
Improved handling of local times.
* A magic value USE_LOCAL_TIME (defined as 99999) may be passed as the
Timezone to Convert(), instructing it to use mktime() to work
in the local time zone, instead of using mktime_z to work in UTC
(and then adding the specified timezone offset).
* Some old code is removed now that there's no need to find the local
timezone offset.
* Allow either one or both of the now and zone arguments to
parsedate() to be NULL, treating them independently. Previously,
if either one was NULL, the other was ignored.
* If the zone argument is specified, then the current date is calculated
in the specified zone, not in local time.
Also add some disabled debug code.
This should fix PR lib/47916.
Fix capitalization and typo, from Bug Hunting.
Document that errno may be used to distinguish between a
non-error result of -1 and an error.
Document that years in ISO 8601 dates are taken literally.
"69-09-10" is in the year 69, not 2069.
The tzoff argument is in minutes (behind/west of UTC), not seconds.
While here, also say that time = NULL and tzoff = NULL are independent.
The code doesn't yet implement that, but it will soon.
mention the PR# in the description like everyone else.
To be on the safe side, use the category/number notation when referring to
PRs (otherwise third-party sed-scripts might miss the references). Also
remove white-space.
* Test that parsedate("@0", ...) returns (time_t)0 regardless of timezone.
* Test that parsedate("@-1", NULL, NULL) returns (time_t)-1
without setting errno.
Test parsedate("@-2",...) (should return -2 and not set errno);
and parsedate("@junk",...) (should return -1 and set errno).
We were already testing "@-1".
Add local parsecheck() function and use it for several tests.
Instead of just checking that parsedate(3) does not return an error,
also pass the result through localtime_r(3) or gmtime_r(3) and check the
year/month/day/hour/minute/second fields in the resulting struct tm.
Add comments for some non-obvious cases.
Also add a test with year=70, which is documented to be treated as 1970.
Adapt to a recent change in parsedate().
"9/10/69" still refers to 2069, and "9/10/70" still refers to 1970,
but "69-09-10" and "70-09-10" now refer to the years 69 and 70.
Add tests for PR lib/47916. Some of these fail.
When tests fail, print all args, notjust the date string.
2013-07-09 was in British Summer TIme, so use tzoff=-60, not 0.
 1.10.6.2 23-Jan-2013  yamt sync with head
 1.10.6.1 17-Apr-2012  yamt sync with head
 1.11.2.1 25-Feb-2013  tls resync with head
 1.12.8.2 11-Oct-2014  snj Pull up following revision(s) (requested by apb in ticket #135):
lib/libutil/parsedate.3: revision 1.14
The tzoff argument is in minutes (behind/west of UTC), not seconds.
While here, also say that time = NULL and tzoff = NULL are independent.
The code doesn't yet implement that, but it will soon.
 1.12.8.1 11-Oct-2014  snj Pull up following revision(s) (requested by apb in ticket #135):
lib/libutil/parsedate.3: revision 1.13
Document that years in ISO 8601 dates are taken literally.
"69-09-10" is in the year 69, not 2069.
 1.21.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.21.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.22.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.25.2.1 31-May-2021  cjep sync with head
 1.40 02-May-2024  christos revert previous.
 1.39 01-May-2024  christos next should increement by 1 not 2.
 1.38 29-Feb-2024  rillig parsedate.y: remove outdated comment

The number of shift/reduce conflicts has grown to 16.
 1.37 23-Apr-2022  christos fix date -d 12/01/2022, found by Anon Ymous
 1.36 30-Oct-2020  kre PR lib/46542

Add checks to detect overflow, and also detect other invalid
(out of range) inputs for parsedate().

There could be more, and some of what is being added is not
perfect, but many calculation overflows will be detected now
(and cause an error return) and some of the most bizarre
inputs that were previously accepted no longer will be.
 1.35 19-Oct-2020  kre Check the year field of a tentative ISO-8601 date format for overflow
before committing to it being an 8601 format date, rather than after
(or the fall back grammar parser doesn't start with a clean slate).

This isn't likely to ever bother anyone, the chances of encountering
something that looks just like an 8601 format date, but with a year
field so large it overflows a long are kind of slim. If it did happen
the chances that the string could be correctly parsed (into something
different) by the grammar are even slimmer. But better to do it properly.
 1.34 19-Oct-2020  kre For touch -d (which uses parsedate()) POSIX specifies that the
ISO-8601 format yyyy-mm-ddTHH:MM:SS[radix_and+frac][Z]
be accepted.

We didn't handle that, as in parsedate(), 'T' represents the
military timezone designator, not a padding separator between
date & time as POSIX specified it.

The way parsedate() is written, fixing this in the grammar/lexer
would be hard without deleting support for T as a zone indicator
(it is *my* timezone!).

So, instead of doing that, parse an ISO-8901 string which occurs
right at the start of the input (not even any preceding white space)
by hand, before invoking the grammar, and so not involving the lexer.
This is sufficient to make touch -d conform.

After doing that, we still need to allow earlier valid inputs,
where an ISO-8601 format (using space as the separator, but without
the 'Z' (Zulu, or UTC) suffix) followed by an arbitrary timezone
designation, and other modifiers (eg: "+5 minutes" work. So we
call the grammar on whatever is left of the input after the 8601
string has been consumed. This all "just works" with one exception,
a format like "yyyy-mm-dd hh:mm:ss +0700" would have the grammar parse
just "+0700" which by itself would be meaningless, and so wasn't
handled. Add a grammar rule & processing to Handle it.

Also note that while POSIX specifies "at least 4" digits in the YYYY
field, we implement "at least one" so years from 0-999 continue to be
parsed as they always have (nb: these were, and continue to be, treated
as absolute year numbers, year 10 is year 10, not 2010). Years > 2 billion
(give or take) cannot be represented in the tm_year field of a struct tm,
so there's a limit on the max number of digits as well.
 1.33 19-Oct-2020  kre POSIX requires that when converting 2 digit year representations to
actual specific years, values from 69-99 be treated as 20th century,
and values from 0-68 be treated as 21st century. This allows for those
unfortunate enough to reside in a timezone west of Greenwich to convert
the epoch (or a time very close to it) to text, write that with just two
digits, and correctly convert it back to a time near the epoch, rather
than to something in 2069.

We used to split things so 0-69 were 21st century, and 70-99 were 20th.
Change that (this requires a change in the parsedate ATF tests which
test this specific boundary).

While here, add support for another POSIX requirement, that the radix
char before fractional seconds can be either a ',' or a '.'. We used
to allow only '.', add support for ','. This is something of a meaningless
change, as parsedate() returns a time_t in which there is no way to
represent fractional seconds, so there's little point in ever specifying
them regardless of what char is used for the "decimal point" - they will
be ignored anyway. But at least fractional seconds using a ',' as the
radix char will no longer cause the conversion to fail (or do something else
bizarre).
 1.32 22-Mar-2017  kre parsedate.y: meaningless KNF of a comment (no code changes)
parsedate.3: add an item in BUGS noting the weirdness of "next"

The real purpose of this commit is to supply the following message
which should be used for the immediately previous commit, replacing
its commit message (the two are similar, but definitely not the
same). With thanks to gdt@ for pointing out one of the (many) errors
in the previous message (and noting others I had already seen).

----

Make parsedate handle "12 noon" and "12 midnight" (including when the
time given is "12:00" or "12:00:00") - but only for exactly 12 o'clock.
"12:00:01" is am or pm, not noon or midnight.

"12 am" remains as an alias for "12 midnight", and "12 pm" for noon,
though both are strictly (pedanticly) invalid (and meaningless.)

Note that "12 midnight" (or "12 am") means 00:00:00 (ie: midnight at
the start of the day, not at the end.)
 1.31 22-Mar-2017  kre Make parsedate handle "12 noon" and "12 midnight" (including when
the time is "12:00" or "12:00:00) - but only for exactly 12 o'clock.
"12:00:01" is am or pm, not noon or midnight.

"12 am" remains as an alias for "12 midnight", and "12 pm" for midnight,
though both are strictly invalid (and meaningless.)

Note that "12 pm" means 00:00:00 (ie: midnight at the start of the
day, not at the end.)
 1.30 22-Mar-2017  kre Fix PR lib/52101 -- 12:30 am is 00:30:00 and 12:30 pm is 12:30:00
 1.29 26-Jun-2016  kre branches: 1.29.2; 1.29.4;

Remove dawn/sunup/sunset/sundown (sunrise was never there...)
If 06:00 or 18:00 are wanted, just say "06:00" (etc). If these
are ever added back, they really should determine location, and
calculate actual sunrise/sunset times for the location and date.
That's not likely to happen...
 1.28 03-May-2016  kre Make relative date changes ("+ 2 months") etc, work a little more sanely.

OK christos@
 1.27 31-Dec-2015  dholland When computing relative months, use mktime() directly and don't call
our Convert(). And check it for failure. This fixes three sets of
problems:

(1) depending on the passed-in value of Timezone it might
disassemble the time in one timezone and reassemble it in
another, causing mysterious offsets of a few hours;

(2) with the previous set of changes to this file, Convert() fails
if it ends up normalizing a date, so e.g. going three months
forward from March 31 would fail;

(3) previously if Convert() failed we passed -1 on to DSTcorrect(),
which made a mess.

PR 50574.
 1.26 31-Dec-2015  dholland Always use localtime_r; I don't think any of this code is tripping
itself up, but it's still good practice for library functions to not
trash static libc state. Might be relevant to PR 50574.
 1.25 31-Dec-2015  dholland Reformat grammar part according to my standards for yacc grammars.
 1.24 08-Dec-2015  christos preserve a copy of the tm so we can check later.
 1.23 07-Dec-2015  christos - Add support for "midnight" "noon", dawn etc.
- Add validation to date/time strings by checking that mktime did not change
the fields of struct tm from the ones requested
- Allow the format "year monthname day".
From kre
 1.22 06-Dec-2015  christos Fix west australia offset, from kre
 1.21 26-Nov-2015  christos Patch from kre:
- fix missing/inconsistent abbreviations
- set dst only if we are using localtime.
- properly check for errors where there were missing checks
- handle errno properly including saving and restoring.
 1.20 08-Oct-2014  apb Improved handling of local times.

* A magic value USE_LOCAL_TIME (defined as 99999) may be passed as the
Timezone to Convert(), instructing it to use mktime() to work
in the local time zone, instead of using mktime_z to work in UTC
(and then adding the specified timezone offset).
* Some old code is removed now that there's no need to find the local
timezone offset.
* Allow either one or both of the now and zone arguments to
parsedate() to be NULL, treating them independently. Previously,
if either one was NULL, the other was ignored.
* If the zone argument is specified, then the current date is calculated
in the specified zone, not in local time.

Also add some disabled debug code.

This should fix PR lib/47916.
 1.19 08-Oct-2014  apb Add a new non-terminal "time_numericzone" for a time with
a numeric timezone. Move some productions from "time" to "time_numericzone".
Increment yyHaveZone when encountering one of these.

Previously, input of the form "HH:MM:SS +ZZZZ" would not have set the
yyhaveZone flag.
 1.18 08-Oct-2014  apb A time like HH:MM:SS.sss says nothing about whether DST is on or off.
 1.17 07-Oct-2014  apb Some years don't need the "maybe add 1900 or 2000" adjustment
that was designed for handling two-digit abbreviated years.
For example, "1/2/70" still refers to the year 1970, as before,
but "70-01-02" now refers to the year 70.

* Add a new yyHaveFullYear member to struct dateinfo, to record whether
or not the year needs to be adjusted.
* Code that parses years sets yyHaveFullYear=1 if they know that the
year should not be adjusted (as is the case for ISO 8601 dates), or if
they perform their own adjustment (as is the case for CVS timestamps).
* Move the year adjustment code into a new function, AdjustYear,
instead of inline in Convert().
* Make Convert() assume the year doesn't need to be adjusted,
and make Convert's callers first call AdjustYear() if appropriate.
 1.16 12-Jun-2013  yamt branches: 1.16.6;
fix timezone bugs in rev.1.11 and rev.1.13. PR/47916.
 1.15 12-Jun-2013  yamt add rcsid
 1.14 19-Jan-2013  apb Distinguish between a non-error result of (time_t)-1 and an error result.
Modernise the test code inside #ifdef TEST.
 1.13 19-Jan-2013  apb mktime(3) works in local time, and trying to trick it by
setting tm_gmtoff doesn't work. Instead, call mktime_z(3)
with a null timezone (so it works in UTC) and adjust the
result afterwards. Now "date -d @0" correctly
prints the local equivalent of 1970-01-01 00:00:00 UTC.
 1.12 13-Sep-2012  joerg Don't use const foo const as type, one const is enough.
 1.11 17-Dec-2011  apb branches: 1.11.2; 1.11.6; 1.11.8;
Use mktime(3) instead of hand-coded equivalent.
Don't treat negative results as errors (we should be able
to handle years before 1970).

XXX: This still fails on 1969-12-31 23:59:59.
 1.10 24-Dec-2010  christos branches: 1.10.6;
restore lost overlow check fix.
 1.9 24-Dec-2010  christos make this thread-safe. We could use localtime_tz and make it even better,
but not now.
 1.8 21-Dec-2010  christos fix incorrect overflow check from Nicholas Joly
 1.7 21-Dec-2010  christos - fix off by one in comparison with 69 (it should be 70)
- add aliases for 1 (one), 2 (two), etc.
- allow parsing of HH:MM:SS.sss as the man page mentions, and ignore sss
 1.6 12-Dec-2010  christos PR/42549: Izumi Tsutsui: parsedate does not work after 2038.
Fix multiple issues:
- Remove bogus 2038 check and add overflow checks in the appropriate places.
- Correct incomplete leap year calculation that broke things after 2100.
- Check localtime return values
- Change int calculations to time_t to avoid oveflow.
- Consistently check/return -1 and remove bogus comment about not being
able to return -1.

Now:
$ date -d 20991201
Tue Dec 1 00:00:00 EST 2099
$ date -d 40991201
Tue Dec 1 00:00:00 EST 4099
$ date -d 10000000991201
Tue Dec 1 00:00:00 EST 1000000099
TIME=0:04.48 CPU=117.8% (5.288u 0.000s) SWAPS=0 (0+95)pf (0i+0o) (0Kc+0Kd)
$ date -d 100000000991201
date: Cannot parse `100000000991201'
TIME=0:53.48 CPU=99.2% (53.086u 0.000s) SWAPS=0 (0+96)pf (0i+0o) (0Kc+0Kd)
Exit 1
 1.5 21-Aug-2010  tron Add support for parsing the data format "@<seconds since epoch>" e.g.
"@735275209" for "Tue Apr 20 03:06:49 UTC 1993". This change was inspired
by coreutil's "date" utility.
 1.4 11-Jan-2009  christos merge christos-time_t
 1.3 17-Jul-2008  drochner branches: 1.3.4; 1.3.6;
include <stdlib.h> explicitely, for exit(), getprogname() etc.
(it happens to be pulled in by the yacc skeleton, but we shouldn't
rely on this)
 1.2 20-Dec-2006  christos branches: 1.2.12;
From Anon Ymous:
- add __unused
- remove __GNUC__ hack
 1.1 20-Nov-2006  christos rename getdate to parsedate to avoid conflict with posix function
 1.2.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.6.2 29-Dec-2008  christos hide yacc symbols from parsedate. Broke other yacc applications.
 1.3.6.1 17-Jul-2008  christos file parsedate.y was added on branch christos-time_t on 2008-12-29 17:02:18 +0000
 1.3.4.1 21-Nov-2010  riz Pull up following revision(s) (requested by tron in ticket #1443):
lib/libutil/parsedate.3: revision 1.7
lib/libutil/parsedate.y: revision 1.5
Add support for parsing the data format "@<seconds since epoch>" e.g.
"@735275209" for "Tue Apr 20 03:06:49 UTC 1993". This change was inspired
by coreutil's "date" utility.
Mention recent enhancement and not that this function is neither
re-entrant nor thread-safe.
 1.10.6.6 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.6.5 12-Jun-2013  yamt revert the previous (wrong branch)
 1.10.6.4 12-Jun-2013  yamt add rcsid
 1.10.6.3 23-Jan-2013  yamt sync with head
 1.10.6.2 30-Oct-2012  yamt sync with head
 1.10.6.1 17-Apr-2012  yamt sync with head
 1.11.8.1 08-Feb-2013  riz Pull up following revision(s) (requested by apb in ticket #791):
lib/libutil/parsedate.y: revision 1.13
mktime(3) works in local time, and trying to trick it by
setting tm_gmtoff doesn't work. Instead, call mktime_z(3)
with a null timezone (so it works in UTC) and adjust the
result afterwards. Now "date -d @0" correctly
prints the local equivalent of 1970-01-01 00:00:00 UTC.
 1.11.6.3 23-Jun-2013  tls resync from head
 1.11.6.2 25-Feb-2013  tls resync with head
 1.11.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.11.2.2 17-Apr-2015  msaitoh Pull up following revision(s) (requested by nonaka in ticket #1291):
tests/lib/libutil/t_parsedate.c: revision 1.4-1.13
lib/libutil/parsedate.y: revision 1.14-1.20
lib/libutil/parsedate.3: revision 1.11-1.14
Distinguish between a non-error result of (time_t)-1 and an error result.
Modernise the test code inside #ifdef TEST.
add rcsid
fix timezone bugs in rev.1.11 and rev.1.13. PR/47916.
Some years don't need the "maybe add 1900 or 2000" adjustment
that was designed for handling two-digit abbreviated years.
For example, "1/2/70" still refers to the year 1970, as before,
but "70-01-02" now refers to the year 70.
* Add a new yyHaveFullYear member to struct dateinfo, to record whether
or not the year needs to be adjusted.
* Code that parses years sets yyHaveFullYear=1 if they know that the
year should not be adjusted (as is the case for ISO 8601 dates), or if
they perform their own adjustment (as is the case for CVS timestamps).
* Move the year adjustment code into a new function, AdjustYear,
instead of inline in Convert().
* Make Convert() assume the year doesn't need to be adjusted,
and make Convert's callers first call AdjustYear() if appropriate.
A time like HH:MM:SS.sss says nothing about whether DST is on or off.
Add a new non-terminal "time_numericzone" for a time with
a numeric timezone. Move some productions from "time" to "time_numericzone".
Increment yyHaveZone when encountering one of these.
Previously, input of the form "HH:MM:SS +ZZZZ" would not have set the
yyhaveZone flag.
Improved handling of local times.
* A magic value USE_LOCAL_TIME (defined as 99999) may be passed as the
Timezone to Convert(), instructing it to use mktime() to work
in the local time zone, instead of using mktime_z to work in UTC
(and then adding the specified timezone offset).
* Some old code is removed now that there's no need to find the local
timezone offset.
* Allow either one or both of the now and zone arguments to
parsedate() to be NULL, treating them independently. Previously,
if either one was NULL, the other was ignored.
* If the zone argument is specified, then the current date is calculated
in the specified zone, not in local time.
Also add some disabled debug code.
This should fix PR lib/47916.
Fix capitalization and typo, from Bug Hunting.
Document that errno may be used to distinguish between a
non-error result of -1 and an error.
Document that years in ISO 8601 dates are taken literally.
"69-09-10" is in the year 69, not 2069.
The tzoff argument is in minutes (behind/west of UTC), not seconds.
While here, also say that time = NULL and tzoff = NULL are independent.
The code doesn't yet implement that, but it will soon.
mention the PR# in the description like everyone else.
To be on the safe side, use the category/number notation when referring to
PRs (otherwise third-party sed-scripts might miss the references). Also
remove white-space.
* Test that parsedate("@0", ...) returns (time_t)0 regardless of timezone.
* Test that parsedate("@-1", NULL, NULL) returns (time_t)-1
without setting errno.
Test parsedate("@-2",...) (should return -2 and not set errno);
and parsedate("@junk",...) (should return -1 and set errno).
We were already testing "@-1".
Add local parsecheck() function and use it for several tests.
Instead of just checking that parsedate(3) does not return an error,
also pass the result through localtime_r(3) or gmtime_r(3) and check the
year/month/day/hour/minute/second fields in the resulting struct tm.
Add comments for some non-obvious cases.
Also add a test with year=70, which is documented to be treated as 1970.
Adapt to a recent change in parsedate().
"9/10/69" still refers to 2069, and "9/10/70" still refers to 1970,
but "69-09-10" and "70-09-10" now refer to the years 69 and 70.
Add tests for PR lib/47916. Some of these fail.
When tests fail, print all args, notjust the date string.
2013-07-09 was in British Summer TIme, so use tzoff=-60, not 0.
 1.11.2.1 08-Feb-2013  riz Pull up following revision(s) (requested by apb in ticket #791):
lib/libutil/parsedate.y: revision 1.13
mktime(3) works in local time, and trying to trick it by
setting tm_gmtoff doesn't work. Instead, call mktime_z(3)
with a null timezone (so it works in UTC) and adjust the
result afterwards. Now "date -d @0" correctly
prints the local equivalent of 1970-01-01 00:00:00 UTC.
 1.16.6.4 11-Oct-2014  snj Pull up following revision(s) (requested by apb in ticket #135):
lib/libutil/parsedate.y: revision 1.20
Improved handling of local times.
* A magic value USE_LOCAL_TIME (defined as 99999) may be passed as the
Timezone to Convert(), instructing it to use mktime() to work
in the local time zone, instead of using mktime_z to work in UTC
(and then adding the specified timezone offset).
* Some old code is removed now that there's no need to find the local
timezone offset.
* Allow either one or both of the now and zone arguments to
parsedate() to be NULL, treating them independently. Previously,
if either one was NULL, the other was ignored.
* If the zone argument is specified, then the current date is calculated
in the specified zone, not in local time.
Also add some disabled debug code.
This should fix PR lib/47916.
 1.16.6.3 11-Oct-2014  snj Pull up following revision(s) (requested by apb in ticket #135):
lib/libutil/parsedate.y: revision 1.19
Previously, input of the form "HH:MM:SS +ZZZZ" would not have set the
yyhaveZone flag.
 1.16.6.2 11-Oct-2014  snj Pull up following revision(s) (requested by apb in ticket #135):
lib/libutil/parsedate.y: revision 1.18
A time like HH:MM:SS.sss says nothing about whether DST is on or off.
 1.16.6.1 11-Oct-2014  snj Pull up following revision(s) (requested by apb in ticket #135):
lib/libutil/parsedate.y: revision 1.17
Some years don't need the "maybe add 1900 or 2000" adjustment
that was designed for handling two-digit abbreviated years.
For example, "1/2/70" still refers to the year 1970, as before,
but "70-01-02" now refers to the year 70.
* Add a new yyHaveFullYear member to struct dateinfo, to record whether
or not the year needs to be adjusted.
* Code that parses years sets yyHaveFullYear=1 if they know that the
year should not be adjusted (as is the case for ISO 8601 dates), or if
they perform their own adjustment (as is the case for CVS timestamps).
* Move the year adjustment code into a new function, AdjustYear,
instead of inline in Convert().
* Make Convert() assume the year doesn't need to be adjusted,
and make Convert's callers first call AdjustYear() if appropriate.
 1.29.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.29.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.53 24-Jun-2018  kamil Prevent underflow buffer read in trim_whitespace() in libutil/passwd.c

If a string is empty or contains only white characters, the algorithm of
removal of white characters at the end of the passed string will read
buffer at index -1 and keep iterating backward.

Detected with MKSANITIZER/ASan when executing passwd(1).
 1.52 25-Jun-2012  abs branches: 1.52.24; 1.52.30;
Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.51 24-Apr-2011  christos branches: 1.51.4;
fix freudian slip
 1.50 18-Aug-2010  christos Log why pwd_mkdb failed. Currently on aslr systems, pwd_mkdb either aborts
or when s/vfork/fork/ dies with SEGV accessing the the stack. The same abort
effect can be achieved when we remove all resource limits.
 1.49 18-Aug-2010  christos Log via syslog(3) when we run pwd_mkdb(8).
 1.48 18-Jan-2009  lukem fix -Wsign-compare issues
 1.47 11-Jan-2009  christos merge christos-time_t
 1.46 21-Dec-2008  christos branches: 1.46.2;
PR/18150: John F. Woods: Print meaningful error messages on inconsistent/
corrupt entries.
 1.45 20-Dec-2006  christos From Anon Ymous:
- add __unused
- remove __GNUC__ hack
 1.44 15-Oct-2006  christos add volatile to prevent gcc clobbering.
 1.43 20-Mar-2006  elad plug leaks, coverity cids 1618, 1619.
 1.42 14-Sep-2005  christos Use the re-entrant getgr*_r functions. From John Nemeth.
 1.41 19-Aug-2005  elad Make this compile without warnings.
 1.40 18-Aug-2005  elad Make pw_getconf(3) set errno so we have indication on what went wrong.
Document possible errno values in the manpage.
 1.39 15-Jan-2005  christos PR/28792: FUKAUMI Naoki: passwd: Couldn't generate salt: Invalid argument
I broke the case where /etc/passwd.conf was empty.
 1.38 12-Jan-2005  christos add pw_getpwconf(), bump.
 1.37 11-Dec-2004  christos WARNS=3; fix cast-qual issues.
 1.36 03-Aug-2004  thorpej - Rename pw_copy() to pw_copyx(), make it return a success/failure code,
and add "errbuf" and "errbufsz" parameters so that errors can be handled
gracefully, rather than simply exiting the process.
- Add a pw_copy() wrapper around pw_copyx() to preserve old behavior for
apps that use it.
- Bump shlib version to 7.4.
 1.35 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.34 17-Apr-2002  ad Back out previous - it will come as a surprise to many users.
 1.33 15-Apr-2002  perry Per discussion on tech-security and tech-userlevel, upgrade default
passwd type to md5. Note that with the passwd.conf facility, one may
easily "downgrade" the default to type old if one wishes, and that
existing passwds continue to work as before -- this only changes the
default for new passwds.
 1.32 05-Nov-2001  lukem WARNS=2 fix
 1.31 23-Oct-2001  lukem - add _PATH_USERMGMT_CONF. resolves [bin/14305]
- add _PATH_PASSWD_CONF to be consistent with almost all other _PATH_xxx_CONF
defines, and change from using _PATH_PASSWDCONF to the former. keep the
latter for compatibility, although arguably it could be removed because
it was never in a release and was only used in one file in the tree.
 1.30 18-Aug-2001  ad Add two arguments to pw_mkdb(), a la OpenBSD. This is to allow us to pass
the -u and -s options to pwd_mkdb.
 1.29 03-Jan-2001  lukem sprinkle in _DIAGASSERT() as appropriate
 1.28 08-Dec-2000  tron Fix oversight in last commit.
 1.27 06-Dec-2000  tron Add two new passwd file update functions:
- The pw_setprefix() function defines the root directory used for passwd
file updates. If the prefix is set to /newroot pw_lock() will operate on
/newroot/etc/ptmp afterwards. The default prefix is an empty string.
- The pw_getprefix() function returns the root directory which is currently
used for passwd file updates.
 1.26 04-Oct-2000  itojun honor behavior of warn(NULL).
 1.25 03-Oct-2000  sommerfeld Close possible format string attack.
 1.24 11-Jul-2000  itohy Correct ctype(3) usage.
Passing "char" value is wrong. Use "unsigned char" instead.
 1.23 07-Jul-2000  ad Fix typo. This probably would have stopped passwd(1) working if
/etc/passwd.conf didn't exist.
 1.22 06-Jul-2000  ad Oops - declare static functions.
 1.21 06-Jul-2000  ad Use ':' as group prefix; suggested by hubertf.
 1.20 06-Jul-2000  ad - Add pw_getconf(). This is used to read configuration information from
passwd.conf. From OpenBSD.
- ANSIfy.
 1.19 03-Dec-1999  mjl branches: 1.19.4;
Use /bin/sh to take care of the EDITOR command parsing instead of home
grown method. Fixes PR/8935 by myself. Fix is from OpenBSD. Also pull
in a couple of minor changes like checking the return value of vfork().
 1.18 20-Sep-1999  lukem branches: 1.18.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.17 17-Sep-1999  lukem remove diagnostic check for name==NULL; it's ok to call pw_error() in this case
 1.16 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.15 09-Dec-1998  christos branches: 1.15.2;
Delint
 1.14 26-Sep-1998  christos Preserve the correct errno so that programs know the reason we failed.
 1.13 19-Aug-1998  thorpej Add some braces to make egcs happy.
 1.12 08-Jun-1998  lukem move pw_scan() out of here (into libc)
document _PASSWORD_NOWARN and _PASSWORD_OLDFMT inflags to pw_scan()
 1.11 31-Dec-1997  thorpej Change an exit() to _exit(), so that it's safe for vfork().
 1.10 24-Jul-1997  phil Change pw_copy to take an optional 4th parameter (old_pw), a pointer
to a passwd structure. If a good pointer, make sure old entry in file
is identical to passed passwd (old_pw). If not, abort.

Update documentation, bump major version due to change to pw_copy.
 1.9 06-Jul-1997  christos PR/3832: Enami Tsugutomo: passwd.c will not compile on NetBSD/alpha
 1.8 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.7 20-Jun-1997  mikel add parens for gcc -Wall
 1.6 22-May-1997  lukem in pw_scan(), parse [gu]id with strtoul() instead of atoi(), and sanity
check a) the parsed value was just a number, b) it doesn't exceed [GU]ID_MAX
 1.5 09-May-1997  mycroft Pull in err.h for prototypes.
 1.4 23-Apr-1997  mycroft Allow the full range of UIDs and GIDs.
 1.3 09-Dec-1996  thorpej Deal with complex EDITOR strings (e.g. `pico -t'). Fixes PR #2520.
 1.2 02-Jun-1996  ghudson Don't delete the lock file if pwd_mkdb fails. The caller will take care
of it by calling pw_abort() or pw_error() as appropriate.
 1.1 15-May-1996  jtc branches: 1.1.4;
Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.1.4.1 02-Jun-1996  ghudson Bring in bugfix from mainline.
 1.15.2.2 04-Oct-2000  he Pull up revision 1.25 (requested by sommerfeld):
Close possible format-string hole.
 1.15.2.1 04-Dec-1999  he Pull up revision 1.19 (requested by mjl):
Correct handling of more complex EDITOR environment variable
settings by using /bin/sh. Fixes PR#8935.
 1.18.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.4.3 26-Feb-2002  he Pull up revisions 1.20-1.23 (requested by jonathan):
Add support for local MD5-encrypted passwords.
 1.19.4.2 17-Oct-2000  tv Pullup 1.26 [itojun]:
honor behavior of warn(NULL).
[This fixes a bug in the format string changes.]
 1.19.4.1 03-Oct-2000  sommerfeld Pull up 1.25: fix possible format string vulnerability.
approved by thorpej
 1.46.2.2 28-Dec-2008  christos compat code for libutil.
 1.46.2.1 21-Dec-2008  christos file passwd.c was added on branch christos-time_t on 2008-12-28 01:14:32 +0000
 1.51.4.1 30-Oct-2012  yamt sync with head
 1.52.30.1 25-Jun-2018  pgoyette Sync with HEAD
 1.52.24.1 24-Jun-2018  martin Pull up following revision(s) (requested by kamil in ticket #899):

lib/libutil/passwd.c: revision 1.53

Prevent underflow buffer read in trim_whitespace() in libutil/passwd.c

If a string is empty or contains only white characters, the algorithm of
removal of white characters at the end of the passed string will read
buffer at index -1 and keep iterating backward.

Detected with MKSANITIZER/ASan when executing passwd(1).
 1.16 22-Oct-2017  abhinav Add missing functions to the NAME section
 1.15 11-Apr-2016  wiz Add serial commas. Fix minus. Sort SEE ALSO. Fix xref.
 1.14 10-Apr-2016  roy Implement pidfile_lock, pidfile_read and pidfile_clean.

Discussed on tech-net@, ok core@.
 1.13 29-Mar-2011  jmmv Extend pidfile(3) to support creating pid files in arbitrary locations.

If the argument provided to pidfile(3) contains a '/', then the value is
considered to be an absolute/relative path and the pid file is created
in the given location.

Otherwise, pidfile(3) behaves as before and treats the provided value as
a basename to construct a pid file in /var/run/<basename>.pid. This means
that to create a pid file named "foo.pid" in the current directory, one
must specify "./foo.pid".
 1.12 05-May-2010  wiz Mark up NULL with Dv.
 1.11 04-May-2010  jruoho Use .Fn instead of .Nm.
 1.10 30-Apr-2008  martin branches: 1.10.8;
Convert TNF licenses to new 2 clause variant
 1.9 16-Apr-2003  wiz branches: 1.9.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.7 22-May-2002  wiz Grammar fix, and drop a .Pp after a section header.
 1.6 22-May-2002  itojun if called multiple times with different names, only the last pid file
will be kept
 1.5 22-May-2002  itojun change return type of pidfile(3) to int (-1 on error), to inform caller
of errors. behavior now in sync with openbsd implementation.
(see tech-userlevel and bsd-api-discuss)
 1.4 07-Feb-2002  ross Generate <>& symbolically.
 1.3 19-Oct-2001  tron - Don't delete the pidfile if the process executing the cleanup handler
isn't the process who created it.
- If a new basename is supplied remove the an old pidfile if it was created
by this process and create a new one as suggested by Jason Thorpe.
This fixes PR lib/13357 by Greg A. Woods.
 1.2 12-Apr-2001  sommerfeld Fix typo.
 1.1 06-Jun-1999  thorpej Add pidfile(3), which write a pid file in /var/run, and arranges for it
to be removed on normal exit.
 1.9.30.1 18-May-2008  yamt sync with head.
 1.10.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.10.8.1 30-Apr-2008  martin file pidfile.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.16 01-Aug-2021  andvar fix typos in word "otherwise".
 1.15 27-Dec-2019  msaitoh s/sucess/success/ in comment.
 1.14 12-Apr-2016  roy branches: 1.14.16;
Removed botched debug left over.
 1.13 12-Apr-2016  roy Fix pidfile location path rules to match prior version.
 1.12 10-Apr-2016  roy Implement pidfile_lock, pidfile_read and pidfile_clean.

Discussed on tech-net@, ok core@.
 1.11 22-Jan-2015  christos s/basename/bname/
 1.10 22-Jan-2015  christos - not all asprintfs return -1 *and* set buf = NULL, check explicitly.
- don't shadow basename(3)
 1.9 29-Mar-2011  jmmv Extend pidfile(3) to support creating pid files in arbitrary locations.

If the argument provided to pidfile(3) contains a '/', then the value is
considered to be an absolute/relative path and the pid file is created
in the given location.

Otherwise, pidfile(3) behaves as before and treats the provided value as
a basename to construct a pid file in /var/run/<basename>.pid. This means
that to create a pid file named "foo.pid" in the current directory, one
must specify "./foo.pid".
 1.8 28-Apr-2008  martin branches: 1.8.8;
Remove clause 3 and 4 from TNF licenses
 1.7 22-May-2002  itojun branches: 1.7.30;
change return type of pidfile(3) to int (-1 on error), to inform caller
of errors. behavior now in sync with openbsd implementation.
(see tech-userlevel and bsd-api-discuss)
 1.6 20-Oct-2001  taca Remove an extra character in a comment block.
 1.5 19-Oct-2001  tron - Don't delete the pidfile if the process executing the cleanup handler
isn't the process who created it.
- If a new basename is supplied remove the an old pidfile if it was created
by this process and create a new one as suggested by Jason Thorpe.
This fixes PR lib/13357 by Greg A. Woods.
 1.4 19-Feb-2001  cgd convert to use getprogname()
 1.3 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.2 06-Jun-1999  thorpej Use asprintf(3), as suggested by Simon Burge.
 1.1 06-Jun-1999  thorpej Add pidfile(3), which write a pid file in /var/run, and arranges for it
to be removed on normal exit.
 1.7.30.1 18-May-2008  yamt sync with head.
 1.8.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8.8.1 28-Apr-2008  martin file pidfile.c was added on branch christos-time_t on 2008-04-28 20:23:04 +0000
 1.14.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.13 23-Oct-2017  wiz Sort errors.
 1.12 09-Mar-2009  joerg Fix preamble to match order set out by mdoc(7). Discussed with wiz.
 1.11 23-Mar-2006  wiz branches: 1.11.30;
Remove trailing whitespace, add 'and' in enumeration.
 1.10 19-Mar-2006  christos Clarify errno's returned by those functions.
 1.9 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.8 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.7 31-Mar-2003  perry runnning->running from Igor Sobrado, PR misc/19814
 1.6 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.5 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.4 07-Feb-2002  ross Generate <>& symbolically.
 1.3 08-Jun-1998  lukem don't need trailing empty paragraph
 1.2 05-Feb-1998  perry add LIBRARY section to man page
 1.1 11-Oct-1997  cjs Add pidlock, ttylock, ttyunlock functions.
 1.11.30.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.17 30-Mar-2020  ryo fail to create a pidfile if hostname contains '/'
 1.16 07-Apr-2012  christos branches: 1.16.32;
read returns ssize_t, and err is a function name.
 1.15 18-Jan-2009  lukem branches: 1.15.8;
fix -Wsign-compare issues
 1.14 19-Mar-2006  christos Coverity CID 1209: Avoid negative close. While I am there fix bugs (open
returning 0 is ok). Reorganize code to factor out common parts, cleanup
syscall checking and error code return.
 1.13 27-Aug-2005  elad Lint warnings.
 1.12 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.11 21-Apr-2003  christos PR/7885: Kip Rugger: ttylock(3) ignores flags and locker parameters
 1.10 16-Nov-2002  itojun use strlcpy/cat
 1.9 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.8 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.7 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.6 11-Jan-1999  kleink In userland, pull in <errno.h> instead of <sys/errno.h> for the declaration
of errno.
 1.5 09-Dec-1998  christos Delint
 1.4 06-Jul-1998  mrg - 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
 1.3 19-Oct-1997  mycroft Test file type correctly, using S_IS*().
 1.2 12-Oct-1997  cjs * Add hostname to temporary file to avoid collisions when locking on
an NFS volume and competing with the same pid on another machine.
* Make locking on an NFS-moutned file work properly by checking link
count.
* Make sure correct errno is returned.
 1.1 11-Oct-1997  cjs Add pidlock, ttylock, ttyunlock functions.
 1.15.8.1 17-Apr-2012  yamt sync with head
 1.16.32.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 21-Oct-2011  wiz Minor improvements.
 1.1 21-Oct-2011  christos Forgot to commit this.
 1.32 24-Jun-2018  kamil Fix stack use after scope in libutil/pty

The pt variable's elements are used after the end of the pt scope.
A move of pt to outer scope fixes this.

Detected with MKSANITIZER/ASan with tmux(1), a forkpty(3) user.
 1.31 20-Feb-2009  christos branches: 1.31.38; 1.31.44;
remove pointless static.
 1.30 18-Jan-2009  lukem branches: 1.30.2;
fix -Wsign-compare issues
 1.29 14-Sep-2005  christos Use the re-entrant getgr*_r functions. From John Nemeth.
 1.28 19-Jan-2005  mycroft If TIOCPTMGET fails, close /dev/ptm.
 1.27 25-Nov-2004  christos Don't give write privileges at all if the tty group is missing.
 1.26 24-Nov-2004  christos I really want to kill the hard-coding of _TTY_GID. Set the group to the
primary group of the user if the group tty does not exist.
 1.25 18-Sep-2004  christos KNF; Simplify some logic, so that lines don't wrap. Explain why we
break, continue, or return from the tty scanning loops.
 1.24 18-Sep-2004  yamt openpty: just check errors of syscalls,
instead of checking permission beforehand in userland.
 1.23 18-Jun-2004  christos Don't allow openpty to succeed if the caller is non-superuser.
XXX: we cross-reference ptm 4 which does not exist (yet)
 1.22 27-May-2004  christos use the pty multiplexor if it exists.
 1.21 25-Oct-2003  christos remove unused variable
 1.20 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.19 09-Mar-2002  atatat Fix openpty() so that it correctly scans the entire list of possible
ttys. The new ttys (g-zA-Z) are "optional", since they may not be
present, and their absence is not a "fatal" error.
 1.18 02-Feb-2002  tls Add support for up to 930 pty devices (instead of the current 256).

The openpty() routine has been modified to use the extra pty names
before the "traditional" names, so that programs too dumb to use
openpty() will, hopefully, find one of the "traditional" ptys free
even if many others are in use. The modifications to MAKEDEV are
courtesy Andrew Brown, and are pretty clever: the unit numbers used
by the "traditional" names stay the same, to avoid trouble when
upgrading existing systems. The unusual use of "dd" to index an
array in MAKEDEV is because no other simple method seemed feasible
using only the programs on the install media for all ports.
 1.17 10-May-2001  lukem revert over-zealous pcvt cull; we still need to skip ttyv* whilst pccons uses
ttyv0 on some ports (currently; arm32, bebox, i386, prep). should fix PR 12862.
 1.16 10-Jul-2000  ad Remove PCVT hack.
 1.15 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.14 20-Sep-1999  lukem branches: 1.14.8;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.13 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.12 02-Jul-1999  simonb More trailing white space.
 1.11 09-Dec-1998  christos Delint
 1.10 22-Jan-1998  perry unregisterify
 1.9 22-Jan-1998  perry merge with lite-2
 1.8 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.7 12-Nov-1996  mycroft Make openpty() work more than once.
 1.6 15-May-1996  jtc branches: 1.6.4;
Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.5 05-Jun-1995  pk Prototypes (PR#1100).
 1.4 04-May-1994  cgd minor cleanup; kill unnecessary casts
 1.3 06-Apr-1994  andrew Support up to 256 ptys.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Jan-1998  perry import lite-2 onto vendor branch
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.4.1 10-Dec-1996  mycroft From trunk:
Make openpty(3) work more than once.
 1.14.8.2 15-May-2001  he Pull up revision 1.17 (requested by dogcow):
Since pccons is still used on a few ports, ttyv* should be skipped
in pty allocation.
 1.14.8.1 26-Jul-2000  ad Pull up revision 1.16 (approved by releng):
PCVT is dead.
 1.30.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.31.44.1 25-Jun-2018  pgoyette Sync with HEAD
 1.31.38.1 12-Jul-2018  martin Pull up following revision(s) (requested by kamil in ticket #901):

lib/libutil/pty.c: revision 1.32

Fix stack use after scope in libutil/pty

The pt variable's elements are used after the end of the pt scope.

A move of pt to outer scope fixes this.

Detected with MKSANITIZER/ASan with tmux(1), a forkpty(3) user.
 1.12 04-May-2010  jruoho Use .Fn instead of .Nm.
 1.11 26-Dec-2008  wiz branches: 1.11.2;
Sort errors.
 1.10 26-Dec-2008  christos document pw_getpwconf.
 1.9 10-Sep-2005  wiz Avoid duplicate if.
 1.8 18-Aug-2005  elad Make pw_getconf(3) set errno so we have indication on what went wrong.
Document possible errno values in the manpage.
 1.7 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.5 07-Feb-2002  ross branches: 1.5.2;
Generate <>& symbolically.
 1.4 18-Sep-2000  ad Add a LIBRARY section.
 1.3 10-Jul-2000  ad - More fixes.
- Document the built-in defaults.
 1.2 07-Jul-2000  ad Couple of nits.
 1.1 06-Jul-2000  ad Documentation for pw_getconf(). From OpenBSD.
 1.5.2.2 26-Feb-2002  he Pull up revisions 1.1-1.4 (requested by jonathan):
Add support for local MD5-encrypted passwords.
 1.5.2.1 07-Feb-2002  he file pw_getconf.3 was added on branch netbsd-1-5 on 2002-02-26 22:09:39 +0000
 1.11.2.2 26-Dec-2008  wiz Sort errors.
 1.11.2.1 26-Dec-2008  wiz file pw_getconf.3 was added on branch christos-time_t on 2008-12-26 21:02:29 +0000
 1.17 04-Dec-2022  uwe pw_init(3): Use .Ev for EDITOR
 1.16 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.15 05-May-2010  wiz Mark up NULL with Dv.
 1.14 04-Aug-2004  wiz New sentence, new line.
 1.13 03-Aug-2004  thorpej - Rename pw_copy() to pw_copyx(), make it return a success/failure code,
and add "errbuf" and "errbufsz" parameters so that errors can be handled
gracefully, rather than simply exiting the process.
- Add a pw_copy() wrapper around pw_copyx() to preserve old behavior for
apps that use it.
- Bump shlib version to 7.4.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.10 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.9 26-Sep-2002  wennmach s/_PASSWD_NOCHG/_PASSWORD_NOCHG/
s/_PASSWD_NOEXP/_PASSWORD_NOEXP/
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 10-Jul-2000  ad `.Fn foo' -> `.Fn foo "void"' in SYNOPSIS.
 1.6 19-Nov-1999  kristerw Typos (from OpenBSD)
 1.5 08-Jun-1998  lukem branches: 1.5.6;
move pw_scan() out of here (into libc)
document _PASSWORD_NOWARN and _PASSWORD_OLDFMT inflags to pw_scan()
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 09-Jan-1998  perry RCS Id Police.
 1.2 24-Jul-1997  phil Change pw_copy to take an optional 4th parameter (old_pw), a pointer
to a passwd structure. If a good pointer, make sure old entry in file
is identical to passed passwd (old_pw). If not, abort.

Update documentation, bump major version due to change to pw_copy.
 1.1 15-May-1996  jtc Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.5.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.14 05-May-2010  wiz Mark up NULL with Dv.
 1.13 17-Feb-2007  wiz Remove pw_error prototype, the function is described in a different man page.
Bump date.

From Slava Semushin in private mail.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.10 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.9 06-Aug-2002  wiz Fix Fn argument.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 18-Aug-2001  ad Add two arguments to pw_mkdb(), a la OpenBSD. This is to allow us to pass
the -u and -s options to pwd_mkdb.
 1.6 06-Dec-2000  tron Add two new passwd file update functions:
- The pw_setprefix() function defines the root directory used for passwd
file updates. If the prefix is set to /newroot pw_lock() will operate on
/newroot/etc/ptmp afterwards. The default prefix is an empty string.
- The pw_getprefix() function returns the root directory which is currently
used for passwd file updates.
 1.5 10-Jul-2000  ad `.Fn foo' -> `.Fn foo "void"' in SYNOPSIS.
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 09-Jan-1998  perry RCS Id Police.
 1.2 02-Jun-1996  ghudson Document that the caller must do a pw_abort() if pw_mkdb() fails.
 1.1 15-May-1996  jtc branches: 1.1.4;
Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.1.4.1 02-Jun-1996  ghudson Bring in bugfix from mainline.
 1.10 27-Jan-2010  drochner retire pw_policy(3) -- it is not found useful, there are other
(more common) ways to enforce a password strength policy
approved by elad
 1.9 09-Jan-2007  elad Consistent license.
 1.8 23-Mar-2006  wiz Consistently use .Va for errno. Quote "-" for PostScript output.
 1.7 19-Mar-2006  elad Set errno on failure, and man-page updates.
 1.6 24-Feb-2006  wiz Fix typo.
 1.5 24-Feb-2006  wiz Mark up NULL (with Dv).
 1.4 18-Feb-2006  elad When loading a policy with an "nclasses" option, always set the min/max
values for the various character classes to allow any number, just in
case. Also note about that in the man-page.

This makes it easier to use the "nclasses" option.

Note that alternatively we could just memset() to 0xff when doing the
load, but that might lead to more unexpected behavior.
 1.3 18-Feb-2006  elad Don't expose struct pw_policy and use pw_policy_t, use malloc, man-page
fixups.

As discussed on source-changes@.

Okay yamt@, thorpej@.
 1.2 18-Feb-2006  elad Some stuff that's been sitting in my tree for too long...

Improve the pw_policy(3) API by splitting it to two functions, one to load
the policy from /etc/passwd.conf and another to test passwords against the
policy.

Some bug fixes, more consistent code, and man-page updates.

Minor for libutil bumped.
 1.1 14-Sep-2005  elad Introduce pw_policy(3), an easily extendable way of defining password
policies and enforcing them in programs.

Man-page written with much help and tips from David Maxwell, Hubert
Feyrer, and Thomas Klausner.

This bumps libutil minor to 7.

XXX: Need default policy to go in /etc/passwd.conf, and integration
into local/yp/PAM password changing code.

PR/10206.
 1.15 27-Jan-2010  drochner retire pw_policy(3) -- it is not found useful, there are other
(more common) ways to enforce a password strength policy
approved by elad
 1.14 18-Jan-2009  lukem fix -Wsign-compare issues
 1.13 09-Jan-2007  elad Consistent license.
 1.12 20-Dec-2006  christos From Anon Ymous:
- add __unused
- remove __GNUC__ hack
 1.11 01-Apr-2006  elad Allow explicit length by checking it only if we have a length above 0.
 1.10 30-Mar-2006  elad set all fields to -1 after allocation, this makes it easier to write
policies.
 1.9 19-Mar-2006  elad Set errno on failure, and man-page updates.
 1.8 19-Mar-2006  christos - Don't trash error number returned by the handler; return it instead.
- Add default cases and return EINVAL
- Don't check for NULL arguments and return EFAULT. Let it core-dump instead.
(or add DIAGASSERT)
- Coverity CID 799: Don't dereference m and n if they are known to be NULL.
Bail out sooner with EINVAL.
 1.7 19-Feb-2006  elad needs assert.h to compile.
 1.6 19-Feb-2006  elad add _DIAGASSERT as requested by mrg@.
 1.5 18-Feb-2006  elad When loading a policy with an "nclasses" option, always set the min/max
values for the various character classes to allow any number, just in
case. Also note about that in the man-page.

This makes it easier to use the "nclasses" option.

Note that alternatively we could just memset() to 0xff when doing the
load, but that might lead to more unexpected behavior.
 1.4 18-Feb-2006  elad Don't expose struct pw_policy and use pw_policy_t, use malloc, man-page
fixups.

As discussed on source-changes@.

Okay yamt@, thorpej@.
 1.3 18-Feb-2006  elad Some stuff that's been sitting in my tree for too long...

Improve the pw_policy(3) API by splitting it to two functions, one to load
the policy from /etc/passwd.conf and another to test passwords against the
policy.

Some bug fixes, more consistent code, and man-page updates.

Minor for libutil bumped.
 1.2 16-Sep-2005  elad Rename struct pw_policy -> struct pw_policy_handler.
 1.1 14-Sep-2005  elad Introduce pw_policy(3), an easily extendable way of defining password
policies and enforcing them in programs.

Man-page written with much help and tips from David Maxwell, Hubert
Feyrer, and Thomas Klausner.

This bumps libutil minor to 7.

XXX: Need default policy to go in /etc/passwd.conf, and integration
into local/yp/PAM password changing code.

PR/10206.
 1.3 27-Jan-1994  mycroft Clean up deleted files.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 01-Mar-1995  mycroft Clean up deleted files.
 1.3 19-Jan-1994  jtc Fix off by one bug in pwcashe routine group_from_gid().
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3 27-Mar-2011  njoly Fix sigprocmask section (3 -> 2).
 1.2 30-Apr-2008  martin branches: 1.2.8;
Convert TNF licenses to new 2 clause variant
 1.1 25-Sep-2007  lukem branches: 1.1.2; 1.1.8;
Add raise_default_signal(3) -- raise the default signal handler.
Can be used by applications that have their own SIGINT (et al)
handlers and want to exit in a manner that correctly
signals to the parent that the process was terminated by a signal.
See http://www.cons.org/cracauer/sigint.html for more info.
Discussed on tech-userlevel@.
 1.1.8.1 18-May-2008  yamt sync with head.
 1.1.2.2 06-Nov-2007  matt sync with HEAD
 1.1.2.1 25-Sep-2007  matt file raise_default_signal.3 was added on branch matt-armv6 on 2007-11-06 23:11:59 +0000
 1.2.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.2.8.1 30-Apr-2008  martin file raise_default_signal.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.3 28-Apr-2008  martin branches: 1.3.8;
Remove clause 3 and 4 from TNF licenses
 1.2 28-Sep-2007  lukem branches: 1.2.2; 1.2.8;
support nbtool_config.h.
 1.1 25-Sep-2007  lukem Add raise_default_signal(3) -- raise the default signal handler.
Can be used by applications that have their own SIGINT (et al)
handlers and want to exit in a manner that correctly
signals to the parent that the process was terminated by a signal.
See http://www.cons.org/cracauer/sigint.html for more info.
Discussed on tech-userlevel@.
 1.2.8.1 18-May-2008  yamt sync with head.
 1.2.2.2 06-Nov-2007  matt sync with HEAD
 1.2.2.1 28-Sep-2007  matt file raise_default_signal.c was added on branch matt-armv6 on 2007-11-06 23:12:00 +0000
 1.3.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3.8.1 28-Apr-2008  martin file raise_default_signal.c was added on branch christos-time_t on 2008-04-28 20:23:04 +0000
 1.10 04-May-2010  jruoho Use .Fn instead of .Nm.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 20-Aug-2001  wiz Improve formatting, noted by Simon Burge.
 1.5 09-Apr-2001  wiz Fix date, whitespace and punctuation.
 1.4 21-Sep-2000  ad Use .{B,Bs,F,N,O}x and fix miscellaneous errors.
 1.3 19-Sep-2000  ad Document secure_path() better; in particular, note that it will write
to the system log.
 1.2 18-Sep-2000  ad - Simplify code path.
- Make the first argument to secure_path() constant.
- KNF.
 1.1 07-Jul-2000  itojun branches: 1.1.2;
rename securepath.3 into secure_path.3, as the function is named secure_path().
it is too hard to guess...
 1.1.2.2 07-Jul-2000  itojun pullup, approved by releng-1-5
rename securepath.3 into secure_path.3, as the function is named secure_path().
it is too hard to guess...

basesrc/distrib/sets/lists/comp/mi 1.243 -> 1.244
basesrc/distrib/sets/lists/comp/obsolete.mi 1.23 -> 1.24
basesrc/lib/libutil/Makefile 1.26 -> 1.27
 1.1.2.1 07-Jul-2000  itojun file secure_path.3 was added on branch netbsd-1-5 on 2000-07-07 16:22:18 +0000
 1.2 06-Jan-2003  wiz writable, not writeable.
 1.1 20-Aug-2001  wiz Rename secure_path(3) source file from securepath.c to secure_path.c.
 1.4 07-Jul-2000  itojun rename securepath.3 into secure_path.3, as the function is named secure_path().
it is too hard to guess...
 1.3 08-Mar-2000  mjl branches: 1.3.4;
Added details about origin of code (BSD/OS) in history section.
Closes PR/9410 by Peter Seebach.
 1.2 13-Jan-2000  mjl Add a history section.
 1.1 12-Jan-2000  mjl Add necessary support routines for login.conf.
 1.3.4.1 07-Jul-2000  itojun pullup, approved by releng-1-5
rename securepath.3 into secure_path.3, as the function is named secure_path().
it is too hard to guess...

basesrc/distrib/sets/lists/comp/mi 1.243 -> 1.244
basesrc/distrib/sets/lists/comp/obsolete.mi 1.23 -> 1.24
basesrc/lib/libutil/Makefile 1.26 -> 1.27
 1.6 20-Aug-2001  wiz Rename secure_path(3) source file from securepath.c to secure_path.c.
 1.5 03-Jan-2001  lukem sprinkle in _DIAGASSERT() as appropriate
 1.4 18-Sep-2000  ad - Simplify code path.
- Make the first argument to secure_path() constant.
- KNF.
 1.3 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.2 13-Jan-2000  mjl Make login_cap routines resilient to non-existant conf file, and
secure_path() less noisy.
 1.1 12-Jan-2000  mjl Add necessary support routines for login.conf.
 1.54 11-Apr-2016  roy Bump libutil for new pidfile functions.
 1.53 24-Sep-2015  christos Add kinfo_getvmmap from FreeBSD
 1.52 26-Jul-2015  kamil Bump shlib minor for new function: ereallocarr(3)

Noted by <mrg>
 1.51 07-Apr-2012  christos - add getdiskrawname.
- exit on error for lint.
 1.50 07-Apr-2012  christos add getfsspecname
 1.49 30-Aug-2011  bouyer branches: 1.49.2;
Add getlabelusesmbr(), as proposed in
http://mail-index.netbsd.org/tech-userlevel/2011/08/25/msg005404.html
This is used by disk tools such as disklabel(8) to dynamically decide is
the undelyling platform uses a disklabel-in-mbr-partition or not
(instead of using a compile-time list of ports).
getlabelusesmbr() reads the sysctl kern.labelusesmbr, takes its value from the
machdep #define LABELUSESMBR.
For evbmips, make LABELUSESMBR 1 if the platform uses pmon
as bootloader, and 0 (the previous value) otherwise.
 1.48 28-Aug-2011  christos add strpct, requested by joerg
 1.47 13-May-2009  pgoyette Implement snprintb_m(3) to provide multi-line bit/bit-field decode.
Discussed on tech-kern.
 1.46 11-Jan-2009  christos branches: 1.46.2;
merge christos-time_t
 1.45 25-Sep-2007  lukem Add raise_default_signal(3) -- raise the default signal handler.
Can be used by applications that have their own SIGINT (et al)
handlers and want to exit in a manner that correctly
signals to the parent that the process was terminated by a signal.
See http://www.cons.org/cracauer/sigint.html for more info.
Discussed on tech-userlevel@.
 1.44 01-Jul-2007  pooka branches: 1.44.4;
add estrndup()
 1.43 04-Feb-2007  elad Add support for per-user /tmp.

Enabled via per_user_tmp in /etc/rc.conf (default off).

See security(8) and rc.conf(5) for more details.

Lots of input from thorpej@ & christos@, thanks!
 1.42 14-Dec-2006  he Complete the move of string_to_flags() and flags_to_string() from the
bin/ls sources to libutil:
o Bump libutil minor version number
o Fix uses to include <util.h> to pick up the function definitions
o Fix most uses of flags_to_string() to release the now-malloc()ed result
 1.41 17-Nov-2006  christos add getdate.
 1.40 26-Aug-2006  christos Add efun(3)
 1.39 18-Feb-2006  elad Some stuff that's been sitting in my tree for too long...

Improve the pw_policy(3) API by splitting it to two functions, one to load
the policy from /etc/passwd.conf and another to test passwords against the
policy.

Some bug fixes, more consistent code, and man-page updates.

Minor for libutil bumped.
 1.38 20-Dec-2005  christos make setuserenv and setuserpath take an environment setting function and
an environment pointer and expose them.
bump version.
 1.37 14-Sep-2005  elad Introduce pw_policy(3), an easily extendable way of defining password
policies and enforcing them in programs.

Man-page written with much help and tips from David Maxwell, Hubert
Feyrer, and Thomas Klausner.

This bumps libutil minor to 7.

XXX: Need default policy to go in /etc/passwd.conf, and integration
into local/yp/PAM password changing code.

PR/10206.
 1.36 12-Jan-2005  christos add pw_getpwconf(), bump.
 1.35 19-Nov-2004  christos Add sockaddr_snprintf; XXX: Needs a man page.
 1.34 03-Aug-2004  thorpej - Rename pw_copy() to pw_copyx(), make it return a success/failure code,
and add "errbuf" and "errbufsz" parameters so that errors can be handled
gracefully, rather than simply exiting the process.
- Add a pw_copy() wrapper around pw_copyx() to preserve old behavior for
apps that use it.
- Bump shlib version to 7.4.
 1.33 11-Apr-2003  christos add functions to retrieve option values.
 1.32 22-Mar-2003  jdolecek move getmntopts(3) to libutil, build and install also it's manpage
bump libutil minor
adjust individual mount_*/Makefile to use libutil getmntopts(3)
 1.31 12-Dec-2002  scw Bump minor number for getlabel{sector,offset}() addition.
 1.30 30-Nov-2002  lukem - Migrate fparseln(3) from libutil to libc, where it should have been in
the first place...
- Bump libutil major (to 7.0) and libc minor (to 12.91).
 1.29 20-Sep-2002  christos Add snprintb(3) inspired from bitmask_snprintf(9), but made to look like
more like snprintf(3). Discussed with thorpej.
 1.28 23-Aug-2002  tron Bump minor number to 3 because there are already systems with
"libutil.so.6.2" to avoid further problems.
 1.27 22-Aug-2002  abs Move humanize_number(3) from libutil to libc as per discussion on tech-misc
Revert minor number bump on libutil (with note to skip it next update), and
bump libc.
 1.26 10-Aug-2002  thorpej Actually bump the shlib version to 6.2 as abs intended to.
 1.25 27-Jul-2002  christos add utmpx/wtmpx processing routines.
 1.24 18-Aug-2001  ad branches: 1.24.2;
Bump libutil major for pw_mkdb() change.
 1.23 06-Apr-2001  wiz Add getbootfile(3) to libutil, and a man page.
Bump libutil version to 5.5.
 1.22 06-Dec-2000  tron Add two new passwd file update functions:
- The pw_setprefix() function defines the root directory used for passwd
file updates. If the prefix is set to /newroot pw_lock() will operate on
/newroot/etc/ptmp afterwards. The default prefix is an empty string.
- The pw_getprefix() function returns the root directory which is currently
used for passwd file updates.
 1.21 06-Jul-2000  ad Bump libutil minor (pw_getconf()).
 1.20 12-Jan-2000  mjl branches: 1.20.4;
Add necessary support routines for login.conf.
 1.19 06-Jun-1999  thorpej Add pidfile(3), which write a pid file in /var/run, and arranges for it
to be removed on normal exit.
 1.18 25-Feb-1999  abs Add a note to update src/distrib/sets/lists/base/shl.*, and add a missing
RCS Id.
 1.17 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.16 27-Jun-1998  thorpej Put pw_scan() back into libutil and pretent that libutil.so.5.0 never
existed.
 1.15 09-Jun-1998  lukem actually, bump major for pw_scan() removal, even when it was moved to -lc
 1.14 08-Jun-1998  lukem bump minor (because pw_scan() moved to libc, and old binaries that use libutil.so.4.4 and libc.so.12.26 won't work otherwise)
 1.13 18-Mar-1998  bouyer Add bswap{16,32,64} functions to libutil. Because of this, bump minor.
 1.12 05-Jan-1998  perry RCSID Police.
 1.11 16-Nov-1997  christos Increase minor number for fparseln
 1.10 11-Oct-1997  cjs Add pidlock, ttylock, ttyunlock functions.
 1.9 25-Sep-1997  lukem implement opendisk(3), as discussed with Jason Thorpe
 1.8 24-Jul-1997  phil Change pw_copy to take an optional 4th parameter (old_pw), a pointer
to a passwd structure. If a good pointer, make sure old entry in file
is identical to passed passwd (old_pw). If not, abort.

Update documentation, bump major version due to change to pw_copy.
 1.7 14-Nov-1996  gwr Increment minor version for new function ttyaction().
 1.6 15-May-1996  jtc Minor reorganization of libutil, including the addition of passward
locking and editing functions.
From Greg Hudson <ghudson@MIT.EDU>
 1.5 04-May-1994  cgd minor cleanup; kill unnecessary casts
 1.4 27-Mar-1994  cgd _double_ major number bump! joy!
 1.3 27-Jan-1994  cgd get rid of stuff that doesn't belong here
 1.2 25-Jan-1994  cgd kill the 'prog' arg to getbsize(); it's unneeded. minor rev bump.
 1.1 08-Nov-1993  cgd add shlib_version file, with version 0.0
 1.20.4.1 26-Feb-2002  he Apply patch (requested by he):
Add support for local MD5-encrypted passwords.
Here: add a teeny version number, due to addition of pwd_gensalt().
 1.24.2.1 25-Oct-2003  cyber Pull up diff (requested by jmc in ticket #1461):
Adjust sets list.
Set tiny version.
 1.44.4.1 06-Nov-2007  matt sync with HEAD
 1.46.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.49.2.1 17-Apr-2012  yamt sync with head
 1.40 09-Oct-2025  rillig libutil/snprintb: allow 'f' to be combined with ':'

But only if the numeric value can be clearly distinguished from the
description. This style is used by sh3/dmacreg.h.
 1.39 08-Apr-2024  rillig snprintb.3: provide examples for hexadecimal character escapes

Suggested by uwe@, in reaction to the previous commit, which preferred
octal in the examples. Hexadecimal escapes are more familiar to most
programmers, and the chance of mistaking \x14 for decimal 14 is less
than the chance of mistaking octal \014 for decimal 14.
 1.38 07-Apr-2024  rillig snprintb.3: clean up formatting and wording, prefer octal in examples

Using hexadecimal character escapes requires separate string literals if
the description starts with one of the letters A-F; octal character
escapes have at most 3 digits, reducing ambiguity.
 1.37 07-Apr-2024  rillig snprintb: reject combinations of 'f' with ':' as well as 'F' with '='

These combinations would lead to garbled output.
 1.36 29-Feb-2024  rillig snprintb.3: fix typo
 1.35 22-Feb-2024  rillig snprintb: always null-terminate output

Always null-terminate the output in the buffer, even in error cases. The
wording in the manual page has been promising this since 2008. For
snprintb_m, ensure that the output is terminated with two null
characters, to gracefully handle situations in which the caller does not
check whether snprintb returned an error.

If the buffer size is zero, allow the buffer to be a null pointer,
analogous to snprintf.

Fix an out-of-bounds memory read if the bitfmt ends with a '*' directive
(since today).

In the tests, merge the helper functions for snprintb, snprintb_m, as
they were similar enough.

Fix a few 'line_max exceeded' tests, ensuring that they output a '#'
marker, and that the 'complete' tests don't.
 1.34 22-Feb-2024  rillig snprintb: error out on out-of-bounds bit shifts

Previously, these invoked undefined behavior, now they lead to an early
return. An example of out-of-bounds bit number is in SCZ_PCICTRL_BITS.
Bit fields that extend beyond the msb are still allowed.

Allow 'f' and 'F' to have fields that are 64 bits wide. This only makes
sense when the field starts at bit 0.

Remove the unused 'val_len', it was only needed before snprintb.c 1.20.
 1.33 20-Feb-2024  rillig snprintb.3: sync examples with reality
 1.32 18-Feb-2024  rillig mman.h: fix snprintb description for alignment 2^60
 1.31 15-Feb-2024  rillig snprintb: rename buflen to bufsize, following the wording in snprintf
 1.30 01-Feb-2024  rillig snprintb.3: fix examples, clean up wording

In the examples using hex escape sequences, there must be a delimiter
between the escape sequence and the following description if the
description starts with [A-Fa-f], as hex escape sequences are not
limited in length.

Distinguish between a 'directive' (bit + length + description) and a
'description' (only the text).

The fmt parameter is not a string, as strings only reach to the first
'\0' byte, but the new-style format may include additional '\0' as bit
numbers.
 1.29 22-Jan-2024  uwe snprintb(3): restore empty string in snprintb_m example

Restore the empty string at the end of snprintb_m output that was
accidentally removed along with empty string placeholders in the
format strings. While here, move that example to be next to its
snprintb counterpart.
 1.28 21-Jan-2024  uwe snprintb(3): update mmap example

Bring over the prettier version of the mmap format string that we have
in the header file for some time now. Clarify that the final NUL of
the new format string is supplied by the compiler, g/c explicit final
\0 from the example that had it.
 1.27 21-Jan-2024  uwe snprintb(3): try to improve narration

Try to make the narration more coherent. Make the old and new
syntaxes easy to distinguish and go out of our way to highlight that
the old syntax uses 1-based bit positions.
 1.26 21-Jan-2024  rillig snprintb.3: remove empty string literals from examples

Suggested by uwe@, as gaps in bitmasks are quite common and thus
shouldn't clutter the code.
 1.25 21-Jan-2024  rillig snprintb.3: fix examples

The first example broke the format string at boundaries that didn't
highlight the structure of the format string and also didn't make it
clear that a few bits were omitted from having descriptions.

The second example contained an off-by-one error for SIXTEEN, which was
actually FIFTEEN.

The snprintb_m example repeated the above off-by-one error, and its
output was shown wrong, due to concatenated escape sequences.
 1.24 30-Jul-2020  uwe Fix grammar.
 1.23 07-Dec-2019  wiz Remove trailing whitespace.
 1.22 06-Dec-2019  christos Correct the man page, and say that the printf(3) format characters need
to be uintmax_t.
 1.21 29-Apr-2019  kre snprintb(3) says that, in the new(?) Torek format, all fields specs end with \0
The F spec is one of those, it should be terminated with \0 just like all
the others (irrelevant that it has no extra data to delimit).

Fix <sys/mman.h> to define the snprintb() format string correctly (include
the missing \0's). Fix the copy of that definition included into
snprintb(3) to match the updated mman.h version (ride the date bump
from the day before yesterday .. this is the same change, just corrected).

Undo the previous snprintb.c change ("off by one" fix) which was an
attempt to make the broken mman.h usage work (and did, but not the way
it should be done). Also, after using the new * format (instead of only
when something has already matched) skip the associated data so we don't
attempt to interpret it as more field specifiers. This func needs lots of TLC!

Fix the ATF tests for snprintb() to not assume that F format is really
exactly like f format, and has data after the field specifier. It doesn't.
Add several more tests (including testing the '*' field operator
recently added).
 1.20 27-Apr-2019  wiz Remove trailing whitespace.
 1.19 27-Apr-2019  christos remove dup line
 1.18 27-Apr-2019  christos Document the '*' field and give a more complex example with F and *.
 1.17 22-Oct-2017  abhinav branches: 1.17.4;
Add snprintb_m to the NAME section.
 1.16 07-Aug-2013  pgoyette Update example using hex-escape-sequences to conform to gcc parsing rules.
(See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33167 for details.)
 1.15 07-Aug-2013  pgoyette Add an example using snprintb_m()

Replace \*[Gt] and \*[Lt] with the simple characters > and < (OK wiz)

XXX Note that the examples currently do not compile with GCC! The hex
XXX character sequences such as \x10CACHE are being parsed as longer
XXX than 2-hex-digit strings!
 1.14 13-May-2009  pgoyette branches: 1.14.6; 1.14.12;
Implement snprintb_m(3) to provide multi-line bit/bit-field decode.
Discussed on tech-kern.
 1.13 05-May-2009  pgoyette Update type of argument 4 from u_quad_t to uint64_t to match the actual
implementation.
 1.12 26-Mar-2009  uebayasi Correct the order of arguments in EXAMPLE. Bump date.
 1.11 23-Dec-2008  wiz branches: 1.11.2; 1.11.4;
Fix deleto in previous.
 1.10 23-Dec-2008  christos fix argument order in example.
 1.9 17-Dec-2008  wiz Re-add LIBRARY section.
 1.8 17-Dec-2008  wiz Fix some minor mdoclint complaints.
 1.7 16-Dec-2008  christos use the bitmask_snprintf info which is more complete, and adjust it for
reality.
 1.6 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.5 01-Dec-2004  peter branches: 1.5.24;
Add missing LIBRARY section.

ok wiz@
 1.4 21-Nov-2004  christos fix the header.
 1.3 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.1 20-Sep-2002  christos Add snprintb(3) inspired from bitmask_snprintf(9), but made to look like
more like snprintf(3). Discussed with thorpej.
 1.5.24.1 18-May-2008  yamt sync with head.
 1.11.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.11.2.2 23-Dec-2008  wiz Fix deleto in previous.
 1.11.2.1 23-Dec-2008  wiz file snprintb.3 was added on branch christos-time_t on 2008-12-23 21:46:14 +0000
 1.14.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.17.4.1 10-Jun-2019  christos Sync with HEAD
 1.8 16-Dec-2008  christos move snprintb to common
 1.7 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6 15-Oct-2006  christos branches: 1.6.16;
prevent empty else.
 1.5 27-Aug-2005  elad Lint warnings.
 1.4 11-Dec-2004  christos WARNS=3; fix cast-qual issues.
 1.3 27-Oct-2003  lukem 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).
 1.2 20-Sep-2002  christos Add rcsid, config.h
 1.1 20-Sep-2002  christos Add snprintb(3) inspired from bitmask_snprintf(9), but made to look like
more like snprintf(3). Discussed with thorpej.
 1.6.16.1 18-May-2008  yamt sync with head.
 1.12 15-Sep-2025  christos fix funny typo
 1.11 14-Sep-2025  christos do as the man page describes and explain some more.
 1.10 14-Sep-2025  christos PR/59643: Taylor Campbell: Add a way to print addresses generically.
 1.9 04-Dec-2022  uwe lib: Mark up error names in man pages with .Er
 1.8 07-Jun-2013  christos Add a debugging format that prints all the fields with names.
 1.7 11-Apr-2009  joerg branches: 1.7.6; 1.7.12;
Fix markup.
 1.6 30-Apr-2008  martin branches: 1.6.6; 1.6.8; 1.6.10;
Convert TNF licenses to new 2 clause variant
 1.5 13-Apr-2005  wiz branches: 1.5.18;
Bump date for previous; add commas to make
sentences more readable.
 1.4 09-Apr-2005  atatat Add the 'A' and 'P' format specifiers which use getaddrinfo(3) to turn
numbers into names (if possible). Also add the '?' format modifier
that elides the "N/A" if that's what you would normally get.
 1.3 01-Dec-2004  peter Add missing LIBRARY section.

ok wiz@
 1.2 20-Nov-2004  wiz Formatting fixes, and a typo fix.
 1.1 20-Nov-2004  christos Add a manual page.
 1.5.18.1 18-May-2008  yamt sync with head.
 1.6.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.6.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.6.8.1 30-Apr-2008  martin file sockaddr_snprintf.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.6.6.1 12-Apr-2009  snj Pull up following revision(s) (requested by 694):
lib/libutil/sockaddr_snprintf.3: revision 1.7
Fix markup.
 1.7.12.1 23-Jun-2013  tls resync from head
 1.7.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16 14-Sep-2025  christos do as the man page describes and explain some more.
 1.15 14-Sep-2025  christos PR/59643: Taylor Campbell: Add a way to print addresses generically.
 1.14 29-Dec-2016  christos Make this portable to other OSs
 1.13 01-Jun-2016  christos branches: 1.13.2;
Use NULL instead of 0.
 1.12 06-Apr-2016  christos pretty-print link addresses.
 1.11 31-Dec-2013  mlelstv Use output buffer size to limit copy-out of sun_path. Otherwise you may
get a buffer overflow with strlcpy :)
 1.10 07-Jun-2013  christos Add a debugging format that prints all the fields with names.
 1.9 28-Apr-2008  martin branches: 1.9.4; 1.9.8; 1.9.28;
Remove clause 3 and 4 from TNF licenses
 1.8 24-Jul-2007  dyoung branches: 1.8.10; 1.8.12;
In sockaddr_snprintf(sbuf, len, fmt, sa), do not write the terminating
null character outside of the byte region [sbuf, sbuf + len).

1) If the length of the buffer is 0, do not write a null character
at all. Previously, sockaddr_snprintf() may have been able to
overwrite sbuf[-1] if len was 0.

2) If the length of the buffer, len, is greater than 0, then write
the null at sbuf[len - 1]. Previously, sockaddr_snprintf()
wrote the null at buf[len - 1], where `buf' was a "cursor" that
did not necessarily equal `sbuf', the start of the buffer. Now,
sockaddr_snprintf() always writes the null at sbuf[len - 1].
 1.7 09-Dec-2006  dyoung Render the format %% as %.
 1.6 27-Aug-2005  elad branches: 1.6.4; 1.6.6;
Lint warnings.
 1.5 09-Apr-2005  atatat Add the 'A' and 'P' format specifiers which use getaddrinfo(3) to turn
numbers into names (if possible). Also add the '?' format modifier
that elides the "N/A" if that's what you would normally get.
 1.4 13-Jan-2005  dyoung For consistency of sockaddr_snprintf(3) with snprintf(3) and
snprintb(3), do not count the terminating NUL in the return value.
Update the regression tests to match. Approved by christos@.
 1.3 11-Dec-2004  christos WARNS=3; fix cast-qual issues.
 1.2 19-Nov-2004  christos check for getnameinfo error correctly; thanks to Peter Postma.
 1.1 19-Nov-2004  christos Add sockaddr_snprintf; XXX: Needs a man page.
 1.6.6.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.6.4.2 27-Jul-2007  liamjfoy Pull up following revision(s) (requested by dyoung in ticket #794):
lib/libutil/sockaddr_snprintf.c: revision 1.8
In sockaddr_snprintf(sbuf, len, fmt, sa), do not write the terminating
null character outside of the byte region [sbuf, sbuf + len).
1) If the length of the buffer is 0, do not write a null character
at all. Previously, sockaddr_snprintf() may have been able to
overwrite sbuf[-1] if len was 0.
2) If the length of the buffer, len, is greater than 0, then write
the null at sbuf[len - 1]. Previously, sockaddr_snprintf()
wrote the null at buf[len - 1], where `buf' was a "cursor" that
did not necessarily equal `sbuf', the start of the buffer. Now,
sockaddr_snprintf() always writes the null at sbuf[len - 1].
 1.6.4.1 26-Jul-2007  liamjfoy Pull up following revision(s) (requested by dyoung in ticket #792):
lib/libutil/sockaddr_snprintf.c: revision 1.7
Render the format %% as %.
 1.8.12.2 24-Jul-2007  dyoung In sockaddr_snprintf(sbuf, len, fmt, sa), do not write the terminating
null character outside of the byte region [sbuf, sbuf + len).

1) If the length of the buffer is 0, do not write a null character
at all. Previously, sockaddr_snprintf() may have been able to
overwrite sbuf[-1] if len was 0.

2) If the length of the buffer, len, is greater than 0, then write
the null at sbuf[len - 1]. Previously, sockaddr_snprintf()
wrote the null at buf[len - 1], where `buf' was a "cursor" that
did not necessarily equal `sbuf', the start of the buffer. Now,
sockaddr_snprintf() always writes the null at sbuf[len - 1].
 1.8.12.1 24-Jul-2007  dyoung file sockaddr_snprintf.c was added on branch matt-mips64 on 2007-07-24 08:45:46 +0000
 1.8.10.1 18-May-2008  yamt sync with head.
 1.9.28.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.28.1 23-Jun-2013  tls resync from head
 1.9.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.9.8.1 28-Apr-2008  martin file sockaddr_snprintf.c was added on branch christos-time_t on 2008-04-28 20:23:04 +0000
 1.9.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.9 31-May-2023  uwe stat_flags(3): try to improve the descriptions

List all alternative forms recognized by string_to_flags(3).
Both "dump" and "nonodump" are the negative of "nodump".
string_to_flags does not recognize "snap".
Provide xrefs for flag descriptions where applicable.
 1.8 19-Sep-2012  wiz branches: 1.8.40;
Fix string_to_flags prototype. From Brooks Davis in PR 46986.
Bump date.
 1.7 06-Aug-2011  jruoho branches: 1.7.2; 1.7.8;
Xref chflags(2) and stat_flags(3) with each other.
 1.6 04-May-2010  jruoho Use table instead of a list.
 1.5 30-Apr-2008  martin branches: 1.5.8;
Convert TNF licenses to new 2 clause variant
 1.4 23-Dec-2006  wiz branches: 1.4.10;
Fix typo.
 1.3 23-Dec-2006  wiz Use more macros. Fix section in Xr.
 1.2 23-Dec-2006  wiz Remove trailing whitespace.
 1.1 14-Dec-2006  christos moved string_to_flags and flags_to_string from ls to libutil.
 1.4.10.1 18-May-2008  yamt sync with head.
 1.5.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.5.8.1 30-Apr-2008  martin file stat_flags.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.7.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.7.2.1 30-Oct-2012  yamt sync with head
 1.8.40.1 20-Jul-2024  martin Pull up following revision(s) (requested by rin in ticket #759):

lib/libutil/stat_flags.3: revision 1.9

stat_flags(3): try to improve the descriptions

List all alternative forms recognized by string_to_flags(3).

Both "dump" and "nonodump" are the negative of "nodump".
string_to_flags does not recognize "snap".

Provide xrefs for flag descriptions where applicable.
 1.3 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.2 16-Jan-2007  cbiere Fixed string truncation bug in flags_to_string(): SAPPEND() uses
sizeof(string) but string is a pointer to a malloc()ed buffer.
 1.1 14-Dec-2006  christos moved string_to_flags and flags_to_string from ls to libutil.
 1.7 03-May-2025  rillig strpct: fix rounding errors and loss of accuracy
 1.6 18-Mar-2014  riastradh branches: 1.6.38;
Merge riastradh-drm2 to HEAD.
 1.5 20-Jul-2013  wiz Use Mt for email addresses.
 1.4 07-Jan-2012  christos branches: 1.4.6; 1.4.10;
- add strspct
- be explicit about string not being NUL terminated if bufsiz == 0
 1.3 01-Sep-2011  fair branches: 1.3.2;
Clarify the history and add proper attribution.
 1.2 28-Aug-2011  wiz Minor cleanup.
 1.1 28-Aug-2011  christos add strpct, requested by joerg
 1.3.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.4.10.1 23-Jul-2013  riastradh sync with HEAD
 1.4.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.38.1 02-Aug-2025  perseant Sync with HEAD
 1.6 13-May-2025  rillig strpct: inline simple snprintf calls

For fractions in the typical range from 0 inclusively to 1 exclusively,
snprintf is not called at all. For calling strpct 1 million times in
t_strpct, the run time on my amd64 machine goes from 28 seconds down to
2 seconds.
 1.5 03-May-2025  rillig strpct: fix rounding errors and loss of accuracy
 1.4 02-May-2025  rillig strspct: fix integer overflow in -ftrapv mode
 1.3 07-Jan-2012  christos branches: 1.3.52;
- add strspct
- be explicit about string not being NUL terminated if bufsiz == 0
 1.2 02-Sep-2011  christos branches: 1.2.2;
- use the correct buffer size
- remove obsolete comment
 1.1 28-Aug-2011  christos add strpct, requested by joerg
 1.2.2.1 17-Apr-2012  yamt sync with head
 1.3.52.1 02-Aug-2025  perseant Sync with HEAD
 1.16 21-Mar-2021  mrg note that ttyaction.[35] first appeared in netbsd 1.3.
 1.15 04-May-2010  jruoho Use .Fn instead of .Nm.
 1.14 22-Oct-2009  tsarna Update my email address to one I have used in this millenium.
 1.13 30-Apr-2008  martin branches: 1.13.8;
Convert TNF licenses to new 2 clause variant
 1.12 16-Apr-2003  wiz branches: 1.12.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.11 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.10 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 29-Aug-1998  tsarna Execute ttyaction on termination of rlogind/telnetd sessions.
Also, say a little bit about ttyaction in the getty and login manpages.
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 04-Dec-1997  mikel s/void/int/, from Ty Sarna in PR lib/4627
use .Xr when referring to login and getty instead of .Nm
 1.5 31-Jul-1997  jtc Fix files using old TNF copyright notice
 1.4 17-Nov-1996  lukem fix spello of 'convenience'
 1.3 16-Nov-1996  fvdl The FILES section named '/etc/ttyactions'; remove that 's'.
 1.2 14-Nov-1996  gwr Allow the ttyname parameter of ttyaction() to be the full pathname of
the device, because that is what getty and login have handy. The
"/dev/" part is skipped before scanning the /etc/ttyaction file.
 1.1 14-Nov-1996  gwr Add ttyaction.3 and ttyaction.c
 1.12.30.1 18-May-2008  yamt sync with head.
 1.13.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.13.8.1 30-Apr-2008  martin file ttyaction.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.19 28-Apr-2008  martin branches: 1.19.8;
Remove clause 3 and 4 from TNF licenses
 1.18 27-Aug-2005  elad branches: 1.18.18;
Lint warnings.
 1.17 11-Dec-2004  christos WARNS=3; fix cast-qual issues.
 1.16 29-Mar-2004  wiz Use pid_t for pids. From Jeff Ito in PR 24854.
 1.15 19-Dec-2000  cgd __CONCAT does token pasting, not string concatnation. if something like:
__CONCAT("PATH=",_PATH_STDPATH);
actually works to concantate strings, it's because the preprocessor expands
it into "PATH=""whatever _PATH_STDPATH is" as separate strings, and then
ANSI string concatenation is performed on that. It's more straightforward
to just use ANSI string concatenation directly, and newer GCCs complain
(rightly) about mis-use of token pasting.
 1.14 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.13 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.12 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.11 11-Jan-1999  kleink strtok() -> strtok_r() to avoid side-effects.
 1.10 09-Dec-1998  christos Delint
 1.9 26-Jul-1998  mycroft const poisoning.
 1.8 31-Jul-1997  jtc Fix files using old TNF copyright notice
 1.7 20-Jun-1997  mikel include <fnmatch.h> for fnmatch() prototype
use __CONCAT() to generate pathenv
 1.6 09-May-1997  mycroft Pull in err.h for prototypes.
 1.5 29-Nov-1996  gwr Use _exit after exec failure (not exit).
 1.4 22-Nov-1996  gwr Use snprintf instead of sprintf.
 1.3 18-Nov-1996  gwr Correct lengths used to build environment strings. (Fixes PR#2948)
 1.2 14-Nov-1996  gwr Allow the ttyname parameter of ttyaction() to be the full pathname of
the device, because that is what getty and login have handy. The
"/dev/" part is skipped before scanning the /etc/ttyaction file.
 1.1 14-Nov-1996  gwr Add ttyaction.3 and ttyaction.c
 1.18.18.1 18-May-2008  yamt sync with head.
 1.19.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.19.8.1 28-Apr-2008  martin file ttyaction.c was added on branch christos-time_t on 2008-04-28 20:23:04 +0000
 1.13 16-Jan-2013  wiz Sort sections.
 1.12 15-Jan-2013  christos add some things to add next time we modify the function
 1.11 30-Apr-2008  martin branches: 1.11.4; 1.11.8; 1.11.28;
Convert TNF licenses to new 2 clause variant
 1.10 16-Apr-2003  wiz branches: 1.10.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.8 20-Feb-2002  wiz Drop trailing empty line.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 31-Jul-1997  jtc Fix files using old TNF copyright notice
 1.3 06-Jul-1997  christos Remove accidental copy-right attribution.
 1.2 01-Jul-1997  mikel s/ttyaction/ttymsg/g as noted by Dave Huang <khym@bga.com>
set argument of .Os to NetBSD 1.3
add xref to writev(2), for a better explanation of uio
misc. cleanup
 1.1 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.10.30.1 18-May-2008  yamt sync with head.
 1.11.28.1 25-Feb-2013  tls resync with head
 1.11.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.11.8.1 30-Apr-2008  martin file ttymsg.3 was added on branch christos-time_t on 2008-04-30 13:10:53 +0000
 1.11.4.1 23-Jan-2013  yamt sync with head
 1.23 18-Jan-2009  lukem fix -Wsign-compare issues
 1.22 27-Aug-2005  elad Lint warnings.
 1.21 08-Jan-2005  christos Avoid spinning if writing to a pty returns 0. This happened to me when
I had a pty with a suspended sshd (why?).
 1.20 10-Nov-2004  christos - don't complain if the pty is of the form pts/n
- fix off by one error in iovlen bounds checking
- print the function name in the error message and make the
error messages consistent
- knf
 1.19 29-Mar-2004  wiz Use pid_t for pids. From Jeff Ito in PR 24854.
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 27-Mar-2003  lukem Clear O_NONBLOCK correctly (previous code probably only worked because
O_NONBLOCK and F_SETFL are the same value).
Obtained from FreeBSD PR 8681 via FreeBSD's usr.bin/wall/ttymsg.c 1.5.
 1.16 16-Aug-2002  itojun defend against malicious line in ut_line, which could cause unwanted
writes to anything under /dev. revoke setuid/gid privs earlier.
From: xs@kittenz.org
 1.15 05-Jul-2000  ad - __RCSID() police.
- ANSIfy.
- Miscellaneous style changes.
- Shutup lint(1) in one or two cases.
 1.14 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.13 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.12 02-Jul-1999  simonb More trailing white space.
 1.11 27-Sep-1998  christos Use posix signal system calls.
XXX: Library functions should not unblock signals like this!
 1.10 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.9 09-May-1998  kleink Delint last.
 1.8 08-May-1998  kleink Fix some arithmetics lossage on typeless pointers.
 1.7 22-Jan-1998  perry unregisterify
 1.6 01-Jul-1997  mikel indicate new location in error message
 1.5 29-Jun-1997  christos - RCSID police
- Add ttymsg.3
 1.4 11-Feb-1997  mrg remove possibly dangerous sprintf and strcpy calls.
 1.3 17-Nov-1994  jtc Merged with 4.4lite
Changed to conform to NetBSD's new RCS Id conventions.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Nov-1994  jtc imported from 4.4lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.27 08-Mar-2019  msaitoh s/ the the / the /
 1.26 30-Mar-2017  abhinav branches: 1.26.12;
Use Sy to highlight the table header.
 1.25 30-Mar-2017  abhinav Add missing functions
 1.24 29-Aug-2011  jruoho branches: 1.24.24; 1.24.28;
Fix markup-typo.
 1.23 29-Aug-2011  jruoho Build libutil(3) as a link to util(3).
 1.22 29-Aug-2011  jruoho Note strpct(3).
 1.21 05-May-2010  jruoho Upon lukem@'s request, put the list of functions back.

XXX: Someone, please keep this up-to-date.
 1.20 04-May-2010  jruoho Remove the list of functions in the libutil library.

While such lists are nice, they are doomed to be repeatedly out of date due
maintenance costs related to manual updates. Ideally there should be a
common routine to auto-generate these, but in the meantime, just point to
the directory where libutil is implemented.
 1.19 11-Apr-2009  joerg Use semantic markup.
 1.18 17-Nov-2008  wiz branches: 1.18.2; 1.18.4;
Remove trailing whitespace.
 1.17 17-Nov-2008  wiz Bump date for new section.
 1.16 17-Nov-2008  ahoka SEE ALSO
efun(3)
 1.15 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.14 20-Nov-2004  christos branches: 1.14.24;
Add a manual page.
 1.13 22-Dec-2002  wiz Sync with other libutil man pages.
 1.12 30-Nov-2002  lukem - Migrate fparseln(3) from libutil to libc, where it should have been in
the first place...
- Bump libutil major (to 7.0) and libc minor (to 12.91).
 1.11 12-Oct-2002  elric Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.10 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.9 22-Aug-2002  abs Move humanize_number(3) from libutil to libc as per discussion on tech-misc
Revert minor number bump on libutil (with note to skip it next update), and
bump libc.
 1.8 12-Aug-2002  gmcgarry Clarify what functionality _is_ included and _should be_ included in libutil.
 1.7 08-Aug-2002  wiz Actually, the page was last modified today.
 1.6 08-Aug-2002  abs Add humanize_number.3 from Tomas Svensson in PR lib/15508.
Bump version of libutil
 1.5 07-Feb-2002  ross branches: 1.5.2;
Generate <>& symbolically.
 1.4 07-Dec-2001  wiz Fix pasto in last.
 1.3 07-Dec-2001  gmcgarry Fix pastos.
 1.2 23-Nov-2001  wiz Slight markup improvement.
 1.1 23-Nov-2001  gmcgarry Add a catch-all man page for libutil.
 1.5.2.1 25-Oct-2003  cyber Pull up revision 1.11 (requested by jmc in ticket #1461):
Added two functions disklabel_dkcksum() and disklabel_scan() to libutil
so that they can be shared by disklabel(8) and cgdconfig(8).
 1.14.24.1 18-May-2008  yamt sync with head.
 1.18.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.18.2.2 17-Nov-2008  wiz Remove trailing whitespace.
 1.18.2.1 17-Nov-2008  wiz file util.3 was added on branch christos-time_t on 2008-11-17 15:21:44 +0000
 1.24.28.1 21-Apr-2017  bouyer Sync with HEAD
 1.24.24.1 26-Apr-2017  pgoyette Sync with HEAD
 1.26.12.1 10-Jun-2019  christos Sync with HEAD
 1.1 21-Nov-2024  riastradh branches: 1.1.4;
libutil: Add expected symbols list.

PR lib/58838: shared libraries in base should all have expsym lists
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 21-Nov-2024  perseant file util.expsym was added on branch perseant-exfatfs on 2025-08-02 05:54:59 +0000
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 28-Dec-2008  christos branches: 1.1.2;
file Makefile.inc was initially added on branch christos-time_t.
 1.1.2.1 28-Dec-2008  christos compat code for libutil.
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 28-Dec-2008  christos branches: 1.1.2;
file compat_gepwconf.c was initially added on branch christos-time_t.
 1.1.2.1 28-Dec-2008  christos compat code for libutil.
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 28-Dec-2008  christos branches: 1.1.2;
file compat_login.c was initially added on branch christos-time_t.
 1.1.2.1 28-Dec-2008  christos compat code for libutil.
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 28-Dec-2008  christos branches: 1.1.2;
file compat_login_cap.c was initially added on branch christos-time_t.
 1.1.2.2 05-Jan-2009  christos fix linker warning.
 1.1.2.1 28-Dec-2008  christos compat code for libutil.
 1.3 04-Nov-2012  christos don't include things you don't need
 1.2 11-Jan-2009  christos branches: 1.2.8; 1.2.14;
merge christos-time_t
 1.1 28-Dec-2008  christos branches: 1.1.2;
file compat_loginx.c was initially added on branch christos-time_t.
 1.1.2.1 28-Dec-2008  christos compat code for libutil.
 1.2.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.2.8.1 16-Jan-2013  yamt sync with (a bit old) head
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 28-Dec-2008  christos branches: 1.1.2;
file compat_logoutx.c was initially added on branch christos-time_t.
 1.1.2.1 28-Dec-2008  christos compat code for libutil.
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 28-Dec-2008  christos branches: 1.1.2;
file compat_parsedate.c was initially added on branch christos-time_t.
 1.1.2.1 28-Dec-2008  christos compat code for libutil.
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 28-Dec-2008  christos branches: 1.1.2;
file compat_passwd.c was initially added on branch christos-time_t.
 1.1.2.1 28-Dec-2008  christos compat code for libutil.
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 28-Dec-2008  christos branches: 1.1.2;
file login_cap.h was initially added on branch christos-time_t.
 1.1.2.1 28-Dec-2008  christos compat code for libutil.
 1.3 04-Nov-2012  christos don't include things you don't need
 1.2 11-Jan-2009  christos branches: 1.2.8; 1.2.14;
merge christos-time_t
 1.1 28-Dec-2008  christos branches: 1.1.2;
file util.h was initially added on branch christos-time_t.
 1.1.2.1 28-Dec-2008  christos compat code for libutil.
 1.2.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.2.8.1 16-Jan-2013  yamt sync with (a bit old) head

RSS XML Feed