diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-11-01 16:56:44 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-11-01 16:56:44 +0000 |
commit | 8bf9f802d4321d9b6265d2ed11b96f9dcd319801 (patch) | |
tree | a466ee254e08a5a7b6541862e7d95712e699950b /usr.sbin/ypserv/yptest | |
parent | ed9016f1ebe086095be8004780196d995d8f0798 (diff) |
+ full set of ypserv tools that compile
Diffstat (limited to 'usr.sbin/ypserv/yptest')
-rw-r--r-- | usr.sbin/ypserv/yptest/Makefile | 7 | ||||
-rw-r--r-- | usr.sbin/ypserv/yptest/yptest.8 | 61 | ||||
-rw-r--r-- | usr.sbin/ypserv/yptest/yptest.c | 122 |
3 files changed, 190 insertions, 0 deletions
diff --git a/usr.sbin/ypserv/yptest/Makefile b/usr.sbin/ypserv/yptest/Makefile new file mode 100644 index 00000000000..d5cce8c1190 --- /dev/null +++ b/usr.sbin/ypserv/yptest/Makefile @@ -0,0 +1,7 @@ +# from: @(#)Makefile 5.8 (Berkeley) 7/28/90 +# $Id: Makefile,v 1.1 1995/11/01 16:56:39 deraadt Exp $ + +PROG= yptest +MAN= yptest.8 + +.include <bsd.prog.mk> diff --git a/usr.sbin/ypserv/yptest/yptest.8 b/usr.sbin/ypserv/yptest/yptest.8 new file mode 100644 index 00000000000..433f38425b2 --- /dev/null +++ b/usr.sbin/ypserv/yptest/yptest.8 @@ -0,0 +1,61 @@ +.\" Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. The name of the author may not be used to endorse or promote +.\" products derived from this software without specific prior written +.\" permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" 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: yptest.8,v 1.1 1995/11/01 16:56:40 deraadt Exp $ +.\" +.Dd August 26, 1994 +.Dt YPTEST 8 +.Os NetBSD 1.0 +.Sh NAME +.Nm yptest +.Nd calls different YP routines +.Sh SYNOPSIS +.Nm /usr/sbin/yptest +.\".Op Fl u Ar file +.\".Nm /usr/sbin/makedbm +.\".Op Fl bls +.\".Op Fl i Ar yp_input_file +.\".Op Fl o Ar yp_output_file +.\".Op Fl d Ar yp_domain_name +.\".Op Fl m Ar yp_master_name +.\".Ar infile +.\".Ar outfile +.Sh DESCRIPTION +.Nm Yptest +is a utility written to check if the YP server works as expected. +.Pp +.Pp +.\"The options are as follows: +.\".Bl -tag -width indent +.\".It Fl d Ar yp_domain_name +.\"Include an entry the in the map with the key YP_DOMAIN_NAME and the argument +.\"as value. +.\".El +.Sh SEE ALSO +.Xr ypserv 8 +.Sh AUTHOR +Mats O Jansson <moj@stacken.kth.se> diff --git a/usr.sbin/ypserv/yptest/yptest.c b/usr.sbin/ypserv/yptest/yptest.c new file mode 100644 index 00000000000..896d0e54159 --- /dev/null +++ b/usr.sbin/ypserv/yptest/yptest.c @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * 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. + */ + +#ifndef LINT +static char rcsid[] = "$Id: yptest.c,v 1.1 1995/11/01 16:56:40 deraadt Exp $"; +#endif + +#include <stdio.h> +#include <unistd.h> +#include <strings.h> +#include <rpc/rpc.h> +#include <rpc/xdr.h> +#include <rpcsvc/yp_prot.h> +#include <rpcsvc/ypclnt.h> + +static int +yptest_foreach(status,key,keylen,val,vallen,data) +int status,keylen,vallen,*data; +char *key,*val; +{ + if (status == 2) + return(0); + /* key avslutas med NUL */ + /* val avslutas med NUL */ + key[keylen] = '\0'; + val[vallen] = '\0'; + printf("%s %s\n",key,val); + return 0; +} + +main() +{ + char *Domain; + char *Map = "passwd.byname"; + char *Key = "root"; + int KeyLen; + char *Value; + char *Key2; + int ValLen; + int Status; + int Order; + struct ypall_callback Callback; + struct ypmaplist *ypml,*y; + + yp_get_default_domain(&Domain); + + printf("Test 1: yp_match\n"); + KeyLen = strlen(Key); + Status = yp_match(Domain,Map,Key,KeyLen,&Value,&ValLen); + printf("%*.*s\n",ValLen-1,ValLen-1,Value); + /* yp_match: Value is terminated with LF NUL */ + + printf("\nTest 2: yp_first\n"); + Status = yp_first(Domain,Map,&Key2,&KeyLen,&Value,&ValLen); + printf("%*.*s %*.*s\n",KeyLen-1,KeyLen-1,Key2,ValLen-1,ValLen-1,Value); + /* yp_first: Value is terminated with LF NUL */ + /* Key2 is terminated with LF NUL */ + + printf("\nTest 3: yp_next\n"); + + while (Status == 0) { + Status = yp_next(Domain,Map,Key2,KeyLen,&Key2,&KeyLen,&Value,&ValLen); + if (Status == 0) { + printf("%*.*s %*.*s\n",KeyLen-1,KeyLen-1,Key2,ValLen,ValLen,Value); + } + /* yp_next: Value is terminated with LF NUL */ + /* Key2 is terminated with LF NUL */ + } + + printf("\nTest 4: yp_master\n"); + + Status = yp_master(Domain,Map,&Key2); + printf("%s\n",Key2); + /* yp_master: Key2 is terminated with NUL */ + + printf("\nTest 5: yp_order\n"); + Status = yp_order(Domain,Map,&Order); + printf("%d\n",Order); + + printf("\nTest 6: yp_maplist\n"); + ypml = NULL; + switch(yp_maplist(Domain, &ypml)) { + case 0: + for(y=ypml; y; ) { + ypml=y; + printf("%s\n",ypml->ypml_name); + y=ypml->ypml_next; + } + } + + + printf("\nTest 7: yp_all\n"); + Callback.foreach=yptest_foreach; + Status = yp_all(Domain,Map,&Callback); +} + |