#include <grp.h>
#ifdef YP
#include <rpc/rpc.h>
-#include <rpcsvc/yp_prot.h>
+#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
#endif
#include <machine/param.h>
#include <stdio.h>
#include <rpc/rpc.h>
-#include <rpcsvc/yp_prot.h>
+#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
#endif
#include <string.h>
#ifdef YP
#include <rpc/rpc.h>
-#include <rpcsvc/yp_prot.h>
+#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
#endif
# yp sources
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/yp ${.CURDIR}/yp
-SRCS+= xdryp.c yplib.c
+SRCS+= ypmatch_cache.c yp_bind.c yp_get_default_domain.c \
+ yp_first.c yp_all.c yp_order.c \
+ yp_master.c yp_maplist.c yperr_string.c ypprot_err.c _yp_check.c \
+ xdr_domainname.c xdr_keydat.c xdr_mapname.c xdr_peername.c \
+ xdr_valdat.c xdr_ypbind_binding.c xdr_ypbind_resp.c \
+ xdr_ypbind_resptype.c xdr_ypbind_setdom.c xdr_ypmaplist.c \
+ xdr_ypreq_key.c xdr_ypreq_nokey.c xdr_ypresp_all.c \
+ xdr_ypresp_key_val.c xdr_ypresp_maplist.c xdr_ypresp_master.c \
+ xdr_ypresp_order.c xdr_ypresp_val.c xdr_ypstat.c
MAN+= ypclnt.3
MLINKS+=ypclnt.3 yp_all.3 ypclnt.3 yp_bind.3 ypclnt.3 yp_first.3 \
--- /dev/null
+/* $OpenBSD: _yp_check.c,v 1.1 1996/04/24 12:55:40 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+#include "ypinternal.h"
+
+int
+_yp_check(dom)
+ char **dom;
+{
+ char *unused;
+
+ if (_yp_domain[0] == '\0')
+ if (yp_get_default_domain(&unused))
+ return 0;
+
+ if (dom)
+ *dom = _yp_domain;
+
+ if (yp_bind(_yp_domain) == 0)
+ return 1;
+ return 0;
+}
--- /dev/null
+/* $OpenBSD: xdr_domainname.c,v 1.1 1996/04/24 12:55:42 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_domainname(xdrs, objp)
+XDR *xdrs;
+domainname *objp;
+{
+ return xdr_string(xdrs, objp, YPMAXDOMAIN);
+}
--- /dev/null
+/* $OpenBSD: xdr_keydat.c,v 1.1 1996/04/24 12:55:43 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_keydat(xdrs, objp)
+XDR *xdrs;
+keydat *objp;
+{
+ return xdr_bytes(xdrs, (char **)&objp->keydat_val,
+ (u_int *)&objp->keydat_len, YPMAXRECORD);
+}
--- /dev/null
+/* $OpenBSD: xdr_mapname.c,v 1.1 1996/04/24 12:55:44 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_mapname(xdrs, objp)
+XDR *xdrs;
+mapname *objp;
+{
+ return xdr_string(xdrs, objp, YPMAXMAP);
+}
--- /dev/null
+/* $OpenBSD: xdr_peername.c,v 1.1 1996/04/24 12:55:46 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_peername(xdrs, objp)
+XDR *xdrs;
+peername *objp;
+{
+ return xdr_string(xdrs, objp, YPMAXPEER);
+}
--- /dev/null
+/* $OpenBSD: xdr_valdat.c,v 1.1 1996/04/24 12:55:47 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_valdat(xdrs, objp)
+XDR *xdrs;
+valdat *objp;
+{
+ return xdr_bytes(xdrs, (char **)&objp->valdat_val,
+ (u_int *)&objp->valdat_len, YPMAXRECORD);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypbind_binding.c,v 1.1 1996/04/24 12:55:49 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypbind_binding(xdrs, objp)
+XDR *xdrs;
+struct ypbind_binding *objp;
+{
+ if (!xdr_opaque(xdrs, objp->ypbind_binding_addr, 4)) {
+ return (FALSE);
+ }
+ return xdr_opaque(xdrs, objp->ypbind_binding_port, 2);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypbind_resp.c,v 1.1 1996/04/24 12:55:50 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypbind_resp(xdrs, objp)
+XDR *xdrs;
+struct ypbind_resp *objp;
+{
+ if (!xdr_ypbind_resptype(xdrs, &objp->ypbind_status)) {
+ return FALSE;
+ }
+
+ switch (objp->ypbind_status) {
+ case YPBIND_FAIL_VAL:
+ return xdr_u_int(xdrs,
+ (u_int *)&objp->ypbind_resp_u.ypbind_error);
+ case YPBIND_SUCC_VAL:
+ return xdr_ypbind_binding(xdrs,
+ &objp->ypbind_resp_u.ypbind_bindinfo);
+ default:
+ return FALSE;
+ }
+ /* NOTREACHED */
+}
--- /dev/null
+/* $OpenBSD: xdr_ypbind_resptype.c,v 1.1 1996/04/24 12:55:51 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypbind_resptype(xdrs, objp)
+XDR *xdrs;
+enum ypbind_resptype *objp;
+{
+ return xdr_enum(xdrs, (enum_t *)objp);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypbind_setdom.c,v 1.1 1996/04/24 12:55:52 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypbind_setdom(xdrs, objp)
+XDR *xdrs;
+struct ypbind_setdom *objp;
+{
+ if (!xdr_domainname(xdrs, (domainname *)&objp->ypsetdom_domain)) {
+ return FALSE;
+ }
+ if (!xdr_ypbind_binding(xdrs, &objp->ypsetdom_binding)) {
+ return FALSE;
+ }
+ return xdr_u_int(xdrs, (u_int *)&objp->ypsetdom_vers);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypmaplist.c,v 1.1 1996/04/24 12:55:56 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypmaplist(xdrs, objp)
+XDR *xdrs;
+struct ypmaplist *objp;
+{
+ if (!xdr_mapname(xdrs, (mapname *)&objp->map)) {
+ return FALSE;
+ }
+ return xdr_pointer(xdrs, (caddr_t *)&objp->next,
+ sizeof(struct ypmaplist), xdr_ypmaplist);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypreq_key.c,v 1.1 1996/04/24 12:55:58 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypreq_key(xdrs, objp)
+XDR *xdrs;
+struct ypreq_key *objp;
+{
+ if (!xdr_domainname(xdrs, (domainname *)&objp->domain)) {
+ return FALSE;
+ }
+ if (!xdr_mapname(xdrs, (mapname *)&objp->map)) {
+ return FALSE;
+ }
+ return xdr_keydat(xdrs, &objp->key);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypreq_nokey.c,v 1.1 1996/04/24 12:55:59 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypreq_nokey(xdrs, objp)
+XDR *xdrs;
+struct ypreq_nokey *objp;
+{
+ if (!xdr_domainname(xdrs, (domainname *)&objp->domain)) {
+ return FALSE;
+ }
+ return xdr_mapname(xdrs, (mapname *)&objp->map);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypresp_all.c,v 1.1 1996/04/24 12:56:01 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypresp_all(xdrs, objp)
+XDR *xdrs;
+struct ypresp_all *objp;
+{
+ if (!xdr_bool(xdrs, &objp->more)) {
+ return FALSE;
+ }
+ switch (objp->more) {
+ case TRUE:
+ return xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val);
+ case FALSE:
+ return (TRUE);
+ default:
+ return FALSE;
+ }
+ /* NOTREACHED */
+}
--- /dev/null
+/* $OpenBSD: xdr_ypresp_key_val.c,v 1.1 1996/04/24 12:56:04 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypresp_key_val(xdrs, objp)
+XDR *xdrs;
+struct ypresp_key_val *objp;
+{
+ if (!xdr_ypstat(xdrs, (ypstat *)&objp->stat)) {
+ return FALSE;
+ }
+ if (!xdr_valdat(xdrs, &objp->val)) {
+ return FALSE;
+ }
+ return xdr_keydat(xdrs, &objp->key);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypresp_maplist.c,v 1.1 1996/04/24 12:56:06 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypresp_maplist(xdrs, objp)
+XDR *xdrs;
+struct ypresp_maplist *objp;
+{
+ if (!xdr_ypstat(xdrs, (ypstat *)&objp->stat)) {
+ return FALSE;
+ }
+ return xdr_pointer(xdrs, (caddr_t *)&objp->maps,
+ sizeof(struct ypmaplist), xdr_ypmaplist);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypresp_master.c,v 1.1 1996/04/24 12:56:07 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypresp_master(xdrs, objp)
+XDR *xdrs;
+struct ypresp_master *objp;
+{
+ if (!xdr_ypstat(xdrs, (ypstat *)&objp->stat)) {
+ return FALSE;
+ }
+ return xdr_peername(xdrs, (peername *)&objp->peer);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypresp_order.c,v 1.1 1996/04/24 12:56:09 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypresp_order(xdrs, objp)
+XDR *xdrs;
+struct ypresp_order *objp;
+{
+ if (!xdr_ypstat(xdrs, (ypstat *)&objp->stat)) {
+ return FALSE;
+ }
+ return xdr_u_int(xdrs, (u_int *)&objp->ordernum);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypresp_val.c,v 1.1 1996/04/24 12:56:10 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypresp_val(xdrs, objp)
+XDR *xdrs;
+struct ypresp_val *objp;
+{
+ if (!xdr_ypstat(xdrs, (ypstat *)&objp->stat)) {
+ return FALSE;
+ }
+ return xdr_valdat(xdrs, &objp->val);
+}
--- /dev/null
+/* $OpenBSD: xdr_ypstat.c,v 1.1 1996/04/24 12:56:11 deraadt Exp $ */
+/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+bool_t
+xdr_ypstat(xdrs, objp)
+XDR *xdrs;
+ypstat *objp;
+{
+ return xdr_enum(xdrs, objp);
+}
+++ /dev/null
-/* $OpenBSD: xdryp.c,v 1.3 1996/03/09 02:43:00 niklas Exp $ */
-/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
-
-/*
- * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
- * 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
-#endif
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <rpc/rpc.h>
-#include <rpc/xdr.h>
-#include <rpcsvc/yp_prot.h>
-#include <rpcsvc/ypclnt.h>
-
-extern int (*ypresp_allfn) __P((u_long, char *, int, char *, int, void *));
-extern void *ypresp_data;
-
-bool_t
-xdr_domainname(xdrs, objp)
-XDR *xdrs;
-char *objp;
-{
- return xdr_string(xdrs, &objp, YPMAXDOMAIN);
-}
-
-bool_t
-xdr_peername(xdrs, objp)
-XDR *xdrs;
-char *objp;
-{
- return xdr_string(xdrs, &objp, YPMAXPEER);
-}
-
-bool_t
-xdr_datum(xdrs, objp)
-XDR *xdrs;
-datum *objp;
-{
- return xdr_bytes(xdrs, (char **)&objp->dptr,
- (u_int *)&objp->dsize, YPMAXRECORD);
-}
-
-bool_t
-xdr_mapname(xdrs, objp)
-XDR *xdrs;
-char *objp;
-{
- return xdr_string(xdrs, &objp, YPMAXMAP);
-}
-
-bool_t
-xdr_ypreq_key(xdrs, objp)
-XDR *xdrs;
-struct ypreq_key *objp;
-{
- if (!xdr_domainname(xdrs, (char *)objp->domain)) {
- return FALSE;
- }
- if (!xdr_mapname(xdrs, (char *)objp->map)) {
- return FALSE;
- }
- return xdr_datum(xdrs, &objp->keydat);
-}
-
-bool_t
-xdr_ypreq_nokey(xdrs, objp)
-XDR *xdrs;
-struct ypreq_nokey *objp;
-{
- if (!xdr_domainname(xdrs, (char *)objp->domain)) {
- return FALSE;
- }
- return xdr_mapname(xdrs, (char *)objp->map);
-}
-
-bool_t
-xdr_yp_inaddr(xdrs, objp)
-XDR *xdrs;
-struct in_addr *objp;
-{
- return xdr_opaque(xdrs, (caddr_t)&objp->s_addr, sizeof objp->s_addr);
-}
-
-bool_t
-xdr_ypbind_binding(xdrs, objp)
-XDR *xdrs;
-struct ypbind_binding *objp;
-{
- if (!xdr_yp_inaddr(xdrs, &objp->ypbind_binding_addr)) {
- return FALSE;
- }
- return xdr_opaque(xdrs, (void *)&objp->ypbind_binding_port,
- sizeof objp->ypbind_binding_port);
-}
-
-bool_t
-xdr_ypbind_resptype(xdrs, objp)
-XDR *xdrs;
-enum ypbind_resptype *objp;
-{
- return xdr_enum(xdrs, (enum_t *)objp);
-}
-
-bool_t
-xdr_ypstat(xdrs, objp)
-XDR *xdrs;
-enum ypbind_resptype *objp;
-{
- return xdr_enum(xdrs, (enum_t *)objp);
-}
-
-bool_t
-xdr_ypbind_resp(xdrs, objp)
-XDR *xdrs;
-struct ypbind_resp *objp;
-{
- if (!xdr_ypbind_resptype(xdrs, &objp->ypbind_status)) {
- return FALSE;
- }
-
- switch (objp->ypbind_status) {
- case YPBIND_FAIL_VAL:
- return xdr_u_int(xdrs,
- (u_int *)&objp->ypbind_respbody.ypbind_error);
- case YPBIND_SUCC_VAL:
- return xdr_ypbind_binding(xdrs,
- &objp->ypbind_respbody.ypbind_bindinfo);
- default:
- return FALSE;
- }
- /* NOTREACHED */
-}
-
-bool_t
-xdr_ypresp_val(xdrs, objp)
-XDR *xdrs;
-struct ypresp_val *objp;
-{
- if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)&objp->status)) {
- return FALSE;
- }
- return xdr_datum(xdrs, &objp->valdat);
-}
-
-bool_t
-xdr_ypbind_setdom(xdrs, objp)
-XDR *xdrs;
-struct ypbind_setdom *objp;
-{
- if (!xdr_domainname(xdrs, objp->ypsetdom_domain)) {
- return FALSE;
- }
- if (!xdr_ypbind_binding(xdrs, &objp->ypsetdom_binding)) {
- return FALSE;
- }
- return xdr_u_short(xdrs, &objp->ypsetdom_vers);
-}
-
-bool_t
-xdr_ypresp_key_val(xdrs, objp)
-XDR *xdrs;
-struct ypresp_key_val *objp;
-{
- if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)&objp->status)) {
- return FALSE;
- }
- if (!xdr_datum(xdrs, &objp->valdat)) {
- return FALSE;
- }
- return xdr_datum(xdrs, &objp->keydat);
-}
-
-bool_t
-xdr_ypresp_all(xdrs, objp)
-XDR *xdrs;
-struct ypresp_all *objp;
-{
- if (!xdr_bool(xdrs, &objp->more)) {
- return FALSE;
- }
- switch (objp->more) {
- case TRUE:
- return xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val);
- case FALSE:
- return (TRUE);
- default:
- return FALSE;
- }
- /* NOTREACHED */
-}
-
-bool_t
-xdr_ypresp_all_seq(xdrs, objp)
-XDR *xdrs;
-u_long *objp;
-{
- struct ypresp_all out;
- u_long status;
- char *key, *val;
- int size;
- int r;
-
- memset(&out, 0, sizeof out);
- while(1) {
- if( !xdr_ypresp_all(xdrs, &out)) {
- xdr_free(xdr_ypresp_all, (char *)&out);
- *objp = YP_YPERR;
- return FALSE;
- }
- if(out.more == 0) {
- xdr_free(xdr_ypresp_all, (char *)&out);
- return FALSE;
- }
- status = out.ypresp_all_u.val.status;
- switch(status) {
- case YP_TRUE:
- size = out.ypresp_all_u.val.keydat.dsize;
- if ((key = malloc(size + 1)) != NULL) {
- (void)memcpy(key,
- out.ypresp_all_u.val.keydat.dptr,
- size);
- key[size] = '\0';
- }
- size = out.ypresp_all_u.val.valdat.dsize;
- if ((val = malloc(size + 1)) != NULL) {
- (void)memcpy(val,
- out.ypresp_all_u.val.valdat.dptr,
- size);
- val[size] = '\0';
- }
- else {
- free(key);
- key = NULL;
- }
- xdr_free(xdr_ypresp_all, (char *)&out);
-
- if (key == NULL || val == NULL)
- return FALSE;
-
- r = (*ypresp_allfn)(status,
- key, out.ypresp_all_u.val.keydat.dsize,
- val, out.ypresp_all_u.val.valdat.dsize,
- ypresp_data);
- *objp = status;
- free(key);
- free(val);
- if(r)
- return TRUE;
- break;
- case YP_NOMORE:
- xdr_free(xdr_ypresp_all, (char *)&out);
- return TRUE;
- default:
- xdr_free(xdr_ypresp_all, (char *)&out);
- *objp = status;
- return TRUE;
- }
- }
-}
-
-bool_t
-xdr_ypresp_master(xdrs, objp)
-XDR *xdrs;
-struct ypresp_master *objp;
-{
- if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)&objp->status)) {
- return FALSE;
- }
- return xdr_string(xdrs, &objp->master, YPMAXPEER);
-}
-
-bool_t
-xdr_ypmaplist_str(xdrs, objp)
-XDR *xdrs;
-char *objp;
-{
- return xdr_string(xdrs, &objp, YPMAXMAP+1);
-}
-
-bool_t
-xdr_ypmaplist(xdrs, objp)
-XDR *xdrs;
-struct ypmaplist *objp;
-{
- if (!xdr_ypmaplist_str(xdrs, objp->ypml_name)) {
- return FALSE;
- }
- return xdr_pointer(xdrs, (caddr_t *)&objp->ypml_next,
- sizeof(struct ypmaplist), xdr_ypmaplist);
-}
-
-bool_t
-xdr_ypresp_maplist(xdrs, objp)
-XDR *xdrs;
-struct ypresp_maplist *objp;
-{
- if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)&objp->status)) {
- return FALSE;
- }
- return xdr_pointer(xdrs, (caddr_t *)&objp->list,
- sizeof(struct ypmaplist), xdr_ypmaplist);
-}
-
-bool_t
-xdr_ypresp_order(xdrs, objp)
-XDR *xdrs;
-struct ypresp_order *objp;
-{
- if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)&objp->status)) {
- return FALSE;
- }
- return xdr_u_long(xdrs, &objp->ordernum);
-}
--- /dev/null
+/* $OpenBSD: yp_all.c,v 1.1 1996/04/24 12:56:16 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+#include "ypinternal.h"
+
+bool_t
+xdr_ypresp_all_seq(xdrs, objp)
+XDR *xdrs;
+u_long *objp;
+{
+ struct ypresp_all out;
+ u_long status;
+ char *key, *val;
+ int size;
+ int r;
+
+ memset(&out, 0, sizeof out);
+ while(1) {
+ if( !xdr_ypresp_all(xdrs, &out)) {
+ xdr_free(xdr_ypresp_all, (char *)&out);
+ *objp = YP_YPERR;
+ return FALSE;
+ }
+ if(out.more == 0) {
+ xdr_free(xdr_ypresp_all, (char *)&out);
+ return FALSE;
+ }
+ status = out.ypresp_all_u.val.stat;
+ switch(status) {
+ case YP_TRUE:
+ size = out.ypresp_all_u.val.key.keydat_len;
+ if ((key = malloc(size + 1)) != NULL) {
+ (void)memcpy(key,
+ out.ypresp_all_u.val.key.keydat_val,
+ size);
+ key[size] = '\0';
+ }
+ size = out.ypresp_all_u.val.val.valdat_len;
+ if ((val = malloc(size + 1)) != NULL) {
+ (void)memcpy(val,
+ out.ypresp_all_u.val.val.valdat_val,
+ size);
+ val[size] = '\0';
+ }
+ else {
+ free(key);
+ key = NULL;
+ }
+ xdr_free(xdr_ypresp_all, (char *)&out);
+
+ if (key == NULL || val == NULL)
+ return FALSE;
+
+ r = (*ypresp_allfn)(status,
+ key, out.ypresp_all_u.val.key.keydat_len,
+ val, out.ypresp_all_u.val.val.valdat_len,
+ ypresp_data);
+ *objp = status;
+ free(key);
+ free(val);
+ if(r)
+ return TRUE;
+ break;
+ case YP_NOMORE:
+ xdr_free(xdr_ypresp_all, (char *)&out);
+ return TRUE;
+ default:
+ xdr_free(xdr_ypresp_all, (char *)&out);
+ *objp = status;
+ return TRUE;
+ }
+ }
+}
+
+int
+yp_all(indomain, inmap, incallback)
+ const char *indomain;
+ const char *inmap;
+ struct ypall_callback *incallback;
+{
+ struct ypreq_nokey yprnk;
+ struct dom_binding *ysd;
+ struct timeval tv;
+ struct sockaddr_in clnt_sin;
+ CLIENT *clnt;
+ u_long status;
+ int clnt_sock;
+ int r = 0;
+
+ if (_yp_dobind(indomain, &ysd) != 0)
+ return YPERR_DOMAIN;
+
+ tv.tv_sec = _yplib_timeout;
+ tv.tv_usec = 0;
+ clnt_sock = RPC_ANYSOCK;
+ clnt_sin = ysd->dom_server_addr;
+ clnt_sin.sin_port = 0;
+ clnt = clnttcp_create(&clnt_sin, YPPROG, YPVERS, &clnt_sock, 0, 0);
+ if (clnt == NULL) {
+ printf("clnttcp_create failed\n");
+ r = YPERR_PMAP;
+ goto out;
+ }
+ yprnk.domain = (char *)indomain;
+ yprnk.map = (char *)inmap;
+ ypresp_allfn = incallback->foreach;
+ ypresp_data = (void *) incallback->data;
+
+ (void) clnt_call(clnt, YPPROC_ALL,
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_all_seq, &status, tv);
+ clnt_destroy(clnt);
+ if(status != YP_FALSE)
+ r = ypprot_err(status);
+out:
+ _yp_unbind(ysd);
+ return r;
+}
--- /dev/null
+/* $OpenBSD: yp_bind.c,v 1.1 1996/04/24 12:56:18 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+#include "ypinternal.h"
+
+struct dom_binding *_ypbindlist;
+char _yp_domain[MAXHOSTNAMELEN];
+int _yplib_timeout = 10;
+
+int
+_yp_dobind(dom, ypdb)
+ const char *dom;
+ struct dom_binding **ypdb;
+{
+ static int pid = -1;
+ char path[MAXPATHLEN];
+ struct dom_binding *ysd, *ysd2;
+ struct ypbind_resp ypbr;
+ struct timeval tv;
+ struct sockaddr_in clnt_sin;
+ int clnt_sock, fd, gpid;
+ CLIENT *client;
+ int new = 0, r;
+ int count = 0;
+
+ /*
+ * test if YP is running or not
+ */
+ if ((fd = open(YPBINDLOCK, O_RDONLY)) == -1)
+ return YPERR_YPBIND;
+ if (!(flock(fd, LOCK_EX | LOCK_NB) == -1 && errno == EWOULDBLOCK)) {
+ (void)close(fd);
+ return YPERR_YPBIND;
+ }
+ (void)close(fd);
+
+ gpid = getpid();
+ if (!(pid == -1 || pid == gpid)) {
+ ysd = _ypbindlist;
+ while (ysd) {
+ if (ysd->dom_client)
+ clnt_destroy(ysd->dom_client);
+ ysd2 = ysd->dom_pnext;
+ free(ysd);
+ ysd = ysd2;
+ }
+ _ypbindlist = NULL;
+ }
+ pid = gpid;
+
+ if (ypdb != NULL)
+ *ypdb = NULL;
+
+ if (dom == NULL || strlen(dom) == 0)
+ return YPERR_BADARGS;
+
+ for (ysd = _ypbindlist; ysd; ysd = ysd->dom_pnext)
+ if (strcmp(dom, ysd->dom_domain) == 0)
+ break;
+ if (ysd == NULL) {
+ if ((ysd = malloc(sizeof *ysd)) == NULL)
+ return YPERR_YPERR;
+ (void)memset(ysd, 0, sizeof *ysd);
+ ysd->dom_socket = -1;
+ ysd->dom_vers = 0;
+ new = 1;
+ }
+again:
+ if (ysd->dom_vers == 0) {
+ (void) snprintf(path, sizeof(path), "%s/%s.%d",
+ BINDINGDIR, dom, 2);
+ if ((fd = open(path, O_RDONLY)) == -1) {
+ /*
+ * no binding file, YP is dead, or not yet fully
+ * alive.
+ */
+ goto trynet;
+ }
+ if (flock(fd, LOCK_EX | LOCK_NB) == -1 &&
+ errno == EWOULDBLOCK) {
+ struct iovec iov[2];
+ struct ypbind_resp ybr;
+ u_short ypb_port;
+ struct ypbind_binding *bn;
+
+ iov[0].iov_base = (caddr_t) & ypb_port;
+ iov[0].iov_len = sizeof ypb_port;
+ iov[1].iov_base = (caddr_t) & ybr;
+ iov[1].iov_len = sizeof ybr;
+
+ r = readv(fd, iov, 2);
+ if (r != iov[0].iov_len + iov[1].iov_len) {
+ (void)close(fd);
+ ysd->dom_vers = -1;
+ goto again;
+ }
+ (void)memset(&ysd->dom_server_addr, 0,
+ sizeof ysd->dom_server_addr);
+ ysd->dom_server_addr.sin_len =
+ sizeof(struct sockaddr_in);
+ ysd->dom_server_addr.sin_family = AF_INET;
+ bn = &ybr.ypbind_resp_u.ypbind_bindinfo;
+ memcpy(&ysd->dom_server_addr.sin_port,
+ &bn->ypbind_binding_port,
+ sizeof(ysd->dom_server_addr.sin_port));
+
+ memcpy(&ysd->dom_server_addr.sin_addr,
+ &bn->ypbind_binding_addr,
+ sizeof(ysd->dom_server_addr.sin_addr));
+
+
+ ysd->dom_server_port = ysd->dom_server_addr.sin_port;
+ (void)close(fd);
+ goto gotit;
+ } else {
+ /* no lock on binding file, YP is dead. */
+ (void)close(fd);
+ if (new)
+ free(ysd);
+ return YPERR_YPBIND;
+ }
+ }
+trynet:
+ if (ysd->dom_vers == -1 || ysd->dom_vers == 0) {
+ struct ypbind_binding *bn;
+ (void)memset(&clnt_sin, 0, sizeof clnt_sin);
+ clnt_sin.sin_len = sizeof(struct sockaddr_in);
+ clnt_sin.sin_family = AF_INET;
+ clnt_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+
+ clnt_sock = RPC_ANYSOCK;
+ client = clnttcp_create(&clnt_sin, YPBINDPROG, YPBINDVERS,
+ &clnt_sock, 0, 0);
+ if (client == NULL) {
+ clnt_pcreateerror("clnttcp_create");
+ if (new)
+ free(ysd);
+ return YPERR_YPBIND;
+ }
+ tv.tv_sec = _yplib_timeout;
+ tv.tv_usec = 0;
+ r = clnt_call(client, YPBINDPROC_DOMAIN, xdr_domainname,
+ &dom, xdr_ypbind_resp, &ypbr, tv);
+ if (r != RPC_SUCCESS) {
+ if (new == 0 || count)
+ fprintf(stderr,
+ "YP server for domain %s not responding, still trying\n",
+ dom);
+ count++;
+ clnt_destroy(client);
+ ysd->dom_vers = -1;
+ goto again;
+ }
+ clnt_destroy(client);
+
+ (void)memset(&ysd->dom_server_addr, 0,
+ sizeof ysd->dom_server_addr);
+ ysd->dom_server_addr.sin_len = sizeof(struct sockaddr_in);
+ ysd->dom_server_addr.sin_family = AF_INET;
+ bn = &ypbr.ypbind_resp_u.ypbind_bindinfo;
+ memcpy(&ysd->dom_server_addr.sin_port,
+ &bn->ypbind_binding_port,
+ sizeof(ysd->dom_server_addr.sin_port));
+ memcpy(&ysd->dom_server_addr.sin_addr.s_addr,
+ &bn->ypbind_binding_addr,
+ sizeof(ysd->dom_server_addr.sin_addr.s_addr));
+ ysd->dom_server_port = ysd->dom_server_addr.sin_port;
+gotit:
+ ysd->dom_vers = YPVERS;
+ (void)strcpy(ysd->dom_domain, dom);
+ }
+ tv.tv_sec = _yplib_timeout / 2;
+ tv.tv_usec = 0;
+ if (ysd->dom_client)
+ clnt_destroy(ysd->dom_client);
+ ysd->dom_socket = RPC_ANYSOCK;
+ ysd->dom_client = clntudp_create(&ysd->dom_server_addr,
+ YPPROG, YPVERS, tv, &ysd->dom_socket);
+ if (ysd->dom_client == NULL) {
+ clnt_pcreateerror("clntudp_create");
+ ysd->dom_vers = -1;
+ goto again;
+ }
+ if (fcntl(ysd->dom_socket, F_SETFD, 1) == -1)
+ perror("fcntl: F_SETFD");
+
+ if (new) {
+ ysd->dom_pnext = _ypbindlist;
+ _ypbindlist = ysd;
+ }
+ if (ypdb != NULL)
+ *ypdb = ysd;
+ return 0;
+}
+
+void
+_yp_unbind(ypb)
+ struct dom_binding *ypb;
+{
+ clnt_destroy(ypb->dom_client);
+ ypb->dom_client = NULL;
+ ypb->dom_socket = -1;
+}
+
+int
+yp_bind(dom)
+ const char *dom;
+{
+ return _yp_dobind(dom, NULL);
+}
+
+void
+yp_unbind(dom)
+ const char *dom;
+{
+ struct dom_binding *ypb, *ypbp;
+
+ ypbp = NULL;
+ for (ypb = _ypbindlist; ypb; ypb = ypb->dom_pnext) {
+ if (strcmp(dom, ypb->dom_domain) == 0) {
+ clnt_destroy(ypb->dom_client);
+ if (ypbp)
+ ypbp->dom_pnext = ypb->dom_pnext;
+ else
+ _ypbindlist = ypb->dom_pnext;
+ free(ypb);
+ return;
+ }
+ ypbp = ypb;
+ }
+ return;
+}
--- /dev/null
+/* $OpenBSD: yp_first.c,v 1.1 1996/04/24 12:56:19 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+#include "ypinternal.h"
+
+int
+yp_first(indomain, inmap, outkey, outkeylen, outval, outvallen)
+ const char *indomain;
+ const char *inmap;
+ char **outkey;
+ int *outkeylen;
+ char **outval;
+ int *outvallen;
+{
+ struct ypresp_key_val yprkv;
+ struct ypreq_nokey yprnk;
+ struct dom_binding *ysd;
+ struct timeval tv;
+ int r;
+
+ *outkey = *outval = NULL;
+ *outkeylen = *outvallen = 0;
+
+again:
+ if (_yp_dobind(indomain, &ysd) != 0)
+ return YPERR_DOMAIN;
+
+ tv.tv_sec = _yplib_timeout;
+ tv.tv_usec = 0;
+
+ yprnk.domain = (char *)indomain;
+ yprnk.map = (char *)inmap;
+ (void)memset(&yprkv, 0, sizeof yprkv);
+
+ r = clnt_call(ysd->dom_client, YPPROC_FIRST,
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_key_val, &yprkv, tv);
+ if (r != RPC_SUCCESS) {
+ clnt_perror(ysd->dom_client, "yp_first: clnt_call");
+ ysd->dom_vers = -1;
+ goto again;
+ }
+ if (!(r = ypprot_err(yprkv.stat))) {
+ *outkeylen = yprkv.key.keydat_len;
+ if ((*outkey = malloc(*outkeylen + 1)) == NULL)
+ r = RPC_SYSTEMERROR;
+ else {
+ (void)memcpy(*outkey, yprkv.key.keydat_val, *outkeylen);
+ (*outkey)[*outkeylen] = '\0';
+ }
+ *outvallen = yprkv.val.valdat_len;
+ if ((*outval = malloc(*outvallen + 1)) == NULL)
+ r = RPC_SYSTEMERROR;
+ else {
+ (void)memcpy(*outval, yprkv.val.valdat_val, *outvallen);
+ (*outval)[*outvallen] = '\0';
+ }
+ }
+ xdr_free(xdr_ypresp_key_val, (char *) &yprkv);
+ _yp_unbind(ysd);
+ return r;
+}
--- /dev/null
+/* $OpenBSD: yp_get_default_domain.c,v 1.1 1996/04/24 12:56:20 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+#include "ypinternal.h"
+
+int
+yp_get_default_domain(domp)
+ char **domp;
+{
+ *domp = NULL;
+ if (_yp_domain[0] == '\0')
+ if (getdomainname(_yp_domain, sizeof _yp_domain))
+ return YPERR_NODOM;
+ *domp = _yp_domain;
+ return 0;
+}
--- /dev/null
+/* $OpenBSD: yp_maplist.c,v 1.1 1996/04/24 12:56:22 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+#include "ypinternal.h"
+
+int
+yp_maplist(indomain, outmaplist)
+ const char *indomain;
+ struct ypmaplist **outmaplist;
+{
+ struct dom_binding *ysd;
+ struct ypresp_maplist ypml;
+ struct timeval tv;
+ int r;
+
+again:
+ if (_yp_dobind(indomain, &ysd) != 0)
+ return YPERR_DOMAIN;
+
+ tv.tv_sec = _yplib_timeout;
+ tv.tv_usec = 0;
+
+ memset(&ypml, 0, sizeof ypml);
+
+ r = clnt_call(ysd->dom_client, YPPROC_MAPLIST,
+ xdr_domainname, &indomain, xdr_ypresp_maplist, &ypml, tv);
+ if (r != RPC_SUCCESS) {
+ clnt_perror(ysd->dom_client, "yp_maplist: clnt_call");
+ ysd->dom_vers = -1;
+ goto again;
+ }
+ *outmaplist = ypml.maps;
+ /* NO: xdr_free(xdr_ypresp_maplist, &ypml); */
+ _yp_unbind(ysd);
+ return ypprot_err(ypml.stat);
+}
--- /dev/null
+/* $OpenBSD: yp_master.c,v 1.1 1996/04/24 12:56:25 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+#include "ypinternal.h"
+
+int
+yp_master(indomain, inmap, outname)
+ const char *indomain;
+ const char *inmap;
+ char **outname;
+{
+ struct dom_binding *ysd;
+ struct ypresp_master yprm;
+ struct ypreq_nokey yprnk;
+ struct timeval tv;
+ int r;
+
+again:
+ if (_yp_dobind(indomain, &ysd) != 0)
+ return YPERR_DOMAIN;
+
+ tv.tv_sec = _yplib_timeout;
+ tv.tv_usec = 0;
+
+ yprnk.domain = (char *)indomain;
+ yprnk.map = (char *)inmap;
+
+ (void)memset(&yprm, 0, sizeof yprm);
+
+ r = clnt_call(ysd->dom_client, YPPROC_MASTER,
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_master, &yprm, tv);
+ if (r != RPC_SUCCESS) {
+ clnt_perror(ysd->dom_client, "yp_master: clnt_call");
+ ysd->dom_vers = -1;
+ goto again;
+ }
+ if (!(r = ypprot_err(yprm.stat))) {
+ if ((*outname = strdup(yprm.peer)) == NULL)
+ r = RPC_SYSTEMERROR;
+ }
+ xdr_free(xdr_ypresp_master, (char *) &yprm);
+ _yp_unbind(ysd);
+ return r;
+}
--- /dev/null
+/* $OpenBSD: yp_order.c,v 1.1 1996/04/24 12:56:26 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+#include "ypinternal.h"
+
+int
+yp_order(indomain, inmap, outorder)
+ const char *indomain;
+ const char *inmap;
+ int *outorder;
+{
+ struct dom_binding *ysd;
+ struct ypresp_order ypro;
+ struct ypreq_nokey yprnk;
+ struct timeval tv;
+ int r = 0;
+
+again:
+ if (_yp_dobind(indomain, &ysd) != 0)
+ return YPERR_DOMAIN;
+
+ tv.tv_sec = _yplib_timeout;
+ tv.tv_usec = 0;
+
+ yprnk.domain = (char *)indomain;
+ yprnk.map = (char *)inmap;
+
+ (void)memset(&ypro, 0, sizeof ypro);
+
+ r = clnt_call(ysd->dom_client, YPPROC_ORDER,
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_order, &ypro, tv);
+ /*
+ * XXX
+ * NIS+ YP emulation package does not impliment YPPROC_ORDER, so
+ * we always return 0. Or should we return an error?
+ */
+ if (r == RPC_PROCUNAVAIL) {
+ *outorder = 0;
+ r = 0;
+ goto bail;
+ }
+ if (r != RPC_SUCCESS) {
+ clnt_perror(ysd->dom_client, "yp_order: clnt_call");
+ ysd->dom_vers = -1;
+ goto again;
+ }
+ *outorder = ypro.ordernum;
+ xdr_free(xdr_ypresp_order, (char *) &ypro);
+ r = ypprot_err(ypro.stat);
+bail:
+ _yp_unbind(ysd);
+ return r;
+}
--- /dev/null
+/* $OpenBSD: yperr_string.c,v 1.1 1996/04/24 12:56:28 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+char *
+yperr_string(incode)
+ int incode;
+{
+ static char err[80];
+
+ switch (incode) {
+ case 0:
+ return "Success";
+ case YPERR_BADARGS:
+ return "Request arguments bad";
+ case YPERR_RPC:
+ return "RPC failure";
+ case YPERR_DOMAIN:
+ return "Can't bind to server which serves this domain";
+ case YPERR_MAP:
+ return "No such map in server's domain";
+ case YPERR_KEY:
+ return "No such key in map";
+ case YPERR_YPERR:
+ return "YP server error";
+ case YPERR_RESRC:
+ return "Local resource allocation failure";
+ case YPERR_NOMORE:
+ return "No more records in map database";
+ case YPERR_PMAP:
+ return "Can't communicate with portmapper";
+ case YPERR_YPBIND:
+ return "Can't communicate with ypbind";
+ case YPERR_YPSERV:
+ return "Can't communicate with ypserv";
+ case YPERR_NODOM:
+ return "Local domain name not set";
+ case YPERR_BADDB:
+ return "Server data base is bad";
+ case YPERR_VERS:
+ return "YP server version mismatch - server can't supply service.";
+ case YPERR_ACCESS:
+ return "Access violation";
+ case YPERR_BUSY:
+ return "Database is busy";
+ }
+ (void) snprintf(err, sizeof(err), "YP unknown error %d\n", incode);
+ return err;
+}
--- /dev/null
+/* $OpenBSD: ypinternal.h,v 1.1 1996/04/24 12:56:29 deraadt Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993, 1996 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+/*
+ * XXX We have to define these here due to clashes between
+ * yp_prot.h and yp.h.
+ */
+struct dom_binding {
+ struct dom_binding *dom_pnext;
+ char dom_domain[YPMAXDOMAIN + 1];
+ struct sockaddr_in dom_server_addr;
+ u_short dom_server_port;
+ int dom_socket;
+ CLIENT *dom_client;
+ u_short dom_local_port;
+ long dom_vers;
+};
+
+#define BINDINGDIR "/var/yp/binding"
+#define YPBINDLOCK "/var/run/ypbind.lock"
+#define YPMATCHCACHE
+
+int (*ypresp_allfn) __P((u_long, char *, int, char *, int, void *));
+void *ypresp_data;
+
+extern struct dom_binding *_ypbindlist;
+extern char _yp_domain[MAXHOSTNAMELEN];
+extern int _yplib_timeout;
+
+void _yp_unbind __P((struct dom_binding *));
+
+#ifdef YPMATCHCACHE
+
+static bool_t ypmatch_add __P((const char *, const char *,
+ u_int, char *, u_int));
+static bool_t ypmatch_find __P((const char *, const char *,
+ u_int, char **, u_int *));
+
+static struct ypmatch_ent {
+ struct ypmatch_ent *next;
+ char *map, *key;
+ char *val;
+ int keylen, vallen;
+ time_t expire_t;
+} *ypmc;
+extern int _yplib_cache;
+
+#endif
+++ /dev/null
-/* $OpenBSD: yplib.c,v 1.4 1996/03/09 02:43:01 niklas Exp $ */
-/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
-
-/*
- * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
- * 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
-#include <rpc/rpc.h>
-#include <rpc/xdr.h>
-#include <rpcsvc/yp_prot.h>
-#include <rpcsvc/ypclnt.h>
-
-#define BINDINGDIR "/var/yp/binding"
-#define YPBINDLOCK "/var/run/ypbind.lock"
-#define YPMATCHCACHE
-
-int (*ypresp_allfn) __P((u_long, char *, int, char *, int, void *));
-void *ypresp_data;
-
-struct dom_binding *_ypbindlist;
-static char _yp_domain[MAXHOSTNAMELEN];
-int _yplib_timeout = 10;
-
-static bool_t ypmatch_add __P((const char *, const char *, int, char *, int));
-static bool_t ypmatch_find __P((const char *, const char *, int, const char **,
- int *));
-static void _yp_unbind __P((struct dom_binding *));
-
-#ifdef YPMATCHCACHE
-int _yplib_cache = 5;
-
-static struct ypmatch_ent {
- struct ypmatch_ent *next;
- char *map, *key;
- char *val;
- int keylen, vallen;
- time_t expire_t;
-} *ypmc;
-
-static bool_t
-ypmatch_add(map, key, keylen, val, vallen)
- const char *map;
- const char *key;
- int keylen;
- char *val;
- int vallen;
-{
- struct ypmatch_ent *ep;
- time_t t;
-
- (void)time(&t);
-
- for (ep = ypmc; ep; ep = ep->next)
- if (ep->expire_t < t)
- break;
- if (ep == NULL) {
- if ((ep = malloc(sizeof *ep)) == NULL)
- return 0;
- (void)memset(ep, 0, sizeof *ep);
- if (ypmc)
- ep->next = ypmc;
- ypmc = ep;
- }
-
- if (ep->key) {
- free(ep->key);
- ep->key = NULL;
- }
- if (ep->val) {
- free(ep->val);
- ep->val = NULL;
- }
-
- if ((ep->key = malloc(keylen)) == NULL)
- return 0;
-
- if ((ep->val = malloc(vallen)) == NULL) {
- free(ep->key);
- ep->key = NULL;
- return 0;
- }
-
- ep->keylen = keylen;
- ep->vallen = vallen;
-
- (void)memcpy(ep->key, key, ep->keylen);
- (void)memcpy(ep->val, val, ep->vallen);
-
- if (ep->map) {
- if (strcmp(ep->map, map)) {
- free(ep->map);
- if ((ep->map = strdup(map)) == NULL)
- return 0;
- }
- } else {
- if ((ep->map = strdup(map)) == NULL)
- return 0;
- }
-
- ep->expire_t = t + _yplib_cache;
- return 1;
-}
-
-static bool_t
-ypmatch_find(map, key, keylen, val, vallen)
- const char *map;
- const char *key;
- int keylen;
- const char **val;
- int *vallen;
-{
- struct ypmatch_ent *ep;
- time_t t;
-
- if (ypmc == NULL)
- return 0;
-
- (void) time(&t);
-
- for (ep = ypmc; ep; ep = ep->next) {
- if (ep->keylen != keylen)
- continue;
- if (strcmp(ep->map, map))
- continue;
- if (memcmp(ep->key, key, keylen))
- continue;
- if (t > ep->expire_t)
- continue;
-
- *val = ep->val;
- *vallen = ep->vallen;
- return 1;
- }
- return 0;
-}
-#endif
-
-int
-_yp_dobind(dom, ypdb)
- const char *dom;
- struct dom_binding **ypdb;
-{
- static int pid = -1;
- char path[MAXPATHLEN];
- struct dom_binding *ysd, *ysd2;
- struct ypbind_resp ypbr;
- struct timeval tv;
- struct sockaddr_in clnt_sin;
- int clnt_sock, fd, gpid;
- CLIENT *client;
- int new = 0, r;
- int count = 0;
-
- /*
- * test if YP is running or not
- */
- if ((fd = open(YPBINDLOCK, O_RDONLY)) == -1)
- return YPERR_YPBIND;
- if (!(flock(fd, LOCK_EX | LOCK_NB) == -1 && errno == EWOULDBLOCK)) {
- (void)close(fd);
- return YPERR_YPBIND;
- }
- (void)close(fd);
-
- gpid = getpid();
- if (!(pid == -1 || pid == gpid)) {
- ysd = _ypbindlist;
- while (ysd) {
- if (ysd->dom_client)
- clnt_destroy(ysd->dom_client);
- ysd2 = ysd->dom_pnext;
- free(ysd);
- ysd = ysd2;
- }
- _ypbindlist = NULL;
- }
- pid = gpid;
-
- if (ypdb != NULL)
- *ypdb = NULL;
-
- if (dom == NULL || strlen(dom) == 0)
- return YPERR_BADARGS;
-
- for (ysd = _ypbindlist; ysd; ysd = ysd->dom_pnext)
- if (strcmp(dom, ysd->dom_domain) == 0)
- break;
- if (ysd == NULL) {
- if ((ysd = malloc(sizeof *ysd)) == NULL)
- return YPERR_YPERR;
- (void)memset(ysd, 0, sizeof *ysd);
- ysd->dom_socket = -1;
- ysd->dom_vers = 0;
- new = 1;
- }
-again:
- if (ysd->dom_vers == 0) {
- (void) snprintf(path, sizeof(path), "%s/%s.%d",
- BINDINGDIR, dom, 2);
- if ((fd = open(path, O_RDONLY)) == -1) {
- /*
- * no binding file, YP is dead, or not yet fully
- * alive.
- */
- goto trynet;
- }
- if (flock(fd, LOCK_EX | LOCK_NB) == -1 &&
- errno == EWOULDBLOCK) {
- struct iovec iov[2];
- struct ypbind_resp ybr;
- u_short ypb_port;
- struct ypbind_binding *bn;
-
- iov[0].iov_base = (caddr_t) & ypb_port;
- iov[0].iov_len = sizeof ypb_port;
- iov[1].iov_base = (caddr_t) & ybr;
- iov[1].iov_len = sizeof ybr;
-
- r = readv(fd, iov, 2);
- if (r != iov[0].iov_len + iov[1].iov_len) {
- (void)close(fd);
- ysd->dom_vers = -1;
- goto again;
- }
- (void)memset(&ysd->dom_server_addr, 0,
- sizeof ysd->dom_server_addr);
- ysd->dom_server_addr.sin_len =
- sizeof(struct sockaddr_in);
- ysd->dom_server_addr.sin_family = AF_INET;
- bn = &ybr.ypbind_respbody.ypbind_bindinfo;
- ysd->dom_server_addr.sin_port =
- bn->ypbind_binding_port;
-
- ysd->dom_server_addr.sin_addr =
- bn->ypbind_binding_addr;
-
- ysd->dom_server_port = ysd->dom_server_addr.sin_port;
- (void)close(fd);
- goto gotit;
- } else {
- /* no lock on binding file, YP is dead. */
- (void)close(fd);
- if (new)
- free(ysd);
- return YPERR_YPBIND;
- }
- }
-trynet:
- if (ysd->dom_vers == -1 || ysd->dom_vers == 0) {
- struct ypbind_binding *bn;
- (void)memset(&clnt_sin, 0, sizeof clnt_sin);
- clnt_sin.sin_len = sizeof(struct sockaddr_in);
- clnt_sin.sin_family = AF_INET;
- clnt_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-
- clnt_sock = RPC_ANYSOCK;
- client = clnttcp_create(&clnt_sin, YPBINDPROG, YPBINDVERS,
- &clnt_sock, 0, 0);
- if (client == NULL) {
- clnt_pcreateerror("clnttcp_create");
- if (new)
- free(ysd);
- return YPERR_YPBIND;
- }
- tv.tv_sec = _yplib_timeout;
- tv.tv_usec = 0;
- r = clnt_call(client, YPBINDPROC_DOMAIN, xdr_domainname,
- dom, xdr_ypbind_resp, &ypbr, tv);
- if (r != RPC_SUCCESS) {
- if (new == 0 || count)
- fprintf(stderr,
- "YP server for domain %s not responding, still trying\n",
- dom);
- count++;
- clnt_destroy(client);
- ysd->dom_vers = -1;
- goto again;
- }
- clnt_destroy(client);
-
- (void)memset(&ysd->dom_server_addr, 0,
- sizeof ysd->dom_server_addr);
- ysd->dom_server_addr.sin_len = sizeof(struct sockaddr_in);
- ysd->dom_server_addr.sin_family = AF_INET;
- bn = &ypbr.ypbind_respbody.ypbind_bindinfo;
- ysd->dom_server_addr.sin_port =
- bn->ypbind_binding_port;
- ysd->dom_server_addr.sin_addr.s_addr =
- bn->ypbind_binding_addr.s_addr;
- ysd->dom_server_port =
- bn->ypbind_binding_port;
-gotit:
- ysd->dom_vers = YPVERS;
- (void)strcpy(ysd->dom_domain, dom);
- }
- tv.tv_sec = _yplib_timeout / 2;
- tv.tv_usec = 0;
- if (ysd->dom_client)
- clnt_destroy(ysd->dom_client);
- ysd->dom_socket = RPC_ANYSOCK;
- ysd->dom_client = clntudp_create(&ysd->dom_server_addr,
- YPPROG, YPVERS, tv, &ysd->dom_socket);
- if (ysd->dom_client == NULL) {
- clnt_pcreateerror("clntudp_create");
- ysd->dom_vers = -1;
- goto again;
- }
- if (fcntl(ysd->dom_socket, F_SETFD, 1) == -1)
- perror("fcntl: F_SETFD");
-
- if (new) {
- ysd->dom_pnext = _ypbindlist;
- _ypbindlist = ysd;
- }
- if (ypdb != NULL)
- *ypdb = ysd;
- return 0;
-}
-
-static void
-_yp_unbind(ypb)
- struct dom_binding *ypb;
-{
- clnt_destroy(ypb->dom_client);
- ypb->dom_client = NULL;
- ypb->dom_socket = -1;
-}
-
-int
-yp_bind(dom)
- const char *dom;
-{
- return _yp_dobind(dom, NULL);
-}
-
-void
-yp_unbind(dom)
- const char *dom;
-{
- struct dom_binding *ypb, *ypbp;
-
- ypbp = NULL;
- for (ypb = _ypbindlist; ypb; ypb = ypb->dom_pnext) {
- if (strcmp(dom, ypb->dom_domain) == 0) {
- clnt_destroy(ypb->dom_client);
- if (ypbp)
- ypbp->dom_pnext = ypb->dom_pnext;
- else
- _ypbindlist = ypb->dom_pnext;
- free(ypb);
- return;
- }
- ypbp = ypb;
- }
- return;
-}
-
-int
-yp_match(indomain, inmap, inkey, inkeylen, outval, outvallen)
- const char *indomain;
- const char *inmap;
- const char *inkey;
- int inkeylen;
- char **outval;
- int *outvallen;
-{
- struct dom_binding *ysd;
- struct ypresp_val yprv;
- struct timeval tv;
- struct ypreq_key yprk;
- int r;
-
- *outval = NULL;
- *outvallen = 0;
-
-again:
- if (_yp_dobind(indomain, &ysd) != 0)
- return YPERR_DOMAIN;
-
-#ifdef YPMATCHCACHE
- if (!strcmp(_yp_domain, indomain) && ypmatch_find(inmap, inkey,
- inkeylen, &yprv.valdat.dptr, &yprv.valdat.dsize)) {
- *outvallen = yprv.valdat.dsize;
- if ((*outval = malloc(*outvallen + 1)) == NULL) {
- _yp_unbind(ysd);
- return YPERR_YPERR;
- }
- (void)memcpy(*outval, yprv.valdat.dptr, *outvallen);
- (*outval)[*outvallen] = '\0';
- _yp_unbind(ysd);
- return 0;
- }
-#endif
-
- tv.tv_sec = _yplib_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(ysd->dom_client, YPPROC_MATCH,
- xdr_ypreq_key, &yprk, xdr_ypresp_val, &yprv, tv);
- if (r != RPC_SUCCESS) {
- clnt_perror(ysd->dom_client, "yp_match: clnt_call");
- ysd->dom_vers = -1;
- goto again;
- }
- if (!(r = ypprot_err(yprv.status))) {
- *outvallen = yprv.valdat.dsize;
- if ((*outval = malloc(*outvallen + 1)) == NULL) {
- r = YPERR_YPERR;
- goto out;
- }
- (void)memcpy(*outval, yprv.valdat.dptr, *outvallen);
- (*outval)[*outvallen] = '\0';
-#ifdef YPMATCHCACHE
- if (strcmp(_yp_domain, indomain) == 0)
- if (!ypmatch_add(inmap, inkey, inkeylen,
- *outval, *outvallen))
- r = RPC_SYSTEMERROR;
-#endif
- }
-out:
- xdr_free(xdr_ypresp_val, (char *) &yprv);
- _yp_unbind(ysd);
- return r;
-}
-
-int
-yp_get_default_domain(domp)
- char **domp;
-{
- *domp = NULL;
- if (_yp_domain[0] == '\0')
- if (getdomainname(_yp_domain, sizeof _yp_domain))
- return YPERR_NODOM;
- *domp = _yp_domain;
- return 0;
-}
-
-int
-yp_first(indomain, inmap, outkey, outkeylen, outval, outvallen)
- const char *indomain;
- const char *inmap;
- char **outkey;
- int *outkeylen;
- char **outval;
- int *outvallen;
-{
- struct ypresp_key_val yprkv;
- struct ypreq_nokey yprnk;
- struct dom_binding *ysd;
- struct timeval tv;
- int r;
-
- *outkey = *outval = NULL;
- *outkeylen = *outvallen = 0;
-
-again:
- if (_yp_dobind(indomain, &ysd) != 0)
- return YPERR_DOMAIN;
-
- tv.tv_sec = _yplib_timeout;
- tv.tv_usec = 0;
-
- yprnk.domain = indomain;
- yprnk.map = inmap;
- (void)memset(&yprkv, 0, sizeof yprkv);
-
- r = clnt_call(ysd->dom_client, YPPROC_FIRST,
- xdr_ypreq_nokey, &yprnk, xdr_ypresp_key_val, &yprkv, tv);
- if (r != RPC_SUCCESS) {
- clnt_perror(ysd->dom_client, "yp_first: clnt_call");
- ysd->dom_vers = -1;
- goto again;
- }
- if (!(r = ypprot_err(yprkv.status))) {
- *outkeylen = yprkv.keydat.dsize;
- if ((*outkey = malloc(*outkeylen + 1)) == NULL)
- r = RPC_SYSTEMERROR;
- else {
- (void)memcpy(*outkey, yprkv.keydat.dptr, *outkeylen);
- (*outkey)[*outkeylen] = '\0';
- }
- *outvallen = yprkv.valdat.dsize;
- if ((*outval = malloc(*outvallen + 1)) == NULL)
- r = RPC_SYSTEMERROR;
- else {
- (void)memcpy(*outval, yprkv.valdat.dptr, *outvallen);
- (*outval)[*outvallen] = '\0';
- }
- }
- xdr_free(xdr_ypresp_key_val, (char *) &yprkv);
- _yp_unbind(ysd);
- return r;
-}
-
-int
-yp_next(indomain, inmap, inkey, inkeylen, outkey, outkeylen, outval, outvallen)
- const char *indomain;
- const char *inmap;
- const char *inkey;
- int inkeylen;
- char **outkey;
- int *outkeylen;
- char **outval;
- int *outvallen;
-{
- struct ypresp_key_val yprkv;
- struct ypreq_key yprk;
- struct dom_binding *ysd;
- struct timeval tv;
- int r;
-
- *outkey = *outval = NULL;
- *outkeylen = *outvallen = 0;
-
-again:
- if (_yp_dobind(indomain, &ysd) != 0)
- return YPERR_DOMAIN;
-
- tv.tv_sec = _yplib_timeout;
- tv.tv_usec = 0;
-
- yprk.domain = indomain;
- yprk.map = inmap;
- yprk.keydat.dptr = inkey;
- yprk.keydat.dsize = inkeylen;
- (void)memset(&yprkv, 0, sizeof yprkv);
-
- r = clnt_call(ysd->dom_client, YPPROC_NEXT,
- xdr_ypreq_key, &yprk, xdr_ypresp_key_val, &yprkv, tv);
- if (r != RPC_SUCCESS) {
- clnt_perror(ysd->dom_client, "yp_next: clnt_call");
- ysd->dom_vers = -1;
- goto again;
- }
- if (!(r = ypprot_err(yprkv.status))) {
- *outkeylen = yprkv.keydat.dsize;
- if ((*outkey = malloc(*outkeylen + 1)) == NULL)
- r = RPC_SYSTEMERROR;
- else {
- (void)memcpy(*outkey, yprkv.keydat.dptr, *outkeylen);
- (*outkey)[*outkeylen] = '\0';
- }
- *outvallen = yprkv.valdat.dsize;
- if ((*outval = malloc(*outvallen + 1)) == NULL)
- r = RPC_SYSTEMERROR;
- else {
- (void)memcpy(*outval, yprkv.valdat.dptr, *outvallen);
- (*outval)[*outvallen] = '\0';
- }
- }
- xdr_free(xdr_ypresp_key_val, (char *) &yprkv);
- _yp_unbind(ysd);
- return r;
-}
-
-int
-yp_all(indomain, inmap, incallback)
- const char *indomain;
- const char *inmap;
- struct ypall_callback *incallback;
-{
- struct ypreq_nokey yprnk;
- struct dom_binding *ysd;
- struct timeval tv;
- struct sockaddr_in clnt_sin;
- CLIENT *clnt;
- u_long status;
- int clnt_sock;
- int r = 0;
-
- if (_yp_dobind(indomain, &ysd) != 0)
- return YPERR_DOMAIN;
-
- tv.tv_sec = _yplib_timeout;
- tv.tv_usec = 0;
- clnt_sock = RPC_ANYSOCK;
- clnt_sin = ysd->dom_server_addr;
- clnt_sin.sin_port = 0;
- clnt = clnttcp_create(&clnt_sin, YPPROG, YPVERS, &clnt_sock, 0, 0);
- if (clnt == NULL) {
- printf("clnttcp_create failed\n");
- r = YPERR_PMAP;
- goto out;
- }
- yprnk.domain = indomain;
- yprnk.map = inmap;
- ypresp_allfn = incallback->foreach;
- ypresp_data = (void *) incallback->data;
-
- (void) clnt_call(clnt, YPPROC_ALL,
- xdr_ypreq_nokey, &yprnk, xdr_ypresp_all_seq, &status, tv);
- clnt_destroy(clnt);
- xdr_free(xdr_ypresp_all_seq, (char *) &status);
-out:
- _yp_unbind(ysd);
-
- if (status != YP_FALSE)
- return ypprot_err(status);
- return r;
-}
-
-int
-yp_order(indomain, inmap, outorder)
- const char *indomain;
- const char *inmap;
- int *outorder;
-{
- struct dom_binding *ysd;
- struct ypresp_order ypro;
- struct ypreq_nokey yprnk;
- struct timeval tv;
- int r;
-
-again:
- if (_yp_dobind(indomain, &ysd) != 0)
- return YPERR_DOMAIN;
-
- tv.tv_sec = _yplib_timeout;
- tv.tv_usec = 0;
-
- yprnk.domain = indomain;
- yprnk.map = inmap;
-
- (void)memset(&ypro, 0, sizeof ypro);
-
- r = clnt_call(ysd->dom_client, YPPROC_ORDER,
- xdr_ypreq_nokey, &yprnk, xdr_ypresp_order, &ypro, tv);
- if (r != RPC_SUCCESS) {
- clnt_perror(ysd->dom_client, "yp_order: clnt_call");
- ysd->dom_vers = -1;
- goto again;
- }
- *outorder = ypro.ordernum;
- xdr_free(xdr_ypresp_order, (char *) &ypro);
- _yp_unbind(ysd);
- return ypprot_err(ypro.status);
-}
-
-int
-yp_master(indomain, inmap, outname)
- const char *indomain;
- const char *inmap;
- char **outname;
-{
- struct dom_binding *ysd;
- struct ypresp_master yprm;
- struct ypreq_nokey yprnk;
- struct timeval tv;
- int r;
-
-again:
- if (_yp_dobind(indomain, &ysd) != 0)
- return YPERR_DOMAIN;
-
- tv.tv_sec = _yplib_timeout;
- tv.tv_usec = 0;
-
- yprnk.domain = indomain;
- yprnk.map = inmap;
-
- (void)memset(&yprm, 0, sizeof yprm);
-
- r = clnt_call(ysd->dom_client, YPPROC_MASTER,
- xdr_ypreq_nokey, &yprnk, xdr_ypresp_master, &yprm, tv);
- if (r != RPC_SUCCESS) {
- clnt_perror(ysd->dom_client, "yp_master: clnt_call");
- ysd->dom_vers = -1;
- goto again;
- }
- if (!(r = ypprot_err(yprm.status))) {
- if ((*outname = strdup(yprm.master)) == NULL)
- r = RPC_SYSTEMERROR;
- }
- xdr_free(xdr_ypresp_master, (char *) &yprm);
- _yp_unbind(ysd);
- return r;
-}
-
-int
-yp_maplist(indomain, outmaplist)
- const char *indomain;
- struct ypmaplist **outmaplist;
-{
- struct dom_binding *ysd;
- struct ypresp_maplist ypml;
- struct timeval tv;
- int r;
-
-again:
- if (_yp_dobind(indomain, &ysd) != 0)
- return YPERR_DOMAIN;
-
- tv.tv_sec = _yplib_timeout;
- tv.tv_usec = 0;
-
- memset(&ypml, 0, sizeof ypml);
-
- r = clnt_call(ysd->dom_client, YPPROC_MAPLIST,
- xdr_domainname, indomain, xdr_ypresp_maplist, &ypml, tv);
- if (r != RPC_SUCCESS) {
- clnt_perror(ysd->dom_client, "yp_maplist: clnt_call");
- ysd->dom_vers = -1;
- goto again;
- }
- *outmaplist = ypml.list;
- /* NO: xdr_free(xdr_ypresp_maplist, &ypml); */
- _yp_unbind(ysd);
- return ypprot_err(ypml.status);
-}
-
-char *
-yperr_string(incode)
- int incode;
-{
- static char err[80];
-
- switch (incode) {
- case 0:
- return "Success";
- case YPERR_BADARGS:
- return "Request arguments bad";
- case YPERR_RPC:
- return "RPC failure";
- case YPERR_DOMAIN:
- return "Can't bind to server which serves this domain";
- case YPERR_MAP:
- return "No such map in server's domain";
- case YPERR_KEY:
- return "No such key in map";
- case YPERR_YPERR:
- return "YP server error";
- case YPERR_RESRC:
- return "Local resource allocation failure";
- case YPERR_NOMORE:
- return "No more records in map database";
- case YPERR_PMAP:
- return "Can't communicate with portmapper";
- case YPERR_YPBIND:
- return "Can't communicate with ypbind";
- case YPERR_YPSERV:
- return "Can't communicate with ypserv";
- case YPERR_NODOM:
- return "Local domain name not set";
- case YPERR_BADDB:
- return "Server data base is bad";
- case YPERR_VERS:
- return "YP server version mismatch - server can't supply service.";
- case YPERR_ACCESS:
- return "Access violation";
- case YPERR_BUSY:
- return "Database is busy";
- }
- (void) snprintf(err, sizeof(err), "YP unknown error %d\n", incode);
- return err;
-}
-
-int
-ypprot_err(incode)
- unsigned int incode;
-{
- switch (incode) {
- case YP_TRUE:
- return 0;
- case YP_FALSE:
- return YPERR_YPBIND;
- case YP_NOMORE:
- return YPERR_NOMORE;
- case YP_NOMAP:
- return YPERR_MAP;
- case YP_NODOM:
- return YPERR_NODOM;
- case YP_NOKEY:
- return YPERR_KEY;
- case YP_BADOP:
- return YPERR_YPERR;
- case YP_BADDB:
- return YPERR_BADDB;
- case YP_YPERR:
- return YPERR_YPERR;
- case YP_BADARGS:
- return YPERR_BADARGS;
- case YP_VERS:
- return YPERR_VERS;
- }
- return YPERR_YPERR;
-}
-
-int
-_yp_check(dom)
- char **dom;
-{
- char *unused;
-
- if (_yp_domain[0] == '\0')
- if (yp_get_default_domain(&unused))
- return 0;
-
- if (dom)
- *dom = _yp_domain;
-
- if (yp_bind(_yp_domain) == 0)
- return 1;
- return 0;
-}
--- /dev/null
+/* $OpenBSD: ypmatch_cache.c,v 1.1 1996/04/24 12:56:31 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+#include "ypinternal.h"
+
+int _yplib_cache = 5;
+
+static bool_t
+ypmatch_add(map, key, keylen, val, vallen)
+ const char *map;
+ const char *key;
+ u_int keylen;
+ char *val;
+ u_int vallen;
+{
+ struct ypmatch_ent *ep;
+ time_t t;
+
+ (void)time(&t);
+
+ for (ep = ypmc; ep; ep = ep->next)
+ if (ep->expire_t < t)
+ break;
+ if (ep == NULL) {
+ if ((ep = malloc(sizeof *ep)) == NULL)
+ return 0;
+ (void)memset(ep, 0, sizeof *ep);
+ if (ypmc)
+ ep->next = ypmc;
+ ypmc = ep;
+ }
+
+ if (ep->key) {
+ free(ep->key);
+ ep->key = NULL;
+ }
+ if (ep->val) {
+ free(ep->val);
+ ep->val = NULL;
+ }
+
+ if ((ep->key = malloc(keylen)) == NULL)
+ return 0;
+
+ if ((ep->val = malloc(vallen)) == NULL) {
+ free(ep->key);
+ ep->key = NULL;
+ return 0;
+ }
+
+ ep->keylen = keylen;
+ ep->vallen = vallen;
+
+ (void)memcpy(ep->key, key, ep->keylen);
+ (void)memcpy(ep->val, val, ep->vallen);
+
+ if (ep->map) {
+ if (strcmp(ep->map, map)) {
+ free(ep->map);
+ if ((ep->map = strdup(map)) == NULL)
+ return 0;
+ }
+ } else {
+ if ((ep->map = strdup(map)) == NULL)
+ return 0;
+ }
+
+ ep->expire_t = t + _yplib_cache;
+ return 1;
+}
+
+static bool_t
+ypmatch_find(map, key, keylen, val, vallen)
+ const char *map;
+ const char *key;
+ u_int keylen;
+ char **val;
+ u_int *vallen;
+{
+ struct ypmatch_ent *ep;
+ time_t t;
+
+ if (ypmc == NULL)
+ return 0;
+
+ (void) time(&t);
+
+ for (ep = ypmc; ep; ep = ep->next) {
+ if (ep->keylen != keylen)
+ continue;
+ if (strcmp(ep->map, map))
+ continue;
+ if (memcmp(ep->key, key, keylen))
+ continue;
+ if (t > ep->expire_t)
+ continue;
+
+ *val = ep->val;
+ *vallen = ep->vallen;
+ return 1;
+ }
+ return 0;
+}
+
+int
+yp_match(indomain, inmap, inkey, inkeylen, outval, outvallen)
+ const char *indomain;
+ const char *inmap;
+ const char *inkey;
+ int inkeylen;
+ char **outval;
+ int *outvallen;
+{
+ struct dom_binding *ysd;
+ struct ypresp_val yprv;
+ struct timeval tv;
+ struct ypreq_key yprk;
+ int r;
+
+ *outval = NULL;
+ *outvallen = 0;
+
+again:
+ if (_yp_dobind(indomain, &ysd) != 0)
+ return YPERR_DOMAIN;
+
+#ifdef YPMATCHCACHE
+ if (!strcmp(_yp_domain, indomain) && ypmatch_find(inmap, inkey,
+ inkeylen, &yprv.val.valdat_val, &yprv.val.valdat_len)) {
+ *outvallen = yprv.val.valdat_len;
+ if ((*outval = malloc(*outvallen + 1)) == NULL) {
+ _yp_unbind(ysd);
+ return YPERR_YPERR;
+ }
+ (void)memcpy(*outval, yprv.val.valdat_val, *outvallen);
+ (*outval)[*outvallen] = '\0';
+ _yp_unbind(ysd);
+ return 0;
+ }
+#endif
+
+ tv.tv_sec = _yplib_timeout;
+ tv.tv_usec = 0;
+
+ yprk.domain = (char *)indomain;
+ yprk.map = (char *)inmap;
+ yprk.key.keydat_val = (char *) inkey;
+ yprk.key.keydat_len = inkeylen;
+
+ memset(&yprv, 0, sizeof yprv);
+
+ r = clnt_call(ysd->dom_client, YPPROC_MATCH,
+ xdr_ypreq_key, &yprk, xdr_ypresp_val, &yprv, tv);
+ if (r != RPC_SUCCESS) {
+ clnt_perror(ysd->dom_client, "yp_match: clnt_call");
+ ysd->dom_vers = -1;
+ goto again;
+ }
+ if (!(r = ypprot_err(yprv.stat))) {
+ *outvallen = yprv.val.valdat_len;
+ if ((*outval = malloc(*outvallen + 1)) == NULL) {
+ r = YPERR_YPERR;
+ goto out;
+ }
+ (void)memcpy(*outval, yprv.val.valdat_val, *outvallen);
+ (*outval)[*outvallen] = '\0';
+#ifdef YPMATCHCACHE
+ if (strcmp(_yp_domain, indomain) == 0)
+ if (!ypmatch_add(inmap, inkey, inkeylen,
+ *outval, *outvallen))
+ r = RPC_SYSTEMERROR;
+#endif
+ }
+out:
+ xdr_free(xdr_ypresp_val, (char *) &yprv);
+ _yp_unbind(ysd);
+ return r;
+}
+
+int
+yp_next(indomain, inmap, inkey, inkeylen, outkey, outkeylen, outval, outvallen)
+ const char *indomain;
+ const char *inmap;
+ const char *inkey;
+ int inkeylen;
+ char **outkey;
+ int *outkeylen;
+ char **outval;
+ int *outvallen;
+{
+ struct ypresp_key_val yprkv;
+ struct ypreq_key yprk;
+ struct dom_binding *ysd;
+ struct timeval tv;
+ int r;
+
+ *outkey = *outval = NULL;
+ *outkeylen = *outvallen = 0;
+
+again:
+ if (_yp_dobind(indomain, &ysd) != 0)
+ return YPERR_DOMAIN;
+
+ tv.tv_sec = _yplib_timeout;
+ tv.tv_usec = 0;
+
+ yprk.domain = (char *)indomain;
+ yprk.map = (char *)inmap;
+ yprk.key.keydat_val = (char *)inkey;
+ yprk.key.keydat_len = inkeylen;
+ (void)memset(&yprkv, 0, sizeof yprkv);
+
+ r = clnt_call(ysd->dom_client, YPPROC_NEXT,
+ xdr_ypreq_key, &yprk, xdr_ypresp_key_val, &yprkv, tv);
+ if (r != RPC_SUCCESS) {
+ clnt_perror(ysd->dom_client, "yp_next: clnt_call");
+ ysd->dom_vers = -1;
+ goto again;
+ }
+ if (!(r = ypprot_err(yprkv.stat))) {
+ *outkeylen = yprkv.key.keydat_len;
+ if ((*outkey = malloc(*outkeylen + 1)) == NULL)
+ r = RPC_SYSTEMERROR;
+ else {
+ (void)memcpy(*outkey, yprkv.key.keydat_val, *outkeylen);
+ (*outkey)[*outkeylen] = '\0';
+ }
+ *outvallen = yprkv.val.valdat_len;
+ if ((*outval = malloc(*outvallen + 1)) == NULL)
+ r = RPC_SYSTEMERROR;
+ else {
+ (void)memcpy(*outval, yprkv.val.valdat_val, *outvallen);
+ (*outval)[*outvallen] = '\0';
+ }
+ }
+ xdr_free(xdr_ypresp_key_val, (char *) &yprkv);
+ _yp_unbind(ysd);
+ return r;
+}
--- /dev/null
+/* $OpenBSD: ypprot_err.c,v 1.1 1996/04/24 12:56:33 deraadt Exp $ */
+/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc 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 <unistd.h>
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+int
+ypprot_err(incode)
+ unsigned int incode;
+{
+ switch (incode) {
+ case YP_TRUE:
+ return 0;
+ case YP_FALSE:
+ return YPERR_YPBIND;
+ case YP_NOMORE:
+ return YPERR_NOMORE;
+ case YP_NOMAP:
+ return YPERR_MAP;
+ case YP_NODOM:
+ return YPERR_NODOM;
+ case YP_NOKEY:
+ return YPERR_KEY;
+ case YP_BADOP:
+ return YPERR_YPERR;
+ case YP_BADDB:
+ return YPERR_BADDB;
+ case YP_YPERR:
+ return YPERR_YPERR;
+ case YP_BADARGS:
+ return YPERR_BADARGS;
+ case YP_VERS:
+ return YPERR_VERS;
+ }
+ return YPERR_YPERR;
+}