Home | History | Annotate | only in /src/usr.sbin/ypbind
History log of /src/usr.sbin/ypbind
RevisionDateAuthorComments
 1.20 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.19 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.18 22-Apr-2009  lukem branches: 1.18.46;
Enable WARNS=4 by default, except for:
cpuctl dumplfs hprop ipf iprop-log kadmin kcm kdc kdigest
kimpersonate kstash ktutil makefs ndbootd ntp pppd quot
racoon racoonctl rtadvd sntp sup tcpdchk tcpdmatch tcpdump
traceroute traceroute6 user veriexecgen wsmoused zic
(Mostly third-party applications)
 1.17 07-Jul-2007  christos branches: 1.17.20;
- Compile in with debugging by default.
- General cleanup.
 1.16 28-May-2007  tls Add new Makefile knob, USE_FORT, which extends USE_SSP by turning on the
FORTIFY_SOURCE feature of libssp, thus checking the size of arguments to
various string and memory copy and set functions (as well as a few system
calls and other miscellany) where known at function entry. RedHat has
evidently built all "core system packages" with this option for some time.

This option should be used at the top of Makefiles (or Makefile.inc where
this is used for subdirectories) but after any setting of LIB.

This is only useful for userland code, and cannot be used in libc or in
any code which includes the libc internals, because it overrides certain
libc functions with macros. Some effort has been made to make USE_FORT=yes
work correctly for a full-system build by having the bsd.sys.mk logic
disable the feature where it should not be used (libc, libssp iteself,
the kernel) but no attempt has been made to build the entire system with
USE_FORT and doing so will doubtless expose numerous bugs and misfeatures.

Adjust the system build so that all programs and libraries that are setuid,
directly handle network data (including serial comm data), perform
authentication, or appear likely to have (or have a history of having)
data-driven bugs (e.g. file(1)) are built with USE_FORT=yes by default,
with the exception of libc, which cannot use USE_FORT and thus uses
only USE_SSP by default. Tested on i386 with no ill results; USE_FORT=no
per-directory or in a system build will disable if desired.
 1.15 06-Jun-1999  thorpej Use pidfile(3).
 1.14 25-Oct-1997  lukem use CPPFLAGS instead of CFLAGS
 1.13 18-Oct-1997  lukem branches: 1.13.2;
enable WARNS=1 by default, but disable in unclean 3rd party code
 1.12 06-Oct-1997  lukem use WARNS?=1 not WARNS=1 , cleanup manpage typo
 1.11 18-Jul-1997  thorpej Teensy change to use WARNS.
 1.10 07-Jul-1997  lukem * use _yp_invalid_domain() (from libc) to validate the domainnames
* cleanup for -Wall
* use __RCSID

the following were inspired by openbsd:
* only allow connections from reserved ports
* implement -insecure, which turns off the above restriction (required
for sunos 3.x and ultrix)
* prevent more than 100 domains from being bound at once, preventing
a denial of service attacks
 1.9 09-Jul-1996  thorpej -DDEAMON is no longer used, so remove it from CFLAGS.
 1.8 13-May-1996  thorpej RCS id police.
 1.7 22-Dec-1994  cgd specify man pages the new way.
 1.6 28-Oct-1994  deraadt man page from Jason Thorpe
 1.5 02-Jul-1994  deraadt from wolfgang, various further cleanup, and
mpliment the "clients are asking via RPC, therefore that might mean
the server is possibly dead" heuristic I bailed on earlier.
 1.4 18-Feb-1994  cgd kill bindirs
 1.3 30-Jul-1993  mycroft Add RCS identifiers.
 1.2 28-May-1993  cgd use BINDIR, rather than DESTDIR to specify binary's location.
the former is correct, the latter is not. actually, this makefile
probably should be hacked a bit more, but i'm not up to it now
 1.1 26-Apr-1993  deraadt initial rev
 1.13.2.1 08-Nov-1997  lukem sync with trunk (approved by thorpej)
 1.17.20.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.46.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2 30-Jul-1997  jtc branches: 1.2.44;
Fix files using old TNF copyright notice
 1.1 01-Oct-1996  thorpej Add Luke Mewburn's support for a .ypservers file, which contains a list
of YP servers a client should bind to, mostly verbatim, but slightly
modified for better semantics when nagging servers if a ypset has been
issued. Default to broadcast mode if no .ypservers file is present.

Documentation changes to match, slightly tweaked by Scott Reynolds and
myself.

