diff options
author | Mats O Jansson <maja@cvs.openbsd.org> | 1999-03-20 15:36:13 +0000 |
---|---|---|
committer | Mats O Jansson <maja@cvs.openbsd.org> | 1999-03-20 15:36:13 +0000 |
commit | b839eb77feef795f3208dc38de88ab20cc6fa417 (patch) | |
tree | 2d283b58eb8e6241b9291b32b2775902c325e607 /usr.bin/ypwhich | |
parent | 23e9862bcd1cec2160166d253b928b0f12e59f0a (diff) |
New improved -h support. In this version ypwhich -m even works on machines
that isn't ypserver. Reported by Jeff Schneiter <jschneit@Adobe.COM>. -moj
Diffstat (limited to 'usr.bin/ypwhich')
-rw-r--r-- | usr.bin/ypwhich/Makefile | 7 | ||||
-rw-r--r-- | usr.bin/ypwhich/ypwhich.1 | 9 | ||||
-rw-r--r-- | usr.bin/ypwhich/ypwhich.c | 38 |
3 files changed, 44 insertions, 10 deletions
diff --git a/usr.bin/ypwhich/Makefile b/usr.bin/ypwhich/Makefile index cd42d4dd1b8..e138ba4a0b2 100644 --- a/usr.bin/ypwhich/Makefile +++ b/usr.bin/ypwhich/Makefile @@ -1,6 +1,11 @@ -# $OpenBSD: Makefile,v 1.5 1999/03/19 22:21:27 deraadt Exp $ +# $OpenBSD: Makefile,v 1.6 1999/03/20 15:36:12 maja Exp $ # from: @(#)Makefile 5.8 (Berkeley) 7/28/90 PROG= ypwhich +SRCS= ypwhich.c yplib_host.c +MAN= ypwhich.1 + +.PATH: ${.CURDIR}/../../usr.sbin/ypserv/common +CFLAGS+=-I${.CURDIR}/../../usr.sbin/ypserv/common .include <bsd.prog.mk> diff --git a/usr.bin/ypwhich/ypwhich.1 b/usr.bin/ypwhich/ypwhich.1 index bccf614b0d1..6ad737b28f9 100644 --- a/usr.bin/ypwhich/ypwhich.1 +++ b/usr.bin/ypwhich/ypwhich.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ypwhich.1,v 1.6 1999/03/19 22:21:27 deraadt Exp $ +.\" $OpenBSD: ypwhich.1,v 1.7 1999/03/20 15:36:12 maja Exp $ .\" $NetBSD: ypwhich.1,v 1.3 1996/05/13 02:43:46 thorpej Exp $ .\" .\" Copyright (c) 1994 Christopher G. Demetriou @@ -29,7 +29,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. .\" -.\" $Id: ypwhich.1,v 1.6 1999/03/19 22:21:27 deraadt Exp $ +.\" $Id: ypwhich.1,v 1.7 1999/03/20 15:36:12 maja Exp $ .\" .Dd February 23, 1994 .Dt YPWHICH 1 @@ -41,6 +41,7 @@ .Nm ypwhich .Op Fl d Ar domain .Oo +.Op Fl h Ar host .Op Fl t .Fl m Op Ar mname | @@ -69,6 +70,10 @@ The options are as follows: .Bl -tag -width indent .It Fl d Ar domain Specify a domain other than the default domain. +.It Fl h Ar host +Specify which host to ask when +.Fl m +is given. .It Fl t Inhibit translation of map nicknames to their corresponding map names. diff --git a/usr.bin/ypwhich/ypwhich.c b/usr.bin/ypwhich/ypwhich.c index b7f45941ec3..1364356a9ef 100644 --- a/usr.bin/ypwhich/ypwhich.c +++ b/usr.bin/ypwhich/ypwhich.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypwhich.c,v 1.10 1999/03/19 22:21:27 deraadt Exp $ */ +/* $OpenBSD: ypwhich.c,v 1.11 1999/03/20 15:36:12 maja Exp $ */ /* $NetBSD: ypwhich.c,v 1.6 1996/05/13 02:43:48 thorpej Exp $ */ /* @@ -34,7 +34,7 @@ */ #ifndef LINT -static char rcsid[] = "$Id: ypwhich.c,v 1.10 1999/03/19 22:21:27 deraadt Exp $"; +static char rcsid[] = "$Id: ypwhich.c,v 1.11 1999/03/20 15:36:12 maja Exp $"; #endif #include <sys/param.h> @@ -57,6 +57,8 @@ static char rcsid[] = "$Id: ypwhich.c,v 1.10 1999/03/19 22:21:27 deraadt Exp $"; #include <rpcsvc/yp.h> #include <rpcsvc/ypclnt.h> +#include "yplib_host.h" + struct ypalias { char *alias, *name; } ypaliases[] = { @@ -74,7 +76,7 @@ void usage() { fprintf(stderr, "Usage:\n"); - fprintf(stderr, "\typwhich [-d domain] [[-t] -m [mname] | host]\n"); + fprintf(stderr, "\typwhich [-d domain] [[-h host] [-t] -m [mname] | host]\n"); fprintf(stderr, "\typwhich -x\n"); exit(1); } @@ -149,6 +151,8 @@ main(argc, argv) struct sockaddr_in sin; int notrans, mode, getmap; int c, r, i; + CLIENT *client; + char *host = NULL; map = NULL; getmap = notrans = mode = 0; @@ -157,13 +161,16 @@ main(argc, argv) if (domain == NULL) errx(1, "YP domain name not set"); - while ((c = getopt(argc, argv, "xd:mt")) != -1) + while ((c = getopt(argc, argv, "xd:h:mt")) != -1) switch(c) { case 'x': for (i=0; i<sizeof ypaliases/sizeof ypaliases[0]; i++) printf("Use \"%s\" for \"%s\"\n", ypaliases[i].alias, ypaliases[i].name); exit(0); + case 'h': + host = optarg; + break; case 'd': domain = optarg; break; @@ -214,13 +221,21 @@ main(argc, argv) if (argc > 1) usage(); + if (host != NULL) { + client = yp_bind_host(host,YPPROG,YPVERS,0,1); + } + if (argv[0]) { map = argv[0]; for (i=0; (!notrans) && i<sizeof ypaliases/sizeof ypaliases[0]; i++) if (strcmp(map, ypaliases[i].alias) == 0) map = ypaliases[i].name; - r = yp_master(domain, map, &master); + if (host != NULL) { + r = yp_master_host(client, domain, map, &master); + } else { + r = yp_master(domain, map, &master); + } switch (r) { case 0: printf("%s\n", master); @@ -238,13 +253,22 @@ main(argc, argv) } ypml = NULL; - r = yp_maplist(domain, &ypml); + if (host != NULL) { + r = yp_maplist_host(client, domain, &ypml); + } else { + r = yp_maplist(domain, &ypml); + } r = 0; switch(r) { case 0: for (y = ypml; y; ) { ypml = y; - r = yp_master(domain, ypml->map, &master); + if (host != NULL) { + r = yp_master_host(client, + domain, ypml->map, &master); + } else { + r = yp_master(domain, ypml->map, &master); + } switch(r) { case 0: printf("%s %s\n", ypml->map, master); |