Commit Graph

98 Commits

Author SHA1 Message Date
dholland d7edebe630 Log state transitions. 2014-06-10 17:19:48 +00:00
dholland 106e29fe05 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.
2014-06-10 17:19:36 +00:00
dholland f69eb308e3 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).
2014-06-10 17:19:22 +00:00
dholland ff58b21755 Load up with comments. 2014-06-10 17:19:12 +00:00
dholland aed51c4afc 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.
2014-06-10 17:19:00 +00:00
dholland af0d2ab5da 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.
2014-06-10 17:18:45 +00:00
dholland acc6243e9f Factor out some rpc validation code. 2014-06-10 17:18:18 +00:00
dholland 4363781772 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.
2014-06-10 17:18:02 +00:00
plunky 87d4f6076b 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.
2011-08-30 17:06:20 +00:00
joerg dccf569e0e Use __dead. 2011-08-29 20:38:53 +00:00
dholland 0c53a1f2e4 Don't print uninitialized values off the stack, even as debug messages. 2011-05-25 04:59:22 +00:00
dholland ef192e52d5 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.
2011-05-25 04:33:52 +00:00
dholland 8066ee6b9b 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>.
2011-05-24 07:02:08 +00:00
dholland cfb05cb343 Merge a couple more minor improvements from Wolfgang Stukenbrock's
patch in PR 43900.
2011-05-24 07:01:53 +00:00
dholland 9d84fe187a 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.
2011-05-24 07:01:40 +00:00
dholland 6f997d891d The been_ypset flag really needs to be per-domain also. Do that.
Partly from Wolfgang Stukenbrock's patch in PR 43900.
2011-05-24 07:01:24 +00:00
dholland bb36c8993e The ypbindmode really needs to be per-domain, so adjust accordingly.
Partly from Wolfgang Stukenbrock's patch in PR 43900.
2011-05-24 07:01:15 +00:00
dholland 0d20b396fd 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.
2011-05-24 07:00:34 +00:00
dholland e61f3e4872 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.
2011-05-24 07:00:07 +00:00
dholland fec4c9631a 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.)
2011-05-24 06:59:53 +00:00
dholland 771940852d The default name for a "domain" variable should be "dom", not "ypdb".
Change them all, and make a couple other related adjustments.
2011-05-24 06:59:35 +00:00
dholland 006489acb9 ypbindlist -> domains 2011-05-24 06:59:07 +00:00
dholland c9b3b0763b xid2ypdb() -> domain_find() 2011-05-24 06:58:54 +00:00
dholland df3a50ea87 Rename struct _dom_binding -> struct domain. 2011-05-24 06:58:42 +00:00
dholland 1cb987c954 Move a bunch of messy sunrpc-related initialization stuff into its own
function instead of blatting it all into main().
2011-05-24 06:58:19 +00:00
dholland fe8f2f2d61 Assimilate the open/flock combination used several times into its own
function.
2011-05-24 06:58:07 +00:00
dholland 2b880b64f4 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.
2011-05-24 06:57:55 +00:00
dholland 15569646a4 Abstract out some of the handling of the ypservers file. 2011-05-24 06:57:30 +00:00
dholland dfd8a41891 Check that the domain name is valid up front, instead of doing it
after opening sockets and registering services and whatnot.
2011-05-24 06:57:04 +00:00
dholland cb269e446a Remove now-unnecessary extra forward decls; sprinkle a little more static. 2011-05-24 06:56:48 +00:00
dholland 20f9d4037f Sort contents of file. 2011-05-24 06:56:16 +00:00
dholland 58a3e249b1 sort includes 2011-05-23 02:54:53 +00:00
dholland d2f44d281f Don't use _t as an identifier suffix meaning "variable containing a time". 2011-05-23 02:43:10 +00:00
dholland 86a03218b2 Introduce DPRINTF() macro, remove most #ifdef DEBUG usages.
No change to compiler output.
2011-05-23 02:36:35 +00:00
dholland 41741c3c2a u_int32_t -> uint32_t and similar 2011-05-23 02:06:41 +00:00
dholland 81f95bf6fa Don't cast return value of malloc 2011-03-30 05:24:05 +00:00
dholland b639c25325 use __printflike() 2011-03-30 05:20:59 +00:00
skrll 96092d9e00 Whitespace. 2009-11-06 15:41:58 +00:00
christos 225e9fc5c1 make this compile. 2009-11-06 15:36:55 +00:00
chuck 1f5ddb4eb6 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...)
2009-11-05 19:34:06 +00:00
lukem b118202501 fix -Wsign-compare issues 2009-01-18 10:39:17 +00:00
christos 97dcde77bc - Compile in with debugging by default.
- General cleanup.
2007-07-07 22:33:57 +00:00
tron 886853e55b 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.
2006-10-05 09:18:11 +00:00
elad c443814068 Fix misleading error message (from PR/32519). 2006-10-01 19:43:15 +00:00
mrg 0c37c63edc change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.
2006-05-09 20:18:05 +00:00
dsl 3cca093e74 Add (unsigned char) cast to ctype functions 2004-10-30 15:51:20 +00:00
jrf 190b2e4c51 Replaced strncpy with strlcpy. Thanks to Peter Postma who
pointed them our in PR #25762. Approved by christos@NetBSD.org.
2004-09-07 13:20:39 +00:00
jmmv b635f565e7 Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
2004-01-05 23:23:32 +00:00
agc 7db1d33cba 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.
2003-12-10 12:06:25 +00:00
bouyer 6f4c1c24ee 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.
2003-11-17 21:29:21 +00:00