112891Swpaul/* 212891Swpaul * Copyright (c) 1995 312891Swpaul * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 412891Swpaul * 512891Swpaul * Redistribution and use in source and binary forms, with or without 612891Swpaul * modification, are permitted provided that the following conditions 712891Swpaul * are met: 812891Swpaul * 1. Redistributions of source code must retain the above copyright 912891Swpaul * notice, this list of conditions and the following disclaimer. 1012891Swpaul * 2. Redistributions in binary form must reproduce the above copyright 1112891Swpaul * notice, this list of conditions and the following disclaimer in the 1212891Swpaul * documentation and/or other materials provided with the distribution. 1312891Swpaul * 3. All advertising materials mentioning features or use of this software 1412891Swpaul * must display the following acknowledgement: 1512891Swpaul * This product includes software developed by Bill Paul. 1612891Swpaul * 4. Neither the name of the author nor the names of any co-contributors 1712891Swpaul * may be used to endorse or promote products derived from this software 1812891Swpaul * without specific prior written permission. 1912891Swpaul * 2012891Swpaul * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 2112891Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2212891Swpaul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2312891Swpaul * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE 2412891Swpaul * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2512891Swpaul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2612891Swpaul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2712891Swpaul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2812891Swpaul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2912891Swpaul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3012891Swpaul * SUCH DAMAGE. 3112891Swpaul * 3250479Speter * $FreeBSD$ 3312891Swpaul */ 3430827Scharnier 3530827Scharnier#include <db.h> 3630827Scharnier#include <limits.h> 3712891Swpaul#include <stdio.h> 3812891Swpaul#include <string.h> 3912891Swpaul#include <unistd.h> 4012891Swpaul#include <sys/cdefs.h> 4112891Swpaul#include <sys/types.h> 4212891Swpaul#include <rpc/rpc.h> 4320818Swpaul#include <rpcsvc/yp.h> 4412891Swpaul 4512891Swpaul#ifndef _PATH_YP 4612891Swpaul#define _PATH_YP "/var/yp/" 4712891Swpaul#endif 4812891Swpaul 4912891Swpaul#ifndef _PATH_LIBEXEC 5012891Swpaul#define _PATH_LIBEXEC "/usr/libexec/" 5112891Swpaul#endif 5212891Swpaul 5312891Swpaul#ifndef MAX_CHILDREN 5412891Swpaul#define MAX_CHILDREN 20 5512891Swpaul#endif 5612891Swpaul 5719161Swpaul#define YP_SECURE 0x1 5819161Swpaul#define YP_INTERDOMAIN 0x2 5919161Swpaul 6012891Swpaul/* 6112891Swpaul * External functions and variables. 6212891Swpaul */ 6312891Swpaul 6412891Swpaulextern int debug; 6512997Swpaulextern int ypdb_debug; 6612891Swpaulextern int do_dns; 6712891Swpaulextern int children; 6820818Swpaulextern int resfd; 6912891Swpaulextern char *progname; 7012891Swpaulextern char *yp_dir; 7146186Swpaulextern pid_t yp_pid; 7246186Swpaul 7320818Swpaulextern enum ypstat yp_errno; 7490297Sdesextern void yp_error(const char *, ...) __printflike(1, 2); 7520818Swpaul#ifdef DB_CACHE 7690297Sdesextern int yp_get_record(DB *, const DBT *, DBT *, int); 7720818Swpaul#else 7890297Sdesextern int yp_get_record(const char *, const char *, const DBT *, DBT *, int); 7920818Swpaul#endif 8090297Sdesextern int yp_first_record(const DB *, DBT *, DBT *, int); 8190297Sdesextern int yp_next_record(const DB *, DBT *, DBT *, int, int); 8290297Sdesextern char *yp_dnsname(char *); 8390297Sdesextern char *yp_dnsaddr(const char *); 8419161Swpaul#ifdef DB_CACHE 8590297Sdesextern int yp_access(const char *, const char *, const struct svc_req *); 8619161Swpaul#else 8790297Sdesextern int yp_access(const char *, const struct svc_req *); 8819161Swpaul#endif 8990297Sdesextern int yp_validdomain(const char *); 9090297Sdesextern DB *yp_open_db(const char *, const char *); 9190297Sdesextern DB *yp_open_db_cache(const char *, const char *, const char *, int); 9290297Sdesextern void yp_flush_all(void); 9390297Sdesextern void yp_init_dbs(void); 9490297Sdesextern int yp_testflag(char *, char *, int); 9590297Sdesextern void load_securenets(void); 9620818Swpaul 9720818Swpaul#ifdef DB_CACHE 9890297Sdesextern ypstat yp_select_map(char *, char *, keydat *, int); 9990297Sdesextern ypstat yp_getbykey(keydat *, valdat *); 10090297Sdesextern ypstat yp_firstbykey(keydat *, valdat *); 10190297Sdesextern ypstat yp_nextbykey(keydat *, valdat *); 10220818Swpaul#endif 10320818Swpaul 10490297Sdesextern unsigned long svcudp_set_xid(SVCXPRT *, unsigned long); 10590297Sdesextern unsigned long svcudp_get_xid(SVCXPRT *); 10620818Swpaul 10720818Swpaul#ifndef RESOLVER_TIMEOUT 10820818Swpaul#define RESOLVER_TIMEOUT 3600 10920818Swpaul#endif 11020818Swpaul 11190297Sdesextern int yp_init_resolver(void); 11290297Sdesextern void yp_run_dnsq(void); 11390297Sdesextern void yp_prune_dnsq(void); 114145792Sumeextern ypstat yp_async_lookup_name(struct svc_req *, char *, int); 115145792Sumeextern ypstat yp_async_lookup_addr(struct svc_req *, char *, int); 116