History log of /freebsd-head/usr.sbin/ypbind/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
7551d83c353e040b32c6ac205e577dbc5f2c8955 27-Nov-2017 pfg <pfg@FreeBSD.org> various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
9da7bdde061c43b87cf9bb2852984b78e292b1e6 18-Nov-2017 pfg <pfg@FreeBSD.org> spdx: initial adoption of licensing ID tags.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes: yes
Differential Revision: https://reviews.freebsd.org/D13133
a598c4b809a73772d7452991213407cdac302156 31-Oct-2017 bdrewery <bdrewery@FreeBSD.org> DIRDEPS_BUILD: Update dependencies.

Sponsored by: Dell EMC Isilon
3d6e7fda3eec4f11d2a955d14e98e3c1b1ee5e38 13-Mar-2017 pfg <pfg@FreeBSD.org> ypbind(8): let calloc(3) do the multiplying.
7e6cabd06e6caa6a02eeb86308dc0cb3f27e10da 28-Feb-2017 imp <imp@FreeBSD.org> Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96
96fdc95a9bcedf1bdb7cc90c8ef0942dd16ab1d2 12-May-2016 truckman <truckman@FreeBSD.org> Use strlcpy() instead of strncpy() when copying to dom_domain to
ensure that the latter is NUL terminated since it is passed
as an argument to *printf().

Warn about NIS domains that are too long.

Reported by: Coverity
CID: 1009620, 1009621
MFH: 1 week
cfe4909e4131418096c6330aa1d7b64fe9e0eb4f 16-Nov-2015 araujo <araujo@FreeBSD.org> Don't need cast malloc.

Approved by: rodrigc (mentor)
Differential Revision: D4117
21a3003f8f5c49c0acbcb49462e5b221076076d0 21-Oct-2015 eadler <eadler@FreeBSD.org> Fix a ton of speelling errors

arc lint is helpful

Reviewed By: allanjude, wblock, #manpages, chris@bsdjunk.com
Differential Revision: https://reviews.freebsd.org/D3337
ed4d6dbea261a4dc66b41c906a7fd91fc2332e4f 16-Jul-2015 araujo <araujo@FreeBSD.org> Fix a warning spotted by gcc4.9: dereferencing type-punned pointer will break
strict-aliasing rules.

Declare some variables as statics as well as some functions that are internal
helpers. Update the function broadcast_result() to a post-K&R definition.

Differential Revision: D2690
Reviewed by: rodrigc, dim
008d7c831feeec7a3430b92f009e28762c6740f1 13-Jun-2015 sjg <sjg@FreeBSD.org> Add META_MODE support.

Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision: D2796
Reviewed by: brooks imp
75a137820de70f75cd932fd2fa365fabaf06fa90 08-Jun-2015 sjg <sjg@FreeBSD.org> dirdeps.mk now sets DEP_RELDIR
d7cd1d425cc1ea9451fa235e3af9b6625c3e0de2 19-Aug-2014 sjg <sjg@FreeBSD.org> Merge head from 7/28
c0cd28f92874c0ee4efaddd658bbb67a64200f47 20-Jun-2014 bapt <bapt@FreeBSD.org> use .Mt to mark up email addresses consistently (part2)

PR: 191174
Submitted by: Franco Fichtner <franco@lastsummer.de>
5860f0d10657dc9748acf6637885ee7fbf6fb212 16-May-2014 sjg <sjg@FreeBSD.org> Updated dependencies
1a7e48acf1acf8cb3ef3ba6787cc57e18faa8479 10-May-2014 sjg <sjg@FreeBSD.org> Updated dependencies
5e568154a01fb6be74908baed265f265a56f002f 28-Apr-2014 sjg <sjg@FreeBSD.org> Merge head
a29cf848953a4bcf7504a3eb69f9207d164f3d54 15-Dec-2013 hrs <hrs@FreeBSD.org> Replace Sun RPC license for TI-RPC library with a 3-clause BSD license,
with the explicit permission of Sun Microsystems in 2009.
The code in question in this file was copied from lib/libc/rpc/pmap_getport.c.
6d37b86f2b6abb5c0c11a9162e37ddc0ad94f01d 11-Mar-2013 sjg <sjg@FreeBSD.org> Updated dependencies
0ee5295509f95c5780976697a2d3539b994458ca 16-Feb-2013 sjg <sjg@FreeBSD.org> Updated dependencies
9dd41e3647df728006e0749ac139cfeb773c3873 22-Aug-2012 marcel <marcel@FreeBSD.org> Sync FreeBSD's bmake branch with Juniper's internal bmake branch.

