PR/46111: Wolfgang Stukenbrock: Add yp_setbindtries(3) so that yp operations

don't hang forever if requested.
This commit is contained in:
christos 2012-03-02 17:27:48 +00:00
parent 88bfa5cb05
commit 2b01a8ad07
15 changed files with 137 additions and 49 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1743 2012/02/29 20:07:52 tron Exp $
# $NetBSD: mi,v 1.1744 2012/03/02 17:27:48 christos Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -9463,6 +9463,7 @@
./usr/share/man/cat3/ypclnt.0 comp-c-catman yp,.cat
./usr/share/man/cat3/yperr_string.0 comp-c-catman yp,.cat
./usr/share/man/cat3/ypprot_err.0 comp-c-catman yp,.cat
./usr/share/man/cat3/yp_setbindtries.0 comp-c-catman yp,.cat
./usr/share/man/cat3/zlib.0 comp-c-catman .cat
./usr/share/man/cat5/config.0 comp-util-catman .cat
./usr/share/man/cat5/config.samples.0 comp-util-catman .cat
@ -15679,6 +15680,7 @@
./usr/share/man/html3/ypclnt.html comp-c-htmlman yp,html
./usr/share/man/html3/yperr_string.html comp-c-htmlman yp,html
./usr/share/man/html3/ypprot_err.html comp-c-htmlman yp,html
./usr/share/man/html3/yp_setbindtries.html comp-c-htmlman yp,html
./usr/share/man/html3/zlib.html comp-c-htmlman html
./usr/share/man/html5/config.html comp-util-htmlman html
./usr/share/man/html5/config.samples.html comp-util-htmlman html
@ -21971,6 +21973,7 @@
./usr/share/man/man3/ypclnt.3 comp-c-man yp,.man
./usr/share/man/man3/yperr_string.3 comp-c-man yp,.man
./usr/share/man/man3/ypprot_err.3 comp-c-man yp,.man
./usr/share/man/man3/yp_setbindtries.3 comp-c-man yp,.man
./usr/share/man/man3/zlib.3 comp-c-man .man
./usr/share/man/man5/config.5 comp-util-man .man
./usr/share/man/man5/config.samples.5 comp-util-man .man

View File

