From 77cbf0b31b6442d59561757f57b2cb30036c998a Mon Sep 17 00:00:00 2001 From: Philippe Charnier Date: Mon, 27 Oct 1997 07:45:47 +0000 Subject: [PATCH] Use err(3). Change `=' to `==' in two places, so that server not responding/ server ok is not displayed too often. OKed by: Bill (wpaul). --- usr.sbin/ypbind/yp_ping.c | 23 +++++----- usr.sbin/ypbind/ypbind.8 | 53 +++++++++++----------- usr.sbin/ypbind/ypbind.c | 92 ++++++++++++++++----------------------- 3 files changed, 75 insertions(+), 93 deletions(-) diff --git a/usr.sbin/ypbind/yp_ping.c b/usr.sbin/ypbind/yp_ping.c index 31df5b832f37..6550ab08b73e 100644 --- a/usr.sbin/ypbind/yp_ping.c +++ b/usr.sbin/ypbind/yp_ping.c @@ -28,8 +28,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $Id: yp_ping.c,v 1.1 1997/05/25 19:49:29 wpaul Exp $ */ /* @@ -69,9 +67,12 @@ */ #ifndef lint -/*static char *sccsid = "from: @(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";*/ -static const char rcsid[] = "@(#) $Id: yp_ping.c,v 1.1 1997/05/25 19:49:29 wpaul Exp $"; +#if 0 +static char *sccsid = "@(#)from: clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; +static char *sccsid = "@(#)from: clnt_udp.c 2.2 88/08/01 4.0 RPCSRC"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* @@ -80,19 +81,19 @@ static const char rcsid[] = "@(#) $Id: yp_ping.c,v 1.1 1997/05/25 19:49:29 wpaul * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include +#include #include #include -#include #include +#include #include -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include #include "yp_ping.h" #ifndef timeradd diff --git a/usr.sbin/ypbind/ypbind.8 b/usr.sbin/ypbind/ypbind.8 index 04971b9478a3..3498ae4b95c5 100644 --- a/usr.sbin/ypbind/ypbind.8 +++ b/usr.sbin/ypbind/ypbind.8 @@ -29,7 +29,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: ypbind.8,v 1.9 1997/04/15 07:15:47 jmg Exp $ +.\" $Id: ypbind.8,v 1.10 1997/05/25 19:49:32 wpaul Exp $ .\" .Dd April 9, 1995 .Dt YPBIND 8 @@ -45,7 +45,7 @@ .Op Fl m .Op Fl S Ar domainname,server1,server2,... .Sh DESCRIPTION -.Nm +.Nm Ypbind is the process that maintains NIS binding information. At startup, it searches for an NIS server responsible for serving the system's default domain (as set by the @@ -67,16 +67,15 @@ intervals. If it fails to receive a reply to one of these requests, .Nm assumes that the server is no longer running and resumes its network broadcasts until another binding is established. -.Nm +.Nm Ypbind will also log warning messages using the .Xr syslog 3 facility each time it detects that a server has stopped responding, as well as when it has bound to a new server. -.Pp .Sh OPTIONS The following options are supported by .Nm Ns : -.Bl -tag -width flag +.Bl -tag -width indent .It Fl ypset It is possible to force .Nm @@ -99,17 +98,15 @@ This is similar to the flag, except that it only permits YPBINDPROC_SETDOM requests to be processed if they originated from the local host. .It Fl s -The -.Fl s -flag causes +Cause .Nm to run in secure mode: it will refuse to bind to any NIS server that is not running as root (i.e. that is not using privileged TCP ports). .It Fl S Ar domainname,server1,server2,server3,... -The -.Fl S -flag allows the system administrator to lock ypbind to a particular +Allow the system administrator to lock +.Nm +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 the system binds @@ -136,22 +133,22 @@ will consider the domainname specified with the .Fl S flag to be the system default domain. .It Fl m -The +Cause +.Nm +to use a 'many-cast' rather than a broadcast for choosing a server +from the restricted mode server list. In many-cast mode, +.Nm +will transmit directly to the YPPROC_DOMAIN_NONACK procedure of the +servers specified in the restricted list and bind to the server that +responds the fastest. +This mode of operation is useful for NIS clients on remote subnets +where no local NIS servers are available. The .Fl m flag can only be used in conjunction with the .Fl S flag above (if used without the .Fl S -flag, it has no effect). It causes -.Nm ypbind -to use a 'many-cast' rather than a broadcast for choosing a server -from the restricted mode server list. In many-cast mode, -.Nm ypbind -will transmit directly to the YPPROC_DOMAIN_NONACK procedure of the -servers specified in the restricted list and bind to the server that -responds the fastest. -This mode of operation is useful for NIS clients on remote subnets -where no local NIS servers are available. +flag, it has no effect). .El .Sh NOTES The @@ -167,12 +164,12 @@ will try broadcasting again. By contrast, will automatically maintain a binding for the default domain whether client programs reference it ot not. .Sh FILES -.Bl -tag -width Pa -compact +.Bl -tag -width /etc/rc.conf -compact .It Pa /var/yp/binding/[domainname].[version] -The files used to hold binding information for each NIS domain. -.It Pa /etc/sysconfig -System configuration file where the system default domain and -ypbind startup options are specified. +the files used to hold binding information for each NIS domain +.It Pa /etc/rc.conf +system configuration file where the system default domain and +ypbind startup options are specified .El .Sh SEE ALSO .Xr domainname 1 , @@ -181,4 +178,4 @@ ypbind startup options are specified. .Xr ypserv 8 , .Xr ypset 8 .Sh AUTHOR -Theo de Raadt +.An Theo de Raadt Aq deraadt@fsa.ca diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c index 3771de6db879..5c893f790bc7 100644 --- a/usr.sbin/ypbind/ypbind.c +++ b/usr.sbin/ypbind/ypbind.c @@ -27,9 +27,10 @@ * SUCH DAMAGE. */ -#ifndef LINT -static char rcsid[] = "$Id: ypbind.c,v 1.24 1997/04/10 14:18:03 wpaul Exp $"; -#endif +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include #include @@ -41,13 +42,17 @@ static char rcsid[] = "$Id: ypbind.c,v 1.24 1997/04/10 14:18:03 wpaul Exp $"; #include #include #include -#include -#include -#include #include #include +#include +#include #include +#include +#include +#include #include +#include +#include #include #include #include @@ -56,8 +61,7 @@ static char rcsid[] = "$Id: ypbind.c,v 1.24 1997/04/10 14:18:03 wpaul Exp $"; #include #include #include -#include -#include +#include #include struct dom_binding{}; #include @@ -247,7 +251,7 @@ CLIENT *clnt; if (strchr(argp->ypsetdom_domain, '/')) { syslog(LOG_WARNING, "Domain name '%s' has embedded slash -- \ rejecting.", argp->ypsetdom_domain); - return; + return(NULL); } fromsin = svc_getcaller(transp); @@ -255,7 +259,7 @@ rejecting.", argp->ypsetdom_domain); case YPSET_LOCAL: if( fromsin->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) { svcerr_noprog(transp); - return; + return(NULL); } break; case YPSET_ALL: @@ -263,17 +267,17 @@ rejecting.", argp->ypsetdom_domain); case YPSET_NO: default: svcerr_noprog(transp); - return; + return(NULL); } if(ntohs(fromsin->sin_port) >= IPPORT_RESERVED) { svcerr_noprog(transp); - return; + return(NULL); } if(argp->ypsetdom_vers != YPVERS) { svcerr_noprog(transp); - return; + return(NULL); } bzero((char *)&bindsin, sizeof bindsin); @@ -282,7 +286,7 @@ rejecting.", argp->ypsetdom_domain); bindsin.sin_port = *(u_short *)argp->ypsetdom_binding.ypbind_binding_port; rpc_received(argp->ypsetdom_domain, &bindsin, 1); - return; + return(NULL); } static void @@ -385,7 +389,6 @@ main(argc, argv) int argc; char **argv; { - char path[MAXPATHLEN]; struct timeval tv; int i; DIR *dird; @@ -393,22 +396,16 @@ char **argv; struct _dom_binding *ypdb; /* Check that another ypbind isn't already running. */ - if ((yplockfd = (open(YPBINDLOCK, O_RDONLY|O_CREAT, 0444))) == -1) { - perror(YPBINDLOCK); - exit(1); - } + if ((yplockfd = (open(YPBINDLOCK, O_RDONLY|O_CREAT, 0444))) == -1) + err(1, "%s", YPBINDLOCK); - if(flock(yplockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) { - fprintf (stderr, "Another ypbind is already running. Aborting.\n"); - exit(1); - } + if(flock(yplockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) + errx(1, "another ypbind is already running. Aborting"); /* XXX domainname will be overriden if we use restricted mode */ yp_get_default_domain(&domain_name); - if( domain_name[0] == '\0') { - fprintf(stderr, "domainname not set. Aborting.\n"); - exit(1); - } + if( domain_name[0] == '\0') + errx(1, "domainname not set. Aborting"); for(i=1; idom_domain, domain_name, sizeof ypbindlist->dom_domain); ypbindlist->dom_vers = YPVERS; @@ -683,7 +668,7 @@ struct _dom_binding *ypdb; return; } - if (ypdb->dom_vers = -1 && (long)ypdb->dom_server_addr.sin_addr.s_addr) + if (ypdb->dom_vers == -1 && (long)ypdb->dom_server_addr.sin_addr.s_addr) syslog(LOG_WARNING, "NIS server [%s] for domain \"%s\" not responding", inet_ntoa(ypdb->dom_server_addr.sin_addr), ypdb->dom_domain); @@ -791,7 +776,6 @@ struct _dom_binding *ypdb; enum clnt_stat stat; int rpcsock = RPC_ANYSOCK; CLIENT *client_handle; - time_t t; interval.tv_sec = FAIL_THRESHOLD; interval.tv_usec = 0; @@ -917,7 +901,7 @@ int force; } /* We've recovered from a crash: inform the world. */ - if (ypdb->dom_vers = -1 && ypdb->dom_server_addr.sin_addr.s_addr) + if (ypdb->dom_vers == -1 && ypdb->dom_server_addr.sin_addr.s_addr) syslog(LOG_WARNING, "NIS server [%s] for domain \"%s\" OK", inet_ntoa(raddrp->sin_addr), ypdb->dom_domain);