History log of /netbsd-current/usr.sbin/ypbind/ypbind.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.101 11-Apr-2022 andvar

s/serivce/service/ in comments.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.100 15-Mar-2018 ginsbach

Initialize ypbind_resp before first possible error return condition.


Revision tags: pgoyette-compat-base
# 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.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-7-2-RELEASE netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: cherry-xenmp-base
# 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()


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 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...)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.58 18-Jan-2009 lukem

fix -Wsign-compare issues


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.57 07-Jul-2007 christos

branches: 1.57.18;
- Compile in with debugging by default.
- General cleanup.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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).


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 1.47 06-Jul-2002 wiz

ANSIfy, remove __P(), unifdef __STDC__.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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>


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.40 16-Aug-1999 simonb

Spell "privilege" correctly (correct spelling from Jonathan Stone).


# 1.39 06-Jun-1999 thorpej

Use pidfile(3).


Revision tags: netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 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


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-base
# 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.)


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-base
# 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


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.2 16-May-1993 deraadt

added my copyright.. how self efacing of me


# 1.1 26-Apr-1993 deraadt

initial rev


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.100 15-Mar-2018 ginsbach

Initialize ypbind_resp before first possible error return condition.


Revision tags: pgoyette-compat-base
# 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.


Revision tags: netbsd-7-2-RELEASE netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: cherry-xenmp-base
# 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()


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 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...)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.58 18-Jan-2009 lukem

fix -Wsign-compare issues


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.57 07-Jul-2007 christos

branches: 1.57.18;
- Compile in with debugging by default.
- General cleanup.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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).


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 1.47 06-Jul-2002 wiz

ANSIfy, remove __P(), unifdef __STDC__.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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>


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.40 16-Aug-1999 simonb

Spell "privilege" correctly (correct spelling from Jonathan Stone).


# 1.39 06-Jun-1999 thorpej

Use pidfile(3).


Revision tags: netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 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


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-base
# 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.)


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-base
# 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


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.2 16-May-1993 deraadt

added my copyright.. how self efacing of me


# 1.1 26-Apr-1993 deraadt

initial rev


# 1.99 09-Aug-2017 ginsbach

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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: cherry-xenmp-base
# 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()


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 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...)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.58 18-Jan-2009 lukem

fix -Wsign-compare issues


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.57 07-Jul-2007 christos

branches: 1.57.18;
- Compile in with debugging by default.
- General cleanup.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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).


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 1.47 06-Jul-2002 wiz

ANSIfy, remove __P(), unifdef __STDC__.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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>


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.40 16-Aug-1999 simonb

Spell "privilege" correctly (correct spelling from Jonathan Stone).


# 1.39 06-Jun-1999 thorpej

Use pidfile(3).


Revision tags: netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 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


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-base
# 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.)


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-base
# 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


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.2 16-May-1993 deraadt

added my copyright.. how self efacing of me


# 1.1 26-Apr-1993 deraadt

initial rev