summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/yppush
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1995-01-31 09:47:11 +0000
committerwpaul <wpaul@FreeBSD.org>1995-01-31 09:47:11 +0000
commit41d13cf350157b1d608acc2fb5710763b089f865 (patch)
tree420cd1cb3fce739d620de2ee39d71d656a919851 /gnu/usr.bin/yppush
parentb8cfd20c170a58cf087aeee932e9a0a3bd73820d (diff)
downloadFreeBSD-src-41d13cf350157b1d608acc2fb5710763b089f865.zip
FreeBSD-src-41d13cf350157b1d608acc2fb5710763b089f865.tar.gz
Obtained from: The NYS project
This is a ported/modified version of the yppush program from the yps-0.21 package from the NYS project. This program is used to propagate updated NIS maps from an NIS master to an NIS slave. It's normally invoked by /var/yp/Makefile. This version of yppush has been modified in the following ways: - Cleared up several Linux/BSD incompatibilities, largely involving header files. - converted from GDBM to DB with extreme predjudice. (well, not really...) - removed lots of ugly debugging code that really didn't do anyone any good. - Fixed a couple of inaccurate/badly formatted error messages. - Renamed some functions to avoid collisions with certain YP routines hidden inside libc. - Small signal handling kludge: Linux has different struct sigaction that us. - Incorporated some functions from the yps-0.21 library that yppush was dependent on. Like ypxfr, this works, but could use come cleaning up.
Diffstat (limited to 'gnu/usr.bin/yppush')
-rw-r--r--gnu/usr.bin/yppush/Makefile10
-rw-r--r--gnu/usr.bin/yppush/yp.h292
-rw-r--r--gnu/usr.bin/yppush/yp_clnt.c216
-rw-r--r--gnu/usr.bin/yppush/yp_xdr.c477
-rw-r--r--gnu/usr.bin/yppush/ypclnt.c128
-rw-r--r--gnu/usr.bin/yppush/yppush.c373
-rw-r--r--gnu/usr.bin/yppush/yppush_s.c156
7 files changed, 1652 insertions, 0 deletions
diff --git a/gnu/usr.bin/yppush/Makefile b/gnu/usr.bin/yppush/Makefile
new file mode 100644
index 0000000..0306b62
--- /dev/null
+++ b/gnu/usr.bin/yppush/Makefile
@@ -0,0 +1,10 @@
+
+PROG= yppush
+MAN8=
+
+SRCS= yppush.c yppush_s.c yp_clnt.c yp_xdr.c ypclnt.c
+
+BINOWN= bin
+BINMODE=555
+
+.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/yppush/yp.h b/gnu/usr.bin/yppush/yp.h
new file mode 100644
index 0000000..da300d4
--- /dev/null
+++ b/gnu/usr.bin/yppush/yp.h
@@ -0,0 +1,292 @@
+/*
+ * $Id$
+ */
+
+#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;
+bool_t __xdr_ypstat();
+
+
+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;
+bool_t __xdr_ypxfrstat();
+
+
+typedef char *domainname;
+bool_t xdr_domainname();
+
+
+typedef char *mapname;
+bool_t xdr_mapname();
+
+
+typedef char *peername;
+bool_t xdr_peername();
+
+
+typedef struct {
+ u_int keydat_len;
+ char *keydat_val;
+} keydat;
+bool_t xdr_keydat();
+
+
+typedef struct {
+ u_int valdat_len;
+ char *valdat_val;
+} valdat;
+bool_t xdr_valdat();
+
+
+struct ypmap_parms {
+ domainname domain;
+ mapname map;
+ u_int ordernum;
+ peername peer;
+};
+typedef struct ypmap_parms ypmap_parms;
+bool_t __xdr_ypmap_parms();
+
+
+struct ypreq_key {
+ domainname domain;
+ mapname map;
+ keydat key;
+};
+typedef struct ypreq_key ypreq_key;
+bool_t __xdr_ypreq_key();
+
+
+struct ypreq_nokey {
+ domainname domain;
+ mapname map;
+};
+typedef struct ypreq_nokey ypreq_nokey;
+bool_t __xdr_ypreq_nokey();
+
+
+struct ypreq_xfr {
+ ypmap_parms map_parms;
+ u_int transid;
+ u_int prog;
+ u_int port;
+};
+typedef struct ypreq_xfr ypreq_xfr;
+bool_t __xdr_ypreq_xfr();
+
+
+struct ypresp_val {
+ ypstat stat;
+ valdat val;
+};
+typedef struct ypresp_val ypresp_val;
+bool_t __xdr_ypresp_val();
+
+
+struct ypresp_key_val {
+ ypstat stat;
+ keydat key;
+ valdat val;
+};
+typedef struct ypresp_key_val ypresp_key_val;
+bool_t __xdr_ypresp_key_val();
+
+
+struct ypresp_master {
+ ypstat stat;
+ peername peer;
+};
+typedef struct ypresp_master ypresp_master;
+bool_t __xdr_ypresp_master();
+
+
+struct ypresp_order {
+ ypstat stat;
+ u_int ordernum;
+};
+typedef struct ypresp_order ypresp_order;
+bool_t __xdr_ypresp_order();
+
+
+struct ypresp_all {
+ bool_t more;
+ union {
+ ypresp_key_val val;
+ } ypresp_all_u;
+};
+typedef struct ypresp_all ypresp_all;
+bool_t __xdr_ypresp_all();
+
+
+struct ypresp_xfr {
+ u_int transid;
+ ypxfrstat xfrstat;
+};
+typedef struct ypresp_xfr ypresp_xfr;
+bool_t __xdr_ypresp_xfr();
+
+
+struct ypmaplist {
+ mapname map;
+ struct ypmaplist *next;
+};
+typedef struct ypmaplist ypmaplist;
+bool_t __xdr_ypmaplist();
+
+
+struct ypresp_maplist {
+ ypstat stat;
+ ypmaplist *maps;
+};
+typedef struct ypresp_maplist ypresp_maplist;
+bool_t __xdr_ypresp_maplist();
+
+
+enum yppush_status {
+ YPPUSH_SUCC = 1,
+ YPPUSH_AGE = 2,
+ YPPUSH_NOMAP = -1,
+ YPPUSH_NODOM = -2,
+ YPPUSH_RSRC = -3,
+ YPPUSH_RPC = -4,
+ YPPUSH_MADDR = -5,
+ YPPUSH_YPERR = -6,
+ YPPUSH_BADARGS = -7,
+ YPPUSH_DBM = -8,
+ YPPUSH_FILE = -9,
+ YPPUSH_SKEW = -10,
+ YPPUSH_CLEAR = -11,
+ YPPUSH_FORCE = -12,
+ YPPUSH_XFRERR = -13,
+ YPPUSH_REFUSED = -14,
+};
+typedef enum yppush_status yppush_status;
+bool_t __xdr_yppush_status();
+
+
+struct yppushresp_xfr {
+ u_int transid;
+ yppush_status status;
+};
+typedef struct yppushresp_xfr yppushresp_xfr;
+bool_t __xdr_yppushresp_xfr();
+
+
+enum ypbind_resptype {
+ YPBIND_SUCC_VAL = 1,
+ YPBIND_FAIL_VAL = 2,
+};
+typedef enum ypbind_resptype ypbind_resptype;
+bool_t __xdr_ypbind_resptype();
+
+
+struct ypbind_binding {
+ char ypbind_binding_addr[4];
+ char ypbind_binding_port[2];
+};
+typedef struct ypbind_binding ypbind_binding;
+bool_t __xdr_ypbind_binding();
+
+
+struct ypbind_resp {
+ ypbind_resptype ypbind_status;
+ union {
+ u_int ypbind_error;
+ ypbind_binding ypbind_bindinfo;
+ } ypbind_resp_u;
+};
+typedef struct ypbind_resp ypbind_resp;
+bool_t __xdr_ypbind_resp();
+
+#define YPBIND_ERR_ERR 1
+#define YPBIND_ERR_NOSERV 2
+#define YPBIND_ERR_RESC 3
+
+struct ypbind_setdom {
+ domainname ypsetdom_domain;
+ ypbind_binding ypsetdom_binding;
+ u_int ypsetdom_vers;
+};
+typedef struct ypbind_setdom ypbind_setdom;
+bool_t __xdr_ypbind_setdom();
+
+
+#define YPPROG ((u_long)100004)
+#define YPVERS ((u_long)2)
+#define YPPROC_NULL ((u_long)0)
+extern void *ypproc_null_2();
+#define YPPROC_DOMAIN ((u_long)1)
+extern bool_t *ypproc_domain_2();
+#define YPPROC_DOMAIN_NONACK ((u_long)2)
+extern bool_t *ypproc_domain_nonack_2();
+#define YPPROC_MATCH ((u_long)3)
+extern ypresp_val *ypproc_match_2();
+#define YPPROC_FIRST ((u_long)4)
+extern ypresp_key_val *ypproc_first_2();
+#define YPPROC_NEXT ((u_long)5)
+extern ypresp_key_val *ypproc_next_2();
+#define YPPROC_XFR ((u_long)6)
+extern ypresp_xfr *ypproc_xfr_2();
+#define YPPROC_CLEAR ((u_long)7)
+extern void *ypproc_clear_2();
+#define YPPROC_ALL ((u_long)8)
+extern ypresp_all *ypproc_all_2();
+#define YPPROC_MASTER ((u_long)9)
+extern ypresp_master *ypproc_master_2();
+#define YPPROC_ORDER ((u_long)10)
+extern ypresp_order *ypproc_order_2();
+#define YPPROC_MAPLIST ((u_long)11)
+extern ypresp_maplist *ypproc_maplist_2();
+
+
+#define YPPUSH_XFRRESPPROG ((u_long)0x40000000)
+#define YPPUSH_XFRRESPVERS ((u_long)1)
+#define YPPUSHPROC_NULL ((u_long)0)
+extern void *yppushproc_null_1();
+#define YPPUSHPROC_XFRRESP ((u_long)1)
+extern yppushresp_xfr *yppushproc_xfrresp_1();
+
+
+#define YPBINDPROG ((u_long)100007)
+#define YPBINDVERS ((u_long)2)
+#define YPBINDPROC_NULL ((u_long)0)
+extern void *ypbindproc_null_2();
+#define YPBINDPROC_DOMAIN ((u_long)1)
+extern ypbind_resp *ypbindproc_domain_2();
+#define YPBINDPROC_SETDOM ((u_long)2)
+extern void *ypbindproc_setdom_2();
+
diff --git a/gnu/usr.bin/yppush/yp_clnt.c b/gnu/usr.bin/yppush/yp_clnt.c
new file mode 100644
index 0000000..32d9007
--- /dev/null
+++ b/gnu/usr.bin/yppush/yp_clnt.c
@@ -0,0 +1,216 @@
+/*
+ YPS-0.2, NIS-Server for Linux
+ Copyright (C) 1994 Tobias Reber
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Modified for use with FreeBSD 2.x by Bill Paul (wpaul@ctr.columbia.edu)
+
+ $Id$
+*/
+
+/*
+ * $Author: root $
+ * $Log: yp_clnt.c,v $
+ * Revision 0.16 1994/01/02 22:48:22 root
+ * Added strict prototypes
+ *
+ * Revision 0.15 1994/01/02 20:09:39 root
+ * Added GPL notice
+ *
+ * Revision 0.14 1993/12/19 12:42:32 root
+ * *** empty log message ***
+ *
+ * Revision 0.13 1993/06/12 09:39:30 root
+ * Align with include-4.4
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <rpc/rpc.h>
+#include <sys/time.h>
+#include "yp.h"
+
+#ifdef DEBUG
+#define PRINTF(x) printf x
+#else
+#define PRINTF(x)
+#endif
+
+static struct timeval TIMEOUT = { 25, 0 };
+
+void *
+ypproc_null_2( int *argp, CLIENT *clnt)
+{
+ static char res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_NULL, xdr_void, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return ((void *)&res);
+}
+
+
+bool_t *
+ypproc_domain_2( domainname *argp, CLIENT *clnt)
+{
+ static bool_t res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_DOMAIN, xdr_domainname, argp, xdr_bool, &res, TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&res);
+}
+
+
+bool_t *
+ypproc_domain_nonack_2( domainname *argp, CLIENT *clnt)
+{
+ static bool_t res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_DOMAIN_NONACK, xdr_domainname, argp, xdr_bool, &res, TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&res);
+}
+
+
+ypresp_val *
+ypproc_match_2( ypreq_key *argp, CLIENT *clnt)
+{
+ static ypresp_val res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_MATCH, __xdr_ypreq_key, argp, __xdr_ypresp_val, &res, TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&res);
+}
+
+
+ypresp_key_val *
+ypproc_first_2( ypreq_key *argp, CLIENT *clnt)
+{
+ static ypresp_key_val res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_FIRST, __xdr_ypreq_key, argp, __xdr_ypresp_key_val, &res, TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&res);
+}
+
+
+ypresp_key_val *
+ypproc_next_2( ypreq_key *argp, CLIENT *clnt)
+{
+ static ypresp_key_val res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_NEXT, __xdr_ypreq_key, argp, __xdr_ypresp_key_val, &res, TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&res);
+}
+
+
+ypresp_xfr *
+ypproc_xfr_2( ypreq_xfr *argp, CLIENT *clnt)
+{
+ static ypresp_xfr res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_XFR, __xdr_ypreq_xfr, argp, __xdr_ypresp_xfr, &res, TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&res);
+}
+
+
+void *
+ypproc_clear_2( int *argp, CLIENT *clnt)
+{
+ static char res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_CLEAR, xdr_void, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return ((void *)&res);
+}
+
+
+ypresp_all *
+ypproc_all_2( ypreq_nokey *argp, CLIENT *clnt)
+{
+ static ypresp_all res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_ALL, __xdr_ypreq_nokey, argp, __xdr_ypresp_all, &res, TIMEOUT) != RPC_SUCCESS) {
+ PRINTF(("ypproc_all_2 retuning NULL\n"));
+ return (NULL);
+ }
+ PRINTF(("ypproc_all_2 retuning non-NULL\n"));
+ return (&res);
+}
+
+
+ypresp_master *
+ypproc_master_2( ypreq_nokey *argp, CLIENT *clnt)
+{
+ static ypresp_master res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_MASTER, __xdr_ypreq_nokey, argp, __xdr_ypresp_master, &res, TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&res);
+}
+
+
+ypresp_order *
+ypproc_order_2( ypreq_nokey *argp, CLIENT *clnt)
+{
+ static ypresp_order res;
+ PRINTF (("ypproc_order_2()\n"));
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_ORDER, __xdr_ypreq_nokey, argp, __xdr_ypresp_order, &res, TIMEOUT) != RPC_SUCCESS) {
+ PRINTF (("ypproc_order_2()\n"));
+ return (NULL);
+ }
+ PRINTF (("ypproc_order_2()\n"));
+ return (&res);
+}
+
+
+ypresp_maplist *
+ypproc_maplist_2( domainname *argp, CLIENT *clnt)
+{
+ static ypresp_maplist res;
+
+ bzero(&res, sizeof(res));
+ if (clnt_call(clnt, YPPROC_MAPLIST, xdr_domainname, argp, __xdr_ypresp_maplist, &res, TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&res);
+}
+
diff --git a/gnu/usr.bin/yppush/yp_xdr.c b/gnu/usr.bin/yppush/yp_xdr.c
new file mode 100644
index 0000000..5afc8d9c
--- /dev/null
+++ b/gnu/usr.bin/yppush/yp_xdr.c
@@ -0,0 +1,477 @@
+/*
+ YPS-0.2, NIS-Server for Linux
+ Copyright (C) 1994 Tobias Reber
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Modified for use with FreeBSD 2.x by Bill Paul (wpaul@ctr.columbia.edu)
+
+ $Id$
+*/
+
+/*
+ * $Author: root $
+ * $Log: yp_xdr.c,v $
+ * Revision 0.20 1994/01/02 22:48:22 root
+ * Added strict prototypes
+ *
+ * Revision 0.19 1994/01/02 20:09:39 root
+ * Added GPL notice
+ *
+ * Revision 0.18 1994/01/02 18:06:13 root
+ * Fixed another bug in __xdr_ypresp_all
+ *
+ * Revision 0.17 1993/12/30 22:34:57 root
+ * *** empty log message ***
+ *
+ * Revision 0.16 1993/12/29 00:37:37 root
+ * Fixed a bug in __xdr_ypresp_key_val
+ *
+ * Revision 0.15 1993/06/16 22:54:12 dok235
+ * Fix a bug in ypresp_key_val
+ *
+ * Revision 0.14 1993/06/12 09:39:30 root
+ * Align with include-4.4
+ *
+ * Revision 0.13 1993/06/11 21:45:00 root
+ * Regenned from yp.x, that came with include-4.4
+ *
+ */
+
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include <rpc/rpc.h>
+#include <rpcsvc/yp.h>
+
+#ifdef DEBUG
+#define PRINTF(x) printf x
+#define PRLINENO printf(__FILE__ "(%d): ", __LINE__)
+#else
+#define PRINTF(x)
+#define PRLINENO
+#endif
+
+struct {
+ union {
+ int (*encoder)(char *, int, char **, int *, char **, int *);
+ int (*decoder)(int, char *, int, char *, int, char *);
+ } foreach;
+ char *data;
+} *__xdr_ypall_callback;
+
+bool_t
+__xdr_ypstat(XDR *xdrs, ypstat *objp)
+{
+
+ if (!xdr_enum(xdrs, (enum_t *)objp)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_ypxfrstat(XDR *xdrs, ypxfrstat *objp)
+{
+
+ if (!xdr_enum(xdrs, (enum_t *)objp)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_domainname(XDR *xdrs, domainname *objp)
+{
+
+ if (!xdr_string(xdrs, objp, YPMAXDOMAIN)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_mapname(XDR *xdrs, mapname *objp)
+{
+
+ if (!xdr_string(xdrs, objp, YPMAXMAP)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_peername(XDR *xdrs, peername *objp)
+{
+
+ if (!xdr_string(xdrs, objp, YPMAXPEER)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_keydat(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(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(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(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(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(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(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(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(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(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(XDR *xdrs, ypresp_all *objp)
+{
+ int CallAgain = 0;
+ PRLINENO;
+ if (xdrs->x_op == XDR_DECODE) {
+ while(1) {
+#if 1
+ int s=objp->ypresp_all_u.val.stat;
+ bzero((char *)objp, sizeof (*objp));
+ objp->ypresp_all_u.val.stat=s;
+#endif
+ 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);
+ }
+ if (CallAgain==0) {
+ CallAgain=(*(__xdr_ypall_callback->foreach.decoder))(
+ objp->ypresp_all_u.val.stat,
+ objp->ypresp_all_u.val.key.keydat_val,
+ objp->ypresp_all_u.val.key.keydat_len,
+ objp->ypresp_all_u.val.val.valdat_val,
+ objp->ypresp_all_u.val.val.valdat_len,
+ __xdr_ypall_callback->data);
+ }
+ break;
+ case FALSE:
+ return TRUE;
+ }
+#if 0
+ xdrs->x_op=XDR_FREE;
+ if (!__xdr_ypresp_all(xdrs, objp)) {
+ return FALSE;
+ }
+ xdrs->x_op=XDR_DECODE;
+#else
+ xdr_free(__xdr_ypresp_all, (char *)objp);
+#endif
+ }
+ } else if (xdrs->x_op == XDR_ENCODE) {
+ while(1) {
+ if (!xdr_bool(xdrs, &(objp->more))) {
+ return (FALSE);
+ }
+ if (!__xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val)) {
+ printf("__xdr_ypresp_key_val failed\n");
+ return (FALSE);
+ }
+ if (objp->ypresp_all_u.val.stat!=YP_TRUE) {
+ objp->more=FALSE;
+ if (!xdr_bool(xdrs, &(objp->more))) {
+ return (FALSE);
+ }
+ return(TRUE);
+ }
+ objp->ypresp_all_u.val.stat =
+ (enum ypstat)(*(__xdr_ypall_callback->foreach.encoder))(
+ objp->ypresp_all_u.val.key.keydat_val,
+ objp->ypresp_all_u.val.key.keydat_len,
+ &(objp->ypresp_all_u.val.key.keydat_val),
+ &(objp->ypresp_all_u.val.key.keydat_len),
+ &(objp->ypresp_all_u.val.val.valdat_val),
+ &(objp->ypresp_all_u.val.val.valdat_len));
+ }
+ } else {
+#if 0
+ bool_t more=objp->more;
+ if (more==TRUE) {
+ if (!xdr_bool(xdrs, &objp->more)) {
+ return FALSE;
+ }
+ if (!__xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val)) {
+ return (FALSE);
+ }
+ }
+#endif
+
+ return(TRUE);
+ }
+}
+
+bool_t
+__xdr_ypresp_xfr(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(XDR *xdrs, ypmaplist *objp)
+{
+
+ if (!__xdr_mapname(xdrs, &objp->map)) {
+ return (FALSE);
+ }
+ if (!xdr_pointer(xdrs, (char **)&objp->next, sizeof(ypmaplist), (xdrproc_t)__xdr_ypmaplist)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_ypresp_maplist(XDR *xdrs, ypresp_maplist *objp)
+{
+
+ if (!__xdr_ypstat(xdrs, &objp->stat)) {
+ return (FALSE);
+ }
+ if (!xdr_pointer(xdrs, (char **)&objp->maps, sizeof(ypmaplist), (xdrproc_t)__xdr_ypmaplist)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_yppush_status(XDR *xdrs, yppush_status *objp)
+{
+
+ if (!xdr_enum(xdrs, (enum_t *)objp)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_yppushresp_xfr(XDR *xdrs, yppushresp_xfr *objp)
+{
+
+ if (!xdr_u_int(xdrs, &objp->transid)) {
+ return (FALSE);
+ }
+ if (!__xdr_yppush_status(xdrs, &objp->status)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_ypbind_resptype(XDR *xdrs, ypbind_resptype *objp)
+{
+
+ if (!xdr_enum(xdrs, (enum_t *)objp)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_ypbind_binding(XDR *xdrs, ypbind_binding *objp)
+{
+
+ if (!xdr_opaque(xdrs, objp->ypbind_binding_addr, 4)) {
+ return (FALSE);
+ }
+ if (!xdr_opaque(xdrs, objp->ypbind_binding_port, 2)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_ypbind_resp(XDR *xdrs, ypbind_resp *objp)
+{
+
+ if (!__xdr_ypbind_resptype(xdrs, &objp->ypbind_status)) {
+ return (FALSE);
+ }
+ switch (objp->ypbind_status) {
+ case YPBIND_FAIL_VAL:
+ if (!xdr_u_int(xdrs, &objp->ypbind_resp_u.ypbind_error)) {
+ return (FALSE);
+ }
+ break;
+ case YPBIND_SUCC_VAL:
+ if (!__xdr_ypbind_binding(xdrs, &objp->ypbind_resp_u.ypbind_bindinfo)) {
+ return (FALSE);
+ }
+ break;
+ default:
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+__xdr_ypbind_setdom(XDR *xdrs, ypbind_setdom *objp)
+{
+
+ if (!__xdr_domainname(xdrs, &objp->ypsetdom_domain)) {
+ return (FALSE);
+ }
+ if (!__xdr_ypbind_binding(xdrs, &objp->ypsetdom_binding)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->ypsetdom_vers)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
diff --git a/gnu/usr.bin/yppush/ypclnt.c b/gnu/usr.bin/yppush/ypclnt.c
new file mode 100644
index 0000000..0088754
--- /dev/null
+++ b/gnu/usr.bin/yppush/ypclnt.c
@@ -0,0 +1,128 @@
+/*
+ YPS-0.2, NIS-Server for Linux
+ Copyright (C) 1994 Tobias Reber
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Modified for use with FreeBSd 2.x by Bill Paul (wpaul@ctr.columbia.edu)
+
+ $Id$
+*/
+
+/*
+ * $Author: root $
+ * $Log: ypclnt.c,v $
+ * Revision 2.0 1994/01/06 16:58:48 root
+ * Version 2.0
+ *
+ * Revision 0.17 1994/01/02 22:48:22 root
+ * Added strict prototypes
+ *
+ * Revision 0.16 1994/01/02 20:09:39 root
+ * Added GPL notice
+ *
+ * Revision 0.15 1993/12/30 22:34:57 root
+ * *** empty log message ***
+ *
+ * Revision 0.14 1993/12/19 12:42:32 root
+ * *** empty log message ***
+ *
+ * Revision 0.13 1993/06/12 09:39:30 root
+ * Align with include-4.4
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <rpc/rpc.h>
+#include <rpc/pmap_clnt.h>
+#include <rpcsvc/yp.h>
+/*
+ * ypclnt.h does not have a definition for struct dom_binding,
+ * although it is used there. It is defined in yp_prot.h, but
+ * we cannot use it here.
+ */
+struct dom_binding {
+ void * m;
+};
+#include <rpcsvc/ypclnt.h>
+
+#if 0
+#define SOCKSERVER 0x7f000001
+#endif
+
+static struct sockaddr_in ServerAddress;
+static CLIENT *UdpClient=NULL, *TcpClient=NULL;
+
+void
+_yp_unbind(char *DomainName)
+{
+ if (UdpClient) clnt_destroy(UdpClient);
+ UdpClient=NULL;
+ if (TcpClient) clnt_destroy(TcpClient);
+ TcpClient=NULL;
+}
+
+int
+_yp_bind(struct sockaddr_in *ServerAddress, char *DomainName)
+{
+ struct sockaddr_in UdpServerAddress, TcpServerAddress;
+ int UdpSockp, TcpSockp;
+ static struct timeval Wait = { 5, 0 };
+
+ if (UdpClient || TcpClient) yp_unbind(DomainName);
+
+ bcopy(ServerAddress, &UdpServerAddress, sizeof(*ServerAddress));
+ UdpServerAddress.sin_port=0;
+ UdpSockp=(RPC_ANYSOCK);
+ bcopy(ServerAddress, &TcpServerAddress, sizeof(*ServerAddress));
+ TcpServerAddress.sin_port=0;
+ TcpSockp=(RPC_ANYSOCK);
+ if ((UdpClient=clntudp_create(&UdpServerAddress, YPPROG, YPVERS,
+ Wait, &UdpSockp))==NULL) {
+ clnt_pcreateerror("UdpClient");
+ return(YPERR_RPC);
+ }
+ if ((TcpClient=clnttcp_create(&TcpServerAddress, YPPROG, YPVERS,
+ &TcpSockp, 0, 0))==NULL) {
+ clnt_pcreateerror("TcpClient");
+ return(YPERR_RPC);
+ }
+ return(0);
+
+}
+
+
+int
+_yp_clear(char *DomainName)
+{
+ void *resp;
+ int Status;
+
+ do {
+ if (UdpClient==NULL)
+ if ((Status=yp_bind(DomainName))) return(Status);
+ if ((resp=ypproc_clear_2(NULL, UdpClient))==NULL) {
+ clnt_perror(UdpClient, "_yp_clear");
+ _yp_unbind(DomainName);
+ }
+ } while(resp==NULL);
+ return 0;
+}
diff --git a/gnu/usr.bin/yppush/yppush.c b/gnu/usr.bin/yppush/yppush.c
new file mode 100644
index 0000000..5ca5898
--- /dev/null
+++ b/gnu/usr.bin/yppush/yppush.c
@@ -0,0 +1,373 @@
+/*
+ YPS-0.2, NIS-Server for Linux
+ Copyright (C) 1994 Tobias Reber
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Modified for use with FreeBSD 2.x by Bill Paul (wpaul@ctr.columbia.edu)
+
+ $Id$
+*/
+/*
+ * $Author: root $
+ * $Log: yppush.c,v $
+ * Revision 2.0 1994/01/06 16:58:08 root
+ * Version 2.0
+ *
+ * Revision 1.4 1994/01/02 23:00:59 root
+ * Use -v flag
+ *
+ * Revision 1.3 1994/01/02 21:59:08 root
+ * Strict prototypes
+ *
+ * Revision 1.2 1994/01/02 20:10:08 root
+ * Added GPL notice
+ *
+ * Revision 1.1 1994/01/02 18:04:08 root
+ * Initial revision
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <rpc/rpc.h>
+#include <paths.h>
+#include "yp.h"
+/*
+ * ypclnt.h does not have a definition for struct dom_binding,
+ * although it is used there. It is defined in yp_prot.h, but
+ * we cannot use it here.
+ */
+struct dom_binding {
+ void * m;
+};
+#include <rpcsvc/ypclnt.h>
+#include <sys/param.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+#include <ctype.h>
+#include <netdb.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <db.h>
+#include <limits.h>
+#include <sys/stat.h>
+
+#define PERM_SECURE (S_IRUSR|S_IWUSR)
+HASHINFO openinfo = {
+ 4096, /* bsize */
+ 32, /* ffactor */
+ 256, /* nelem */
+ 2048 * 1024, /* cachesize */
+ NULL, /* hash */
+ 0 /* lorder */
+};
+
+#undef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+
+static char *DomainName=NULL;
+static bool_t Verbose=FALSE;
+
+static char *ThisHost=NULL;
+
+static char *MapName;
+static u_int MapOrderNum;
+
+static CLIENT *PushClient=NULL;
+
+static u_int CallbackTransid;
+static u_int CallbackProg=0;
+static SVCXPRT *CallbackXprt;
+
+/*
+ * This is the rpc server side idle loop
+ * Wait for input, call server program.
+ */
+
+static void
+_svc_run( void)
+{
+#ifdef FD_SETSIZE
+ fd_set readfds;
+#else
+ int readfds;
+#endif /* def FD_SETSIZE */
+ extern int errno;
+ struct timeval t;
+
+ t.tv_sec=60; t.tv_usec=0;
+
+ for (;;) {
+#ifdef FD_SETSIZE
+ readfds = svc_fdset;
+#else
+ readfds = svc_fds;
+#endif /* def FD_SETSIZE */
+ switch (select(_rpc_dtablesize(), &readfds, (void *)0,
+ (void *)0, &t)) {
+ case -1:
+ if (errno == EINTR) {
+ continue;
+ }
+ perror("svc_run: - select failed");
+ return;
+ case 0:
+ fprintf(stderr, "YPPUSH: Callback timed out\n");
+ exit(0);
+ default:
+ svc_getreqset(&readfds);
+ }
+ }
+}
+
+static void
+Usage(void)
+{
+ fprintf(stderr, "Usage: yppush [ -d domain ] [ -v ] mapname ...\n");
+ exit(1);
+}
+
+static char *
+getHostName( void)
+{
+ static char hostname[MAXHOSTNAMELEN+1];
+ struct hostent *h;
+ if (gethostname(hostname, sizeof hostname)!=0) {
+ perror("YPPUSH: gethostname");
+ return NULL;
+ }
+ h=gethostbyname(hostname);
+ if (h!=NULL) {
+ strncpy(hostname, h->h_name, sizeof (hostname)-1);
+ hostname[sizeof (hostname)-1]='\0';
+ }
+ return hostname;
+}
+
+static u_int
+getOrderNum( void)
+{
+ char mapPath[MAXPATHLEN];
+ DB *db;
+ DBT o,d;
+ int i;
+
+ strcpy(mapPath, _PATH_YP);
+ strcat(mapPath, "/");
+ strcat(mapPath, DomainName);
+ strcat(mapPath, "/");
+ strcat(mapPath, MapName);
+ if ((db = dbopen(mapPath, O_RDWR|O_EXCL, PERM_SECURE, DB_HASH,
+ &openinfo)) == NULL) {
+ fprintf(stderr, "YPPUSH: %s: Cannot open\n", mapPath);
+ return -1;
+ }
+
+ o.data="YP_LAST_MODIFIED"; o.size=strlen(o.data);
+ (db->get)(db,&o,&d,0);
+ if (d.data==NULL) {
+ fprintf(stderr, "YPPUSH: %s: Cannot determine order number\n",
+ MapName);
+ return -1;
+ }
+
+ for (i=0; i<d.size; i++) {
+ if (!isdigit(*((char *)d.data+i))) {
+ fprintf(stderr, "YPPUSH: %s: Invalid order number '%s'\n",
+ MapName, d.data);
+ return -1;
+ }
+ }
+ (void)(db->close)(db);
+ return atoi(d.data);
+}
+
+static void
+doPushClient( const char *targetHost)
+{
+ struct ypreq_xfr req;
+ static struct timeval tv={0,0};
+
+ req.map_parms.domain=DomainName ;
+ req.map_parms.map=(char *)MapName;
+ req.map_parms.peer=ThisHost;
+ req.map_parms.ordernum=MapOrderNum;
+ req.transid=CallbackTransid;
+ req.prog=CallbackProg;
+ req.port=CallbackXprt->xp_port;
+
+ if (Verbose)
+ printf("%d: %s(%d@%s) -> %s@%s\n", req.transid,
+ req.map_parms.map, req.map_parms.ordernum,
+ req.map_parms.peer, targetHost,
+ req.map_parms.domain);
+ switch (clnt_call(PushClient, YPPROC_XFR, __xdr_ypreq_xfr, &req,
+ xdr_void, NULL, tv)) {
+ case RPC_SUCCESS:
+ case RPC_TIMEDOUT:
+ break;
+ default:
+ clnt_perror(PushClient, "YPPUSH: Cannot call YPPROC_XFR");
+ kill(CallbackTransid, SIGTERM);
+ }
+ return;
+}
+
+extern void yppush_xfrrespprog_1(struct svc_req *request, SVCXPRT *xprt);
+
+static bool_t
+registerServer(void)
+{
+ int s;
+ s=RPC_ANYSOCK;
+ CallbackXprt=svcudp_create(s);
+ if (CallbackXprt==NULL) {
+ fprintf(stderr, "YPPUSH: Cannot create callback transport.\n");
+ return FALSE;
+ }
+ for (CallbackProg=0x40000000; CallbackProg<0x5fffffff; CallbackProg++) {
+ if (svc_register(CallbackXprt, CallbackProg, 1,
+ yppush_xfrrespprog_1, IPPROTO_UDP))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static bool_t
+createClient(const char *targetHost)
+{
+ PushClient=clnt_create((char *)targetHost, YPPROG, YPVERS, "tcp");
+ if (PushClient==NULL) {
+ clnt_pcreateerror("YPPUSH: Cannot create client");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void
+doPush( const char *targetHost)
+{
+ int s;
+ struct rusage r;
+
+ if (!createClient(targetHost))
+ return;
+ if (!registerServer())
+ return;
+
+ switch (CallbackTransid=fork()) {
+ case -1:
+ perror("YPPUSH: Cannot fork");
+ exit(1);
+ case 0:
+ _svc_run();
+ exit(0);
+ default:
+ close(CallbackXprt->xp_sock);
+ doPushClient(targetHost);
+ wait4(CallbackTransid, &s, 0, &r);
+ svc_unregister(CallbackProg, 1);
+ CallbackProg=0;
+ if (PushClient!=NULL) {
+ clnt_destroy(PushClient);
+ PushClient=NULL;
+ }
+ }
+}
+
+static int
+yppushForeach(int status, const char *inKey, int inKeylen,
+ const char *inVal, int inVallen, const char *data)
+{
+ char targetHost[YPMAXPEER+1];
+
+ if (status!=YP_TRUE) return 0;
+ memcpy(targetHost, inKey, MIN(sizeof (targetHost)-1, inKeylen));
+ targetHost[MIN(sizeof (targetHost)-1, inKeylen)]='\0';
+ doPush(targetHost);
+ return 0;
+}
+
+static void
+intrHandler(int sig)
+{
+ if (CallbackProg!=0)
+ svc_unregister(CallbackProg, 1);
+ exit(1);
+}
+
+int
+main(int argc, char **argv)
+{
+ char c;
+ struct ypall_callback f;
+ enum ypstat y;
+ struct sigaction a;
+
+ a.sa_handler=intrHandler;
+ a.sa_mask=0;
+ /* a.sa_flags=SA_NOMASK;
+ a.sa_restorer=NULL; */
+ sigaction(SIGINT, &a, NULL);
+
+ while((c=getopt(argc, argv, "d:v"))!=EOF) {
+ switch(c) {
+ case 'd':
+ DomainName=optarg;
+ break;
+ case 'v':
+ Verbose=TRUE;
+ break;
+ default:
+ Usage();
+ }
+ }
+ argc-=optind;
+ argv+=optind;
+ if (argc<1) Usage();
+
+ if (DomainName==NULL) {
+ if (yp_get_default_domain(&DomainName)!=0) {
+ fprintf(stderr, "YPPUSH: Cannot get default domain\n");
+ exit(1);
+ }
+ }
+
+ ThisHost=getHostName();
+ if (ThisHost==NULL) {
+ fprintf(stderr, "YPPUSH: Cannot determine local hostname\n");
+ exit(1);
+ }
+
+ while (*argv) {
+ MapName=*argv++;
+ MapOrderNum=getOrderNum();
+ if (MapOrderNum==0xffffffff)
+ continue;
+ f.foreach=yppushForeach;
+ y=yp_all(DomainName, "ypservers", &f);
+ if (y && y!=YP_NOMORE) {
+ fprintf(stderr, "YPPUSH: Could not read ypservers: %d %s\n",
+ y, yperr_string(y));
+ exit(1);
+ }
+ }
+ exit(0);
+}
diff --git a/gnu/usr.bin/yppush/yppush_s.c b/gnu/usr.bin/yppush/yppush_s.c
new file mode 100644
index 0000000..89cc8e8
--- /dev/null
+++ b/gnu/usr.bin/yppush/yppush_s.c
@@ -0,0 +1,156 @@
+/*
+ YPS-0.2, NIS-Server for Linux
+ Copyright (C) 1994 Tobias Reber
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Modified for use with FreeBSD 2.x by Bill Paul (wpaul@ctr.columbia.edu)
+
+ $Id$
+*/
+/*
+ * $Author: root $
+ * $Log: yppush_s.c,v $
+ * Revision 1.3 1994/01/02 21:59:08 root
+ * Strict prototypes
+ *
+ * Revision 1.2 1994/01/02 20:10:08 root
+ * Added GPL notice
+ *
+ * Revision 1.1 1994/01/02 18:04:08 root
+ * Initial revision
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rpc/rpc.h>
+
+enum yppush_status {
+ YPPUSH_SUCC = 1,
+ YPPUSH_AGE = 2,
+ YPPUSH_NOMAP = -1,
+ YPPUSH_NODOM = -2,
+ YPPUSH_RSRC = -3,
+ YPPUSH_RPC = -4,
+ YPPUSH_MADDR = -5,
+ YPPUSH_YPERR = -6,
+ YPPUSH_BADARGS = -7,
+ YPPUSH_DBM = -8,
+ YPPUSH_FILE = -9,
+ YPPUSH_SKEW = -10,
+ YPPUSH_CLEAR = -11,
+ YPPUSH_FORCE = -12,
+ YPPUSH_XFRERR = -13,
+ YPPUSH_REFUSED = -14,
+};
+typedef enum yppush_status yppush_status;
+bool_t __xdr_yppush_status(XDR *, void *);
+
+static inline char *
+yppush_err_string(enum yppush_status y) {
+ switch(y) {
+ case YPPUSH_SUCC: return "Success";
+ case YPPUSH_AGE: return "Master's version not newer";
+ case YPPUSH_NOMAP: return "Can't find server for map";
+ case YPPUSH_NODOM: return "Domain not supported";
+ case YPPUSH_RSRC: return "Local resource alloc failure";
+ case YPPUSH_RPC: return "RPC failure talking to server";
+ case YPPUSH_MADDR: return "Can't get master address";
+ case YPPUSH_YPERR: return "YP server/map db error";
+ case YPPUSH_BADARGS: return "Request arguments bad";
+ case YPPUSH_DBM: return "Local dbm operation failed";
+ case YPPUSH_FILE: return "Local file I/O operation failed";
+ case YPPUSH_SKEW: return "Map version skew during transfer";
+ case YPPUSH_CLEAR: return "Can't send \"Clear\" req to local ypserv";
+ case YPPUSH_FORCE: return "No local order number in map use -f flag.";
+ case YPPUSH_XFRERR: return "ypxfr error";
+ case YPPUSH_REFUSED: return "Transfer request refused by ypserv";
+ }
+}
+
+struct yppushresp_xfr {
+ u_int transid;
+ yppush_status status;
+};
+typedef struct yppushresp_xfr yppushresp_xfr;
+bool_t __xdr_yppushresp_xfr(XDR *, void *);
+
+
+#define YPPUSH_XFRRESPPROG ((u_long)0x40000000)
+#define YPPUSH_XFRRESPVERS ((u_long)1)
+
+#define YPPUSHPROC_NULL ((u_long)0)
+static inline void *
+yppushproc_null_1(void * req, struct svc_req * rqstp) {
+ static int resp;
+ return &resp;
+}
+
+#define YPPUSHPROC_XFRRESP ((u_long)1)
+static inline void *
+yppushproc_xfrresp_1(yppushresp_xfr *req, struct svc_req * rqstp) {
+ static int resp;
+
+ if (req->status!=YPPUSH_SUCC)
+ fprintf(stderr, "YPPUSH: %s\n", yppush_err_string(req->status));
+ return &resp;
+}
+
+void
+yppush_xfrrespprog_1( struct svc_req *rqstp, SVCXPRT *transp)
+{
+ union {
+ int fill;
+ } argument;
+ char *result;
+ bool_t (*xdr_argument)(XDR *, void *), (*xdr_result)(XDR *, void *);
+ char *(*local)( void *, struct svc_req *);
+
+ switch (rqstp->rq_proc) {
+ case YPPUSHPROC_NULL:
+ xdr_argument = (bool_t (*)(XDR *, void *))xdr_void;
+ xdr_result = (bool_t (*)(XDR *, void *))xdr_void;
+ local = (char *(*)( void *, struct svc_req *)) yppushproc_null_1;
+ break;
+
+ case YPPUSHPROC_XFRRESP:
+ xdr_argument = __xdr_yppushresp_xfr;
+ xdr_result = (bool_t (*)(XDR *, void *))xdr_void;
+ local = (char *(*)( void *, struct svc_req *)) yppushproc_xfrresp_1;
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ exit(1);
+ }
+ bzero((char *)&argument, sizeof(argument));
+ if (!svc_getargs(transp, xdr_argument, &argument)) {
+ svcerr_decode(transp);
+ exit(1);
+ }
+ result = (*local)(&argument, rqstp);
+ if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
+ svcerr_systemerr(transp);
+ }
+ if (!svc_freeargs(transp, xdr_argument, &argument)) {
+ (void)fprintf(stderr, "unable to free arguments\n");
+ exit(1);
+ if (rqstp->rq_proc!=YPPUSHPROC_NULL)
+ exit(0);
+ }
+ exit(0);
+}
OpenPOWER on IntegriCloud