History log of /freebsd-current/usr.bin/ypwhich/ypwhich.c
Revision Date Author Comments
# 5e3934b1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# b61a5730 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD

The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <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.


# 58458d06 25-Aug-2015 Marcelo Araujo <araujo@FreeBSD.org>

Sync ypwhich(1) code with the OpenBSD version that is more modern.
Update the BSD LICENSE and remove the 3rd clause.

Reviewed by: rodrigc, kib, bapt
Approved by: bapt (mentor)
Obtained from: OpenBSD
Differential Revision: D3249


# 07c1d44f 12-Aug-2015 Marcelo Araujo <araujo@FreeBSD.org>

Use nitems instead of "sizeof ypaliases/sizeof ypaliases[0]".
Make the if statement more expressive.

Differential Revision: D3366
Reviewed by: ed
Approved by: bapt, rodrigc (mentor)


# 006a388b 28-Jul-2015 Marcelo Araujo <araujo@FreeBSD.org>

Compilers will complain the usage of obsolescent variable declarations.
Also it will fix the build problem with sparc64.

Submitted by: ed@


# 033af09d 27-Jul-2015 Marcelo Araujo <araujo@FreeBSD.org>

Staticfy and constify some variables and clean up the code a bit to make it
more readable. No functional change.

Differential Revision: D3166
Reviewed by: kib
Sponsored by: gandi.net


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# ae7f9676 19-Jun-2010 Gavin Atkinson <gavin@FreeBSD.org>

Variable 'getmap' is unused.

Found by: clang static analyzer


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 821df508 12-Dec-2009 Xin LI <delphij@FreeBSD.org>

Revert most part of 200420 as requested, as more review and polish is
needed.


# 6f2d3221 11-Dec-2009 Xin LI <delphij@FreeBSD.org>

Remove unneeded header includes from usr.bin/ except contributed code.

Tested with: make universe


# 53c40578 25-Jun-2009 Brian Somers <brian@FreeBSD.org>

Support shadow.byname and shadow.byuid maps, protecting them by
insisting on privileged port access.

Include /var/yp/Makefile.local if it exists and suggest using
it to override /var/yp/Makefile behaviour.

Approved by: re (kib)
MFC after: 3 weeks


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 79a32d27 04-Apr-2004 Philippe Charnier <charnier@FreeBSD.org>

Be consistant while reporting error conditions.


# cd9df728 25-Oct-2003 Peter Wemm <peter@FreeBSD.org>

Fix up warnings. There were some biggies here. There seems to be two
different sets of definitions in /usr/include/rpcsvc, mostly compatable,
but with different names. Will the real one please stand up?
In order to get prototypes for yp_maplist, we had to use the 'other'
naming system.


# 29da6db8 27-Feb-2002 David Malone <dwmalone@FreeBSD.org>

1) Remove blank line between include of sys/cdefs.h and __FBSDID
2) compare return value of inet_addr to INADDR_NONE rather than -1.


# ed4d1c46 06-Feb-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Apply the following mechanical transformations in preparation for
ansification and constification:

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

Also add $FreeBSD$ where needed.

MFC after: 1 week


# 082d8262 11-Dec-2001 Mark Murray <markm@FreeBSD.org>

WARNS=2 fixes
__FBSDID() additions
some include file sorting.
Some Makefile sorting.

WARNS?=2 is not added to the Makefile, because it is going to be
default for usr.bin/
NO_WERROR is set because there are rpc*.h file issues.


# c3aac50f 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 28faa530 12-Jun-1998 Peter Wemm <peter@FreeBSD.org>

#include <arpa/inet.h>
Also, use real struct in_addr rather than u_long.


# 7008c93d 29-Aug-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3). Cosmetic in usage(). Delay the compute of defaultdomain (from
OpenBSD).
Obtained from: OpenBSD.


# d228e65c 12-Jul-1997 Peter Wemm <peter@FreeBSD.org>

Add an alias for master.passwd -> master.passwd.byname to the list
of convenience map aliases.


# 7db881e1 14-Dec-1995 Bill Paul <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.


# bbdb094b 20-Jul-1995 Garrett Wollman <wollman@FreeBSD.org>

Slightly better message for `ypwhich -x':

was: Use "foo" for "foo.bar"
now: "foo" is an alias for "foo.bar"


# 7799f52a 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 456ebbf8 26-Apr-1995 Bill Paul <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.

ypbind.8:

- Updated man page to reflect modifications.

ypwhich.c:

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

yplib.c:

- 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.


# 8a5bd1a2 21-Apr-1995 Bill Paul <wpaul@FreeBSD.org>

Make Rod Grimes's life a little simpler: replace all exit(1)'s with
seperate exit values depending on the error. (The error values are
#defined and commented near the top of the file for clarity). This
is to help write a small bit of shell script for /etc/rc that calls
ypwhich a few times after ypbind is invoked to make sure we're
actually bound to a server before proceeding (if we aren't, the
automounter can fail if it's using NIS maps).


# 64416168 21-Apr-1995 Bill Paul <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.


# 73407b34 07-Aug-1994 Garrett Wollman <wollman@FreeBSD.org>

Move more YP user programs over.