Closes PR #1759.
 1.2.44.1 18-May-2008  yamt sync with head.
 1.22 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.21 20-Sep-2014  wiz Add missing .El. From Henning Petersen in PR 49227.
 1.20 15-Jun-2014  wiz Use more markup.
 1.19 15-Jun-2014  dholland Document exponential backoff behavior and SIGHUP support, plus a couple
other minor edits.
 1.18 30-Apr-2008  martin branches: 1.18.6; 1.18.22; 1.18.26; 1.18.38;
Convert TNF licenses to new 2 clause variant
 1.17 03-Dec-2005  wiz branches: 1.17.18;
Improve diagnostics section. Inspired by PR 32217 from Jeff Ito.
 1.16 26-Feb-2005  wiz Sort SEE ALSO (first section, then name); new sentence, new line; bump date for previous.
 1.15 26-Feb-2005  thorpej YP -> NIS
 1.14 08-Feb-2002  ross Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.13 02-Feb-2002  wiz Improve markup in once place, sort SEE ALSO, use standard headers.
 1.12 19-Jan-2002  wiz Whitespace nits.
 1.11 21-Aug-1998  bouyer note that messages are send to syslog daemon using facility LOG_DAEMON.
 1.10 23-Jan-1998  lukem * -insecure is for binding to insecure *servers*, not insecure *clients*.
noted by Bill Studenmund <skippy@macro.stanford.edu>.
* use .Tn YP instead of YP
 1.9 06-Oct-1997  lukem branches: 1.9.2;
clarify that "domainname" in various pathnames is the actual domain name
 1.8 06-Oct-1997  lukem use WARNS?=1 not WARNS=1 , cleanup manpage typo
 1.7 30-Jul-1997  jtc Fix files using old TNF copyright notice
 1.6 07-Jul-1997  lukem * use _yp_invalid_domain() (from libc) to validate the domainnames
* cleanup for -Wall
* use __RCSID

the following were inspired by openbsd:
* only allow connections from reserved ports
* implement -insecure, which turns off the above restriction (required
for sunos 3.x and ultrix)
* prevent more than 100 domains from being bound at once, preventing
a denial of service attacks
 1.5 02-Oct-1996  thorpej Change name of ypservers file to /var/yp/binding/domain.ypservers.
This is a compromise between the Solaris 2.5 naming of this file
(/var/yp/binding/domain/ypservers and /var/yp/binding/domain/vers)
and traditional NetBSD naming (/var/yp/binding/domain.vers).
Changing to the Solaris naming makes the C library incompatible
with ypbind. While it's easy to change the C library, I don't feel
right about introducing a gratuitous incompatibility.

The current name (/var/yp/domain/ypservers) conflicts with the name
of the YP map listing slave servers for a domain.

Per discussion w/ Chris Demetriou and Luke Mewburn.
 1.4 01-Oct-1996  thorpej .ypservers -> ypservers, to match Solaris 2.5
 1.3 01-Oct-1996  thorpej Add Luke Mewburn's support for a .ypservers file, which contains a list
of YP servers a client should bind to, mostly verbatim, but slightly
modified for better semantics when nagging servers if a ypset has been
issued. Default to broadcast mode if no .ypservers file is present.

Documentation changes to match, slightly tweaked by Scott Reynolds and
myself.

