summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/Makefile5
-rw-r--r--usr.sbin/makedbm/Makefile11
-rw-r--r--usr.sbin/makedbm/TODO2
-rw-r--r--usr.sbin/ypserv/Makefile11
-rw-r--r--usr.sbin/ypserv/Makefile.inc4
-rw-r--r--usr.sbin/ypserv/common/ypdb.c (renamed from usr.sbin/ypserv/ypdb.c)2
-rw-r--r--usr.sbin/ypserv/common/ypdb.h (renamed from usr.sbin/ypserv/ypdb.h)2
-rw-r--r--usr.sbin/ypserv/common/ypdef.h (renamed from usr.sbin/ypserv/ypdef.h)2
-rw-r--r--usr.sbin/ypserv/common/yplib_host.c394
-rw-r--r--usr.sbin/ypserv/common/yplib_host.h59
-rw-r--r--usr.sbin/ypserv/common/yplog.c (renamed from usr.sbin/ypserv/yplog.c)2
-rw-r--r--usr.sbin/ypserv/common/yplog.h (renamed from usr.sbin/ypserv/yplog.h)2
-rw-r--r--usr.sbin/ypserv/makedbm/Makefile10
-rw-r--r--usr.sbin/ypserv/makedbm/TODO4
-rw-r--r--usr.sbin/ypserv/makedbm/makedbm.8 (renamed from usr.sbin/makedbm/makedbm.8)2
-rw-r--r--usr.sbin/ypserv/makedbm/makedbm.c (renamed from usr.sbin/makedbm/makedbm.c)14
-rw-r--r--usr.sbin/ypserv/stdhosts/Makefile (renamed from usr.sbin/stdhosts/Makefile)2
-rw-r--r--usr.sbin/ypserv/stdhosts/stdhosts.8 (renamed from usr.sbin/stdhosts/stdhosts.8)2
-rw-r--r--usr.sbin/ypserv/stdhosts/stdhosts.c (renamed from usr.sbin/stdhosts/stdhosts.c)2
-rw-r--r--usr.sbin/ypserv/ypinit/Makefile12
-rw-r--r--usr.sbin/ypserv/ypinit/Makefile.main8
-rw-r--r--usr.sbin/ypserv/ypinit/Makefile.yp172
-rw-r--r--usr.sbin/ypserv/ypinit/ypinit.sh210
-rw-r--r--usr.sbin/ypserv/ypserv.c311
-rw-r--r--usr.sbin/ypserv/ypserv/Makefile10
-rw-r--r--usr.sbin/ypserv/ypserv/acl.c (renamed from usr.sbin/ypserv/acl.c)2
-rw-r--r--usr.sbin/ypserv/ypserv/acl.h (renamed from usr.sbin/ypserv/acl.h)2
-rw-r--r--usr.sbin/ypserv/ypserv/securenet (renamed from usr.sbin/ypserv/securenet)0
-rw-r--r--usr.sbin/ypserv/ypserv/securenet.5 (renamed from usr.sbin/ypserv/securenet.5)2
-rw-r--r--usr.sbin/ypserv/ypserv/yp.h443
-rw-r--r--usr.sbin/ypserv/ypserv/ypserv.8 (renamed from usr.sbin/ypserv/ypserv.8)2
-rw-r--r--usr.sbin/ypserv/ypserv/ypserv.acl (renamed from usr.sbin/ypserv/ypserv.acl)0
-rw-r--r--usr.sbin/ypserv/ypserv/ypserv.acl.5 (renamed from usr.sbin/ypserv/ypserv.acl.5)2
-rw-r--r--usr.sbin/ypserv/ypserv/ypserv.c431
-rw-r--r--usr.sbin/ypserv/ypserv/ypserv_db.c (renamed from usr.sbin/ypserv/ypserv_db.c)2
-rw-r--r--usr.sbin/ypserv/ypserv/ypserv_proc.c (renamed from usr.sbin/ypserv/ypserv_proc.c)52
-rw-r--r--usr.sbin/ypserv/ypserv/ypserv_xdr.c75
-rw-r--r--usr.sbin/ypserv/ypserv_xdr.c364
-rw-r--r--usr.sbin/ypserv/yptest/Makefile7
-rw-r--r--usr.sbin/ypserv/yptest/yptest.861
-rw-r--r--usr.sbin/ypserv/yptest/yptest.c122
-rw-r--r--usr.sbin/ypserv/ypxfr/Makefile10
-rw-r--r--usr.sbin/ypserv/ypxfr/ypxfr.874
-rw-r--r--usr.sbin/ypserv/ypxfr/ypxfr.c624
-rw-r--r--usr.sbin/ypserv/ypxfr/ypxfr_xdr.c88
45 files changed, 2875 insertions, 743 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index 62c8292e6e0..718f008a9eb 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -1,5 +1,5 @@
# from: @(#)Makefile 5.6.1.2 (Berkeley) 5/8/91
-# $Id: Makefile,v 1.4 1995/10/28 14:15:22 deraadt Exp $
+# $Id: Makefile,v 1.5 1995/11/01 16:55:29 deraadt Exp $
# not yet done: catman
@@ -13,8 +13,7 @@ SUBDIR= ac accton arp bootpd bootpgw bootpef bootptest \
sa sendmail sliplogin slstats spray sysctl \
syslogd tcpdump timed traceroute trpt trsp update \
vipw vnconfig ypbind yppoll ypset \
- yppush ypserv yptest ypxfr stdhosts makedbm ypinit \
- zdump zic
+ ypserv zdump zic
# should be listed above, but doesn't work on the Alpha.
.if (${MACHINE_ARCH} != "alpha") || make(clean) || make(cleandir)
diff --git a/usr.sbin/makedbm/Makefile b/usr.sbin/makedbm/Makefile
deleted file mode 100644
index ae5ee3b7c9d..00000000000
--- a/usr.sbin/makedbm/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
-# $Id: Makefile,v 1.1 1995/10/23 07:46:12 deraadt Exp $
-
-PROG= makedbm
-SRCS= makedbm.c ypdb.c
-MAN= makedbm.8
-BINDIR= /usr/sbin
-.PATH: ${.CURDIR}/../../usr.sbin/ypserv
-CFLAGS+=-I${.CURDIR}/../../usr.sbin/ypserv
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/makedbm/TODO b/usr.sbin/makedbm/TODO
deleted file mode 100644
index d798c5c6a47..00000000000
--- a/usr.sbin/makedbm/TODO
+++ /dev/null
@@ -1,2 +0,0 @@
-Go through code and add error handling.
-
diff --git a/usr.sbin/ypserv/Makefile b/usr.sbin/ypserv/Makefile
index 2156b76daf3..4064026e630 100644
--- a/usr.sbin/ypserv/Makefile
+++ b/usr.sbin/ypserv/Makefile
@@ -1,9 +1,6 @@
-# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
-# $Id: Makefile,v 1.1 1995/10/23 07:46:34 deraadt Exp $
+# from: @(#)Makefile 5.6.1.2 (Berkeley) 5/8/91
+# $Id: Makefile,v 1.2 1995/11/01 16:56:03 deraadt Exp $
-PROG= ypserv
-SRCS= ypserv.c ypserv_xdr.c ypserv_proc.c ypserv_db.c acl.c yplog.c ypdb.c
-MAN= ypserv.acl.5 securenet.5 ypserv.8
-CFLAGS+=-DDAEMON -DOPTDB
+SUBDIR= makedbm stdhosts ypinit ypserv yptest ypxfr
-.include <bsd.prog.mk>
+.include <bsd.subdir.mk>
diff --git a/usr.sbin/ypserv/Makefile.inc b/usr.sbin/ypserv/Makefile.inc
new file mode 100644
index 00000000000..8ac3c3cf2ef
--- /dev/null
+++ b/usr.sbin/ypserv/Makefile.inc
@@ -0,0 +1,4 @@
+# from: @(#)Makefile.inc 5.1 (Berkeley) 5/11/90
+# $Id: Makefile.inc,v 1.1 1995/11/01 16:56:04 deraadt Exp $
+
+BINDIR?= /usr/sbin
diff --git a/usr.sbin/ypserv/ypdb.c b/usr.sbin/ypserv/common/ypdb.c
index 9ac9aac8af4..bf50d7c231b 100644
--- a/usr.sbin/ypserv/ypdb.c
+++ b/usr.sbin/ypserv/common/ypdb.c
@@ -38,7 +38,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ypdb.c,v 1.1 1995/10/23 07:46:39 deraadt Exp $
+ * $Id: ypdb.c,v 1.1 1995/11/01 16:56:16 deraadt Exp $
*/
#include <sys/param.h>
diff --git a/usr.sbin/ypserv/ypdb.h b/usr.sbin/ypserv/common/ypdb.h
index 00f9ecd27ae..c8cb8b06651 100644
--- a/usr.sbin/ypserv/ypdb.h
+++ b/usr.sbin/ypserv/common/ypdb.h
@@ -38,7 +38,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ypdb.h,v 1.1 1995/10/23 07:46:40 deraadt Exp $
+ * $Id: ypdb.h,v 1.1 1995/11/01 16:56:17 deraadt Exp $
*/
#ifndef _YPDB_H_
diff --git a/usr.sbin/ypserv/ypdef.h b/usr.sbin/ypserv/common/ypdef.h
index 77c9488e3c1..0fe79bbc93f 100644
--- a/usr.sbin/ypserv/ypdef.h
+++ b/usr.sbin/ypserv/common/ypdef.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ypdef.h,v 1.1 1995/10/23 07:46:40 deraadt Exp $
+ * $Id: ypdef.h,v 1.1 1995/11/01 16:56:17 deraadt Exp $
*/
#ifndef _YPDEF_H_
diff --git a/usr.sbin/ypserv/common/yplib_host.c b/usr.sbin/ypserv/common/yplib_host.c
new file mode 100644
index 00000000000..2ef86099e70
--- /dev/null
+++ b/usr.sbin/ypserv/common/yplib_host.c
@@ -0,0 +1,394 @@
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Theo de Raadt.
+ * 4. 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: yplib_host.c,v 1.1 1995/11/01 16:56:18 deraadt Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/file.h>
+#include <sys/uio.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp_prot.h>
+#include <rpcsvc/ypclnt.h>
+
+extern bool_t xdr_domainname(), xdr_ypbind_resp();
+extern bool_t xdr_ypreq_key(), xdr_ypresp_val();
+extern bool_t xdr_ypreq_nokey(), xdr_ypresp_key_val();
+extern bool_t xdr_ypresp_all(), xdr_ypresp_all_seq();
+extern bool_t xdr_ypresp_master();
+
+extern int (*ypresp_allfn)();
+extern void *ypresp_data;
+
+int _yplib_host_timeout = 10;
+
+CLIENT *
+yp_bind_host(server,program,version,port)
+char *server;
+u_long program,version;
+u_short port;
+{
+ struct sockaddr_in rsrv_sin;
+ int rsrv_sock;
+ struct hostent *h;
+ struct timeval tv;
+ static CLIENT *client;
+
+ memset(&rsrv_sin, 0, sizeof rsrv_sin);
+ rsrv_sin.sin_len = sizeof rsrv_sin;
+ rsrv_sin.sin_family = AF_INET;
+ rsrv_sock = RPC_ANYSOCK;
+ if (port != 0) {
+ rsrv_sin.sin_port = htons(port);
+ }
+
+ if ((*server >= '0') && (*server <= '9')) {
+ if(inet_aton(server,&rsrv_sin.sin_addr) == 0) {
+ fprintf(stderr, "inet_aton: invalid address %s.\n",
+ server);
+ exit(1);
+ }
+ } else {
+ h = gethostbyname(server);
+ if(h == NULL) {
+ fprintf(stderr, "gethostbyname: unknown host %s.\n",
+ server);
+ exit(1);
+ }
+ rsrv_sin.sin_addr.s_addr = *(u_long*)h->h_addr;
+ }
+
+ tv.tv_sec = 10;
+ tv.tv_usec = 0;
+
+ client = clntudp_create(&rsrv_sin, program, version, tv, &rsrv_sock);
+ if (client == NULL) {
+ fprintf(stderr, "clntudp_create: no contact with host %s.\n",
+ server);
+ exit(1);
+ }
+
+ return(client);
+
+}
+
+CLIENT *
+yp_bind_local(program,version)
+u_long program,version;
+{
+ struct sockaddr_in rsrv_sin;
+ int rsrv_sock;
+ struct timeval tv;
+ static CLIENT *client;
+
+ memset(&rsrv_sin, 0, sizeof rsrv_sin);
+ rsrv_sin.sin_len = sizeof rsrv_sin;
+ rsrv_sin.sin_family = AF_INET;
+ rsrv_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ rsrv_sock = RPC_ANYSOCK;
+
+ tv.tv_sec = 10;
+ tv.tv_usec = 0;
+
+ client = clntudp_create(&rsrv_sin, program, version, tv, &rsrv_sock);
+ if (client == NULL) {
+ fprintf(stderr,"clntudp_create: no contact with localhost.\n");
+ exit(1);
+ }
+
+ return(client);
+
+}
+
+int
+yp_match_host(client, indomain, inmap, inkey, inkeylen, outval, outvallen)
+CLIENT *client;
+char *indomain;
+char *inmap;
+const char *inkey;
+int inkeylen;
+char **outval;
+int *outvallen;
+{
+ struct ypresp_val yprv;
+ struct timeval tv;
+ struct ypreq_key yprk;
+ int r;
+
+ *outval = NULL;
+ *outvallen = 0;
+
+ tv.tv_sec = _yplib_host_timeout;
+ tv.tv_usec = 0;
+
+ yprk.domain = indomain;
+ yprk.map = inmap;
+ yprk.keydat.dptr = (char *)inkey;
+ yprk.keydat.dsize = inkeylen;
+
+ memset(&yprv, 0, sizeof yprv);
+
+ r = clnt_call(client, YPPROC_MATCH,
+ xdr_ypreq_key, &yprk, xdr_ypresp_val, &yprv, tv);
+ if(r != RPC_SUCCESS) {
+ clnt_perror(client, "yp_match_host: clnt_call");
+ }
+ if( !(r=ypprot_err(yprv.status)) ) {
+ *outvallen = yprv.valdat.dsize;
+ *outval = (char *)malloc(*outvallen+1);
+ memcpy(*outval, yprv.valdat.dptr, *outvallen);
+ (*outval)[*outvallen] = '\0';
+ }
+ xdr_free(xdr_ypresp_val, (char *)&yprv);
+ return r;
+}
+
+int
+yp_first_host(client, indomain, inmap, outkey, outkeylen, outval, outvallen)
+CLIENT *client;
+char *indomain;
+char *inmap;
+char **outkey;
+int *outkeylen;
+char **outval;
+int *outvallen;
+{
+ struct ypresp_key_val yprkv;
+ struct ypreq_nokey yprnk;
+ struct timeval tv;
+ int r;
+
+ *outkey = *outval = NULL;
+ *outkeylen = *outvallen = 0;
+
+ tv.tv_sec = _yplib_host_timeout;
+ tv.tv_usec = 0;
+
+ yprnk.domain = indomain;
+ yprnk.map = inmap;
+ memset(&yprkv, 0, sizeof yprkv);
+
+ r = clnt_call(client, YPPROC_FIRST,
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_key_val, &yprkv, tv);
+ if(r != RPC_SUCCESS) {
+ clnt_perror(client, "yp_first_host: clnt_call");
+ }
+ if( !(r=ypprot_err(yprkv.status)) ) {
+ *outkeylen = yprkv.keydat.dsize;
+ *outkey = (char *)malloc(*outkeylen+1);
+ memcpy(*outkey, yprkv.keydat.dptr, *outkeylen);
+ (*outkey)[*outkeylen] = '\0';
+ *outvallen = yprkv.valdat.dsize;
+ *outval = (char *)malloc(*outvallen+1);
+ memcpy(*outval, yprkv.valdat.dptr, *outvallen);
+ (*outval)[*outvallen] = '\0';
+ }
+ xdr_free(xdr_ypresp_key_val, (char *)&yprkv);
+ return r;
+}
+
+int
+yp_next_host(client, indomain, inmap, inkey, inkeylen, outkey, outkeylen, outval, outvallen)
+CLIENT *client;
+char *indomain;
+char *inmap;
+char *inkey;
+int inkeylen;
+char **outkey;
+int *outkeylen;
+char **outval;
+int *outvallen;
+{
+ struct ypresp_key_val yprkv;
+ struct ypreq_key yprk;
+ struct timeval tv;
+ int r;
+
+ *outkey = *outval = NULL;
+ *outkeylen = *outvallen = 0;
+
+ tv.tv_sec = _yplib_host_timeout;
+ tv.tv_usec = 0;
+
+ yprk.domain = indomain;
+ yprk.map = inmap;
+ yprk.keydat.dptr = inkey;
+ yprk.keydat.dsize = inkeylen;
+ memset(&yprkv, 0, sizeof yprkv);
+
+ r = clnt_call(client, YPPROC_NEXT,
+ xdr_ypreq_key, &yprk, xdr_ypresp_key_val, &yprkv, tv);
+ if(r != RPC_SUCCESS) {
+ clnt_perror(client, "yp_next_host: clnt_call");
+ }
+ if( !(r=ypprot_err(yprkv.status)) ) {
+ *outkeylen = yprkv.keydat.dsize;
+ *outkey = (char *)malloc(*outkeylen+1);
+ memcpy(*outkey, yprkv.keydat.dptr, *outkeylen);
+ (*outkey)[*outkeylen] = '\0';
+ *outvallen = yprkv.valdat.dsize;
+ *outval = (char *)malloc(*outvallen+1);
+ memcpy(*outval, yprkv.valdat.dptr, *outvallen);
+ (*outval)[*outvallen] = '\0';
+ }
+ xdr_free(xdr_ypresp_key_val, (char *)&yprkv);
+ return r;
+}
+
+int
+yp_all_host(client, indomain, inmap, incallback)
+CLIENT *client;
+char *indomain;
+char *inmap;
+struct ypall_callback *incallback;
+{
+ struct ypreq_nokey yprnk;
+ struct timeval tv;
+ u_long status;
+
+ tv.tv_sec = _yplib_host_timeout;
+ tv.tv_usec = 0;
+
+ yprnk.domain = indomain;
+ yprnk.map = inmap;
+ ypresp_allfn = incallback->foreach;
+ ypresp_data = (void *)incallback->data;
+
+ (void) clnt_call(client, YPPROC_ALL,
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_all_seq, &status, tv);
+ xdr_free(xdr_ypresp_all_seq, (char *)&status); /* not really needed... */
+
+ if(status != YP_FALSE)
+ return ypprot_err(status);
+ return 0;
+}
+
+int
+yp_order_host(client, indomain, inmap, outorder)
+CLIENT *client;
+char *indomain;
+char *inmap;
+int *outorder;
+{
+ struct ypresp_order ypro;
+ struct ypreq_nokey yprnk;
+ struct timeval tv;
+ int r;
+
+ tv.tv_sec = _yplib_host_timeout;
+ tv.tv_usec = 0;
+
+ yprnk.domain = indomain;
+ yprnk.map = inmap;
+
+ memset(&ypro, 0, sizeof ypro);
+
+ r = clnt_call(client, YPPROC_ORDER,
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_order, &ypro, tv);
+ if(r != RPC_SUCCESS) {
+ clnt_perror(client, "yp_order_host: clnt_call");
+ }
+
+ *outorder = ypro.ordernum;
+ xdr_free(xdr_ypresp_order, (char *)&ypro);
+ return ypprot_err(ypro.status);
+}
+
+int
+yp_master_host(client, indomain, inmap, outname)
+CLIENT *client;
+char *indomain;
+char *inmap;
+char **outname;
+{
+ struct ypresp_master yprm;
+ struct ypreq_nokey yprnk;
+ struct timeval tv;
+ int r;
+
+ tv.tv_sec = _yplib_host_timeout;
+ tv.tv_usec = 0;
+
+ yprnk.domain = indomain;
+ yprnk.map = inmap;
+
+ memset(&yprm, 0, sizeof yprm);
+
+ r = clnt_call(client, YPPROC_MASTER,
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_master, &yprm, tv);
+ if(r != RPC_SUCCESS) {
+ clnt_perror(client, "yp_master: clnt_call");
+ }
+ if( !(r=ypprot_err(yprm.status)) ) {
+ *outname = (char *)strdup(yprm.master);
+ }
+ xdr_free(xdr_ypresp_master, (char *)&yprm);
+ return r;
+}
+
+int
+yp_maplist_host(client, indomain, outmaplist)
+CLIENT *client;
+char *indomain;
+struct ypmaplist **outmaplist;
+{
+ struct ypresp_maplist ypml;
+ struct timeval tv;
+ int r;
+
+ tv.tv_sec = _yplib_host_timeout;
+ tv.tv_usec = 0;
+
+ memset(&ypml, 0, sizeof ypml);
+
+ r = clnt_call(client, YPPROC_MAPLIST,
+ xdr_domainname, indomain, xdr_ypresp_maplist, &ypml, tv);
+ if (r != RPC_SUCCESS) {
+ clnt_perror(client, "yp_maplist: clnt_call");
+ }
+ *outmaplist = ypml.list;
+ /* NO: xdr_free(xdr_ypresp_maplist, &ypml);*/
+ return ypprot_err(ypml.status);
+}
+
diff --git a/usr.sbin/ypserv/common/yplib_host.h b/usr.sbin/ypserv/common/yplib_host.h
new file mode 100644
index 00000000000..54d8d66a9bc
--- /dev/null
+++ b/usr.sbin/ypserv/common/yplib_host.h
@@ -0,0 +1,59 @@
+/* $NetBSD: yplib_host.h,v 1.6 1994/10/26 00:57:11 cgd Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Theo de Raadt.
+ * 4. 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 _YPLIB_HOST_H_
+#define _YPLIB_HOST_H_
+
+int yp_match_host __P((CLIENT *client, char *indomain, char *inmap,
+ const char *inkey, int inkeylen, char **outval,
+ int *outvallen));
+int yp_first_host __P((CLIENT *client, char *indomain, char *inmap,
+ char **outkey, int *outkeylen, char **outval,
+ int *outvallen));
+int yp_next_host __P((CLIENT *client, char *indomain, char *inmap,
+ char *inkey, int inkeylen, char **outkey,
+ int *outkeylen, char **outval, int *outvallen));
+int yp_master_host __P((CLIENT *client,
+ char *indomain, char *inmap, char **outname));
+int yp_order_host __P((CLIENT *client,
+ char *indomain, char *inmap, int *outorder));
+int yp_all_host __P((CLIENT *client, char *indomain, char *inmap,
+ struct ypall_callback *incallback));
+int yp_maplist_host __P((CLIENT *client, char *indomain,
+ struct ypmaplist **outmaplist));
+CLIENT *yp_bind_local __P((u_long program, u_long version));
+CLIENT *yp_bind_host __P((char *server, u_long program, u_long version,
+ u_short port));
+
+#endif /* _YPLIB_HOST_H_ */
+
diff --git a/usr.sbin/ypserv/yplog.c b/usr.sbin/ypserv/common/yplog.c
index 913c4809d6a..59ec35becd5 100644
--- a/usr.sbin/ypserv/yplog.c
+++ b/usr.sbin/ypserv/common/yplog.c
@@ -28,7 +28,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$Id: yplog.c,v 1.1 1995/10/23 07:46:41 deraadt Exp $";
+static char rcsid[] = "$Id: yplog.c,v 1.1 1995/11/01 16:56:20 deraadt Exp $";
#endif
#include <stdio.h>
diff --git a/usr.sbin/ypserv/yplog.h b/usr.sbin/ypserv/common/yplog.h
index 0c9b4893e49..77b1ea46097 100644
--- a/usr.sbin/ypserv/yplog.h
+++ b/usr.sbin/ypserv/common/yplog.h
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: yplog.h,v 1.1 1995/10/23 07:46:41 deraadt Exp $
+ * $Id: yplog.h,v 1.1 1995/11/01 16:56:21 deraadt Exp $
*/
#ifndef _YPLOG_H_
diff --git a/usr.sbin/ypserv/makedbm/Makefile b/usr.sbin/ypserv/makedbm/Makefile
new file mode 100644
index 00000000000..1cfecd42606
--- /dev/null
+++ b/usr.sbin/ypserv/makedbm/Makefile
@@ -0,0 +1,10 @@
+# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
+# $Id: Makefile,v 1.1 1995/11/01 16:56:22 deraadt Exp $
+
+PROG= makedbm
+SRCS= makedbm.c ypdb.c
+MAN= makedbm.8
+.PATH: ${.CURDIR}/../common
+CFLAGS+=-I${.CURDIR}/../common
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/ypserv/makedbm/TODO b/usr.sbin/ypserv/makedbm/TODO
new file mode 100644
index 00000000000..be0d219069e
--- /dev/null
+++ b/usr.sbin/ypserv/makedbm/TODO
@@ -0,0 +1,4 @@
+Go through code and add error handling.
+
+fgets in read_line in create_db coredumps if file don't exists. (Fixed 950908)
+
diff --git a/usr.sbin/makedbm/makedbm.8 b/usr.sbin/ypserv/makedbm/makedbm.8
index 8fe2bd3f092..de1a1082862 100644
--- a/usr.sbin/makedbm/makedbm.8
+++ b/usr.sbin/ypserv/makedbm/makedbm.8
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: makedbm.8,v 1.1 1995/10/23 07:46:13 deraadt Exp $
+.\" $Id: makedbm.8,v 1.1 1995/11/01 16:56:23 deraadt Exp $
.\"
.Dd July 19, 1994
.Dt MAKEDBM 8
diff --git a/usr.sbin/makedbm/makedbm.c b/usr.sbin/ypserv/makedbm/makedbm.c
index 33b597b2415..35242781bae 100644
--- a/usr.sbin/makedbm/makedbm.c
+++ b/usr.sbin/ypserv/makedbm/makedbm.c
@@ -28,7 +28,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$Id: makedbm.c,v 1.1 1995/10/23 07:46:14 deraadt Exp $";
+static char rcsid[] = "$Id: makedbm.c,v 1.1 1995/11/01 16:56:24 deraadt Exp $";
#endif
#include <stdio.h>
@@ -37,6 +37,7 @@ static char rcsid[] = "$Id: makedbm.c,v 1.1 1995/10/23 07:46:14 deraadt Exp $";
#include <sys/stat.h>
#include <unistd.h>
#include <strings.h>
+#include <sys/errno.h>
#include "ypdb.h"
#include "ypdef.h"
@@ -109,7 +110,7 @@ add_record(db, str1, str2, check)
}
if (status != 0) {
- printf("makedbm: problem storing %s %s\n",str1,str2);
+ printf("%s: problem storing %s %s\n",ProgramName,str1,str2);
exit(1);
}
}
@@ -127,7 +128,7 @@ file_date(filename)
} else {
status = stat(filename, &finfo);
if (status < 0) {
- fprintf(stderr, "makedbm: can't stat %s\n", filename);
+ fprintf(stderr, "%s: can't stat %s\n", ProgramName, filename);
exit(1);
}
sprintf(datestr, "%010d", finfo.st_mtime);
@@ -146,7 +147,7 @@ list_database(database)
db = ypdb_open(database, O_RDONLY, 0444);
if (db == NULL) {
- fprintf(stderr, "makedbm: can't open database %s\n", database);
+ fprintf(stderr, "%s: can't open database %s\n", ProgramName, database);
exit(1);
}
@@ -191,6 +192,11 @@ create_database(infile,database,
data_file = stdin;
} else {
data_file = fopen(infile, "r");
+ if (errno != 0) {
+ (void)fprintf(stderr,"%s: ",ProgramName);
+ perror(infile);
+ exit(1);
+ }
}
j = 0;
diff --git a/usr.sbin/stdhosts/Makefile b/usr.sbin/ypserv/stdhosts/Makefile
index 60e878a5c53..e4712050962 100644
--- a/usr.sbin/stdhosts/Makefile
+++ b/usr.sbin/ypserv/stdhosts/Makefile
@@ -1,5 +1,5 @@
# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
-# $Id: Makefile,v 1.1 1995/10/23 07:46:22 deraadt Exp $
+# $Id: Makefile,v 1.1 1995/11/01 16:56:25 deraadt Exp $
PROG= stdhosts
MAN= stdhosts.8
diff --git a/usr.sbin/stdhosts/stdhosts.8 b/usr.sbin/ypserv/stdhosts/stdhosts.8
index 4634f80aded..78168ddea81 100644
--- a/usr.sbin/stdhosts/stdhosts.8
+++ b/usr.sbin/ypserv/stdhosts/stdhosts.8
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: stdhosts.8,v 1.1 1995/10/23 07:46:22 deraadt Exp $
+.\" $Id: stdhosts.8,v 1.1 1995/11/01 16:56:26 deraadt Exp $
.\"
.Dd August 25, 1994
.Dt STDHOSTS 8
diff --git a/usr.sbin/stdhosts/stdhosts.c b/usr.sbin/ypserv/stdhosts/stdhosts.c
index fe17b0ce465..7adf1f74695 100644
--- a/usr.sbin/stdhosts/stdhosts.c
+++ b/usr.sbin/ypserv/stdhosts/stdhosts.c
@@ -28,7 +28,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$Id: stdhosts.c,v 1.1 1995/10/23 07:46:23 deraadt Exp $";
+static char rcsid[] = "$Id: stdhosts.c,v 1.1 1995/11/01 16:56:26 deraadt Exp $";
#endif
#include <sys/types.h>
diff --git a/usr.sbin/ypserv/ypinit/Makefile b/usr.sbin/ypserv/ypinit/Makefile
new file mode 100644
index 00000000000..618ebfd4132
--- /dev/null
+++ b/usr.sbin/ypserv/ypinit/Makefile
@@ -0,0 +1,12 @@
+# from: @(#)Makefile 5.3 (Berkeley) 6/22/90
+# $Id: Makefile,v 1.1 1995/11/01 16:56:27 deraadt Exp $
+
+FILES= Makefile.main Makefile.yp
+NOOBJ= noobj
+
+install:
+ install -c -o root -g wheel -m 751 ${FILES} ${DESTDIR}/var/yp
+ install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${.CURDIR}/ypinit.sh ${DESTDIR}/usr/sbin/ypinit
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/ypserv/ypinit/Makefile.main b/usr.sbin/ypserv/ypinit/Makefile.main
new file mode 100644
index 00000000000..c7dd091871d
--- /dev/null
+++ b/usr.sbin/ypserv/ypinit/Makefile.main
@@ -0,0 +1,8 @@
+# from: @(#)Makefile 5.6.1.2 (Berkeley) 5/8/91
+# $Id: Makefile.main,v 1.1 1995/11/01 16:56:28 deraadt Exp $
+
+SUBDIR=
+
+passwd group hosts networks rpc services protocols: _SUBDIRUSE
+
+.include <bsd.subdir.mk>
diff --git a/usr.sbin/ypserv/ypinit/Makefile.yp b/usr.sbin/ypserv/ypinit/Makefile.yp
new file mode 100644
index 00000000000..5df9f91c4ad
--- /dev/null
+++ b/usr.sbin/ypserv/ypinit/Makefile.yp
@@ -0,0 +1,172 @@
+# from: @(#)Makefile 5.6.1.2 (Berkeley) 5/8/91
+# $Id: Makefile.yp,v 1.1 1995/11/01 16:56:28 deraadt Exp $
+
+YPDBDIR=/var/yp
+DIR=/etc
+NOPUSH=""
+#
+AWK=/usr/bin/awk
+CAT=/bin/cat
+CUT=/usr/bin/cut
+ECHO=/bin/echo
+MAKEDBM=/usr/sbin/makedbm
+SED=/usr/bin/sed
+STDHOSTS=/usr/sbin/stdhosts
+TOUCH=/usr/bin/touch
+YPPUSH=$(ECHO) "YPPUSH Not Yet Implemented: "
+
+all: passwd group hosts networks rpc services protocols
+
+passwd.time: $(DIR)/master.passwd
+ -@if [ -f $(>) ]; then \
+ $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 | \
+ $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
+ { print $$1, $$0 }' - | $(MAKEDBM) - passwd.byname; \
+ $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 |\
+ $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
+ { print $$3, $$0 }' - | $(MAKEDBM) - passwd.byuid; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated passwd"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) passwd.byname; \
+ $(YPPUSH) passwd.byuid; \
+ $(ECHO) "pushed passwd"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+
+group.time: $(DIR)/group
+ -@if [ -f $(>) ]; then \
+ $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
+ { print $$1, $$0 }' $(>) | \
+ $(MAKEDBM) - group.byname; \
+ $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
+ { print $$3, $$0 }' $(>) | \
+ $(MAKEDBM) - group.bygid; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated group"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) group.byname; \
+ $(YPPUSH) group.bygid; \
+ $(ECHO) "pushed group"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+hosts.time: $(DIR)/hosts
+ -@if [ -f $(DIR)/hosts ]; then \
+ $(STDHOSTS) $(>) | $(SED) -e s/#.*$$// | \
+ $(AWK) '{for (i = 2; i <= NF; i++) print $$i, $$0 }' | \
+ $(MAKEDBM) - hosts.byname; \
+ $(STDHOSTS) $(>) | \
+ $(AWK) 'BEGIN { OFS="\t"; } { print $$1, $$0 }' | \
+ $(MAKEDBM) - hosts.byaddr; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated hosts"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) hosts.byname; \
+ $(YPPUSH) hosts.byaddr; \
+ $(ECHO) "pushed hosts"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+networks.time: $(DIR)/networks
+ -@if [ -f $(>) ]; then \
+ $(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
+ $(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
+ $(MAKEDBM) - networks.byname; \
+ $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
+ $(MAKEDBM) - networks.byaddr; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated networks"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) networks.byname; \
+ $(YPPUSH) networks.byaddr; \
+ $(ECHO) "pushed networks"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+rpc.time: $(DIR)/rpc
+ -@if [ -f $(>) ]; then \
+ $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
+ $(MAKEDBM) - rpc.bynumber; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated rpc"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) rpc.bynumber; \
+ $(ECHO) "pushed rpc"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+
+services.time: $(DIR)/services
+ -@if [ -f $(>) ]; then \
+ $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
+ $(MAKEDBM) - services.byname; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated services"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) services.byname; \
+ $(ECHO) "pushed services"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+
+protocols.time: $(DIR)/protocols
+ -@if [ -f $(>) ]; then \
+ $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
+ $(MAKEDBM) - protocols.bynumber; \
+ $(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
+ $(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
+ $(MAKEDBM) - protocols.byname; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated protocols"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) protocols.bynumber; \
+ $(YPPUSH) protocols.byname; \
+ $(ECHO) "pushed protocols"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+
+passwd: passwd.time
+group: group.time
+hosts: hosts.time
+networks: networks.time
+rpc: rpc.time
+services: services.time
+protocols: protocols.time
+$(DIR)/passwd:
+$(DIR)/group:
+$(DIR)/hosts:
+$(DIR)/networks:
+$(DIR)/rpc:
+$(DIR)/services:
+$(DIR)/protocols:
diff --git a/usr.sbin/ypserv/ypinit/ypinit.sh b/usr.sbin/ypserv/ypinit/ypinit.sh
new file mode 100644
index 00000000000..e6211f67a1a
--- /dev/null
+++ b/usr.sbin/ypserv/ypinit/ypinit.sh
@@ -0,0 +1,210 @@
+#!/bin/sh
+# $Id: ypinit.sh,v 1.1 1995/11/01 16:56:29 deraadt Exp $
+#
+# ypinit.sh - setup an master or slave server.
+#
+DOMAINNAME=/bin/domainname
+HOSTNAME=/bin/hostname
+YPWHICH=/usr/bin/ypwhich
+YPXFR=/usr/sbin/ypxfr
+YP_DIR=/var/yp
+
+#set -xv
+
+ERROR=USAGE # assume usage error
+
+if [ $# -eq 1 ]
+then
+ if [ $1 = "-m" ] # ypinit -m
+ then
+ DOMAIN=`${DOMAINNAME}`
+ SERVERTYPE=MASTER
+ ERROR=
+ fi
+fi
+
+if [ $# -eq 2 ]
+then
+ if [ $1 = "-m" ] # ypinit -m domainname
+ then
+ DOMAIN=${2}
+ SERVERTYPE=MASTER
+ ERROR=
+ fi
+ if [ $1 = "-s" ] # ypinit -s master_server
+ then
+ DOMAIN=`${DOMAINNAME}`
+ SERVERTYPE=SLAVE
+ MASTER=${2}
+ ERROR=
+ fi
+fi
+
+if [ $# -eq 3 ]
+then
+ if [ $1 = "-s" ] # ypinit -s master_server domainname
+ then
+ DOMAIN=`${3}`
+ SERVERTYPE=MASTER
+ MASTER=${2}
+ ERROR=
+ fi
+fi
+
+if [ "${ERROR}" = "USAGE" ]
+then
+ echo "usage: ypinit -m [domainname]" 1>&2
+ echo " ypinit -s master_server [domainname]" 1>&2
+ echo "" 1>&2
+ echo "\
+where -m is used to build a master YP server data base, and -s is used for" 1>&2
+ echo "\
+a slave data base. master_server must be an existing reachable YP server." 1>&2
+ exit 1
+fi
+
+# Just allow master server for now!
+
+#if [ "${SERVERTYPE}" != "MASTER" ];
+#then
+# echo "Sorry, only master server is implemented. Support for slave server" 1>&2
+# echo "needs support for map transfer which isn't implemented yet." 1>&2
+# exit 1
+#fi
+
+# Check if domainname is set, don't accept an empty domainname
+
+if [ -z "${DOMAIN}" ]
+then
+ echo "The local host's domain name hasn't been set. Please set it." 1>&2
+ exit 1
+fi
+
+# Check if hostname is set, don't accept an empty hostname
+
+HOST=`${HOSTNAME}`
+
+if [ -z "${HOST}" ]
+then
+ echo "The local host's name hasn't been set. Please set it." 1>&2
+ exit 1
+fi
+
+# Check if the YP directory exists.
+
+if [ ! -d ${YP_DIR} -o -f ${YP_DIR} ]
+then
+ echo "The directory ${YP_DIR} doesn't exist. Restore it from the distribution." 1>&2
+ exit 1
+
+fi
+
+#echo "Server Type: ${SERVERTYPE} Domain: ${DOMAIN} Master: ${MASTER}"
+
+echo "Installing the YP data base will require that you answer a few questions."
+echo "Questions will all be asked at the beginning of the procedure."
+echo ""
+
+if [ -d ${YP_DIR}/${DOMAIN} ]; then
+
+ echo -n "Can we destroy the existing ${YP_DIR}/${DOMAIN} and its contents? [y/n: n] "
+ read KILL
+
+ ERROR=
+ case ${KILL} in
+ y*) ERROR=DELETE;;
+ Y*) ERROR=DELETE;;
+ *) ERROR=;;
+ esac
+
+ if [ -z "${ERROR}" ]
+ then
+ echo "OK, please clean it up by hand and start again. Bye"
+ exit 0
+ fi
+
+ if [ "${ERROR}" = "DELETE" ]
+ then
+ rm -r -f ${YP_DIR}/${DOMAIN}
+
+ if [ $? -ne 0 ]
+ then
+ echo "Can't clean up old directory ${YP_DIR}/${DOMAIN}. Fatal error." 1>&2
+ exit 1
+ fi
+ fi
+
+fi
+
+mkdir ${YP_DIR}/${DOMAIN}
+
+if [ $? -ne 0 ]
+then
+ echo "Can't make new directory ${YP_DIR}/${DOMAIN}. Fatal error." 1>&2
+ exit 1
+fi
+
+if [ "${SERVERTYPE}" = "MASTER" ];
+then
+
+ if [ ! -f ${YP_DIR}/Makefile ]
+ then
+ if [ ! -f ${YP_DIR}/Makefile.main ]
+ then
+ echo "Can't find ${YP_DIR}/Makefile.main. " 1>&2
+ exit 1
+ fi
+ cp ${YP_DIR}/Makefile.main ${YP_DIR}/Makefile
+ fi
+
+ SUBDIR=`grep "^SUBDIR=" ${YP_DIR}/Makefile`
+
+ if [ -z "${SUBDIR}" ]
+ then
+ echo "Can't find line starting with 'SUBDIR=' in ${YP_DIR}/Makefile. " 1>&2
+ exit 1
+ fi
+
+ NEWSUBDIR="SUBDIR="
+ for DIR in `echo ${SUBDIR} | cut -c8-255`
+ do
+ if [ ${DIR} != ${DOMAIN} ]
+ then
+ NEWSUBDIR="${NEWSUBDIR} ${DIR}"
+ fi
+ done
+ NEWSUBDIR="${NEWSUBDIR} ${DOMAIN}"
+
+ if [ -f ${YP_DIR}/Makefile.tmp ]
+ then
+ rm ${YP_DIR}/Makefile.tmp
+ fi
+
+ mv ${YP_DIR}/Makefile ${YP_DIR}/Makefile.tmp
+ sed -e "s/^${SUBDIR}/${NEWSUBDIR}/" ${YP_DIR}/Makefile.tmp > ${YP_DIR}/Makefile
+ rm ${YP_DIR}/Makefile.tmp
+
+ if [ ! -f ${YP_DIR}/Makefile.yp ]
+ then
+ echo "Can't find ${YP_DIR}/Makefile.yp. " 1>&2
+ exit 1
+ fi
+
+ cp ${YP_DIR}/Makefile.yp ${YP_DIR}/${DOMAIN}/Makefile
+
+fi
+
+if [ "${SERVERTYPE}" = "SLAVE" ];
+then
+
+ for MAP in `${YPWHICH} -d ${DOMAIN} -m | cut -d\ -f1`
+ do
+ ${YPXFR} -h ${MASTER} -c -d ${DOMAIN} ${MAP}
+
+ if [ $? -ne 0 ]
+ then
+ echo "Can't transfer map ${MAP}." 1>&2
+ exit 1
+ fi
+ done
+fi
diff --git a/usr.sbin/ypserv/ypserv.c b/usr.sbin/ypserv/ypserv.c
deleted file mode 100644
index fed9fe96666..00000000000
--- a/usr.sbin/ypserv/ypserv.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * 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: ypserv.c,v 1.1 1995/10/23 07:46:44 deraadt Exp $";
-#endif
-
-#include <stdio.h>
-#include <rpc/rpc.h>
-#include <rpc/auth.h>
-#include <rpcsvc/yp.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <string.h>
-#include <rpc/pmap_clnt.h>
-#include "acl.h"
-#include "yplog.h"
-
-#define YP_SECURENET_FILE "/var/yp/securenet"
-
-static void ypprog_2();
-void sig_child();
-
-int usedns = FALSE;
-int acl_access_ok;
-char *progname = "ypserv";
-
-int
-main (argc,argv)
-int argc;
-char *argv[];
-{
- SVCXPRT *transp;
- int usage = 0;
- int xflag = 0;
- char ch;
- extern char *optarg;
- char *aclfile = NULL;
-
- while ((ch = getopt(argc, argv, "a:dx")) != EOF)
- switch (ch) {
- case 'a':
- aclfile = optarg;
- break;
- case 'd':
- usedns = TRUE;
- break;
- case 'x':
- xflag = TRUE;
- break;
- default:
- usage++;
- break;
- }
-
- if (usage) {
- (void)fprintf(stderr,"usage: %s [-a aclfile] [-d] [-x]\n",progname);
- exit(1);
- }
-
- if (geteuid() != 0) {
- (void)fprintf(stderr,"%s: must be root to run.\n",progname);
- exit(1);
- }
-
- if (aclfile != NULL) {
- (void)acl_init(aclfile);
- } else {
- (void)acl_securenet(YP_SECURENET_FILE);
- }
- if (xflag) {
- exit(1);
- };
-
-#ifdef DAEMON
- switch(fork()) {
- case 0:
- break;
- case -1:
- (void)fprintf(stderr,"%s: fork failure\n",progname);
- exit(1);
- default:
- exit(0);
- }
- setsid();
-#endif
-
- yplog_init(progname);
-
- chdir("/");
-
- (void)pmap_unset(YPPROG, YPVERS);
-
- (void)signal(SIGCHLD, sig_child);
-
- transp = svctcp_create(RPC_ANYSOCK, 0, 0);
- if (transp == NULL) {
- (void)fprintf(stderr, "cannot create tcp service.\n");
- exit(1);
- }
- if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, IPPROTO_TCP)) {
- (void)fprintf(stderr, "unable to register (YPPROG, YPVERS, tcp).\n");
- exit(1);
- }
-
- transp = svcudp_create(RPC_ANYSOCK);
- if (transp == NULL) {
- (void)fprintf(stderr, "cannot create udp service.\n");
- exit(1);
- }
- if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, IPPROTO_UDP)) {
- (void)fprintf(stderr, "unable to register (YPPROG, YPVERS, udp).\n");
- exit(1);
- }
- svc_run();
- (void)fprintf(stderr, "svc_run returned\n");
- exit(1);
-}
-
-static void
-ypprog_2(rqstp, transp)
- struct svc_req *rqstp;
- SVCXPRT *transp;
-{
- union {
- domainname ypproc_domain_2_arg;
- domainname ypproc_domain_nonack_2_arg;
- ypreq_key ypproc_match_2_arg;
- ypreq_nokey ypproc_first_2_arg;
- ypreq_key ypproc_next_2_arg;
- ypreq_xfr ypproc_xfr_2_arg;
- ypreq_nokey ypproc_all_2_arg;
- ypreq_nokey ypproc_master_2_arg;
- ypreq_nokey ypproc_order_2_arg;
- domainname ypproc_maplist_2_arg;
- } argument;
- char *result;
- bool_t (*xdr_argument)(), (*xdr_result)();
- char *(*local)();
- struct sockaddr_in *caller;
-
- caller = svc_getcaller(transp);
- acl_access_ok = acl_check_host(&caller->sin_addr);
- if (!acl_access_ok) {
- yplog_date("ypserv: access denied");
- yplog_call(transp);
- switch (rqstp->rq_proc) {
- case YPPROC_NULL:
- yplog_line("request: NULL");
- break;
- case YPPROC_DOMAIN:
- yplog_line("request: DOMAIN");
- break;
- case YPPROC_DOMAIN_NONACK:
- yplog_line("request: DOMAIN_NONACK");
- break;
- case YPPROC_MATCH:
- yplog_line("request: MATCH");
- break;
- case YPPROC_FIRST:
- yplog_line("request: FIRST");
- break;
- case YPPROC_NEXT:
- yplog_line("request: NEXT");
- break;
- case YPPROC_XFR:
- yplog_line("request: XFR");
- break;
- case YPPROC_CLEAR:
- yplog_line("request: CLEAR");
- break;
- case YPPROC_ALL:
- yplog_line("request: ALL");
- break;
- case YPPROC_MASTER:
- yplog_line("request: MASTER");
- break;
- case YPPROC_ORDER:
- yplog_line("request: ORDER");
- break;
- case YPPROC_MAPLIST:
- yplog_line("request: MAPLIST");
- break;
- default:
- yplog_line("request: unknown");
- break;
- }
-
-
- }
-
- switch (rqstp->rq_proc) {
- case YPPROC_NULL:
- xdr_argument = xdr_void;
- xdr_result = xdr_void;
- local = (char *(*)()) ypproc_null_2;
- break;
-
- case YPPROC_DOMAIN:
- xdr_argument = xdr_domainname;
- xdr_result = xdr_bool;
- local = (char *(*)()) ypproc_domain_2;
- break;
-
- case YPPROC_DOMAIN_NONACK:
- xdr_argument = xdr_domainname;
- xdr_result = xdr_bool;
- local = (char *(*)()) ypproc_domain_nonack_2;
- break;
-
- case YPPROC_MATCH:
- xdr_argument = xdr_ypreq_key;
- xdr_result = xdr_ypresp_val;
- local = (char *(*)()) ypproc_match_2;
- break;
-
- case YPPROC_FIRST:
- xdr_argument = xdr_ypreq_nokey;
- xdr_result = xdr_ypresp_key_val;
- local = (char *(*)()) ypproc_first_2;
- break;
-
- case YPPROC_NEXT:
- xdr_argument = xdr_ypreq_key;
- xdr_result = xdr_ypresp_key_val;
- local = (char *(*)()) ypproc_next_2;
- break;
-
- case YPPROC_XFR:
- xdr_argument = xdr_ypreq_xfr;
- xdr_result = xdr_ypresp_xfr;
- local = (char *(*)()) ypproc_xfr_2;
- break;
-
- case YPPROC_CLEAR:
- xdr_argument = xdr_void;
- xdr_result = xdr_void;
- local = (char *(*)()) ypproc_clear_2;
- break;
-
- case YPPROC_ALL:
- xdr_argument = xdr_ypreq_nokey;
- xdr_result = xdr_ypresp_all;
- local = (char *(*)()) ypproc_all_2;
- break;
-
- case YPPROC_MASTER:
- xdr_argument = xdr_ypreq_nokey;
- xdr_result = xdr_ypresp_master;
- local = (char *(*)()) ypproc_master_2;
- break;
-
- case YPPROC_ORDER:
- xdr_argument = xdr_ypreq_nokey;
- xdr_result = xdr_ypresp_order;
- local = (char *(*)()) ypproc_order_2;
- break;
-
- case YPPROC_MAPLIST:
- xdr_argument = xdr_domainname;
- xdr_result = xdr_ypresp_maplist;
- local = (char *(*)()) ypproc_maplist_2;
- break;
-
- default:
- printf("switch default: %d\n",(int) rqstp->rq_proc);
- svcerr_noproc(transp);
- return;
- }
-
- bzero((char *)&argument, sizeof(argument));
- if (!svc_getargs(transp, xdr_argument, &argument)) {
- svcerr_decode(transp);
- return;
- }
- result = (*local)(&argument, rqstp, transp);
-
-}
-
-void
-sig_child()
-{
- while (wait3((int *)NULL, WNOHANG, (struct rusage *)NULL) > 0);
-}
diff --git a/usr.sbin/ypserv/ypserv/Makefile b/usr.sbin/ypserv/ypserv/Makefile
new file mode 100644
index 00000000000..3af375ddc7b
--- /dev/null
+++ b/usr.sbin/ypserv/ypserv/Makefile
@@ -0,0 +1,10 @@
+# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
+# $Id: Makefile,v 1.1 1995/11/01 16:56:30 deraadt Exp $
+
+PROG= ypserv
+SRCS= ypserv.c ypserv_proc.c ypserv_db.c acl.c yplog.c ypdb.c ypserv_xdr.c
+MAN= ypserv.acl.5 securenet.5 ypserv.8
+.PATH: ${.CURDIR}/../common
+CFLAGS+=-DDAEMON -I${.CURDIR}/../common
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/ypserv/acl.c b/usr.sbin/ypserv/ypserv/acl.c
index 82b5627fb6c..cfa8810ae78 100644
--- a/usr.sbin/ypserv/acl.c
+++ b/usr.sbin/ypserv/ypserv/acl.c
@@ -28,7 +28,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$Id: acl.c,v 1.1 1995/10/23 07:46:36 deraadt Exp $";
+static char rcsid[] = "$Id: acl.c,v 1.1 1995/11/01 16:56:31 deraadt Exp $";
#endif
#include <sys/types.h>
diff --git a/usr.sbin/ypserv/acl.h b/usr.sbin/ypserv/ypserv/acl.h
index 36b4c0b755c..d865728ec37 100644
--- a/usr.sbin/ypserv/acl.h
+++ b/usr.sbin/ypserv/ypserv/acl.h
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: acl.h,v 1.1 1995/10/23 07:46:38 deraadt Exp $
+ * $Id: acl.h,v 1.1 1995/11/01 16:56:32 deraadt Exp $
*/
#ifndef _ACL_H_
diff --git a/usr.sbin/ypserv/securenet b/usr.sbin/ypserv/ypserv/securenet
index a136cfb6000..a136cfb6000 100644
--- a/usr.sbin/ypserv/securenet
+++ b/usr.sbin/ypserv/ypserv/securenet
diff --git a/usr.sbin/ypserv/securenet.5 b/usr.sbin/ypserv/ypserv/securenet.5
index 0f4f547500d..bf17338afd2 100644
--- a/usr.sbin/ypserv/securenet.5
+++ b/usr.sbin/ypserv/ypserv/securenet.5
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: securenet.5,v 1.1 1995/10/23 07:46:39 deraadt Exp $
+.\" $Id: securenet.5,v 1.1 1995/11/01 16:56:33 deraadt Exp $
.\"
.Dd June 27, 1994
.Dt SECURENET 5
diff --git a/usr.sbin/ypserv/ypserv/yp.h b/usr.sbin/ypserv/ypserv/yp.h
new file mode 100644
index 00000000000..ef5bf4b6d48
--- /dev/null
+++ b/usr.sbin/ypserv/ypserv/yp.h
@@ -0,0 +1,443 @@
+/*
+ * Copyright (c) 1995 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: yp.h,v 1.1 1995/11/01 16:56:33 deraadt Exp $
+ */
+
+#ifndef _YPSERV_H_RPCGEN
+#define _YPSERV_H_RPCGEN
+
+#include <rpc/rpc.h>
+
+#define YPMAXRECORD 1024
+#define YPMAXDOMAIN 64
+#define YPMAXMAP 64
+#define YPMAXPEER 64
+
+enum ypstat {
+ YP_TRUE = 1,
+ YP_NOMORE = 2,
+ YP_FALSE = 0,
+ YP_NOMAP = -1,
+ YP_NODOM = -2,
+ YP_NOKEY = -3,
+ YP_BADOP = -4,
+ YP_BADDB = -5,
+ YP_YPERR = -6,
+ YP_BADARGS = -7,
+ YP_VERS = -8,
+};
+typedef enum ypstat ypstat;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypstat(XDR *, ypstat*);
+#elif __STDC__
+extern bool_t xdr_ypstat(XDR *, ypstat*);
+#else /* Old Style C */
+bool_t xdr_ypstat();
+#endif /* Old Style C */
+
+
+enum ypxfrstat {
+ YPXFR_SUCC = 1,
+ YPXFR_AGE = 2,
+ YPXFR_NOMAP = -1,
+ YPXFR_NODOM = -2,
+ YPXFR_RSRC = -3,
+ YPXFR_RPC = -4,
+ YPXFR_MADDR = -5,
+ YPXFR_YPERR = -6,
+ YPXFR_BADARGS = -7,
+ YPXFR_DBM = -8,
+ YPXFR_FILE = -9,
+ YPXFR_SKEW = -10,
+ YPXFR_CLEAR = -11,
+ YPXFR_FORCE = -12,
+ YPXFR_XFRERR = -13,
+ YPXFR_REFUSED = -14,
+};
+typedef enum ypxfrstat ypxfrstat;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypxfrstat(XDR *, ypxfrstat*);
+#elif __STDC__
+extern bool_t xdr_ypxfrstat(XDR *, ypxfrstat*);
+#else /* Old Style C */
+bool_t xdr_ypxfrstat();
+#endif /* Old Style C */
+
+
+typedef char *domainname;
+#ifdef __cplusplus
+extern "C" bool_t xdr_domainname(XDR *, domainname*);
+#elif __STDC__
+extern bool_t xdr_domainname(XDR *, domainname*);
+#else /* Old Style C */
+bool_t xdr_domainname();
+#endif /* Old Style C */
+
+
+typedef char *mapname;
+#ifdef __cplusplus
+extern "C" bool_t xdr_mapname(XDR *, mapname*);
+#elif __STDC__
+extern bool_t xdr_mapname(XDR *, mapname*);
+#else /* Old Style C */
+bool_t xdr_mapname();
+#endif /* Old Style C */
+
+
+typedef char *peername;
+#ifdef __cplusplus
+extern "C" bool_t xdr_peername(XDR *, peername*);
+#elif __STDC__
+extern bool_t xdr_peername(XDR *, peername*);
+#else /* Old Style C */
+bool_t xdr_peername();
+#endif /* Old Style C */
+
+
+typedef struct {
+ u_int keydat_len;
+ char *keydat_val;
+} keydat;
+#ifdef __cplusplus
+extern "C" bool_t xdr_keydat(XDR *, keydat*);
+#elif __STDC__
+extern bool_t xdr_keydat(XDR *, keydat*);
+#else /* Old Style C */
+bool_t xdr_keydat();
+#endif /* Old Style C */
+
+
+typedef struct {
+ u_int valdat_len;
+ char *valdat_val;
+} valdat;
+#ifdef __cplusplus
+extern "C" bool_t xdr_valdat(XDR *, valdat*);
+#elif __STDC__
+extern bool_t xdr_valdat(XDR *, valdat*);
+#else /* Old Style C */
+bool_t xdr_valdat();
+#endif /* Old Style C */
+
+
+struct ypmap_parms {
+ domainname domain;
+ mapname map;
+ u_int ordernum;
+ peername peer;
+};
+typedef struct ypmap_parms ypmap_parms;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypmap_parms(XDR *, ypmap_parms*);
+#elif __STDC__
+extern bool_t xdr_ypmap_parms(XDR *, ypmap_parms*);
+#else /* Old Style C */
+bool_t xdr_ypmap_parms();
+#endif /* Old Style C */
+
+
+struct ypreq_key {
+ domainname domain;
+ mapname map;
+ keydat key;
+};
+typedef struct ypreq_key ypreq_key;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypreq_key(XDR *, ypreq_key*);
+#elif __STDC__
+extern bool_t xdr_ypreq_key(XDR *, ypreq_key*);
+#else /* Old Style C */
+bool_t xdr_ypreq_key();
+#endif /* Old Style C */
+
+
+struct ypreq_nokey {
+ domainname domain;
+ mapname map;
+};
+typedef struct ypreq_nokey ypreq_nokey;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypreq_nokey(XDR *, ypreq_nokey*);
+#elif __STDC__
+extern bool_t xdr_ypreq_nokey(XDR *, ypreq_nokey*);
+#else /* Old Style C */
+bool_t xdr_ypreq_nokey();
+#endif /* Old Style C */
+
+
+struct ypreq_xfr {
+ ypmap_parms map_parms;
+ u_int transid;
+ u_int prog;
+ u_int port;
+};
+typedef struct ypreq_xfr ypreq_xfr;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypreq_xfr(XDR *, ypreq_xfr*);
+#elif __STDC__
+extern bool_t xdr_ypreq_xfr(XDR *, ypreq_xfr*);
+#else /* Old Style C */
+bool_t xdr_ypreq_xfr();
+#endif /* Old Style C */
+
+
+struct ypresp_val {
+ ypstat stat;
+ valdat val;
+};
+typedef struct ypresp_val ypresp_val;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypresp_val(XDR *, ypresp_val*);
+#elif __STDC__
+extern bool_t xdr_ypresp_val(XDR *, ypresp_val*);
+#else /* Old Style C */
+bool_t xdr_ypresp_val();
+#endif /* Old Style C */
+
+
+struct ypresp_key_val {
+ ypstat stat;
+ keydat key;
+ valdat val;
+};
+typedef struct ypresp_key_val ypresp_key_val;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypresp_key_val(XDR *, ypresp_key_val*);
+#elif __STDC__
+extern bool_t xdr_ypresp_key_val(XDR *, ypresp_key_val*);
+#else /* Old Style C */
+bool_t xdr_ypresp_key_val();
+#endif /* Old Style C */
+
+
+struct ypresp_master {
+ ypstat stat;
+ peername peer;
+};
+typedef struct ypresp_master ypresp_master;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypresp_master(XDR *, ypresp_master*);
+#elif __STDC__
+extern bool_t xdr_ypresp_master(XDR *, ypresp_master*);
+#else /* Old Style C */
+bool_t xdr_ypresp_master();
+#endif /* Old Style C */
+
+
+struct ypresp_order {
+ ypstat stat;
+ u_int ordernum;
+};
+typedef struct ypresp_order ypresp_order;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypresp_order(XDR *, ypresp_order*);
+#elif __STDC__
+extern bool_t xdr_ypresp_order(XDR *, ypresp_order*);
+#else /* Old Style C */
+bool_t xdr_ypresp_order();
+#endif /* Old Style C */
+
+
+struct ypresp_all {
+ bool_t more;
+ union {
+ ypresp_key_val val;
+ } ypresp_all_u;
+};
+typedef struct ypresp_all ypresp_all;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypresp_all(XDR *, ypresp_all*);
+#elif __STDC__
+extern bool_t xdr_ypresp_all(XDR *, ypresp_all*);
+#else /* Old Style C */
+bool_t xdr_ypresp_all();
+#endif /* Old Style C */
+
+
+struct ypresp_xfr {
+ u_int transid;
+ ypxfrstat xfrstat;
+};
+typedef struct ypresp_xfr ypresp_xfr;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypresp_xfr(XDR *, ypresp_xfr*);
+#elif __STDC__
+extern bool_t xdr_ypresp_xfr(XDR *, ypresp_xfr*);
+#else /* Old Style C */
+bool_t xdr_ypresp_xfr();
+#endif /* Old Style C */
+
+
+struct ypmaplist {
+ mapname map;
+ struct ypmaplist *next;
+};
+typedef struct ypmaplist ypmaplist;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypmaplist(XDR *, ypmaplist*);
+#elif __STDC__
+extern bool_t xdr_ypmaplist(XDR *, ypmaplist*);
+#else /* Old Style C */
+bool_t xdr_ypmaplist();
+#endif /* Old Style C */
+
+
+struct ypresp_maplist {
+ ypstat stat;
+ ypmaplist *maps;
+};
+typedef struct ypresp_maplist ypresp_maplist;
+#ifdef __cplusplus
+extern "C" bool_t xdr_ypresp_maplist(XDR *, ypresp_maplist*);
+#elif __STDC__
+extern bool_t xdr_ypresp_maplist(XDR *, ypresp_maplist*);
+#else /* Old Style C */
+bool_t xdr_ypresp_maplist();
+#endif /* Old Style C */
+
+
+#define YPPROG ((u_long)100004)
+#define YPVERS ((u_long)2)
+
+#ifdef __cplusplus
+#define YPPROC_NULL ((u_long)0)
+extern "C" void * ypproc_null_2(void *, CLIENT *);
+extern "C" void * ypproc_null_2_svc(void *, struct svc_req *, SVCXPRT *);
+#define YPPROC_DOMAIN ((u_long)1)
+extern "C" bool_t * ypproc_domain_2(domainname *, CLIENT *);
+extern "C" bool_t * ypproc_domain_2_svc(domainname *, struct svc_req *, SVCXPRT *);
+#define YPPROC_DOMAIN_NONACK ((u_long)2)
+extern "C" bool_t * ypproc_domain_nonack_2(domainname *, CLIENT *);
+extern "C" bool_t * ypproc_domain_nonack_2_svc(domainname *, struct svc_req *, SVCXPRT *);
+#define YPPROC_MATCH ((u_long)3)
+extern "C" ypresp_val * ypproc_match_2(ypreq_key *, CLIENT *);
+extern "C" ypresp_val * ypproc_match_2_svc(ypreq_key *, struct svc_req *, SVCXPRT *);
+#define YPPROC_FIRST ((u_long)4)
+extern "C" ypresp_key_val * ypproc_first_2(ypreq_key *, CLIENT *);
+extern "C" ypresp_key_val * ypproc_first_2_svc(ypreq_key *, struct svc_req *, SVCXPRT *);
+#define YPPROC_NEXT ((u_long)5)
+extern "C" ypresp_key_val * ypproc_next_2(ypreq_key *, CLIENT *);
+extern "C" ypresp_key_val * ypproc_next_2_svc(ypreq_key *, struct svc_req *, SVCXPRT *);
+#define YPPROC_XFR ((u_long)6)
+extern "C" ypresp_xfr * ypproc_xfr_2(ypreq_xfr *, CLIENT *);
+extern "C" ypresp_xfr * ypproc_xfr_2_svc(ypreq_xfr *, struct svc_req *, SVCXPRT *);
+#define YPPROC_CLEAR ((u_long)7)
+extern "C" void * ypproc_clear_2(void *, CLIENT *);
+extern "C" void * ypproc_clear_2_svc(void *, struct svc_req *, SVCXPRT *);
+#define YPPROC_ALL ((u_long)8)
+extern "C" ypresp_all * ypproc_all_2(ypreq_nokey *, CLIENT *);
+extern "C" ypresp_all * ypproc_all_2_svc(ypreq_nokey *, struct svc_req *, SVCXPRT *);
+#define YPPROC_MASTER ((u_long)9)
+extern "C" ypresp_master * ypproc_master_2(ypreq_nokey *, CLIENT *);
+extern "C" ypresp_master * ypproc_master_2_svc(ypreq_nokey *, struct svc_req *, SVCXPRT *);
+#define YPPROC_ORDER ((u_long)10)
+extern "C" ypresp_order * ypproc_order_2(ypreq_nokey *, CLIENT *);
+extern "C" ypresp_order * ypproc_order_2_svc(ypreq_nokey *, struct svc_req *, SVCXPRT *);
+#define YPPROC_MAPLIST ((u_long)11)
+extern "C" ypresp_maplist * ypproc_maplist_2(domainname *, CLIENT *);
+extern "C" ypresp_maplist * ypproc_maplist_2_svc(domainname *, struct svc_req *, SVCXPRT *);
+
+#elif __STDC__
+#define YPPROC_NULL ((u_long)0)
+extern void * ypproc_null_2(void *, CLIENT *);
+extern void * ypproc_null_2_svc(void *, struct svc_req *, SVCXPRT *);
+#define YPPROC_DOMAIN ((u_long)1)
+extern bool_t * ypproc_domain_2(domainname *, CLIENT *);
+extern bool_t * ypproc_domain_2_svc(domainname *, struct svc_req *, SVCXPRT *);
+#define YPPROC_DOMAIN_NONACK ((u_long)2)
+extern bool_t * ypproc_domain_nonack_2(domainname *, CLIENT *);
+extern bool_t * ypproc_domain_nonack_2_svc(domainname *, struct svc_req *, SVCXPRT *);
+#define YPPROC_MATCH ((u_long)3)
+extern ypresp_val * ypproc_match_2(ypreq_key *, CLIENT *);
+extern ypresp_val * ypproc_match_2_svc(ypreq_key *, struct svc_req *, SVCXPRT *);
+#define YPPROC_FIRST ((u_long)4)
+extern ypresp_key_val * ypproc_first_2(ypreq_key *, CLIENT *);
+extern ypresp_key_val * ypproc_first_2_svc(ypreq_key *, struct svc_req *, SVCXPRT *);
+#define YPPROC_NEXT ((u_long)5)
+extern ypresp_key_val * ypproc_next_2(ypreq_key *, CLIENT *);
+extern ypresp_key_val * ypproc_next_2_svc(ypreq_key *, struct svc_req *, SVCXPRT *);
+#define YPPROC_XFR ((u_long)6)
+extern ypresp_xfr * ypproc_xfr_2(ypreq_xfr *, CLIENT *);
+extern ypresp_xfr * ypproc_xfr_2_svc(ypreq_xfr *, struct svc_req *, SVCXPRT *);
+#define YPPROC_CLEAR ((u_long)7)
+extern void * ypproc_clear_2(void *, CLIENT *);
+extern void * ypproc_clear_2_svc(void *, struct svc_req *, SVCXPRT *);
+#define YPPROC_ALL ((u_long)8)
+extern ypresp_all * ypproc_all_2(ypreq_nokey *, CLIENT *);
+extern ypresp_all * ypproc_all_2_svc(ypreq_nokey *, struct svc_req *, SVCXPRT *);
+#define YPPROC_MASTER ((u_long)9)
+extern ypresp_master * ypproc_master_2(ypreq_nokey *, CLIENT *);
+extern ypresp_master * ypproc_master_2_svc(ypreq_nokey *, struct svc_req *, SVCXPRT *);
+#define YPPROC_ORDER ((u_long)10)
+extern ypresp_order * ypproc_order_2(ypreq_nokey *, CLIENT *);
+extern ypresp_order * ypproc_order_2_svc(ypreq_nokey *, struct svc_req *, SVCXPRT *);
+#define YPPROC_MAPLIST ((u_long)11)
+extern ypresp_maplist * ypproc_maplist_2(domainname *, CLIENT *);
+extern ypresp_maplist * ypproc_maplist_2_svc(domainname *, struct svc_req *, SVCXPRT *);
+
+#else /* Old Style C */
+#define YPPROC_NULL ((u_long)0)
+extern void * ypproc_null_2();
+extern void * ypproc_null_2_svc();
+#define YPPROC_DOMAIN ((u_long)1)
+extern bool_t * ypproc_domain_2();
+extern bool_t * ypproc_domain_2_svc();
+#define YPPROC_DOMAIN_NONACK ((u_long)2)
+extern bool_t * ypproc_domain_nonack_2();
+extern bool_t * ypproc_domain_nonack_2_svc();
+#define YPPROC_MATCH ((u_long)3)
+extern ypresp_val * ypproc_match_2();
+extern ypresp_val * ypproc_match_2_svc();
+#define YPPROC_FIRST ((u_long)4)
+extern ypresp_key_val * ypproc_first_2();
+extern ypresp_key_val * ypproc_first_2_svc();
+#define YPPROC_NEXT ((u_long)5)
+extern ypresp_key_val * ypproc_next_2();
+extern ypresp_key_val * ypproc_next_2_svc();
+#define YPPROC_XFR ((u_long)6)
+extern ypresp_xfr * ypproc_xfr_2();
+extern ypresp_xfr * ypproc_xfr_2_svc();
+#define YPPROC_CLEAR ((u_long)7)
+extern void * ypproc_clear_2();
+extern void * ypproc_clear_2_svc();
+#define YPPROC_ALL ((u_long)8)
+extern ypresp_all * ypproc_all_2();
+extern ypresp_all * ypproc_all_2_svc();
+#define YPPROC_MASTER ((u_long)9)
+extern ypresp_master * ypproc_master_2();
+extern ypresp_master * ypproc_master_2_svc();
+#define YPPROC_ORDER ((u_long)10)
+extern ypresp_order * ypproc_order_2();
+extern ypresp_order * ypproc_order_2_svc();
+#define YPPROC_MAPLIST ((u_long)11)
+extern ypresp_maplist * ypproc_maplist_2();
+extern ypresp_maplist * ypproc_maplist_2_svc();
+#endif /* Old Style C */
+
+#endif /* !_YPSERV_H_RPCGEN */
diff --git a/usr.sbin/ypserv/ypserv.8 b/usr.sbin/ypserv/ypserv/ypserv.8
index 5a644720738..cb91a3aab03 100644
--- a/usr.sbin/ypserv/ypserv.8
+++ b/usr.sbin/ypserv/ypserv/ypserv.8
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: ypserv.8,v 1.1 1995/10/23 07:46:42 deraadt Exp $
+.\" $Id: ypserv.8,v 1.1 1995/11/01 16:56:34 deraadt Exp $
.\"
.Dd June 27, 1994
.Dt YPSERV 8
diff --git a/usr.sbin/ypserv/ypserv.acl b/usr.sbin/ypserv/ypserv/ypserv.acl
index 33c68568c80..33c68568c80 100644
--- a/usr.sbin/ypserv/ypserv.acl
+++ b/usr.sbin/ypserv/ypserv/ypserv.acl
diff --git a/usr.sbin/ypserv/ypserv.acl.5 b/usr.sbin/ypserv/ypserv/ypserv.acl.5
index ae648a69674..591e11ddc3b 100644
--- a/usr.sbin/ypserv/ypserv.acl.5
+++ b/usr.sbin/ypserv/ypserv/ypserv.acl.5
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: ypserv.acl.5,v 1.1 1995/10/23 07:46:43 deraadt Exp $
+.\" $Id: ypserv.acl.5,v 1.1 1995/11/01 16:56:35 deraadt Exp $
.\"
.Dd July 2, 1994
.Dt YPSERV.ACL 5
diff --git a/usr.sbin/ypserv/ypserv/ypserv.c b/usr.sbin/ypserv/ypserv/ypserv.c
new file mode 100644
index 00000000000..ca8c44159e8
--- /dev/null
+++ b/usr.sbin/ypserv/ypserv/ypserv.c
@@ -0,0 +1,431 @@
+/*
+ * 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: ypserv.c,v 1.1 1995/11/01 16:56:36 deraadt Exp $";
+#endif
+
+#include "yp.h"
+#include <stdio.h>
+#include <stdlib.h>/* getenv, exit */
+#include <rpc/pmap_clnt.h> /* for pmap_unset */
+#include <string.h> /* strcmp */
+#include <netdb.h>
+#include <signal.h>
+#include <sys/ttycom.h>/* TIOCNOTTY */
+#ifdef __cplusplus
+#include <sysent.h> /* getdtablesize, open */
+#endif /* __cplusplus */
+#include <memory.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#ifdef SYSLOG
+#include <syslog.h>
+#else
+#define LOG_ERR 1
+#define openlog(a, b, c)
+#endif
+#include "acl.h"
+#include "yplog.h"
+#include <sys/wait.h>
+
+#define YP_SECURENET_FILE "/var/yp/securenet"
+
+#ifdef __STDC__
+#define SIG_PF void(*)(int)
+#endif
+
+#ifdef DEBUG
+#define RPC_SVC_FG
+#endif
+
+#define _RPCSVC_CLOSEDOWN 120
+static int _rpcpmstart; /* Started by a port monitor ? */
+static int _rpcfdtype; /* Whether Stream or Datagram ? */
+static int _rpcsvcdirty; /* Still serving ? */
+
+int usedns = FALSE;
+int acl_access_ok;
+char *progname = "ypserv";
+
+void sig_child();
+
+static
+void _msgout(char* msg)
+{
+#ifdef RPC_SVC_FG
+ if (_rpcpmstart)
+ syslog(LOG_ERR, msg);
+ else
+ (void) fprintf(stderr, "%s\n", msg);
+#else
+ syslog(LOG_ERR, msg);
+#endif
+}
+
+static void
+closedown()
+{
+ if (_rpcsvcdirty == 0) {
+ extern fd_set svc_fdset;
+ static int size;
+ int i, openfd;
+
+ if (_rpcfdtype == SOCK_DGRAM)
+ exit(0);
+ if (size == 0) {
+ size = getdtablesize();
+ }
+ for (i = 0, openfd = 0; i < size && openfd < 2; i++)
+ if (FD_ISSET(i, &svc_fdset))
+ openfd++;
+ if (openfd <= (_rpcpmstart?0:1))
+ exit(0);
+ }
+ (void) alarm(_RPCSVC_CLOSEDOWN);
+}
+
+static void
+ypprog_2(struct svc_req *rqstp, register SVCXPRT *transp)
+{
+ union {
+ domainname ypproc_domain_2_arg;
+ domainname ypproc_domain_nonack_2_arg;
+ ypreq_key ypproc_match_2_arg;
+ ypreq_key ypproc_first_2_arg;
+ ypreq_key ypproc_next_2_arg;
+ ypreq_xfr ypproc_xfr_2_arg;
+ ypreq_nokey ypproc_all_2_arg;
+ ypreq_nokey ypproc_master_2_arg;
+ ypreq_nokey ypproc_order_2_arg;
+ domainname ypproc_maplist_2_arg;
+ } argument;
+ char *result;
+ xdrproc_t xdr_argument, xdr_result;
+ char *(*local)(char *, struct svc_req *, SVCXPRT *);
+ struct sockaddr_in *caller;
+
+ _rpcsvcdirty = 1;
+
+ caller = svc_getcaller(transp);
+ acl_access_ok = acl_check_host(&caller->sin_addr);
+
+ if (!acl_access_ok) {
+ yplog_date("ypserv: access denied");
+ yplog_call(transp);
+ switch (rqstp->rq_proc) {
+ case YPPROC_NULL:
+ yplog_line("request: NULL");
+ break;
+ case YPPROC_DOMAIN:
+ yplog_line("request: DOMAIN");
+ break;
+ case YPPROC_DOMAIN_NONACK:
+ yplog_line("request: DOMAIN_NONACK");
+ break;
+ case YPPROC_MATCH:
+ yplog_line("request: MATCH");
+ break;
+ case YPPROC_FIRST:
+ yplog_line("request: FIRST");
+ break;
+ case YPPROC_NEXT:
+ yplog_line("request: NEXT");
+ break;
+ case YPPROC_XFR:
+ yplog_line("request: XFR");
+ break;
+ case YPPROC_CLEAR:
+ yplog_line("request: CLEAR");
+ break;
+ case YPPROC_ALL:
+ yplog_line("request: ALL");
+ break;
+ case YPPROC_MASTER:
+ yplog_line("request: MASTER");
+ break;
+ case YPPROC_ORDER:
+ yplog_line("request: ORDER");
+ break;
+ case YPPROC_MAPLIST:
+ yplog_line("request: MAPLIST");
+ break;
+ default:
+ yplog_line("request: unknown");
+ break;
+ }
+ }
+
+ switch (rqstp->rq_proc) {
+ case YPPROC_NULL:
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_void;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_null_2_svc;
+ break;
+
+ case YPPROC_DOMAIN:
+ xdr_argument = (xdrproc_t) xdr_domainname;
+ xdr_result = (xdrproc_t) xdr_bool;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_domain_2_svc;
+ break;
+
+ case YPPROC_DOMAIN_NONACK:
+ xdr_argument = (xdrproc_t) xdr_domainname;
+ xdr_result = (xdrproc_t) xdr_bool;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_domain_nonack_2_svc;
+ break;
+
+ case YPPROC_MATCH:
+ xdr_argument = (xdrproc_t) xdr_ypreq_key;
+ xdr_result = (xdrproc_t) xdr_ypresp_val;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_match_2_svc;
+ break;
+
+ case YPPROC_FIRST:
+ xdr_argument = (xdrproc_t) xdr_ypreq_key;
+ xdr_result = (xdrproc_t) xdr_ypresp_key_val;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_first_2_svc;
+ break;
+
+ case YPPROC_NEXT:
+ xdr_argument = (xdrproc_t) xdr_ypreq_key;
+ xdr_result = (xdrproc_t) xdr_ypresp_key_val;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_next_2_svc;
+ break;
+
+ case YPPROC_XFR:
+ xdr_argument = (xdrproc_t) xdr_ypreq_xfr;
+ xdr_result = (xdrproc_t) xdr_ypresp_xfr;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_xfr_2_svc;
+ break;
+
+ case YPPROC_CLEAR:
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_void;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_clear_2_svc;
+ break;
+
+ case YPPROC_ALL:
+ xdr_argument = (xdrproc_t) xdr_ypreq_nokey;
+ xdr_result = (xdrproc_t) xdr_ypresp_all;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_all_2_svc;
+ break;
+
+ case YPPROC_MASTER:
+ xdr_argument = (xdrproc_t) xdr_ypreq_nokey;
+ xdr_result = (xdrproc_t) xdr_ypresp_master;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_master_2_svc;
+ break;
+
+ case YPPROC_ORDER:
+ xdr_argument = (xdrproc_t) xdr_ypreq_nokey;
+ xdr_result = (xdrproc_t) xdr_ypresp_order;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_order_2_svc;
+ break;
+
+ case YPPROC_MAPLIST:
+ xdr_argument = (xdrproc_t) xdr_domainname;
+ xdr_result = (xdrproc_t) xdr_ypresp_maplist;
+ local = (char *(*)(char *, struct svc_req *, SVCXPRT *)) ypproc_maplist_2_svc;
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ _rpcsvcdirty = 0;
+ return;
+ }
+ (void) memset((char *)&argument, 0, sizeof (argument));
+ if (!svc_getargs(transp, xdr_argument, (caddr_t) &argument)) {
+ svcerr_decode(transp);
+ _rpcsvcdirty = 0;
+ return;
+ }
+ result = (*local)((char *)&argument, rqstp, transp);
+/*
+ if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
+ svcerr_systemerr(transp);
+ }
+ if (!svc_freeargs(transp, xdr_argument, (caddr_t) &argument)) {
+ _msgout("unable to free arguments");
+ exit(1);
+ }
+*/
+ _rpcsvcdirty = 0;
+ return;
+}
+
+int
+main (argc,argv)
+int argc;
+char *argv[];
+{
+ register SVCXPRT *transp;
+ int sock;
+ int proto;
+ struct sockaddr_in saddr;
+ int asize = sizeof (saddr);
+ int usage = 0;
+ int xflag = 0;
+ char ch;
+ extern char *optarg;
+ char *aclfile = NULL;
+
+ while ((ch = getopt(argc, argv, "a:dx")) != EOF)
+ switch (ch) {
+ case 'a':
+ aclfile = optarg;
+ break;
+ case 'd':
+ usedns = TRUE;
+ break;
+ case 'x':
+ xflag = TRUE;
+ break;
+ default:
+ usage++;
+ break;
+ }
+
+ if (usage) {
+ (void)fprintf(stderr,"usage: %s [-a aclfile] [-d] [-x]\n",progname);
+ exit(1);
+ }
+
+ if (geteuid() != 0) {
+ (void)fprintf(stderr,"%s: must be root to run.\n",progname);
+ exit(1);
+ }
+
+ if (aclfile != NULL) {
+ (void)acl_init(aclfile);
+ } else {
+ (void)acl_securenet(YP_SECURENET_FILE);
+ }
+ if (xflag) {
+ exit(1);
+ };
+
+ if (getsockname(0, (struct sockaddr *)&saddr, &asize) == 0) {
+ int ssize = sizeof (int);
+
+ if (saddr.sin_family != AF_INET)
+ exit(1);
+ if (getsockopt(0, SOL_SOCKET, SO_TYPE,
+ (char *)&_rpcfdtype, &ssize) == -1)
+ exit(1);
+ sock = 0;
+ _rpcpmstart = 1;
+ proto = 0;
+ openlog("ypserv", LOG_PID, LOG_DAEMON);
+ } else {
+#ifndef RPC_SVC_FG
+ int size;
+ int pid, i;
+
+ pid = fork();
+ if (pid < 0) {
+ perror("cannot fork");
+ exit(1);
+ }
+ if (pid)
+ exit(0);
+ size = getdtablesize();
+ for (i = 0; i < size; i++)
+ (void) close(i);
+ i = open("/dev/console", 2);
+ (void) dup2(i, 1);
+ (void) dup2(i, 2);
+ i = open("/dev/tty", 2);
+ if (i >= 0) {
+ (void) ioctl(i, TIOCNOTTY, (char *)NULL);
+ (void) close(i);
+ }
+ openlog("ypserv", LOG_PID, LOG_DAEMON);
+#endif
+ sock = RPC_ANYSOCK;
+ (void) pmap_unset(YPPROG, YPVERS);
+ }
+
+ yplog_init(progname);
+
+ chdir("/");
+
+ (void)signal(SIGCHLD, sig_child);
+
+ if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_DGRAM)) {
+ transp = svcudp_create(sock);
+ if (transp == NULL) {
+ _msgout("cannot create udp service.");
+ exit(1);
+ }
+ if (!_rpcpmstart)
+ proto = IPPROTO_UDP;
+ if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, proto)) {
+ _msgout("unable to register (YPPROG, YPVERS, udp).");
+ exit(1);
+ }
+ }
+
+ if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_STREAM)) {
+ if (_rpcpmstart)
+ transp = svcfd_create(sock, 0, 0);
+ else
+ transp = svctcp_create(sock, 0, 0);
+ if (transp == NULL) {
+ _msgout("cannot create tcp service.");
+ exit(1);
+ }
+ if (!_rpcpmstart)
+ proto = IPPROTO_TCP;
+ if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, proto)) {
+ _msgout("unable to register (YPPROG, YPVERS, tcp).");
+ exit(1);
+ }
+ }
+
+ if (transp == (SVCXPRT *)NULL) {
+ _msgout("could not create a handle");
+ exit(1);
+ }
+ if (_rpcpmstart) {
+ (void) signal(SIGALRM, (SIG_PF) closedown);
+ (void) alarm(_RPCSVC_CLOSEDOWN);
+ }
+ svc_run();
+ _msgout("svc_run returned");
+ exit(1);
+ /* NOTREACHED */
+}
+
+void
+sig_child()
+{
+ while (wait3((int *)NULL, WNOHANG, (struct rusage *)NULL) > 0);
+}
+
diff --git a/usr.sbin/ypserv/ypserv_db.c b/usr.sbin/ypserv/ypserv/ypserv_db.c
index 36a0f2a6ee7..3b85e13e066 100644
--- a/usr.sbin/ypserv/ypserv_db.c
+++ b/usr.sbin/ypserv/ypserv/ypserv_db.c
@@ -28,7 +28,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$Id: ypserv_db.c,v 1.1 1995/10/23 07:46:45 deraadt Exp $";
+static char rcsid[] = "$Id: ypserv_db.c,v 1.1 1995/11/01 16:56:37 deraadt Exp $";
#endif
#include <rpc/rpc.h>
diff --git a/usr.sbin/ypserv/ypserv_proc.c b/usr.sbin/ypserv/ypserv/ypserv_proc.c
index 1aa13f0239f..f74fa63b682 100644
--- a/usr.sbin/ypserv/ypserv_proc.c
+++ b/usr.sbin/ypserv/ypserv/ypserv_proc.c
@@ -28,11 +28,11 @@
*/
#ifndef LINT
-static char rcsid[] = "$Id: ypserv_proc.c,v 1.1 1995/10/23 07:46:46 deraadt Exp $";
+static char rcsid[] = "$Id: ypserv_proc.c,v 1.1 1995/11/01 16:56:37 deraadt Exp $";
#endif
#include <rpc/rpc.h>
-#include <rpcsvc/yp.h>
+#include "yp.h"
#include <rpcsvc/ypclnt.h>
#include <sys/stat.h>
#include <sys/socket.h>
@@ -58,7 +58,7 @@ extern void ypdb_close_all();
extern int acl_access_ok;
void *
-ypproc_null_2(argp, rqstp, transp)
+ypproc_null_2_svc(argp, rqstp, transp)
void *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -74,7 +74,7 @@ ypproc_null_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_void, argp)) {
+ if (!svc_freeargs(transp, xdr_void, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -83,7 +83,7 @@ ypproc_null_2(argp, rqstp, transp)
}
bool_t *
-ypproc_domain_2(argp, rqstp, transp)
+ypproc_domain_2_svc(argp, rqstp, transp)
domainname *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -121,7 +121,7 @@ ypproc_domain_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_domainname, argp)) {
+ if (!svc_freeargs(transp, xdr_domainname, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -130,7 +130,7 @@ ypproc_domain_2(argp, rqstp, transp)
}
bool_t *
-ypproc_domain_nonack_2(argp, rqstp, transp)
+ypproc_domain_nonack_2_svc(argp, rqstp, transp)
domainname *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -178,7 +178,7 @@ ypproc_domain_nonack_2(argp, rqstp, transp)
}
- if (!svc_freeargs(transp, xdr_domainname, argp)) {
+ if (!svc_freeargs(transp, xdr_domainname, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -187,7 +187,7 @@ ypproc_domain_nonack_2(argp, rqstp, transp)
}
ypresp_val *
-ypproc_match_2(argp, rqstp, transp)
+ypproc_match_2_svc(argp, rqstp, transp)
ypreq_key *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -221,7 +221,7 @@ ypproc_match_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_ypreq_key, argp)) {
+ if (!svc_freeargs(transp, xdr_ypreq_key, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -230,7 +230,7 @@ ypproc_match_2(argp, rqstp, transp)
}
ypresp_key_val *
-ypproc_first_2(argp, rqstp, transp)
+ypproc_first_2_svc(argp, rqstp, transp)
ypreq_key *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -262,7 +262,7 @@ ypproc_first_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_ypreq_key, argp)) {
+ if (!svc_freeargs(transp, xdr_ypreq_key, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -271,7 +271,7 @@ ypproc_first_2(argp, rqstp, transp)
}
ypresp_key_val *
-ypproc_next_2(argp, rqstp, transp)
+ypproc_next_2_svc(argp, rqstp, transp)
ypreq_key *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -305,7 +305,7 @@ ypproc_next_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_ypreq_key, argp)) {
+ if (!svc_freeargs(transp, xdr_ypreq_key, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -314,7 +314,7 @@ ypproc_next_2(argp, rqstp, transp)
}
ypresp_xfr *
-ypproc_xfr_2(argp, rqstp, transp)
+ypproc_xfr_2_svc(argp, rqstp, transp)
ypreq_xfr *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -360,7 +360,7 @@ ypproc_xfr_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_ypreq_xfr, argp)) {
+ if (!svc_freeargs(transp, xdr_ypreq_xfr, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -369,7 +369,7 @@ ypproc_xfr_2(argp, rqstp, transp)
}
void *
-ypproc_clear_2(argp, rqstp, transp)
+ypproc_clear_2_svc(argp, rqstp, transp)
void *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -393,7 +393,7 @@ ypproc_clear_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_void, argp)) {
+ if (!svc_freeargs(transp, xdr_void, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -402,7 +402,7 @@ ypproc_clear_2(argp, rqstp, transp)
}
ypresp_all *
-ypproc_all_2(argp, rqstp, transp)
+ypproc_all_2_svc(argp, rqstp, transp)
ypreq_nokey *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -436,7 +436,7 @@ ypproc_all_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_ypreq_nokey, argp)) {
+ if (!svc_freeargs(transp, xdr_ypreq_nokey, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -445,7 +445,7 @@ ypproc_all_2(argp, rqstp, transp)
}
ypresp_master *
-ypproc_master_2(argp, rqstp, transp)
+ypproc_master_2_svc(argp, rqstp, transp)
ypreq_nokey *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -494,7 +494,7 @@ ypproc_master_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_ypreq_nokey, argp)) {
+ if (!svc_freeargs(transp, xdr_ypreq_nokey, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -504,7 +504,7 @@ ypproc_master_2(argp, rqstp, transp)
ypresp_order *
-ypproc_order_2(argp, rqstp, transp)
+ypproc_order_2_svc(argp, rqstp, transp)
ypreq_nokey *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -537,7 +537,7 @@ ypproc_order_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_ypreq_nokey, argp)) {
+ if (!svc_freeargs(transp, xdr_ypreq_nokey, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
@@ -547,7 +547,7 @@ ypproc_order_2(argp, rqstp, transp)
ypresp_maplist *
-ypproc_maplist_2(argp, rqstp, transp)
+ypproc_maplist_2_svc(argp, rqstp, transp)
domainname *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
@@ -638,7 +638,7 @@ ypproc_maplist_2(argp, rqstp, transp)
svcerr_systemerr(transp);
}
- if (!svc_freeargs(transp, xdr_domainname, argp)) {
+ if (!svc_freeargs(transp, xdr_domainname, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
diff --git a/usr.sbin/ypserv/ypserv/ypserv_xdr.c b/usr.sbin/ypserv/ypserv/ypserv_xdr.c
new file mode 100644
index 00000000000..3ce1fd647af
--- /dev/null
+++ b/usr.sbin/ypserv/ypserv/ypserv_xdr.c
@@ -0,0 +1,75 @@
+/*
+ * 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: ypserv_xdr.c,v 1.1 1995/11/01 16:56:38 deraadt Exp $";
+#endif
+
+#include <rpc/rpc.h>
+#include <rpcsvc/yp.h>
+
+bool_t
+xdr_ypmap_parms(xdrs, objp)
+ XDR *xdrs;
+ ypmap_parms *objp;
+{
+ if (!xdr_domainname(xdrs, &objp->domain)) {
+ return (FALSE);
+ }
+ if (!xdr_mapname(xdrs, &objp->map)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->ordernum)) {
+ return (FALSE);
+ }
+ if (!xdr_peername(xdrs, &objp->peer)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_ypreq_xfr(xdrs, objp)
+ XDR *xdrs;
+ ypreq_xfr *objp;
+{
+ if (!xdr_ypmap_parms(xdrs, &objp->map_parms)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->transid)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->prog)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->port)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
diff --git a/usr.sbin/ypserv/ypserv_xdr.c b/usr.sbin/ypserv/ypserv_xdr.c
deleted file mode 100644
index 9bda5ae48e6..00000000000
--- a/usr.sbin/ypserv/ypserv_xdr.c
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * 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: ypserv_xdr.c,v 1.1 1995/10/23 07:46:47 deraadt Exp $";
-#endif
-
-
-
-#include <rpc/rpc.h>
-#include <rpcsvc/yp.h>
-
-bool_t
-xdr_ypstat(xdrs, objp)
- XDR *xdrs;
- ypstat *objp;
-{
- if (!xdr_enum(xdrs, (enum_t *)objp)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypxfrstat(xdrs, objp)
- XDR *xdrs;
- ypxfrstat *objp;
-{
- if (!xdr_enum(xdrs, (enum_t *)objp)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_domainname(xdrs, objp)
- XDR *xdrs;
- domainname *objp;
-{
- if (!xdr_string(xdrs, objp, YPMAXDOMAIN)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_mapname(xdrs, objp)
- XDR *xdrs;
- mapname *objp;
-{
- if (!xdr_string(xdrs, objp, YPMAXMAP)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_peername(xdrs, objp)
- XDR *xdrs;
- peername *objp;
-{
- if (!xdr_string(xdrs, objp, YPMAXPEER)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_keydat(xdrs, objp)
- XDR *xdrs;
- keydat *objp;
-{
- if (!xdr_bytes(xdrs, (char **)&objp->keydat_val, (u_int *)&objp->keydat_len, YPMAXRECORD)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_valdat(xdrs, objp)
- XDR *xdrs;
- valdat *objp;
-{
- if (!xdr_bytes(xdrs, (char **)&objp->valdat_val, (u_int *)&objp->valdat_len, YPMAXRECORD)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypmap_parms(xdrs, objp)
- XDR *xdrs;
- ypmap_parms *objp;
-{
- if (!xdr_domainname(xdrs, &objp->domain)) {
- return (FALSE);
- }
- if (!xdr_mapname(xdrs, &objp->map)) {
- return (FALSE);
- }
- if (!xdr_u_int(xdrs, &objp->ordernum)) {
- return (FALSE);
- }
- if (!xdr_peername(xdrs, &objp->peer)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypreq_key(xdrs, objp)
- XDR *xdrs;
- ypreq_key *objp;
-{
- if (!xdr_domainname(xdrs, &objp->domain)) {
- return (FALSE);
- }
- if (!xdr_mapname(xdrs, &objp->map)) {
- return (FALSE);
- }
- if (!xdr_keydat(xdrs, &objp->key)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypreq_nokey(xdrs, objp)
- XDR *xdrs;
- ypreq_nokey *objp;
-{
- if (!xdr_domainname(xdrs, &objp->domain)) {
- return (FALSE);
- }
- if (!xdr_mapname(xdrs, &objp->map)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypreq_xfr(xdrs, objp)
- XDR *xdrs;
- ypreq_xfr *objp;
-{
- if (!xdr_ypmap_parms(xdrs, &objp->map_parms)) {
- return (FALSE);
- }
- if (!xdr_u_int(xdrs, &objp->transid)) {
- return (FALSE);
- }
- if (!xdr_u_int(xdrs, &objp->prog)) {
- return (FALSE);
- }
- if (!xdr_u_int(xdrs, &objp->port)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypresp_val(xdrs, objp)
- XDR *xdrs;
- ypresp_val *objp;
-{
- if (!xdr_ypstat(xdrs, &objp->stat)) {
- return (FALSE);
- }
- if (!xdr_valdat(xdrs, &objp->val)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypresp_key_val(xdrs, objp)
- XDR *xdrs;
- ypresp_key_val *objp;
-{
- if (!xdr_ypstat(xdrs, &objp->stat)) {
- return (FALSE);
- }
- if (!xdr_valdat(xdrs, &objp->val)) {
- return (FALSE);
- }
- if (!xdr_keydat(xdrs, &objp->key)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypresp_master(xdrs, objp)
- XDR *xdrs;
- ypresp_master *objp;
-{
- if (!xdr_ypstat(xdrs, &objp->stat)) {
- return (FALSE);
- }
- if (!xdr_peername(xdrs, &objp->peer)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypresp_order(xdrs, objp)
- XDR *xdrs;
- ypresp_order *objp;
-{
- if (!xdr_ypstat(xdrs, &objp->stat)) {
- return (FALSE);
- }
- if (!xdr_u_int(xdrs, &objp->ordernum)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypresp_all(xdrs, objp)
- XDR *xdrs;
- ypresp_all *objp;
-{
- if (!xdr_bool(xdrs, &objp->more)) {
- return (FALSE);
- }
- switch (objp->more) {
- case TRUE:
- if (!xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val)) {
- return (FALSE);
- }
- break;
- case FALSE:
- break;
- default:
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypresp_xfr(xdrs, objp)
- XDR *xdrs;
- ypresp_xfr *objp;
-{
- if (!xdr_u_int(xdrs, &objp->transid)) {
- return (FALSE);
- }
- if (!xdr_ypxfrstat(xdrs, &objp->xfrstat)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypmaplist(xdrs, objp)
- XDR *xdrs;
- ypmaplist *objp;
-{
- if (!xdr_mapname(xdrs, &objp->map)) {
- return (FALSE);
- }
- if (!xdr_pointer(xdrs, (char **)&objp->next, sizeof(ypmaplist), xdr_ypmaplist)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
-
-
-bool_t
-xdr_ypresp_maplist(xdrs, objp)
- XDR *xdrs;
- ypresp_maplist *objp;
-{
- if (!xdr_ypstat(xdrs, &objp->stat)) {
- return (FALSE);
- }
- if (!xdr_pointer(xdrs, (char **)&objp->maps, sizeof(ypmaplist), xdr_ypmaplist)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-
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);
+}
+
diff --git a/usr.sbin/ypserv/ypxfr/Makefile b/usr.sbin/ypserv/ypxfr/Makefile
new file mode 100644
index 00000000000..46640a89201
--- /dev/null
+++ b/usr.sbin/ypserv/ypxfr/Makefile
@@ -0,0 +1,10 @@
+# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
+# $Id: Makefile,v 1.1 1995/11/01 16:56:42 deraadt Exp $
+
+PROG= ypxfr
+SRCS= ypxfr.c ypdb.c yplog.c yplib_host.c ypxfr_xdr.c
+MAN= ypxfr.8
+.PATH: ${.CURDIR}/../common
+CFLAGS+=-I${.CURDIR}/../common
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/ypserv/ypxfr/ypxfr.8 b/usr.sbin/ypserv/ypxfr/ypxfr.8
new file mode 100644
index 00000000000..efe6c7b8a24
--- /dev/null
+++ b/usr.sbin/ypserv/ypxfr/ypxfr.8
@@ -0,0 +1,74 @@
+.\" 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: ypxfr.8,v 1.1 1995/11/01 16:56:42 deraadt Exp $
+.\"
+.Dd August 18, 1994
+.Dt YPXFR 8
+.Os NetBSD 1.0
+.Sh NAME
+.Nm ypxfr
+.Nd get a YP map from YP server
+.Sh SYNOPSIS
+.Nm /usr/sbin/ypxfr
+.Op Fl bcf
+.Op Fl d Ar domain
+.Op Fl h Ar host
+.Op Fl s Ar domain
+.Op Fl C Ar tid prog ipadd port
+.Ar mapname
+.Sh DESCRIPTION
+.Nm ypxfr
+is the utiliy in YP that transfers maps to the local host.
+.Pp
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl b
+Preserve the entry in the database informing a YP server to use
+DNS to get information about unknown hosts. This option will only have
+effect on the two maps hosts.byname and hosts.byaddr.
+.It Fl c
+Don't send a "Clear current map" to local ypserv process. Useful if ypserv
+isn't running localy to avoid timeout message.
+.It Fl f
+Force map transfer, even if version of master is older than local copy.
+.It Fl d Ar domain
+Don't use default domain, use the specifiyed domain.
+.It Fl h Ar host
+Get map from host insteed of the maps master host.
+.It Fl s Ar domain
+Specify a source domain other than the target domain.
+.It Fl C Ar tid prog ipadd port
+This option is only used by ypserv. This is to open communication with
+an yppush on another host.
+.El
+.Sh SEE ALSO
+.Xr yppush 8 ,
+.Xr ypserv 8
+.Sh AUTHOR
+Mats O Jansson <moj@stacken.kth.se>
diff --git a/usr.sbin/ypserv/ypxfr/ypxfr.c b/usr.sbin/ypserv/ypxfr/ypxfr.c
new file mode 100644
index 00000000000..7e7c92cb5dc
--- /dev/null
+++ b/usr.sbin/ypserv/ypxfr/ypxfr.c
@@ -0,0 +1,624 @@
+/*
+ * 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: ypxfr.c,v 1.1 1995/11/01 16:56:43 deraadt Exp $";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+/* #include <rpcsvc/yp_prot.h> */
+#include <rpcsvc/ypclnt.h>
+#include <rpcsvc/yp.h>
+
+#include "yplib_host.h"
+#include "yplog.h"
+#include "ypdb.h"
+#include "ypdef.h"
+
+char *progname = "ypxfr";
+DBM *db;
+
+extern bool_t xdr_ypresp_all_seq();
+
+extern int (*ypresp_allfn)();
+extern void *ypresp_data;
+
+static int
+ypxfr_foreach(status,keystr,keylen,valstr,vallen,data)
+int status,keylen,vallen,*data;
+char *keystr,*valstr;
+{
+ datum key,val;
+
+ if (status == 2)
+ return(0);
+
+ keystr[keylen] = '\0';
+ valstr[vallen] = '\0';
+
+ key.dptr = keystr;
+ key.dsize = strlen(keystr) + 1;
+
+ val.dptr = valstr;
+ val.dsize = strlen(valstr) + 1;
+
+ ypdb_store(db, key, val, YPDB_INSERT);
+
+ return 0;
+}
+
+int
+get_local_ordernum(domain,map,lordernum)
+char *domain;
+char *map;
+u_long *lordernum;
+{
+ char map_path[1024];
+ char order_key[YP_LAST_LEN] = YP_LAST_KEY;
+ char order[MAX_LAST_LEN+1];
+ struct stat finfo;
+ DBM *db;
+ datum k,v;
+ int status;
+
+ /* This routine returns YPPUSH_SUCC or YPPUSH_NODOM */
+
+ status = YPPUSH_SUCC;
+
+ sprintf(map_path,"%s/%s",YP_DB_PATH,domain);
+ if (!((stat(map_path, &finfo) == 0) &&
+ ((finfo.st_mode & S_IFMT) == S_IFDIR))) {
+ fprintf(stderr, "%s: domain %s not found locally\n",
+ progname, domain);
+ status = YPPUSH_NODOM;
+ }
+
+ if(status > 0) {
+
+ sprintf(map_path,"%s/%s/%s%s",YP_DB_PATH,domain,map,YPDB_SUFFIX);
+ if(!(stat(map_path, &finfo) == 0)) {
+ status = YPPUSH_NOMAP;
+ }
+ }
+
+ if(status > 0) {
+
+ sprintf(map_path,"%s/%s/%s",YP_DB_PATH,domain,map);
+ db = ypdb_open(map_path, O_RDONLY, 0444);
+ if(db == NULL) {
+ status = YPPUSH_DBM;
+ }
+
+ }
+
+ if(status > 0) {
+
+ k.dptr = (char *) &order_key;
+ k.dsize = YP_LAST_LEN;
+
+ v = ypdb_fetch(db,k);
+ ypdb_close(db);
+
+ if (v.dptr == NULL) {
+ *lordernum = 0;
+ } else {
+ strncpy(order, v.dptr, v.dsize);
+ order[v.dsize] = '\0';
+ *lordernum = (u_long) atol((char *) &order);
+ }
+ }
+
+ if((status == YPPUSH_NOMAP) || (status == YPPUSH_DBM)) {
+ *lordernum = 0;
+ status = YPPUSH_SUCC;
+ }
+
+ return(status);
+
+}
+
+int
+get_remote_ordernum(client,domain,map,lordernum,rordernum)
+CLIENT *client;
+char *domain;
+char *map;
+u_long lordernum;
+u_long *rordernum;
+{
+ int status;
+
+ status = yp_order_host(client, domain, map,(int *)rordernum);
+
+ if (status == 0) {
+ if(*rordernum <= lordernum) {
+ status = YPPUSH_AGE;
+ } else {
+ status = YPPUSH_SUCC;
+ }
+ }
+
+ return status;
+}
+
+void
+get_map(client,domain,map,incallback)
+CLIENT *client;
+char *domain;
+char *map;
+struct ypall_callback *incallback;
+{
+ u_long status;
+
+ status = yp_all_host(client, domain, map, incallback);
+
+}
+
+DBM *
+create_db(domain,map,temp_map)
+char *domain;
+char *map;
+char *temp_map;
+{
+ DBM *db;
+ char db_temp[255];
+
+ sprintf(db_temp,"%s/%s/%s",YP_DB_PATH,domain,temp_map);
+
+ db = ypdb_open(db_temp, O_RDWR|O_CREAT, 0444);
+
+ return db;
+
+ yplog_str("Open DB "); yplog_cat(db_temp); yplog_cat("\n");
+}
+
+int
+install_db(domain,map,temp_map)
+char *domain;
+char *map;
+char *temp_map;
+{
+ char db_name[255],db_temp[255];
+
+ sprintf(db_name,"%s/%s/%s%s",YP_DB_PATH,domain,map,YPDB_SUFFIX);
+ sprintf(db_temp,"%s/%s/%s%s",YP_DB_PATH,domain,temp_map,YPDB_SUFFIX);
+ rename(db_temp,db_name);
+
+ return YPPUSH_SUCC;
+}
+
+int
+add_order(db, ordernum)
+DBM *db;
+u_long ordernum;
+{
+ char datestr[10];
+ datum key,val;
+ char keystr[YP_LAST_LEN] = YP_LAST_KEY;
+ int status;
+
+ sprintf(datestr, "%010d", ordernum);
+
+ key.dptr = keystr;
+ key.dsize = strlen(keystr) + 1;
+
+ val.dptr = datestr;
+ val.dsize = strlen(datestr) + 1;
+
+ status = ypdb_store(db, key, val, YPDB_INSERT);
+ if(status >= 0) {
+ status = YPPUSH_SUCC;
+ } else {
+ status = YPPUSH_DBM;
+ }
+ return(status);
+}
+
+int
+add_master(client, domain, map, db)
+CLIENT *client;
+char *domain;
+char *map;
+DBM *db;
+{
+ char keystr[YP_MASTER_LEN] = YP_MASTER_KEY;
+ char *master;
+ int status;
+ datum key,val;
+
+ master = NULL;
+
+ /* Get MASTER */
+
+ status = yp_master_host(client, domain, map, &master);
+
+ if(master != NULL) {
+ key.dptr = keystr;
+ key.dsize = strlen(keystr) + 1;
+
+ val.dptr = master;
+ val.dsize = strlen(master) + 1;
+
+ status = ypdb_store(db, key, val, YPDB_INSERT);
+ if(status >= 0) {
+ status = YPPUSH_SUCC;
+ } else {
+ status = YPPUSH_DBM;
+ }
+ }
+
+ return status;
+}
+
+int
+add_interdomain(client, domain, map, db)
+CLIENT *client;
+char *domain;
+char *map;
+DBM *db;
+{
+ char keystr[YP_INTERDOMAIN_LEN] = YP_INTERDOMAIN_KEY;
+ char *value;
+ int vallen;
+ int status;
+ datum k,v;
+
+ /* Get INTERDOMAIN */
+
+ k.dptr = keystr;
+ k.dsize = strlen(keystr) + 1;
+
+ status = yp_match_host(client, domain, map,
+ k.dptr, k.dsize, &value, &vallen);
+
+ if(status > 0) {
+ v.dptr = value;
+ v.dsize = vallen;
+
+ if(v.dptr != NULL) {
+ status = ypdb_store(db,k,v,YPDB_INSERT);
+ if(status >= 0) {
+ status = YPPUSH_SUCC;
+ } else {
+ status = YPPUSH_DBM;
+ }
+ }
+ }
+
+ return status;
+}
+
+int
+add_secure(client, domain, map, db)
+CLIENT *client;
+char *domain;
+char *map;
+DBM *db;
+{
+ char keystr[YP_SECURE_LEN] = YP_SECURE_KEY;
+ char *value;
+ int vallen;
+ int status;
+ datum k,v;
+
+ /* Get SECURE */
+
+ k.dptr = keystr;
+ k.dsize = strlen(keystr) + 1;
+
+ status = yp_match_host(client, domain, map,
+ k.dptr, k.dsize, &value, &vallen);
+
+ if(status > 0) {
+ v.dptr = value;
+ v.dsize = vallen;
+
+ if(v.dptr != NULL) {
+ status = ypdb_store(db,k,v,YPDB_INSERT);
+ if(status >= 0) {
+ status = YPPUSH_SUCC;
+ } else {
+ status = YPPUSH_DBM;
+ }
+ }
+ }
+
+ return status;
+
+}
+
+int
+send_clear(client)
+CLIENT *client;
+{
+ struct timeval tv;
+ int r;
+ int status;
+
+ status = YPPUSH_SUCC;
+
+ tv.tv_sec = 10;
+ tv.tv_usec = 0;
+
+ /* Send CLEAR */
+
+ r = clnt_call(client, YPPROC_CLEAR,
+ xdr_void, 0, xdr_void, 0, tv);
+ if(r != RPC_SUCCESS) {
+ clnt_perror(client, "yp_clear: clnt_call");
+ }
+
+ return status;
+
+}
+
+int
+send_reply(client,status,tid)
+CLIENT *client;
+u_long status;
+u_long tid;
+{
+ struct timeval tv;
+ struct ypresp_xfr resp;
+ int r;
+
+ tv.tv_sec = 10;
+ tv.tv_usec = 0;
+
+ resp.transid = tid;
+ resp.xfrstat = status;
+
+ /* Send CLEAR */
+
+ r = clnt_call(client, 1,
+ xdr_ypresp_xfr, &resp, xdr_void, 0, tv);
+ if(r != RPC_SUCCESS) {
+ clnt_perror(client, "yppushresp_xdr: clnt_call");
+ }
+
+ return status;
+
+}
+
+int
+main (argc,argv)
+int argc;
+char *argv[];
+{
+ int usage = 0;
+ int cflag = 0;
+ int fflag = 0;
+ int Cflag = 0;
+ char ch;
+ extern char *optarg;
+ char *domain;
+ char *host = NULL;
+ char *srcdomain = NULL;
+ char *tid = NULL;
+ char *prog = NULL;
+ char *ipadd = NULL;
+ char *port = NULL;
+ char *map = NULL;
+ u_long ordernum,new_ordernum;
+ struct ypall_callback callback;
+ CLIENT *client;
+ char mapname[] = "ypdbXXXXXX";
+ int status,xfr_status;
+
+ status = YPPUSH_SUCC;
+ client = NULL;
+
+ yp_get_default_domain(&domain);
+
+ while ((ch = getopt(argc, argv, "cd:fh:s:C:")) != EOF)
+ switch (ch) {
+ case 'c':
+ cflag++;
+ break;
+ case 'd':
+ domain = optarg;
+ break;
+ case 'f':
+ fflag++;
+ break;
+ case 'h':
+ host = optarg;
+ break;
+ case 's':
+ srcdomain = optarg;
+ break;
+ case 'C':
+ Cflag++;
+ tid = optarg;
+ prog = argv[optind++];
+ ipadd = argv[optind++];
+ port = argv[optind++];
+ break;
+ default:
+ usage++;
+ break;
+ }
+
+ if(optind + 1 != argc) {
+ usage++;
+ } else {
+ map = argv[optind];
+ }
+
+ if (usage) {
+ status = YPPUSH_BADARGS;
+ (void)fprintf(stderr,"usage: %s [-cf] [-d domain] [-h host] [-s domain] [-C tid prog ipadd port] mapname\n",progname);
+ }
+
+ if (status > 0) {
+ yplog_init(progname);
+
+ yplog_date("Arguments:");
+ yplog_str("YP clear to local: ");
+ if (cflag) {
+ yplog_cat("no\n");
+ } else {
+ yplog_cat("yes\n");
+ }
+ yplog_str(" Force transfer: ");
+ if (fflag) {
+ yplog_cat("yes\n");
+ } else {
+ yplog_cat("no\n");
+ }
+ yplog_str(" domain: "); yplog_cat(domain); yplog_cat("\n");
+ yplog_str(" host: "); yplog_cat(host); yplog_cat("\n");
+ yplog_str(" source domain: "); yplog_cat(srcdomain); yplog_cat("\n");
+ yplog_str(" transid: "); yplog_cat(tid); yplog_cat("\n");
+ yplog_str(" prog: "); yplog_cat(prog); yplog_cat("\n");
+ yplog_str(" port: "); yplog_cat(port); yplog_cat("\n");
+ yplog_str(" ipadd: "); yplog_cat(ipadd); yplog_cat("\n");
+ yplog_str(" map: "); yplog_cat(map); yplog_cat("\n\n");
+
+ if(fflag != 0) {
+ ordernum = 0;
+ } else {
+ status = get_local_ordernum(domain,map,&ordernum);
+ }
+ }
+
+ if (status > 0) {
+
+ yplog_str("Get Master\n");
+
+ if (host == NULL) {
+ if (srcdomain == NULL) {
+ status = yp_master(domain,map,&host);
+ } else {
+ status = yp_master(srcdomain,map,&host);
+ }
+ if(status == 0) {
+ status = YPPUSH_SUCC;
+ } else {
+ status = -status;
+ }
+ }
+ };
+
+ if (status > 0) {
+
+ yplog_str("Connect host: "); yplog_cat(host); yplog_cat("\n");
+
+ client = yp_bind_host(host,YPPROG,YPVERS,0);
+
+ status = get_remote_ordernum(client,domain,map,
+ ordernum,&new_ordernum);
+
+ }
+
+ if (status == YPPUSH_SUCC) {
+
+ /* Create temporary db */
+ mktemp(mapname);
+ db = create_db(domain,map,mapname);
+ if(db == NULL) {
+ status = YPPUSH_DBM;
+ }
+
+ /* Add ORDER */
+ if(status > 0) {
+ status = add_order(db, new_ordernum);
+ }
+
+ /* Add MASTER */
+ if(status > 0) {
+ status = add_master(client,domain,map,db);
+ }
+
+ /* Add INTERDOMAIN */
+ if(status > 0) {
+ status = add_interdomain(client,domain,map,db);
+ }
+
+ /* Add SECURE */
+ if(status > 0) {
+ status = add_secure(client,domain,map,db);
+ }
+
+ if(status > 0) {
+ callback.foreach=ypxfr_foreach;
+ get_map(client,domain,map,&callback);
+ }
+
+ /* Close db */
+ if(db != NULL) {
+ ypdb_close(db);
+ }
+
+ /* Rename db */
+ if(status > 0) {
+ status = install_db(domain,map,mapname);
+ }
+
+ }
+
+ xfr_status = status;
+
+ if(client != NULL) {
+ clnt_destroy(client);
+ }
+
+ /* YP_CLEAR */
+
+ if(!cflag) {
+ client = yp_bind_local(YPPROG,YPVERS);
+ status = send_clear(client);
+ clnt_destroy(client);
+ }
+
+ if(Cflag > 0) {
+ /* Send Response */
+ client = yp_bind_host(ipadd,
+ atoi(prog),
+ 1,
+ atoi(port));
+ status = send_reply(client,xfr_status,atoi(tid));
+ clnt_destroy(client);
+ }
+
+ return(0);
+
+}
+
diff --git a/usr.sbin/ypserv/ypxfr/ypxfr_xdr.c b/usr.sbin/ypserv/ypxfr/ypxfr_xdr.c
new file mode 100644
index 00000000000..848bbc0b1ad
--- /dev/null
+++ b/usr.sbin/ypserv/ypxfr/ypxfr_xdr.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1995 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: ypxfr_xdr.c,v 1.1 1995/11/01 16:56:43 deraadt Exp $";
+#endif
+
+
+
+#include <rpc/rpc.h>
+#include <rpcsvc/yp.h>
+
+bool_t
+xdr_ypxfrstat(xdrs, objp)
+ XDR *xdrs;
+ ypxfrstat *objp;
+{
+ if (!xdr_enum(xdrs, (enum_t *)objp)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+#ifdef notdef
+bool_t
+xdr_ypreq_xfr(xdrs, objp)
+ XDR *xdrs;
+ ypreq_xfr *objp;
+{
+ if (!xdr_ypmap_parms(xdrs, &objp->map_parms)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->transid)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->prog)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->port)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+#endif
+
+bool_t
+xdr_ypresp_xfr(xdrs, objp)
+ XDR *xdrs;
+ ypresp_xfr *objp;
+{
+ if (!xdr_u_int(xdrs, &objp->transid)) {
+ return (FALSE);
+ }
+ if (!xdr_ypxfrstat(xdrs, &objp->xfrstat)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+
+
+