@ -1,4 +1,4 @@
/* $NetBSD: ypclnt.h,v 1.13 2005/02/03 04:39:33 perry Exp $ */
/* $NetBSD: ypclnt.h,v 1.14 2012/03/02 17:27:48 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -80,6 +80,7 @@ int yp_order (const char *, const char *, int *);
int yp_all (const char *, const char *, struct ypall_callback *);
char * yperr_string (int);
int ypprot_err (unsigned int);
int yp_setbindtries (int);
__END_DECLS
#endif /* _RPCSVC_YPCLNT_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: namespace.h,v 1.150 2012/02/15 15:49:46 joerg Exp $ */
/* $NetBSD: namespace.h,v 1.151 2012/03/02 17:27:49 christos Exp $ */
/*-
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@ -801,6 +801,7 @@
#define yp_unbind _yp_unbind
#define yperr_string _yperr_string
#define ypprot_err _ypprot_err
#define yp_setbindtries _yp_setbindtries
#define dlopen __dlopen
#define dlclose __dlclose
#define dlsym __dlsym

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.14 1999/02/24 15:05:21 drochner Exp $
# $NetBSD: Makefile.inc,v 1.15 2012/03/02 17:27:49 christos Exp $
# yp sources
.PATH: ${ARCHDIR}/yp ${.CURDIR}/yp
@ -10,4 +10,5 @@ MAN+= ypclnt.3
MLINKS+=ypclnt.3 yp_all.3 ypclnt.3 yp_bind.3 ypclnt.3 yp_first.3 \
ypclnt.3 yp_get_default_domain.3 ypclnt.3 yp_master.3 \
ypclnt.3 yp_match.3 ypclnt.3 yp_next.3 ypclnt.3 yp_order.3 \
ypclnt.3 yp_unbind.3 ypclnt.3 yperr_string.3 ypclnt.3 ypprot_err.3
ypclnt.3 yp_unbind.3 ypclnt.3 yperr_string.3 ypclnt.3 ypprot_err.3 \
ypclnt.3 yp_setbindtries.3

View File

@ -1,4 +1,4 @@
/* $NetBSD: yp_first.c,v 1.14 2003/12/10 12:06:25 agc Exp $ */
/* $NetBSD: yp_first.c,v 1.15 2012/03/02 17:27:49 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: yp_first.c,v 1.14 2003/12/10 12:06:25 agc Exp $");
__RCSID("$NetBSD: yp_first.c,v 1.15 2012/03/02 17:27:49 christos Exp $");
#endif
#include "namespace.h"
@ -41,6 +41,7 @@ __RCSID("$NetBSD: yp_first.c,v 1.14 2003/12/10 12:06:25 agc Exp $");
extern struct timeval _yplib_timeout;
extern int _yplib_nerrs;
extern int _yplib_bindtries;
#ifdef __weak_alias
__weak_alias(yp_first,_yp_first)
@ -84,10 +85,11 @@ again:
(xdrproc_t)xdr_ypreq_nokey,
&yprnk, (xdrproc_t)xdr_ypresp_key_val, &yprkv, _yplib_timeout);
if (r != RPC_SUCCESS) {
if (++nerrs == _yplib_nerrs) {
if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_first: clnt_call");
nerrs = 0;
}
} else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries)
return YPERR_YPSERV;
ysd->dom_vers = -1;
goto again;
}
@ -167,10 +169,11 @@ again:
(xdrproc_t)xdr_ypreq_key,
&yprk, (xdrproc_t)xdr_ypresp_key_val, &yprkv, _yplib_timeout);
if (r != RPC_SUCCESS) {
if (++nerrs == _yplib_nerrs) {
if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_next: clnt_call");
nerrs = 0;
}
} else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries)
return YPERR_YPSERV;
ysd->dom_vers = -1;
goto again;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: yp_maplist.c,v 1.11 2003/12/10 12:06:25 agc Exp $ */
/* $NetBSD: yp_maplist.c,v 1.12 2012/03/02 17:27:49 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: yp_maplist.c,v 1.11 2003/12/10 12:06:25 agc Exp $");
__RCSID("$NetBSD: yp_maplist.c,v 1.12 2012/03/02 17:27:49 christos Exp $");
#endif
#include "namespace.h"
@ -40,6 +40,7 @@ __RCSID("$NetBSD: yp_maplist.c,v 1.11 2003/12/10 12:06:25 agc Exp $");
extern struct timeval _yplib_timeout;
extern int _yplib_nerrs;
extern int _yplib_bindtries;
#ifdef __weak_alias
__weak_alias(yp_maplist,_yp_maplist)
@ -68,10 +69,11 @@ again:
(xdrproc_t)xdr_ypdomain_wrap_string, &indomain,
(xdrproc_t)xdr_ypresp_maplist, &ypml, _yplib_timeout);
if (r != RPC_SUCCESS) {
if (++nerrs == _yplib_nerrs) {
if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_maplist: clnt_call");
nerrs = 0;
}
} else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries)
return YPERR_YPSERV;
ysd->dom_vers = -1;
goto again;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: yp_master.c,v 1.13 2003/12/10 12:06:25 agc Exp $ */
/* $NetBSD: yp_master.c,v 1.14 2012/03/02 17:27:49 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: yp_master.c,v 1.13 2003/12/10 12:06:25 agc Exp $");
__RCSID("$NetBSD: yp_master.c,v 1.14 2012/03/02 17:27:49 christos Exp $");
#endif
#include "namespace.h"
@ -41,6 +41,7 @@ __RCSID("$NetBSD: yp_master.c,v 1.13 2003/12/10 12:06:25 agc Exp $");
extern struct timeval _yplib_timeout;
extern int _yplib_nerrs;
extern int _yplib_bindtries;
#ifdef __weak_alias
__weak_alias(yp_master,_yp_master)
@ -80,10 +81,11 @@ again:
(xdrproc_t)xdr_ypreq_nokey, &yprnk,
(xdrproc_t)xdr_ypresp_master, &yprm, _yplib_timeout);
if (r != RPC_SUCCESS) {
if (++nerrs == _yplib_nerrs) {
if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_master: clnt_call");
nerrs = 0;
}
} else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries)
return YPERR_YPSERV;
ysd->dom_vers = -1;
goto again;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: yp_match.c,v 1.17 2005/11/29 03:12:01 christos Exp $ */
/* $NetBSD: yp_match.c,v 1.18 2012/03/02 17:27:49 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: yp_match.c,v 1.17 2005/11/29 03:12:01 christos Exp $");
__RCSID("$NetBSD: yp_match.c,v 1.18 2012/03/02 17:27:49 christos Exp $");
#endif
#include "namespace.h"
@ -47,6 +47,7 @@ __RCSID("$NetBSD: yp_match.c,v 1.17 2005/11/29 03:12:01 christos Exp $");
extern struct timeval _yplib_timeout;
extern int _yplib_nerrs;
extern int _yplib_bindtries;
extern char _yp_domain[];
#ifdef __weak_alias
@ -229,10 +230,13 @@ again:
(xdrproc_t)xdr_ypresp_val, &yprv,
_yplib_timeout);
if (r != RPC_SUCCESS) {
if (++nerrs == _yplib_nerrs) {
if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_match: clnt_call");
nerrs = 0;
}
else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries) {
return YPERR_YPSERV;
}
ysd->dom_vers = -1;
goto again;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: yp_order.c,v 1.12 2003/12/10 12:06:25 agc Exp $ */
/* $NetBSD: yp_order.c,v 1.13 2012/03/02 17:27:49 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: yp_order.c,v 1.12 2003/12/10 12:06:25 agc Exp $");
__RCSID("$NetBSD: yp_order.c,v 1.13 2012/03/02 17:27:49 christos Exp $");
#endif
#include "namespace.h"
@ -40,6 +40,7 @@ __RCSID("$NetBSD: yp_order.c,v 1.12 2003/12/10 12:06:25 agc Exp $");
extern struct timeval _yplib_timeout;
extern int _yplib_nerrs;
extern int _yplib_bindtries;
#ifdef __weak_alias
__weak_alias(yp_order,_yp_order)
@ -78,10 +79,11 @@ again:
(xdrproc_t)xdr_ypresp_order, &ypro,
_yplib_timeout);
if (r != RPC_SUCCESS) {
if (++nerrs == _yplib_nerrs) {
if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_order: clnt_call");
nerrs = 0;
}
} else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries)
return YPERR_YPSERV;
if (r == RPC_PROCUNAVAIL) {
/* Case of NIS+ server in NIS compat mode */
r = YPERR_YPERR;

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ypclnt.3,v 1.24 2010/03/22 19:30:55 joerg Exp $
.\" $NetBSD: ypclnt.3,v 1.25 2012/03/02 17:27:49 christos Exp $
.\"
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd May 21, 1997
.Dd March 2, 2012
.Dt YPCLNT 3
.Os
.Sh NAME
@ -42,6 +42,7 @@
.Nm yp_unbind ,
.Nm yperr_string ,
.Nm ypprot_err
.Nm yp_setbindtries
.Nd Interface to the YP subsystem
.Sh LIBRARY
.Lb libc
@ -72,6 +73,8 @@
.Fn yperr_string "int incode"
.Ft int
.Fn ypprot_err "unsigned int incode"
.Ft int
.Fn yp_setbindtries "int ntries"
.Sh DESCRIPTION
The
.Nm ypclnt
@ -348,6 +351,17 @@ protocol error code to a
.Nm ypclnt
error code suitable for
.Fn yperr_string .
.It Fn yp_setbindtries
Set the number of tries to attempt to bind to the domain before returning
an error.
The default is
.Dv 0
which means wait forever if no ypserver is not found of if the RPC
communication with the yp server fails.
If the number passed is negative, the current number of tries is not modified.
.Pp
This function is an extention to the client library that allows application
to catch communication problems with the ypserver without blocking forever.
.El
.Sh RETURN VALUES
All functions in the

