diff options
author | charnier <charnier@FreeBSD.org> | 1997-10-27 07:45:47 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-10-27 07:45:47 +0000 |
commit | 8d124fec07a9cc63b694dc8a24bb3295138e93eb (patch) | |
tree | 5c5addb495aa581b127156c0400c88dea8953675 /usr.sbin/ypbind | |
parent | fb8e8d64e8f4eb5de543a883dd6a73f9cc568692 (diff) | |
download | FreeBSD-src-8d124fec07a9cc63b694dc8a24bb3295138e93eb.zip FreeBSD-src-8d124fec07a9cc63b694dc8a24bb3295138e93eb.tar.gz |
Use err(3). Change `=' to `==' in two places, so that server not responding/
server ok is not displayed too often.
OKed by: Bill (wpaul).
Diffstat (limited to 'usr.sbin/ypbind')
-rw-r--r-- | usr.sbin/ypbind/yp_ping.c | 23 | ||||
-rw-r--r-- | usr.sbin/ypbind/ypbind.8 | 51 | ||||
-rw-r--r-- | usr.sbin/ypbind/ypbind.c | 92 |
3 files changed, 74 insertions, 92 deletions
diff --git a/usr.sbin/ypbind/yp_ping.c b/usr.sbin/ypbind/yp_ping.c index 31df5b8..6550ab0 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 <errno.h> +#include <netdb.h> #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #include <string.h> +#include <unistd.h> #include <rpc/rpc.h> -#include <sys/socket.h> -#include <net/if.h> -#include <sys/ioctl.h> -#include <netdb.h> -#include <errno.h> #include <rpc/pmap_clnt.h> #include <rpc/pmap_prot.h> #include <rpcsvc/yp.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <net/if.h> #include "yp_ping.h" #ifndef timeradd diff --git a/usr.sbin/ypbind/ypbind.8 b/usr.sbin/ypbind/ypbind.8 index 04971b9..3498ae4 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 -.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 +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 ypbind +.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. +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). .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 <deraadt@fsa.ca> +.An Theo de Raadt Aq deraadt@fsa.ca diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c index 3771de6..5c893f7 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 <sys/param.h> #include <sys/types.h> @@ -41,13 +42,17 @@ static char rcsid[] = "$Id: ypbind.c,v 1.24 1997/04/10 14:18:03 wpaul Exp $"; #include <sys/fcntl.h> #include <sys/stat.h> #include <sys/uio.h> -#include <syslog.h> -#include <stdio.h> -#include <errno.h> #include <ctype.h> #include <dirent.h> +#include <err.h> +#include <errno.h> #include <netdb.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> #include <string.h> +#include <syslog.h> +#include <unistd.h> #include <rpc/rpc.h> #include <rpc/xdr.h> #include <net/if.h> @@ -56,8 +61,7 @@ static char rcsid[] = "$Id: ypbind.c,v 1.24 1997/04/10 14:18:03 wpaul Exp $"; #include <rpc/pmap_clnt.h> #include <rpc/pmap_prot.h> #include <rpc/pmap_rmt.h> -#include <unistd.h> -#include <stdlib.h> +#include <rpc/rpc_com.h> #include <rpcsvc/yp.h> struct dom_binding{}; #include <rpcsvc/ypclnt.h> @@ -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; i<argc; i++) { if( strcmp("-ypset", argv[i]) == 0) @@ -437,43 +434,31 @@ char **argv; } #ifdef DAEMON - if (daemon(0,0)) { - perror("fork"); - exit(1); - } + if (daemon(0,0)) + err(1, "fork"); #endif pmap_unset(YPBINDPROG, YPBINDVERS); udptransp = svcudp_create(RPC_ANYSOCK); - if (udptransp == NULL) { - fprintf(stderr, "cannot create udp service.\n"); - exit(1); - } + if (udptransp == NULL) + errx(1, "cannot create udp service"); if (!svc_register(udptransp, YPBINDPROG, YPBINDVERS, ypbindprog_2, - IPPROTO_UDP)) { - fprintf(stderr, "unable to register (YPBINDPROG, YPBINDVERS, udp).\n"); - exit(1); - } + IPPROTO_UDP)) + errx(1, "unable to register (YPBINDPROG, YPBINDVERS, udp)"); tcptransp = svctcp_create(RPC_ANYSOCK, 0, 0); - if (tcptransp == NULL) { - fprintf(stderr, "cannot create tcp service.\n"); - exit(1); - } + if (tcptransp == NULL) + errx(1, "cannot create tcp service"); if (!svc_register(tcptransp, YPBINDPROG, YPBINDVERS, ypbindprog_2, - IPPROTO_TCP)) { - fprintf(stderr, "unable to register (YPBINDPROG, YPBINDVERS, tcp).\n"); - exit(1); - } + IPPROTO_TCP)) + errx(1, "unable to register (YPBINDPROG, YPBINDVERS, tcp)"); /* build initial domain binding, make it "unsuccessful" */ ypbindlist = (struct _dom_binding *)malloc(sizeof *ypbindlist); - if (ypbindlist == NULL) { - perror("malloc"); - exit(1); - } + if (ypbindlist == NULL) + errx(1, "malloc"); bzero((char *)ypbindlist, sizeof *ypbindlist); strncpy(ypbindlist->dom_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); |