Closes PR #1759.
 1.2 28-Feb-1996  thorpej Copyright assigned to The NetBSD Foundation.
 1.1 28-Oct-1994  deraadt man page from Jason Thorpe
 1.9.2.1 29-Jan-1998  mellon Pull up 1.10 (lukem)
 1.17.18.1 18-May-2008  yamt sync with head.
 1.18.38.1 10-Aug-2014  tls Rebase.
 1.18.26.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.22.1 09-Sep-2014  msaitoh Pull up following revision(s) (requested by dholland in ticket #1083):
usr.sbin/ypbind/ypbind.c: revision 1.91
usr.sbin/ypbind/ypbind.c: revision 1.92
usr.sbin/ypbind/ypbind.c: revision 1.93
usr.sbin/ypbind/ypbind.c: revision 1.94
usr.sbin/ypbind/ypbind.c: revision 1.95
usr.sbin/ypbind/ypbind.c: revision 1.96
usr.sbin/ypbind/ypbind.c: revision 1.97
usr.sbin/ypbind/ypbind.c: revision 1.98
usr.sbin/ypbind/ypbind.8: revision 1.20
usr.sbin/ypbind/ypbind.8: revision 1.19
Don't store the default domain name in a global. While running we
really don't care which domain is the system's default domain.
Factor out some rpc validation code.
While there are times it's appropriate to call a state variable
"evil", this isn't one of them. Since the logic involved is to wait
until the default domain binds before backgrounding, call the variable
"started" instead.
Don't rake up the default domain until after processing arguments.
Processing arguments just sets flags -- may as well do it first, and
this way detection of silly errors isn't contingent on having things
fully configured and operating.
Load up with comments.
Instead of using magic numbers in what looks like a boolean
(dom_alive), create a state enumeration (domainstates) and use it
instead.
Instead of three states (new, alive, and, effectively, 'troubled') go
to five: new, alive, pinging, lost, and dead.
Domains start in the NEW state. When we get a reply from a server, the
state goes to ALIVE. The state is set to PINGING when we ping the
server (once a minute normally) and if the ping times out, it goes to
LOST. If we stay lost for a minute, go to DEAD, and in DEAD, do
exponential backoff of nag_servers calls.
Getting rid of the broken logic attached to the 'troubled' state fixes
PR 15355 (ypbind defeats disk idle spindown) -- it will now only
rewrite the binding file when the binding changes.
Also, fix the HEURISTIC code so it doesn't trigger except in ALIVE
state. I think this was the source of a lot of the spamming behavior
seen in PR 32519, which is now fixed.
Might also fix PR 23135 (broadcast ypbind sometimes fails to find
servers).
Add a SIGHUP handler; upon SIGHUP do an extra nag_servers on any
domain that's in DEAD state. This lets you explicitly rescue ypbind
from its exponential backoff when you know the world's back up.
Log state transitions.
Don't store the default domain name in a global. While running we
really don't care which domain is the system's default domain.
Factor out some rpc validation code.
While there are times it's appropriate to call a state variable
"evil", this isn't one of them. Since the logic involved is to wait
until the default domain binds before backgrounding, call the variable
"started" instead.
Don't rake up the default domain until after processing arguments.
Processing arguments just sets flags -- may as well do it first, and
this way detection of silly errors isn't contingent on having things
fully configured and operating.
Load up with comments.
Instead of using magic numbers in what looks like a boolean
(dom_alive), create a state enumeration (domainstates) and use it
instead.
Instead of three states (new, alive, and, effectively, 'troubled') go
to five: new, alive, pinging, lost, and dead.
Domains start in the NEW state. When we get a reply from a server, the
state goes to ALIVE. The state is set to PINGING when we ping the
server (once a minute normally) and if the ping times out, it goes to
LOST. If we stay lost for a minute, go to DEAD, and in DEAD, do
exponential backoff of nag_servers calls.
Getting rid of the broken logic attached to the 'troubled' state fixes
PR 15355 (ypbind defeats disk idle spindown) -- it will now only
rewrite the binding file when the binding changes.
Also, fix the HEURISTIC code so it doesn't trigger except in ALIVE
state. I think this was the source of a lot of the spamming behavior
seen in PR 32519, which is now fixed.
Might also fix PR 23135 (broadcast ypbind sometimes fails to find
servers).
Add a SIGHUP handler; upon SIGHUP do an extra nag_servers on any
domain that's in DEAD state. This lets you explicitly rescue ypbind
from its exponential backoff when you know the world's back up.
Log state transitions.
Document exponential backoff behavior and SIGHUP support, plus a couple
other minor edits.
Use more markup.
 1.18.6.1 03-Nov-2014  msaitoh Pull up following revision(s) (requested by dholland in ticket #1925):
usr.sbin/ypbind/ypbind.8 1.19-1.20
usr.sbin/ypbind/ypbind.c 1.63-1.98

State handling fixes and cleanups in ypbind; it no longer churns the
disk, spams syslogd when the server goes down, or gets confused about
its binding state. Fixes PR#15355, PR#32519 and also PR#43900.
 1.101 11-Apr-2022  andvar s/serivce/service/ in comments.
 1.100 15-Mar-2018  ginsbach Initialize ypbind_resp before first possible error return condition.
 1.99 09-Aug-2017  ginsbach branches: 1.99.2;
Make use of the defined YP errors when ypbind encounters one rather than
just returning an empty (successful) RPC result.

Don't exit when allocating memory for a new bound domain received via a RPC.
 1.98 10-Jun-2014  dholland Log state transitions.
 1.97 10-Jun-2014  dholland Add a SIGHUP handler; upon SIGHUP do an extra nag_servers on any
domain that's in DEAD state. This lets you explicitly rescue ypbind
from its exponential backoff when you know the world's back up.
 1.96 10-Jun-2014  dholland Instead of using magic numbers in what looks like a boolean
(dom_alive), create a state enumeration (domainstates) and use it
instead.

Instead of three states (new, alive, and, effectively, 'troubled') go
to five: new, alive, pinging, lost, and dead.

Domains start in the NEW state. When we get a reply from a server, the
state goes to ALIVE. The state is set to PINGING when we ping the
server (once a minute normally) and if the ping times out, it goes to
LOST. If we stay lost for a minute, go to DEAD, and in DEAD, do
exponential backoff of nag_servers calls.

Getting rid of the broken logic attached to the 'troubled' state fixes
PR 15355 (ypbind defeats disk idle spindown) -- it will now only
rewrite the binding file when the binding changes.

Also, fix the HEURISTIC code so it doesn't trigger except in ALIVE
state. I think this was the source of a lot of the spamming behavior
seen in PR 32519, which is now fixed.

Might also fix PR 23135 (broadcast ypbind sometimes fails to find
servers).
 1.95 10-Jun-2014  dholland Load up with comments.
 1.94 10-Jun-2014  dholland Don't rake up the default domain until after processing arguments.
Processing arguments just sets flags -- may as well do it first, and
this way detection of silly errors isn't contingent on having things
fully configured and operating.
 1.93 10-Jun-2014  dholland While there are times it's appropriate to call a state variable
"evil", this isn't one of them. Since the logic involved is to wait
until the default domain binds before backgrounding, call the variable
"started" instead.
 1.92 10-Jun-2014  dholland Factor out some rpc validation code.
 1.91 10-Jun-2014  dholland Don't store the default domain name in a global. While running we
really don't care which domain is the system's default domain.
 1.90 30-Aug-2011  plunky branches: 1.90.4; 1.90.8; 1.90.18;
Apply casts to cases where xdrproc_t is expected but is not
strictly passed, for example because the second argument is
a different kind of pointer.
 1.89 29-Aug-2011  joerg Use __dead.
 1.88 25-May-2011  dholland Don't print uninitialized values off the stack, even as debug messages.
 1.87 25-May-2011  dholland When checking if /var/yp/binding/foo.ypservers exists, use the domain
name of the domain being checked instead of the default domain name. Duh.
Necessary for PR 43900.
 1.86 24-May-2011  dholland Remove two entirely unused members of struct domain (previously struct
_dom_binding). I guess these were there because it was cutpasted at
some point from struct dom_binding in <rpcsvc/yp_prot.h>.
 1.85 24-May-2011  dholland Merge a couple more minor improvements from Wolfgang Stukenbrock's
patch in PR 43900.
 1.84 24-May-2011  dholland The FILE* kept open for /var/yp/binding/foo.ypservers needs to be
per-domain. Also, use the file for the domain we're servicing instead
of always the file for the default domain.

Partly from Wolfgang Stukenbrock's patch in PR 43900.
 1.83 24-May-2011  dholland The been_ypset flag really needs to be per-domain also. Do that.

Partly from Wolfgang Stukenbrock's patch in PR 43900.
 1.82 24-May-2011  dholland The ypbindmode really needs to be per-domain, so adjust accordingly.

Partly from Wolfgang Stukenbrock's patch in PR 43900.
 1.81 24-May-2011  dholland Allowing ypset is a global permission flag, not an operating mode like
broadcast vs. configured/direct. Don't conflate the logic. As I proposed
in PR 43900.
 1.80 24-May-2011  dholland Fix initialization of struct domain; initialize all fields in all
cases, merge duplicate code, make sure every domain gets an xid
assigned.

Partly from Wolfgang Stukenbrock's patch in PR 43900.
 1.79 24-May-2011  dholland The name field of a domain should be dom->dom_name, not dom->dom_domain.
(This and the previous patch make the code far more readable.)
 1.78 24-May-2011  dholland The default name for a "domain" variable should be "dom", not "ypdb".
Change them all, and make a couple other related adjustments.
 1.77 24-May-2011  dholland ypbindlist -> domains
 1.76 24-May-2011  dholland xid2ypdb() -> domain_find()
 1.75 24-May-2011  dholland Rename struct _dom_binding -> struct domain.
 1.74 24-May-2011  dholland Move a bunch of messy sunrpc-related initialization stuff into its own
function instead of blatting it all into main().
 1.73 24-May-2011  dholland Assimilate the open/flock combination used several times into its own
function.
 1.72 24-May-2011  dholland Fix up calls to yp_log. They cannot use %m, because if the -d option
is used the messages are sent via printf instead of syslog(3).

Also, make sure that none of the calls include a trailing newline and
issue a trailing newline in the -d case so they actually print properly.
(This was noted by Wolfgang Stukenbrock in PR 43900.)

And finally, fix some cases that could in some circumstances print
uninitialized errnos.
 1.71 24-May-2011  dholland Abstract out some of the handling of the ypservers file.
 1.70 24-May-2011  dholland Check that the domain name is valid up front, instead of doing it
after opening sockets and registering services and whatnot.
 1.69 24-May-2011  dholland Remove now-unnecessary extra forward decls; sprinkle a little more static.
 1.68 24-May-2011  dholland Sort contents of file.
 1.67 23-May-2011  dholland sort includes
 1.66 23-May-2011  dholland Don't use _t as an identifier suffix meaning "variable containing a time".
 1.65 23-May-2011  dholland Introduce DPRINTF() macro, remove most #ifdef DEBUG usages.
No change to compiler output.
 1.64 23-May-2011  dholland u_int32_t -> uint32_t and similar
 1.63 30-Mar-2011  dholland Don't cast return value of malloc
 1.62 30-Mar-2011  dholland use __printflike()
 1.61 06-Nov-2009  skrll Whitespace.
 1.60 06-Nov-2009  christos make this compile.
 1.59 05-Nov-2009  chuck in the case where ypbind is serving more than one domain (i.e.
not just the yp_get_default_domain() domain), we must remove
any old binding files from /var/yp/binding (BINDINGDIR) from
previous runs, or the non-yp_get_default_domain()'s will not
bind properly. add a purge_bindingdir() function that basically
does "rm BINDINGDIR/*.[0-9]" at ypbind startup time.

example case of where this is an issue: bind a second (non-default)
domain. ypbind will create and flock a /var/yp/binding/xxx.2
file for it. stop and restart ypbind. the old /var/yp/binding/xxx.2
file will remain from the previous run. since it is not flock()'d
by the new instance of ypbind, libc functions like yp_master() will
fail without even bothering to talk to ypbind itself. (and ypbind
is totally unaware of the old file...)
 1.58 18-Jan-2009  lukem fix -Wsign-compare issues
 1.57 07-Jul-2007  christos branches: 1.57.18;
- Compile in with debugging by default.
- General cleanup.
 1.56 05-Oct-2006  tron Ensure alignment of the structure used for RPC requests. This stop
"ypbind" from segfaulting under NetBSD-sparc64 when "ypwhich" is
used to display the current NIS server.
 1.55 01-Oct-2006  elad Fix misleading error message (from PR/32519).
 1.54 09-May-2006  mrg change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.
 1.53 30-Oct-2004  dsl Add (unsigned char) cast to ctype functions
 1.52 07-Sep-2004  jrf Replaced strncpy with strlcpy. Thanks to Peter Postma who
pointed them our in PR #25762. Approved by christos@NetBSD.org.
 1.51 05-Jan-2004  jmmv Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
 1.50 10-Dec-2003  agc Modify the licences of code written by Theo De Raadt from a 4-clause
to a 2-clause licence (retaining UCB clauses (1) and (2)), per PR
22409 from Joel Baker, approved by Theo de Raadt, and ratified by
myself - the only discrepancy being the handling of the original
clause 3 in src/usr.sbin/yppoll/yppoll.c.
 1.49 17-Nov-2003  bouyer Apply patch proposted to tech-userlevel on Sun, 12 Oct 2003:
Remove dom_server_port from struct _dom_binding. It's never initialised
and used in only one place, where dom_server_addr.sin_port was probably
intended.
 1.48 05-Sep-2003  bouyer width needs to be updated before each loop, because svc_maxfd may have
changed.
 1.47 06-Jul-2002  wiz ANSIfy, remove __P(), unifdef __STDC__.
 1.46 19-Feb-2001  cgd branches: 1.46.2;
convert to use getprogname()
 1.45 11-Jan-2001  lukem use LOG_WARNING for warnings and LOG_ERR for fatal errors
 1.44 20-Dec-2000  cgd __CONCAT does token pasting, not string concatnation. if something like:
__CONCAT("foo","bar");
actually works to concantate strings, it's because the preprocessor expands
it into "foo""bar" 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 misuse
of token pasting.
 1.43 11-Oct-2000  is More format string cleanups by sommerfeld.
 1.42 11-Apr-2000  itojun branches: 1.42.4;
use getifaddrs, to avoid complicated alignment constraint in SIOCGIFCONF.
(do we need to keep SIOCGIFCONF code in #ifdef?)
 1.41 20-Feb-2000  itojun avoid 64bit alignment issue with SIOCGIFCONF (packed struct access).
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>
 1.40 16-Aug-1999  simonb Spell "privilege" correctly (correct spelling from Jonathan Stone).
 1.39 06-Jun-1999  thorpej Use pidfile(3).
 1.38 12-Feb-1999  kleink branches: 1.38.2;
<sys/fcntl.h> -> <fcntl.h>
 1.37 21-Aug-1998  bouyer - Makes ypbind use syslog() (with LOG_DAEMON) instead of warn()/err().
Messages will still be printed to stderr if ypbind is started in debug mode.
- Don't exist if none of the servers listed in
/var/yp/binding/<domainname>.ypservers are reacheable. It's a temporary
failure that can be recovered from.
 1.36 13-Jul-1998  mrg minor KNF nits.
 1.35 12-Feb-1998  lukem revert; we can't break the existing ABI and API
 1.34 10-Feb-1998  lukem use u_int32_t instead of u_long
 1.33 18-Jul-1997  thorpej branches: 1.33.2;
Fix typo in previous.
 1.32 18-Jul-1997  thorpej Cast pointers to u_long before casting to another integral type.
 1.31 18-Jul-1997  thorpej Teensy change to use WARNS.
 1.30 07-Jul-1997  lukem * use _yp_invalid_domain() (from libc) to validate the domainnames
* cleanup for -Wall
* use __RCSID

the following were inspired by openbsd:
* only allow connections from reserved ports
* implement -insecure, which turns off the above restriction (required
for sunos 3.x and ultrix)
* prevent more than 100 domains from being bound at once, preventing
a denial of service attacks
 1.29 02-Oct-1996  thorpej Change name of ypservers file to /var/yp/binding/domain.ypservers.
This is a compromise between the Solaris 2.5 naming of this file
(/var/yp/binding/domain/ypservers and /var/yp/binding/domain/vers)
and traditional NetBSD naming (/var/yp/binding/domain.vers).
Changing to the Solaris naming makes the C library incompatible
with ypbind. While it's easy to change the C library, I don't feel
right about introducing a gratuitous incompatibility.

The current name (/var/yp/domain/ypservers) conflicts with the name
of the YP map listing slave servers for a domain.

Per discussion w/ Chris Demetriou and Luke Mewburn.
 1.28 01-Oct-1996  thorpej .ypservers -> ypservers, to match Solaris 2.5
 1.27 01-Oct-1996  thorpej Add Luke Mewburn's support for a .ypservers file, which contains a list
of YP servers a client should bind to, mostly verbatim, but slightly
modified for better semantics when nagging servers if a ypset has been
issued. Default to broadcast mode if no .ypservers file is present.

Documentation changes to match, slightly tweaked by Scott Reynolds and
myself.

Closes PR #1759.
 1.26 25-Jul-1996  ws xdr_bool wants a bool_t (which happens to be an int32_t on our port)
and not a char
 1.25 09-Jul-1996  thorpej Fix a misplaced #endif - if DEBUG wasn't defined, ypbind would never
detach from the controlling tty.
 1.24 22-Jun-1996  christos Code cleanups.
- check malloc returns
- null terminate strncpy() strings
- use snprintf instead of sprintf
- pass the right arguments to the right functions
- check usage
- use err(3) and warn(3) instead of printfs.
 1.23 03-Jun-1996  thorpej Fix typo that can cause ypbind to assume an error when one doesn't
actually exist if the server takes a dive.
 1.22 03-Jun-1996  thorpej Fix buglet in ypbindproc_domain_2() which caused:

ypbind; sleep 10; ypwhich

to fail (where failure is defined as ypwhich hangs until it gives up,
complaining about not being able to communicate with ypbind). Failure
mode pointed out by Chris G. Demetriou <cgd@cs.cmu.edu>.
 1.21 29-May-1996  thorpej Pull down yp/xdr fixes from release branch.
 1.20 30-Mar-1996  cgd branches: 1.20.4;
apply patch from PR 2085: don't treat XIDs and domain mapping pointers
interchangeably, because this is fragile and doesn't work at all on
the alpha. (get rid of the old hack used on the alpha, and fix RCS
Ids, too.)
 1.19 21-Apr-1995  cgd really nasty hack for the alpha. bigtime XXX
 1.18 15-Jan-1995  mycroft Daemonify only after the bind has been completed, and use daemon().
 1.17 15-Jan-1995  mycroft Closer to KNF, ANSI, and POSIX.
 1.16 06-Jan-1995  pk Recompute `width' before each select(), as the value of `svc_maxfd' can
be changed by the rpc library.
 1.15 30-Dec-1994  mycroft Avoid getdtablesize(3). Also, remove some useless FD_CLR()s.
 1.14 23-Dec-1994  cgd be a bit more careful with types, and prototype scope.
 1.13 28-Sep-1994  deraadt create ypbind.lock file
fix ypset code
 1.12 20-Sep-1994  deraadt force first binding poll automatically -- someone will need it very soon!
 1.11 16-Jul-1994  ws Keep a server even if we lost contact when noone else is available
 1.10 14-Jul-1994  deraadt changes from <ws@tools.de> to do selective pinging of servers.
 1.9 02-Jul-1994  deraadt branches: 1.9.2;
from wolfgang, various further cleanup, and
mpliment the "clients are asking via RPC, therefore that might mean
the server is possibly dead" heuristic I bailed on earlier.
 1.8 01-Jul-1994  deraadt improved rebinding from ws@tools.de
 1.7 25-May-1994  deraadt correct copyright
 1.6 03-Dec-1993  deraadt sunos compatible /var/yp/binding/ files.
 1.5 15-Nov-1993  cgd fix typo in last
 1.4 15-Nov-1993  deraadt ypset should only be permitted from a reserved port.
from Tor Egge <tegge@pvv.unit.no>
 1.3 05-Sep-1993  deraadt #endif in the wrong place
 1.2 16-May-1993  deraadt added my copyright.. how self efacing of me
 1.1 26-Apr-1993  deraadt initial rev
 1.9.2.2 16-Jul-1994  cgd update from trunk
 1.9.2.1 15-Jul-1994  cgd from trunk.
 1.20.4.4 30-Jul-1996  jtc Change type of rmtcr_outval from char to bool_t; pulled up by request from Wolfgang
 1.20.4.3 03-Jun-1996  thorpej Pull up typo fix from trunk.
 1.20.4.2 03-Jun-1996  thorpej Pull up ypbindproc_domain_2 fix from the trunk.
 1.20.4.1 26-May-1996  jtc yp/xdr fixes from Jason Thorpe
 1.33.2.1 03-Nov-1998  cgd pull up rev 1.37 from trunk (via patch). (bouyer)
 1.38.2.1 19-Oct-2000  he Pull up revision 1.43 (requested by he):
Format string cleanup.
 1.42.4.2 09-Sep-2003  msaitoh Pull up rev. 1.48 (requested by bouyer in ticket #77):
width needs to be updated before each loop, because svc_maxfd may have
changed.
 1.42.4.1 17-Oct-2000  tv Pullup usr.sbin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.46.2.1 05-Sep-2003  tron Pull up revision 1.48 (requested by bouyer in ticket #1449):
width needs to be updated before each loop, because svc_maxfd may have
changed.
 1.57.18.3 05-Nov-2014  msaitoh Fix compile error (s/__printf/__printf__/).
 1.57.18.2 03-Nov-2014  msaitoh Pull up following revision(s) (requested by dholland in ticket #1925):
usr.sbin/ypbind/ypbind.8 1.19-1.20
usr.sbin/ypbind/ypbind.c 1.63-1.98

State handling fixes and cleanups in ypbind; it no longer churns the
disk, spams syslogd when the server goes down, or gets confused about
its binding state. Fixes PR#15355, PR#32519 and also PR#43900.
 1.57.18.1 16-Feb-2011  bouyer Pull up following revision(s) (requested by chuck in ticket #1549):
usr.sbin/ypbind/ypbind.c: revision 1.58 - 1.61
in the case where ypbind is serving more than one domain (i.e.
not just the yp_get_default_domain() domain), we must remove
any old binding files from /var/yp/binding (BINDINGDIR) from
previous runs, or the non-yp_get_default_domain()'s will not
bind properly. add a purge_bindingdir() function that basically
does "rm BINDINGDIR/*.[0-9]" at ypbind startup time.
example case of where this is an issue: bind a second (non-default)
domain. ypbind will create and flock a /var/yp/binding/xxx.2
file for it. stop and restart ypbind. the old /var/yp/binding/xxx.2
file will remain from the previous run. since it is not flock()'d
by the new instance of ypbind, libc functions like yp_master() will
fail without even bothering to talk to ypbind itself. (and ypbind
is totally unaware of the old file...)
 1.90.18.1 10-Aug-2014  tls Rebase.
 1.90.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.90.4.1 09-Sep-2014  msaitoh Pull up following revision(s) (requested by dholland in ticket #1083):
usr.sbin/ypbind/ypbind.c: revision 1.91
usr.sbin/ypbind/ypbind.c: revision 1.92
usr.sbin/ypbind/ypbind.c: revision 1.93
usr.sbin/ypbind/ypbind.c: revision 1.94
usr.sbin/ypbind/ypbind.c: revision 1.95
usr.sbin/ypbind/ypbind.c: revision 1.96
usr.sbin/ypbind/ypbind.c: revision 1.97
usr.sbin/ypbind/ypbind.c: revision 1.98
usr.sbin/ypbind/ypbind.8: revision 1.20
usr.sbin/ypbind/ypbind.8: revision 1.19
Don't store the default domain name in a global. While running we
really don't care which domain is the system's default domain.
Factor out some rpc validation code.
While there are times it's appropriate to call a state variable
"evil", this isn't one of them. Since the logic involved is to wait
until the default domain binds before backgrounding, call the variable
"started" instead.
Don't rake up the default domain until after processing arguments.
Processing arguments just sets flags -- may as well do it first, and
this way detection of silly errors isn't contingent on having things
fully configured and operating.
Load up with comments.
Instead of using magic numbers in what looks like a boolean
(dom_alive), create a state enumeration (domainstates) and use it
instead.
Instead of three states (new, alive, and, effectively, 'troubled') go
to five: new, alive, pinging, lost, and dead.
Domains start in the NEW state. When we get a reply from a server, the
state goes to ALIVE. The state is set to PINGING when we ping the
server (once a minute normally) and if the ping times out, it goes to
LOST. If we stay lost for a minute, go to DEAD, and in DEAD, do
exponential backoff of nag_servers calls.
Getting rid of the broken logic attached to the 'troubled' state fixes
PR 15355 (ypbind defeats disk idle spindown) -- it will now only
rewrite the binding file when the binding changes.
Also, fix the HEURISTIC code so it doesn't trigger except in ALIVE
state. I think this was the source of a lot of the spamming behavior
seen in PR 32519, which is now fixed.
Might also fix PR 23135 (broadcast ypbind sometimes fails to find
servers).
Add a SIGHUP handler; upon SIGHUP do an extra nag_servers on any
domain that's in DEAD state. This lets you explicitly rescue ypbind
from its exponential backoff when you know the world's back up.
Log state transitions.
Don't store the default domain name in a global. While running we
really don't care which domain is the system's default domain.
Factor out some rpc validation code.
While there are times it's appropriate to call a state variable
"evil", this isn't one of them. Since the logic involved is to wait
until the default domain binds before backgrounding, call the variable
"started" instead.
Don't rake up the default domain until after processing arguments.
Processing arguments just sets flags -- may as well do it first, and
this way detection of silly errors isn't contingent on having things
fully configured and operating.
Load up with comments.
Instead of using magic numbers in what looks like a boolean
(dom_alive), create a state enumeration (domainstates) and use it
instead.
Instead of three states (new, alive, and, effectively, 'troubled') go
to five: new, alive, pinging, lost, and dead.
Domains start in the NEW state. When we get a reply from a server, the
state goes to ALIVE. The state is set to PINGING when we ping the
server (once a minute normally) and if the ping times out, it goes to
LOST. If we stay lost for a minute, go to DEAD, and in DEAD, do
exponential backoff of nag_servers calls.
Getting rid of the broken logic attached to the 'troubled' state fixes
PR 15355 (ypbind defeats disk idle spindown) -- it will now only
rewrite the binding file when the binding changes.
Also, fix the HEURISTIC code so it doesn't trigger except in ALIVE
state. I think this was the source of a lot of the spamming behavior
seen in PR 32519, which is now fixed.
Might also fix PR 23135 (broadcast ypbind sometimes fails to find
servers).
Add a SIGHUP handler; upon SIGHUP do an extra nag_servers on any
domain that's in DEAD state. This lets you explicitly rescue ypbind
from its exponential backoff when you know the world's back up.
Log state transitions.
Document exponential backoff behavior and SIGHUP support, plus a couple
other minor edits.
Use more markup.
 1.99.2.1 15-Mar-2018  pgoyette Synch with HEAD

RSS XML Feed