View File

@ -1,4 +1,4 @@
/* $NetBSD: yplib.c,v 1.43 2006/11/03 20:18:49 christos Exp $ */
/* $NetBSD: yplib.c,v 1.44 2012/03/02 17:27:49 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: yplib.c,v 1.43 2006/11/03 20:18:49 christos Exp $");
__RCSID("$NetBSD: yplib.c,v 1.44 2012/03/02 17:27:49 christos Exp $");
#endif
#include "namespace.h"
@ -67,11 +67,13 @@ struct timeval _yplib_timeout = { YPLIB_TIMEOUT, 0 };
struct timeval _yplib_rpc_timeout = { YPLIB_TIMEOUT / YPLIB_RPC_RETRIES,
1000000 * (YPLIB_TIMEOUT % YPLIB_RPC_RETRIES) / YPLIB_RPC_RETRIES };
int _yplib_nerrs = 5;
int _yplib_bindtries = 0;
#ifdef __weak_alias
__weak_alias(yp_bind, _yp_bind)
__weak_alias(yp_unbind, _yp_unbind)
__weak_alias(yp_get_default_domain, _yp_get_default_domain)
__weak_alias(yp_setbindtries, _yp_setbindtries)
#endif
#ifdef _REENTRANT
@ -83,6 +85,15 @@ static mutex_t _ypmutex = MUTEX_INITIALIZER;
#define YPUNLOCK()
#endif
int
yp_setbindtries(int ntries) {
int old_val = _yplib_bindtries;
if (ntries >= 0)
_yplib_bindtries = ntries;
return old_val;
}
int
_yp_dobind(dom, ypdb)
const char *dom;
@ -214,12 +225,18 @@ trynet:
(xdrproc_t)xdr_ypdomain_wrap_string, &dom,
(xdrproc_t)xdr_ypbind_resp, &ypbr, _yplib_timeout);
if (r != RPC_SUCCESS) {
if (new == 0 && ++nerrs == _yplib_nerrs) {
if (_yplib_bindtries <= 0 && new == 0 &&
++nerrs == _yplib_nerrs) {
nerrs = 0;
fprintf(stderr,
"YP server for domain %s not responding, still trying\n",
dom);
}
else if (_yplib_bindtries > 0 &&
++nerrs == _yplib_bindtries) {
free(ysd);
return YPERR_YPBIND;
}
clnt_destroy(client);
ysd->dom_vers = -1;
goto again;

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ypcat.1,v 1.19 2011/01/12 19:55:06 wiz Exp $
.\" $NetBSD: ypcat.1,v 1.20 2012/03/02 17:27:49 christos Exp $
.\"
.\" Copyright (c) 1993 Winning Strategies, Inc.
.\" All rights reserved.
@ -28,7 +28,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd January 12, 2011
.Dd March 2, 2012
.Dt YPCAT 1
.Os
.Sh NAME
@ -37,6 +37,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl kst
.Op Fl b Ar num_retry
.Op Fl d Ar domainname
.Ar mapname
.Nm
@ -51,6 +52,10 @@ which may be a map name or a map nickname.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl b Ar num_retry
Do not wait infinite time for ypserver to come up.
Retry only the specified number times. See
.Xr yp_setbindtries 3 for explanation. Valid range is limited from 0 to 65535 by this program.
.It Fl d Ar domainname
Specify a domain other than the default domain.
.It Fl k
@ -77,6 +82,7 @@ for details).
.Xr domainname 1 ,
.Xr ypmatch 1 ,
.Xr ypwhich 1 ,
.Xr yp_setbindtries 3 ,
.Xr nicknames 5 ,
.Xr nis 8 ,
.Xr ypbind 8 ,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ypcat.c,v 1.16 2011/01/12 18:51:42 christos Exp $ */
/* $NetBSD: ypcat.c,v 1.17 2012/03/02 17:27:49 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ypcat.c,v 1.16 2011/01/12 18:51:42 christos Exp $");
__RCSID("$NetBSD: ypcat.c,v 1.17 2012/03/02 17:27:49 christos Exp $");
#endif
#include <sys/param.h>
@ -58,7 +58,7 @@ static int compressspace;
int
main(int argc, char *argv[])
{
char *domainname;
char *domainname, b_retry_cnt;
struct ypall_callback ypcb;
const char *inmap;
int notrans;
@ -68,11 +68,15 @@ main(int argc, char *argv[])
int key;
setprogname(*argv);
domainname = NULL;
domainname = b_retry_cnt NULL;
notrans = key = 0;
ypaliases = ypalias_init();
while((c = getopt(argc, argv, "d:kstx")) != -1) {
while((c = getopt(argc, argv, "bd:kstx")) != -1) {
switch (c) {
case 'b':
b_retry_cnt = optarg;
break;
case 'd':
domainname = optarg;
break;
@ -107,6 +111,15 @@ main(int argc, char *argv[])
if (argc != 1)
usage();
if (b_retry_cnt != NULL) {
char *s;
unsigned long l;
l = strtoul(b_retry_cnt, &s, 10);
if (*s != '\0' || l > 0xffff) usage();
yp_setbindtries((int)l);
}
if (domainname == NULL)
yp_get_default_domain(&domainname);
@ -172,8 +185,8 @@ static void
usage(void)
{
(void)fprintf(stderr, "Usage: %s [-kst] [-d domainname] mapname\n",
getprogname());
(void)fprintf(stderr, "Usage: %s [-kst] [-b <num-retry> "
"[-d <domainname>] <mapname>\n", getprogname());
(void)fprintf(stderr, " %s -x\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ypmatch.1,v 1.16 2009/06/21 14:58:58 wiz Exp $
.\" $NetBSD: ypmatch.1,v 1.17 2012/03/02 17:27:49 christos Exp $
.\"
.\" Copyright (c) 1993 Winning Strategies, Inc.
.\" All rights reserved.
@ -28,7 +28,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd June 20, 2009
.Dd March 2, 2012
.Dt YPMATCH 1
.Os
.Sh NAME
@ -37,6 +37,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl ktz
.Op Fl b Ar num_retry
.Op Fl d Ar domainname
.Ar key ...
.Ar mapname
@ -52,6 +53,10 @@ which may be a map name or a map nickname.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl b Ar num_retry
Do not wait infinite time for ypserver to come up.
Retry only the specified number times. See
.Xr yp_setbindtries 3 for explanation. Valid range is limited from 0 to 65535 by this program.
.It Fl d Ar domainname
Specify a domain other than the default domain.
.It Fl k
@ -78,6 +83,7 @@ the keys.
.Xr domainname 1 ,
.Xr ypcat 1 ,
.Xr ypwhich 1 ,
.Xr yp_setbindtries 3 ,
.Xr nicknames 5 ,
.Xr nis 8 ,
.Xr ypbind 8 ,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ypmatch.c,v 1.19 2009/06/21 14:59:53 wiz Exp $ */
/* $NetBSD: ypmatch.c,v 1.20 2012/03/02 17:27:49 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ypmatch.c,v 1.19 2009/06/21 14:59:53 wiz Exp $");
__RCSID("$NetBSD: ypmatch.c,v 1.20 2012/03/02 17:27:49 christos Exp $");
#endif
#include <sys/param.h>
@ -53,7 +53,7 @@ static void usage(void) __attribute__((__noreturn__));
int
main(int argc, char *argv[])
{
char *domainname;
char *domainname, *b_retry_cnt;
char *inkey, *outbuf;
const char *inmap;
int outbuflen, key, null, notrans;
@ -63,10 +63,10 @@ main(int argc, char *argv[])
const struct ypalias *ypaliases;
setprogname(*argv);
domainname = NULL;
domainname = b_retry_cnt = NULL;
notrans = key = null = 0;
ypaliases = ypalias_init();
while ((c = getopt(argc, argv, "xd:ktz")) != -1) {
while ((c = getopt(argc, argv, "bd:ktxz")) != -1) {
switch (c) {
case 'x':
for(i = 0; ypaliases[i].alias; i++)
@ -75,6 +75,10 @@ main(int argc, char *argv[])
ypaliases[i].name);
return 0;
case 'b':
b_retry_cnt = optarg;
break;
case 'd':
domainname = optarg;
break;
@ -102,6 +106,15 @@ main(int argc, char *argv[])
if (argc < 2)
usage();
if (b_retry_cnt != NULL) {
char *s;
unsigned long l;
l = strtoul(b_retry_cnt, &s, 10);
if (*s != '\0' || l > 0xffff) usage();
yp_setbindtries((int)l);
}
if (domainname == NULL)
yp_get_default_domain(&domainname);
@ -147,8 +160,8 @@ static void
usage(void)
{
(void)fprintf(stderr, "Usage: %s [-ktz] [-d domain] key ... "
"mapname\n", getprogname());
(void)fprintf(stderr, "Usage: %s [-ktz] [-b <num-retry>] "
"[-d <domainname>] "<key> ... <mapname>\n", getprogname());
(void)fprintf(stderr, " %s -x\n", getprogname());
exit(1);
}