Requested by: Simon Gerraty <sjg@juniper.net>
62b9f3917a3058cf6c5cd8d3f7d70f0bf7ee2fde 24-Oct-2011 glebius <glebius@FreeBSD.org> Protect NIS client with madvise(2) since this daemon is required
for succesful authentication of users.
f3d9dd1ac925b5458c89e66763a526ca72dc601c 08-Oct-2010 markm <markm@FreeBSD.org> Don't let the "available"/"not available" logs flap quite so badly. In the
case of a multi-interfaced host, sub-second flapping can fill up the logs
too quickly. This fixes that.
76d72447281953457a8a3a319fdc80070bc5152c 28-Aug-2010 brucec <brucec@FreeBSD.org> Fix incorrect usage of 'assure' and 'insure'.

Approved by: rrs (mentor)
073cafdd42b9cd60313d46f72dcb8893ae606832 02-Jan-2010 ed <ed@FreeBSD.org> The last big commit: let usr.sbin/ use WARNS=6 by default.
e0f67daaea9a4bd084a159ca52bce34fb0119a84 15-Sep-2008 dfr <dfr@FreeBSD.org> Don't rely on private RPC data structures when there is a perfectly good
public API.
1541af42f12f8570fb332516efee8f1e030c3e46 13-Feb-2005 ru <ru@FreeBSD.org> Expand *n't contractions.
8d3bcc2e7a86e83206914057c8afab4c45f99dfb 17-Oct-2004 stefanf <stefanf@FreeBSD.org> Remove definition of struct dom_binding, it's non-standard C code and
unnecessary since src/include/rpcsvc/ypclnt.h's revision 1.10.
9fbed704d53384df13f05c4f0b546851054b6f7b 07-Aug-2004 imp <imp@FreeBSD.org> Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived software
(with permission of addtional copyright holders where appropriate)
6294018a208cf7742b1c021a9b75c26962505571 02-Jul-2004 ru <ru@FreeBSD.org> Mechanically kill hard sentence breaks.
08dab4c87f0ea45088a9d148c879c9494d529005 04-Jun-2003 ceri <ceri@FreeBSD.org> Correct a spelling error.
7293a24a2b093fcb82ba80e14cb33ff03e2e24e8 03-May-2003 obrien <obrien@FreeBSD.org> Use __FBSDID over rcsid[]. Protect copyright[] where needed.
0f0a53d15f0152d40095a01108f9cfb8027bd9b3 16-Sep-2002 fenner <fenner@FreeBSD.org> xids are u_int32_ts, which are not necessarily the same size as time_ts or
unsigned longs. This fixes "ypbind -S ... -m" on sparc64.
d2168fe021bd1693c1038503e09d3d74dd8b6f36 14-Jul-2002 charnier <charnier@FreeBSD.org> The .Nm utility
e48f76df853e520cafc8b0a6237838fa12f69ea3 28-Apr-2002 des <des@FreeBSD.org> Spell void * as void * rather than caddr_t. This is complicated by the
fact that caddr_t is often misspelled as char *.

Sponsored by: DARPA, NAI Labs
bcee06d42c20a8ea0e6c6ffb8924e16e7e793c0f 18-Feb-2002 mike <mike@FreeBSD.org> o Move NTOHL() and associated macros into <sys/param.h>. These are
deprecated in favor of the POSIX-defined lowercase variants.
o Change all occurrences of NTOHL() and associated marcros in the
source tree to use the lowercase function variants.
o Add missing license bits to sparc64's <machine/endian.h>.
Approved by: jake
o Clean up <machine/endian.h> files.
o Remove unused __uint16_swap_uint32() from i386's <machine/endian.h>.
o Remove prototypes for non-existent bswapXX() functions.
o Include <machine/endian.h> in <arpa/inet.h> to define the
POSIX-required ntohl() family of functions.
o Do similar things to expose the ntohl() family in libstand, <netinet/in.h>,
and <sys/param.h>.
o Prepend underscores to the ntohl() family to help deal with
complexities associated with having MD (asm and inline) versions, and
having to prevent exposure of these functions in other headers that
happen to make use of endian-specific defines.
o Create weak aliases to the canonical function name to help deal with
third-party software forgetting to include an appropriate header.
o Remove some now unneeded pollution from <sys/types.h>.
o Add missing <arpa/inet.h> includes in userland.

Tested on: alpha, i386
Reviewed by: bde, jake, tmm
d7b064e238d98e1c9942cfb6e53c0767893310b1 06-Feb-2002 des <des@FreeBSD.org> ANSIfy and remove some dead code.

Sponsored by: DARPA, NAI Labs
0f2cb9b020b907000a28323fc57a82fdb7d6626d 06-Feb-2002 des <des@FreeBSD.org> Apply the following mechanical transformations in preparation for
ansification and constification:

s{(\s+)(for|if|switch|while)\(}{$1$2 \(}g;
s{return ([^\(].*?);}{return ($1);}g;
s{([\w\)])([!=+/\*-]?=)([\w\(+-])}{$1 $2 $3}g;

Also add $FreeBSD$ where needed.

MFC after: 1 week
7aa3bf6364a338ebe6de26349bcae887d1e8bba1 14-Jan-2002 ru <ru@FreeBSD.org> yp(4) -> yp(8).

PR: docs/30797
9c97c8f02d579c6988b1d150fd1c0fa8dacf2e87 20-Jul-2001 obrien <obrien@FreeBSD.org> Perform a major cleanup of the usr.sbin Makefiles.
These are not perfectly in agreement with each other style-wise, but they
are orders of orders of magnitude more consistent style-wise than before.
2dcfabf4c9fecf80c5be347d0fe9ee6b8a6b045f 19-Jul-2001 dd <dd@FreeBSD.org> Increment `i' in case of -S so that its argument isn't treated as
another, unknown option.

Submitted by: Naoki Kobayashi <shibata@geo.titech.ac.jp> and
Harti Brandt <brandt@fokus.gmd.de>, respectively.
Pointy hat to: dd
911ca14c8798a89d240d36ecbc63b5df5dd99f66 15-Jul-2001 dd <dd@FreeBSD.org> Remove whitespace at EOL.
948453970e588ce0752772fa3a37b099b55001e3 13-Jul-2001 dd <dd@FreeBSD.org> Whine if we discover an unknown option. This program doesn't use
getopt(3) (and can't be converted without breaking compatibility), and
it's very irritating to have it silently DTWT if one combines options
together (e.g., "-msS domain,server").
7894e59b7f217dd493250aec7b5da6dd7f2cf1c4 24-Jun-2001 dd <dd@FreeBSD.org> Nuke unused variables.
bfe3f93628386e0736234c2a1715d774106ab673 23-Jun-2001 ben <ben@FreeBSD.org> Don't dereference a pointer after freeing that pointer.

PR: 27990
Reviewed by: dd, phk
Tested by: dd
MFC after: 2 weeks
d933c42be698232b6b8b9791d36c778623745b51 27-Mar-2001 wpaul <wpaul@FreeBSD.org> Finally fix __yp_ping(). We can't use the old locally defined clntudp_call()
method anymore since the code inside the RPC library has changed too much.
Now that the clnt_dg module has the necessary code internally, we can yank
out the local method code and turn on the ASYNC hack with clnt_control().
This will make the -m flag work again.
afd506414eebce28d614a4695ce243499d0139bc 26-Mar-2001 ru <ru@FreeBSD.org> - Backout botched attempt to introduce MANSECT feature.
- MAN[1-9] -> MAN.
f10dc9aca1097011cc6fd2f38be5e855132c46f0 20-Mar-2001 ru <ru@FreeBSD.org> Set the default manual section for usr.sbin/ to 8.
f67e4a8fc7fc95c74bd6c09d3453200de47faea5 19-Mar-2001 alfred <alfred@FreeBSD.org> Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.

Bring in required TLI library routines to support this.

Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.

This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).

The submitter has agreed to continue on and bring us up to the
1999 release.

Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
Updated, a more modern interface.

Many userland updates were done to bring the code up to par with
the recent RPC API.

There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads

While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.

New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.

Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.

Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.

Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
7d76aced28ec9c258bd533a4e33516f71f44b6de 06-Feb-2001 asmodai <asmodai@FreeBSD.org> Fix typo: compatability -> compatibility.

Compatability is not an existing english word.
2f1d3e2cdf4534d26d0b712e2d80bdce13126531 06-Feb-2001 asmodai <asmodai@FreeBSD.org> Fix typo: seperate -> separate.

Seperate does not exist in the english language.
66cd8f698eee895c4da383fadb4b96550cc19ccd 01-Feb-2001 ru <ru@FreeBSD.org> mdoc(7) police: split punctuation characters + misc fixes.
b2240fc1c08ba82628285458b057b5f795a68a43 01-Mar-2000 sheldonh <sheldonh@FreeBSD.org> Remove single-space hard sentence breaks. These degrade the quality
of the typeset output, tend to make diffs harder to read and provide
bad examples for new-comers to mdoc.
5a8b335d3bb836f03bbf63ab8131cad063e5fb3f 23-Jan-2000 charnier <charnier@FreeBSD.org> Remove invalid section name.
d53e4c1d809338e9b317d95bdded2f7f7a986556 29-Dec-1999 peter <peter@FreeBSD.org> Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot). This is consistant with the other
BSD's who made this change quite some time ago. More commits to come.
efabb9ccb197b05958967dd035c279ba3bc19cb0 28-Aug-1999 peter <peter@FreeBSD.org> $Id$ -> $FreeBSD$
044dbb065cd9b1b898aee0a76a92d945f6905fee 13-Apr-1999 simokawa <simokawa@FreeBSD.org> Use u_int32_t for sin_addr.s_addr rather than u_long to avoid
unaligned access on alpha.
7a6606c859d9f4ed1eaca3bb258a41fd732971b9 10-Feb-1999 wpaul <wpaul@FreeBSD.org> The ypbind_setdom_2 procedure returns NULL in the success case. This is
incorrect; returning NULL here means that the dispatcher won't send any
response back to the caller, which means the caller will sit there waiting
until it times out. I don't know how this ever worked before. The effect
is that using 'ypset foo' to get the local ypbind to change servers would
work, but would sit there hanging for a long time for no reason.
6e321f37d49e64bb44519bc6e45ea1fb1d3fc284 23-Mar-1998 charnier <charnier@FreeBSD.org> .Sh AUTHOR -> .Sh AUTHORS. Use .An/.Aq.
73bd479ece8b41203de86efb37cf3c3088b81c7b 19-Jan-1998 wpaul <wpaul@FreeBSD.org> Also fix ypbind to compile with ANSI-fied /usr/include/rpcsvc. One of
these days I really should rerwite this creature from the ground up.
8d124fec07a9cc63b694dc8a24bb3295138e93eb 27-Oct-1997 charnier <charnier@FreeBSD.org> Use err(3). Change `=' to `==' in two places, so that server not responding/
server ok is not displayed too often.
OKed by: Bill (wpaul).
8361cef2bae54a6f5144dac924362c4121d44318 09-Oct-1997 wpaul <wpaul@FreeBSD.org> Fix bug in __yp_ping(): keep proper count of assigned request structures.
The test to see if a request struct had been assigned after looping
though the server list was bogus.

Submitted by: "Erik E. Rantapaa" <rantapaa@math.umn.edu>
a51dec7beef5ca5ded9728ffb90982d0311adfc1 25-May-1997 wpaul <wpaul@FreeBSD.org> This commit adds support to ypbind(8) for binding to non-local servers.

The standard SunOS ypbind(8) (and, until now, the FreeBSD ypbind)
only selects servers based on whether or not they respond to clnt_broadcast().
Ypbind(8) broadcasts to the YPPROC_DOMAIN_NONACK procedure and waits
for answers; whichever server answers first is the one ypbind uses
for the local client binding.

This mechanism fails when binding across subnets is desired. In order
for a client on one subnet to bind to a server on another subnet, the
gateway(s) between the client and server must be configured to forward
broadcasts. If this is not possible, then a slave server must be
installed on the remote subnet. If this is also not possible, you
have to force the client to bind to the remote server with ypset(8).

Unfortunately, this last option is less than ideal. If the remote
server becomes unavailable, ypbind(8) will lose its binding and
revert to its broadcast-based search behavior. Even if there are
other servers available, or even if the original server comes back
up, ypbind(8) will not be able to create a new binding since all
the servers are on remote subnets where its broadcasts won't be heard.
If the administrator isn't around to run ypset(8) again, the system
is hosed.

In some Linux NIS implementations, there exists a yp.conf file where
you can explicitly specify a server address and avoid the use of
ypbind altogether. This is not desireable since it removes the
possibility of binding to an alternate server in the event that the
one specified in yp.conf crashes.

Some people have mentioned to me how they though the 'restricted mode'
operation (using the -S flag) could be used as a solution for this
problem since it allows one to specify a list of servers. In fact,
this is not the case: the -S flag just tells ypbind(8) that when it
listens for replies to its broadcasts, it should only honor them if
the replying hosts appear in the specified restricted list.

This behavior has now been changed. If you use the -m flag in conjunction
with the -S flag, ypbind(8) will use a 'many-cast' instead of a broadcast
for choosing a server. In many-cast mode, ypbind(8) will transmit directly
to the YPPROC_DOMAIN_NONACK procedure of all the servers specified in
the restricted mode list and then wait for a reply. As with the broadcast
method, whichever server from the list answers first is used for the
local binding. All other behavior is the same: ypbind(8) continues
to ping its bound server every 60 seconds to insure it's still alive
and will many-cast again if the server fails to respond. The code used
to achieve this is in yp_ping.c; it includes a couple of modified RPC
library routines.

Note that it is not possible to use this mechanism without using
the restricted list since we need to know the addresses of the available
NIS servers ahead of time in order to transmit to them.

Most-recently-requested by: Tom Samplonius
4c3d66cba82b76916fcdeb08d4a8644fda2e8c2c 15-Apr-1997 jmg <jmg@FreeBSD.org> fix a few typos..

Closed PR#3265
052a702922427e213dce37b35b17e76a72d73449 10-Apr-1997 wpaul <wpaul@FreeBSD.org> Avoid processing obviously bogus domain names in the YPBINDPROC_DOMAIN
and YPBINDPROC_SETDOM procedures.
b782f4df30a869a074431c7b185f0c7c69878254 22-Feb-1997 peter <peter@FreeBSD.org> Revert $FreeBSD$ to $Id$
3c5e4a3bbe7e5de66ac045a53ba217928a114996 20-Jan-1997 wosch <wosch@FreeBSD.org> Sort cross references.
808a36ef658c1810327b5d329469bcf5dad24b28 14-Jan-1997 jkh <jkh@FreeBSD.org> Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.
aa35c90f72beca1b6f791d672979f94e3281bc39 12-Jan-1997 wpaul <wpaul@FreeBSD.org> - Save parent pid and check current pid against it upon entry to
terminate(). This makes doubly sure we don't trip the SIGTERM handler
in a child process. Suggested by: phk.

- It's int main(argc, argv), not void main(argc, argv), gosh darn it.
c5b15215e52f7aa9e2eb74570d6714d0257f9303 11-Jan-1997 wpaul <wpaul@FreeBSD.org> Correct two bugs:

- If a child receives a SIGTERM, it will call the terminate() function
and end up doing the shutdown procedurs that should really only be
done by the parent. Set the SIGTERM behavior back to SIG_DLT in the
child after fork()ing.

- If the parent fails to read data back from the child because the
child has exited, it will call rpc_received() with bogus tdata that
can cause the parent to SEGV. Make handle_children() detect this
condition correctly and handle it sanely.

*sigh* Another 2.2 candidate.
2d65710e3608a9dd73ac27c0316aa1a8339d116e 30-Dec-1996 peter <peter@FreeBSD.org> Fix problem caused by new prototypes. Cast object to (caddr_t) as
000fb64288e6720527f55bf8c37e36c07a308d49 05-Oct-1996 wosch <wosch@FreeBSD.org> delete doubled words, e.g.: "the the" -> "the"
3aeb7f1d49074a8872660d87d96bd1ba0e41d3e5 11-Feb-1996 mpp <mpp@FreeBSD.org> Correct a bunch of man page cross references and generally
try and silence "manck".

ncurses, rpc, and some of the gnu stuff are still a big mess, however.
44e05499dea6e05c3f524343043996d1d6a04c20 15-Dec-1995 wpaul <wpaul@FreeBSD.org> More XDR routine cleanups. These three programs should be the only
ones that require this: the others call the yplib functions in libc.
f369859c3287504df6edba262c6f8a9ba1cc8ce3 20-Jul-1995 wpaul <wpaul@FreeBSD.org> Add a -S option to ypbind that allows the following:

-S domainname,server1,server2,server3,...
The -S flag allows the system administrator to lock ypbind to a
particular domain and group of NIS servers. Up to ten servers can
be specified. There must not be any spaces between the commas in
the domain/server specification. This option is used to insure that
that the system binds only to one domain and only to one of the
specified servers, which is useful for systems that are both NIS
servers and NIS clients: it provides a way to restrict what ma-
chines the system can bind to without the need for specifying the
-ypset or -ypsetme options, which are often considered to be secu-
rity holes. The specified servers must have valid entries in the
local /etc/hosts file. IP addresses may be specified in place of
hostnames. If ypbind can't make sense ouf of the arguments, it will
ignore the -S flag and continue running normally.

Note that ypbind will consider the domainname specified with the -S
flag to be the system default domain.

(According to what Garrett showed me, OSF/1 actually only allows 4 servers
to be specified. Ten seemed to be a bit more reasonable to me.)

Suggested by: G. Wollman
Idea lifted from: OSF/1
7715d6b5da9aaadc191f2cffc225a5a82580c013 15-Jul-1995 wpaul <wpaul@FreeBSD.org> Some small signal handling tweaks: be sure to keep wait3()ing until all
children are reaped and make sure to block SIGCHLD delivery during handler
execution when installing SIGCHLD handler with sigaction().
4f960dd75f181e9fa2edc44324f15f0ab5c64b37 30-May-1995 rgrimes <rgrimes@FreeBSD.org> Remove trailing whitespace.
f9661b97c52f14135d1ecd40c593d21d8e740598 29-May-1995 wpaul <wpaul@FreeBSD.org> This is another bug fix that should have gone into my last commit. I
actually had this done at one point and lost it somewhere along the
line. Again, this is an honest to gosh bug fix only: no functionality
is changed.

- After a child broadcaster process dies or is killed, set its dom_pipe_fds
descriptors to -1 so that the 'READFD > 0' test in the select() loop
does the right thing.

Since descriptor values can be re-used, failure to do this can lead
to a situation where a descriptor for an RPC socket can be mistaken for
a pipe. If this happens, RPC sockets could be incorrectly handed off to
handle_children(), which would then clear the descriptor from the select()
descriptor mask and prevent svc_getreqset() from handling them. The end
result would be that some RPC events would go unserviced. Curiously,
the failures only happen intermittently.
3eb2d33debccf5429df8cf9c51a4174a777fb9e2 26-May-1995 wpaul <wpaul@FreeBSD.org> Reviewed by: rgrimes, jkh and davidg (sort of)

Rod, Jordan and David have more or less given me the OK on this
with the understanding that it doesn't change any functionality.
It doesn't: these are bug fixes only. No other part of the system
should be affected. Of course, since I'm the only one working on
NIS, you'll just have to take my word on it. :)

Fixes for the following annoyingly subtle bugs:

- ypbindproc_setdom_2 is supposed to be declared void *, not boot_t *,
and it fails to correctly signal failures back to the ypset(8) command:
we need to call one of the svcerr_*() functions (in this case,
svcerr_noprog() seems a logical choice -- we're really cheating
a bit here because nothing else quite fits) to tell ypset that the
attempt to set the binding for a domain failed. If we don't do this,
failed ypset attempts either appear (incorrectly) to succeed, or
they time out.

- The lock handling for child processes isn't quite right. The
child broadcaster processes have to release all locks on the
binding files and the ypbind.lock file.

- The parent ypbind process will SEGV if you do the following:

-- start ypbind with the -ypset or -ypsetme flag
-- type 'ypwhich -d random_unserved_domain'
-- type 'ypset -d random_unserved_domain anyhost'
-- type 'ypwhich -d random_unserved_domain' again
-- wait about 60 seconds

What happens is this: the ypwhich command causes ypbind to fork a
broadcaster process that searches for a server for random_unserved_domain.
If you then use ypset to force a binding while this process is still alive,
the state flags that tell the ypbind parent process that the child
is running will be cleared. The second ypwhich command then causes
a *second* child process to be forked for random_unserved_domain,
which is verbotten. When the first broadcaster exits and tells the
parent that it wasn't able to find a server for the domain, the parent
clobbers the entry for random_unserved_domain. Then the second broadcaster
exits and the same thing happens, only trying to clobber the entry
twice causes a SEGV.

The fix for this is a slight change in program structure: since we
can't have more than one broadcaster for a given domain at a time,
we save the pipe descriptors and pid for the child broadcaster in members
of the _dom_binding struct for the domain. (As a side effect, we
can get rid of the global child_fds variable.) So when rpc_received()
finds that it's been asked to do a ypset for a domain for which a
broadcaster process exists, it sends a SIGINT to the child to kill it
and closes the pipe to the now-dead child. This keeps everything in sync
and insures that we don't leak file descriptors.

- ping() should be using YPPROC_DOMAIN rather than YPPROC_DOMAIN_NONACK
when it does its clnt_call() to the server.

- Removed the check for client_handle == NULL in ping() and make
client_handle local to ping instead of a member of the _dom_binding
struct. This fixes another potential ypset problem: using ypset to
force a binding to a machine that has an NIS server but which *doesn't*
support the domain we're after can result in permanently bogus bindings.

- the 'server OK' message prints the wrong IP address.
8c0e89af78b6c3f0d502b8ea4e44085b6c336102 12-May-1995 wpaul <wpaul@FreeBSD.org> One for the road: create a ypbind.lock file under /var/run and try to lock
it. If we can't it means there's already a ypbind running and we should
7169c208224599b610407976dda740781dfc7fbf 11-May-1995 wpaul <wpaul@FreeBSD.org> Ack! One slipped through the cracks: remember to return the correctly
filled-in result structure to the caller when a resource allocation
error is encountered in ypbindproc_domain_2.
78ce3864de28cf6df1d35bae1167167384cc0d42 10-May-1995 wpaul <wpaul@FreeBSD.org> Performace improvements/simplifications/cleanups:

- Make the child process reaper signal-driven. (Previously, we called reaper()
once a second each time we went through the select() loop. This was
convenient, but inefficient.)

- Increase main select() timeout from 1 second to 60 seconds and use
this as the ping timer instead of using timestamps in the _dom_binding
structure. This nd the reaper() change noted above makes ypbind a little
less CPU-intensive.

- Don't flag EINTR's from select() as errors since they will happen as a
result of incoming SIGCHLD's interrupting select().

- Prevent possible resource hogging. Currently we malloc() memory
each time a user process asks us to establish a binding for a domain,
but we never free it. This could lead to serious memory leakage if a
'clever' user did something like ask ypwhich to check the bindings
for domains through inclusive.
(This would also make a mess out of the /var/yp/binding directory.)

We now avoid this silliness by a) limiting the maximum number of
simultaneous bindings we can manage to 200, and b) free()ing _dom_binding
structures of secondary domains whose servers have stopped responding.
We unlink the /var/yp/binding/domain.vers files for the free()ed
domains too.

(This is safe to do since a client can prod us into reestablishing the
binding, at which time we'll simply allocate a new _dom_binding structure
for it.)

We keep count of the total number of domains. If asked to
allocate more than the maximum, we return an error. I have yet to hear
of anybody needing 200 simultaneous NIS bindings, so this should be
enough. (I chose the number 200 arbitrarily. It can be increased if need

- Changed "server not responding"/"server OK" messages to display server
IP addresses again since it looks spiffier.

- Use daemon() to daemonify ourselves,

- Added a SIGTERM handler that removes all binding files and unregisters
the ypbind service from the portmapper when a SIGTERM in received.

- The comment 'blow away everything in BINDINGDIR' has no associated code.
Give it some: clean out /var/yp/binding at startup (if it exists).

This completes my ypbind wishlist. Barring bug fixes, I shouldn't need to
go poking around in here anymore. (Of course, this means I can start
working on my ypserv whishlist now... :)
f9be2b50a3a70e395b2a67fbae9f98949cd932fd 03-May-1995 wpaul <wpaul@FreeBSD.org> Cosmetic changes and paranoia checks:

Make fewer assumtions about the state of the dom_alive and dom_broadcasting
flags in roc_received().
Cosmetic changes and paranoia checks:

Make fewer assumtions about the state of the dom_alive and dom_broadcasting
flags in roc_received().

If select() fails, use syslog() to report the error rather than perror().

Check that all our malloc()s succeed. Report malloc() failure in
ypbindproc_setdom_2() to callers.


Use #defined constants in ypbinderr_string() rather than hard-coded values.
b72b2e3557fca50d6b69c47a937520cbe45c26d3 26-Apr-1995 wpaul <wpaul@FreeBSD.org> ypbind.c: Major overhaul.

- Moved to a more client-driven model. We aggressively attempt to keep
the default domain bound (as before) but we give up on non-default
domains if we lose contact with a server and fail to get a response
after one round of broadcasting. This helps drastically reduce the
amount of network bandwitdh that ypbind consumes: if a client references
the secondary domain at some later point, this will prod ypbind into
establishing a new binding anyway, so continuously broadcasting without
need is pointless.

Note that we still actively seek out a binding for our default domain
even if no client program has queried us yet. I'm not exactly sure if
this matches SunOS's behavior or not, but I decided to do it this way
since we can get into all sorts of trouble if our default domain comes
unbound. Even so, we're still much quieter than we used to be.

- Removed a bunch of no-longer pertinent comments and a couple of
chunks of #ifdef 0'ed code that no longer fit in to the new layout.

- Theo deRaadt must have become frustrated with the callback mechanism
in clnt_broadcast(), because he shamelessly stole the clnt_broadcast()
code right out of the RPC library and hacked it up to suit his needs.
(Comments and all! :)

I can understand why: clnt_broadcast() blocks while awaiting replies.
Changing this behavior requires surgery. However, you can work around
this: fork the broadcast into a child process and relay the results
back to the parent via a pipe. (Careful obervation has shown that the
SunOS ypbind forks children for broadcasting too, though I can only
guess what sort of interprocess communication it uses. pipe() seems to
do the job well enough.)

This may seem like the long way around, but it's not really that
hard to implement, and I'd prefer to use documented RPC library functions
wherever possible. We're careful to limit the number of simultaneous
broadcasters to avoid swamping the system (the current limit is 5).
Each clnt_broadcast() call only sends out a small number of packets
at increasing intervals. We're also careful not to spawn more than one
bradcaster for a given domain.

- Used clntudp_bufcreate() and clnt_call() to implement a ping()
function for directly querying a particular server so that we can
check if it's still alive. This lets me completely remove the old
bradcasting code and use actual RPC library calls instead, at the
cost of more than a few handfulls of torn-out hair. (Make no mistake
folks: I *HATE* RPC.) Currently, the ping interval is one minute.

- Fixed another potential 'nfds too big for select()' bug: use
_rpc_dtablesize() instead of getdtablesize().

- Quieted gcc -Wall a bit.

- Probably a bunch of other stuff that I've forgotten.


- Updated man page to reflect modifications.


- Small mind-o fix from last time: decode error results from
ypbind correctly (*groan*)


- same as above

- Change behavior of _yp_dobind() a little: if we get back a 'Domain
not bound' error for a given domain, retry a few times before giving
up and passing the error back to the caller. We have to sleep for a
few seconds between tries since the 'Domain not bound' error comes
back immediately (by repeatedly looping, we end up pounding on ypbind).
We retry at most 20 times at 5 second intervals. This gives us a full
minute to get a response. This seems to deviate a bit from SunOS
behavior -- it appears to wait forever -- but I don't like the idea
of perpetually hanging inside a library call.

Note that this should fix the problems some people have with bindings
not being established fast enough at boot time; sometimes amd is started
in /etc/rc after ypbind has run but before it gets a binding set up. The
automounter gets annoyed at this and tends to exit. By pausing ther YP
calls until a binding is ready, we avoid this situation.

- Another _yp_dobind() change: if we determine that our binding files
are unlocked or nonexistent, jump directly to code that pokes ypbind
into restablishing the binding. Again, if it fails, we'll time out
eventually and return.
be813a3b68f7e9be9bfef131c96c99089a98aa39 21-Apr-1995 wpaul <wpaul@FreeBSD.org> small NIS binding fixes:

ypbind.c: if a client program asks ypbind for the name of the server
for a particular domain, and there isn't a binding for that domain
available yet, ypbind needs to supply a status value along with its
failure message. Set yprespbody.ypbind_error before returning from
a ypbindproc_domain request.

yplib.c: properly handle the error status messages ypbind now has the
ability to send us. Add a ypbinderr_string() function to decode the
error values.

ypwhich.c: handle ypbind errors correctly: yperr_string() can't handle
ypbind_status messages -- use ypbinderr_string instead.
77cd0ce3be5db6841563de22fdfd17dac4e5f8bc 15-Apr-1995 wpaul <wpaul@FreeBSD.org> In environments with multiple NIS servers (a master and several slaves)
one ypbind broadcast can yield several responses. This can lead to
some confusion: the syslog message from ypbind will indicate a rebinding
to the first server that responds, but we may subsequently change our
binding to another server when the other responses arrive. This results
in ypbind reporting 'server OK' to one address and ypwhich reporting a
binding to another.

The behavior of the rpc_received() function has been changed to prevent
this: subsequent responses received after a binding has already been
established are ignored. Rebinding gratuitously each time we get a
new response is silly anyway.

Also backed out the non-fix I made in my last ypbind commit. (Pass
me the extra large conical hat, please.)

(At some point I'm going to seriously re-work ypbind and the _yp_dobind()
library function to bring them in line with SunOS's documented behavior:
binding requests are supposed to be 'client-driven.' The _yp_dobind()
function should be responsible for retrying connections in response to
calls from client programs rather than having ypbind broadcasting
continously until a server responds. The current setup works okay in
normal operation, but we broadcast far too often than we should.)
007c073f7afcd762e5d5360d0a2b128698a63be1 09-Apr-1995 wpaul <wpaul@FreeBSD.org> First crack at a man page for ypbind.
3c9467d883848c3723cd56c864bc23252ee61215 02-Apr-1995 wpaul <wpaul@FreeBSD.org> Fix long standing bogosity in ypbind: if /var/yp/binding doesn't exist,
ypbind is supposed to create it but it doesn't. This is because when
it checks the return value for the attempted open() of
/var/yp/binding/DOMAIN.VERSION, it tests only for a value of -1. This
is bogus because open() doesn't return -1 in this case. Now it checks
for < 0 instead.

This should make life easier for many NIS-newbies who would otherwise
be left scratching their heads wondering why the NIS client stuff won't
work despite their best efforts. ("I set the domain name on my machine,
and /var/yp exists, but when I start ypbind and try a 'ypcat passwd,'
it says it can't bind to a server for this domain! Please help!")

*long, heavy sigh*
c0657f0db190818cf8717ac118b29ee382f889a9 26-Feb-1995 wpaul <wpaul@FreeBSD.org> Submitted by: Sebastian Strollo <seb@erix.eriksson.se>

Fixes to ypbind:

- Correctly report the fact that we've bound to a new server when
logging the 'server OK' message.

- Report 'server not responding' just once instead of every
5 seconds while searching for a new server. (Prevents overstuffing
the syslog.)

- Apply patch from Sebstian Strollo to implement '-s' (secure) flag.
ypbind will reject connections from servers that do not originate
from a reserved TCP port.

- Apply patch from Sebastian Strollo to detect when a YP server has
crashed and come back up on a different port number.
2d9bdef5534f858e9f5c0b38d45d3278cdfc3c2c 16-Feb-1995 wpaul <wpaul@FreeBSD.org> ypbind jumbo patch :)

The existing ypbind exhibits some truly anti-social behavior. After
initially establishing a binding with an NIS server, the following events
take place:

- ypbind waits for 60 seconds before trying to broadcast a ping again
- after the 60 seconds expires, ypbind sends out broadcasts every 5 seconds
come hell or high water.

These broadcasts travel far and wide, even to NIS servers in other domains
which dutifully log the packets even though they don't respond to them.
This leads to lots of unnecessary traffic and bloated log files.

This behavior has been fixed/changed. Here's what happens now:

- We still broadcast every 5 seconds at startup, just like before.

- Once bound, we send out packets once every 60 seconds to the server
we're bound to AND NO ONE ELSE.

- If we fail to receive a reply from our server within FAIL_THRESHOLD
seconds, we assume our server has croaked and go back to broadcasting
everywhere every 5 seconds again until somebody answers. FAIL_THRESHOLD
is currently set to 20 seconds.

Other fixes/improvements:

- ypbind now logs 'server not responding' and 'server OK' messages where

Thanks to Thomas Graichen <graichen@omega.physik.fu-berlin.de> for
reporting the problem and guilt-tripping me into fixing it. :)
8210ef4a47be56116d2395693c043553640bd5b0 23-Sep-1994 dg <dg@FreeBSD.org> Don't return the address of a stack variable.
0d5d309384db435c91bdc7058cbb193169ad5f5b 08-Aug-1994 wollman <wollman@FreeBSD.org> Copying YP programs over from 1.1.5, with a slightly different directory
structure than before.