From 8d124fec07a9cc63b694dc8a24bb3295138e93eb Mon Sep 17 00:00:00 2001 From: charnier Date: Mon, 27 Oct 1997 07:45:47 +0000 Subject: 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/ypbind.c | 92 ++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 54 deletions(-) (limited to 'usr.sbin/ypbind/ypbind.c') 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 #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); -- cgit v1.1