mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
Toss ypxfr into the attic. The new one should be appearing shortly.
This commit is contained in:
parent
4466e54fea
commit
1c16e9536e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13006
@ -1,8 +0,0 @@
|
||||
# $Id: Makefile,v 1.2 1995/02/06 22:15:20 wpaul Exp $
|
||||
|
||||
PROG= ypxfr
|
||||
MAN8= ypxfr.8
|
||||
|
||||
SRCS= ypxfr.c ypclnt.c yp_clnt.c yp_xdr.c log.c
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1995
|
||||
* Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* error logging/reporting facilities
|
||||
* stolen from /usr/libexec/mail.local via ypserv
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <syslog.h>
|
||||
|
||||
extern int logflag;
|
||||
extern char *progname;
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void verr(fmt, ap)
|
||||
const char *fmt;
|
||||
_BSD_VA_LIST_ ap;
|
||||
|
||||
{
|
||||
if (logflag)
|
||||
vsyslog(LOG_NOTICE, fmt, ap);
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"%s: ",progname);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef __STDC__
|
||||
Perror(const char *fmt, ...)
|
||||
#else
|
||||
Perror(fmt, va_list)
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#ifdef __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
verr(fmt,ap);
|
||||
va_end(ap);
|
||||
}
|
@ -1,288 +0,0 @@
|
||||
#define YPMAXRECORD 1024
|
||||
#define YPMAXDOMAIN 64
|
||||
#define YPMAXMAP 64
|
||||
#define YPMAXPEER 64
|
||||
|
||||
enum ypstat {
|
||||
YP_TRUE = 1,
|
||||
YP_NOMORE = 2,
|
||||
YP_FALSE = 0,
|
||||
YP_NOMAP = -1,
|
||||
YP_NODOM = -2,
|
||||
YP_NOKEY = -3,
|
||||
YP_BADOP = -4,
|
||||
YP_BADDB = -5,
|
||||
YP_YPERR = -6,
|
||||
YP_BADARGS = -7,
|
||||
YP_VERS = -8,
|
||||
};
|
||||
typedef enum ypstat ypstat;
|
||||
bool_t xdr_ypstat();
|
||||
|
||||
|
||||
enum ypxfrstat {
|
||||
YPXFR_SUCC = 1,
|
||||
YPXFR_AGE = 2,
|
||||
YPXFR_NOMAP = -1,
|
||||
YPXFR_NODOM = -2,
|
||||
YPXFR_RSRC = -3,
|
||||
YPXFR_RPC = -4,
|
||||
YPXFR_MADDR = -5,
|
||||
YPXFR_YPERR = -6,
|
||||
YPXFR_BADARGS = -7,
|
||||
YPXFR_DBM = -8,
|
||||
YPXFR_FILE = -9,
|
||||
YPXFR_SKEW = -10,
|
||||
YPXFR_CLEAR = -11,
|
||||
YPXFR_FORCE = -12,
|
||||
YPXFR_XFRERR = -13,
|
||||
YPXFR_REFUSED = -14,
|
||||
};
|
||||
typedef enum ypxfrstat ypxfrstat;
|
||||
bool_t xdr_ypxfrstat();
|
||||
|
||||
|
||||
typedef char *domainname;
|
||||
bool_t xdr_domainname();
|
||||
|
||||
|
||||
typedef char *mapname;
|
||||
bool_t xdr_mapname();
|
||||
|
||||
|
||||
typedef char *peername;
|
||||
bool_t xdr_peername();
|
||||
|
||||
|
||||
typedef struct {
|
||||
u_int keydat_len;
|
||||
char *keydat_val;
|
||||
} keydat;
|
||||
bool_t xdr_keydat();
|
||||
|
||||
|
||||
typedef struct {
|
||||
u_int valdat_len;
|
||||
char *valdat_val;
|
||||
} valdat;
|
||||
bool_t xdr_valdat();
|
||||
|
||||
|
||||
struct ypmap_parms {
|
||||
domainname domain;
|
||||
mapname map;
|
||||
u_int ordernum;
|
||||
peername peer;
|
||||
};
|
||||
typedef struct ypmap_parms ypmap_parms;
|
||||
bool_t xdr_ypmap_parms();
|
||||
|
||||
|
||||
struct ypreq_key {
|
||||
domainname domain;
|
||||
mapname map;
|
||||
keydat key;
|
||||
};
|
||||
typedef struct ypreq_key ypreq_key;
|
||||
bool_t xdr_ypreq_key();
|
||||
|
||||
|
||||
struct ypreq_nokey {
|
||||
domainname domain;
|
||||
mapname map;
|
||||
};
|
||||
typedef struct ypreq_nokey ypreq_nokey;
|
||||
bool_t xdr_ypreq_nokey();
|
||||
|
||||
|
||||
struct ypreq_xfr {
|
||||
ypmap_parms map_parms;
|
||||
u_int transid;
|
||||
u_int prog;
|
||||
u_int port;
|
||||
};
|
||||
typedef struct ypreq_xfr ypreq_xfr;
|
||||
bool_t xdr_ypreq_xfr();
|
||||
|
||||
|
||||
struct ypresp_val {
|
||||
ypstat stat;
|
||||
valdat val;
|
||||
};
|
||||
typedef struct ypresp_val ypresp_val;
|
||||
bool_t xdr_ypresp_val();
|
||||
|
||||
|
||||
struct ypresp_key_val {
|
||||
ypstat stat;
|
||||
keydat key;
|
||||
valdat val;
|
||||
};
|
||||
typedef struct ypresp_key_val ypresp_key_val;
|
||||
bool_t xdr_ypresp_key_val();
|
||||
|
||||
|
||||
struct ypresp_master {
|
||||
ypstat stat;
|
||||
peername peer;
|
||||
};
|
||||
typedef struct ypresp_master ypresp_master;
|
||||
bool_t xdr_ypresp_master();
|
||||
|
||||
|
||||
struct ypresp_order {
|
||||
ypstat stat;
|
||||
u_int ordernum;
|
||||
};
|
||||
typedef struct ypresp_order ypresp_order;
|
||||
bool_t xdr_ypresp_order();
|
||||
|
||||
|
||||
struct ypresp_all {
|
||||
bool_t more;
|
||||
union {
|
||||
ypresp_key_val val;
|
||||
} ypresp_all_u;
|
||||
};
|
||||
typedef struct ypresp_all ypresp_all;
|
||||
bool_t __xdr_ypresp_all();
|
||||
|
||||
|
||||
struct ypresp_xfr {
|
||||
u_int transid;
|
||||
ypxfrstat xfrstat;
|
||||
};
|
||||
typedef struct ypresp_xfr ypresp_xfr;
|
||||
bool_t xdr_ypresp_xfr();
|
||||
|
||||
|
||||
struct ypmaplist {
|
||||
mapname map;
|
||||
struct ypmaplist *next;
|
||||
};
|
||||
typedef struct ypmaplist ypmaplist;
|
||||
bool_t xdr_ypmaplist();
|
||||
|
||||
|
||||
struct ypresp_maplist {
|
||||
ypstat stat;
|
||||
ypmaplist *maps;
|
||||
};
|
||||
typedef struct ypresp_maplist ypresp_maplist;
|
||||
bool_t xdr_ypresp_maplist();
|
||||
|
||||
|
||||
enum yppush_status {
|
||||
YPPUSH_SUCC = 1,
|
||||
YPPUSH_AGE = 2,
|
||||
YPPUSH_NOMAP = -1,
|
||||
YPPUSH_NODOM = -2,
|
||||
YPPUSH_RSRC = -3,
|
||||
YPPUSH_RPC = -4,
|
||||
YPPUSH_MADDR = -5,
|
||||
YPPUSH_YPERR = -6,
|
||||
YPPUSH_BADARGS = -7,
|
||||
YPPUSH_DBM = -8,
|
||||
YPPUSH_FILE = -9,
|
||||
YPPUSH_SKEW = -10,
|
||||
YPPUSH_CLEAR = -11,
|
||||
YPPUSH_FORCE = -12,
|
||||
YPPUSH_XFRERR = -13,
|
||||
YPPUSH_REFUSED = -14,
|
||||
};
|
||||
typedef enum yppush_status yppush_status;
|
||||
bool_t xdr_yppush_status();
|
||||
|
||||
|
||||
struct yppushresp_xfr {
|
||||
u_int transid;
|
||||
yppush_status status;
|
||||
};
|
||||
typedef struct yppushresp_xfr yppushresp_xfr;
|
||||
bool_t xdr_yppushresp_xfr();
|
||||
|
||||
|
||||
enum ypbind_resptype {
|
||||
YPBIND_SUCC_VAL = 1,
|
||||
YPBIND_FAIL_VAL = 2,
|
||||
};
|
||||
typedef enum ypbind_resptype ypbind_resptype;
|
||||
bool_t xdr_ypbind_resptype();
|
||||
|
||||
|
||||
struct ypbind_binding {
|
||||
char ypbind_binding_addr[4];
|
||||
char ypbind_binding_port[2];
|
||||
};
|
||||
typedef struct ypbind_binding ypbind_binding;
|
||||
bool_t xdr_ypbind_binding();
|
||||
|
||||
|
||||
struct ypbind_resp {
|
||||
ypbind_resptype ypbind_status;
|
||||
union {
|
||||
u_int ypbind_error;
|
||||
ypbind_binding ypbind_bindinfo;
|
||||
} ypbind_resp_u;
|
||||
};
|
||||
typedef struct ypbind_resp ypbind_resp;
|
||||
bool_t xdr_ypbind_resp();
|
||||
|
||||
#define YPBIND_ERR_ERR 1
|
||||
#define YPBIND_ERR_NOSERV 2
|
||||
#define YPBIND_ERR_RESC 3
|
||||
|
||||
struct ypbind_setdom {
|
||||
domainname ypsetdom_domain;
|
||||
ypbind_binding ypsetdom_binding;
|
||||
u_int ypsetdom_vers;
|
||||
};
|
||||
typedef struct ypbind_setdom ypbind_setdom;
|
||||
bool_t xdr_ypbind_setdom();
|
||||
|
||||
|
||||
#define YPPROG ((u_long)100004)
|
||||
#define YPVERS ((u_long)2)
|
||||
#define YPPROC_NULL ((u_long)0)
|
||||
extern void *ypproc_null_2();
|
||||
#define YPPROC_DOMAIN ((u_long)1)
|
||||
extern bool_t *ypproc_domain_2();
|
||||
#define YPPROC_DOMAIN_NONACK ((u_long)2)
|
||||
extern bool_t *ypproc_domain_nonack_2();
|
||||
#define YPPROC_MATCH ((u_long)3)
|
||||
extern ypresp_val *ypproc_match_2();
|
||||
#define YPPROC_FIRST ((u_long)4)
|
||||
extern ypresp_key_val *ypproc_first_2();
|
||||
#define YPPROC_NEXT ((u_long)5)
|
||||
extern ypresp_key_val *ypproc_next_2();
|
||||
#define YPPROC_XFR ((u_long)6)
|
||||
extern ypresp_xfr *ypproc_xfr_2();
|
||||
#define YPPROC_CLEAR ((u_long)7)
|
||||
extern void *ypproc_clear_2();
|
||||
#define YPPROC_ALL ((u_long)8)
|
||||
extern ypresp_all *ypproc_all_2();
|
||||
#define YPPROC_MASTER ((u_long)9)
|
||||
extern ypresp_master *ypproc_master_2();
|
||||
#define YPPROC_ORDER ((u_long)10)
|
||||
extern ypresp_order *ypproc_order_2();
|
||||
#define YPPROC_MAPLIST ((u_long)11)
|
||||
extern ypresp_maplist *ypproc_maplist_2();
|
||||
|
||||
|
||||
#define YPPUSH_XFRRESPPROG ((u_long)0x40000000)
|
||||
#define YPPUSH_XFRRESPVERS ((u_long)1)
|
||||
#define YPPUSHPROC_NULL ((u_long)0)
|
||||
extern void *yppushproc_null_1();
|
||||
#define YPPUSHPROC_XFRRESP ((u_long)1)
|
||||
extern yppushresp_xfr *yppushproc_xfrresp_1();
|
||||
|
||||
|
||||
#define YPBINDPROG ((u_long)100007)
|
||||
#define YPBINDVERS ((u_long)2)
|
||||
#define YPBINDPROC_NULL ((u_long)0)
|
||||
extern void *ypbindproc_null_2();
|
||||
#define YPBINDPROC_DOMAIN ((u_long)1)
|
||||
extern ypbind_resp *ypbindproc_domain_2();
|
||||
#define YPBINDPROC_SETDOM ((u_long)2)
|
||||
extern void *ypbindproc_setdom_2();
|
||||
|
@ -1,264 +0,0 @@
|
||||
#include <rpc/rpc.h>
|
||||
#include "yp.h"
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)yp.x 2.1 88/08/01 4.0 RPCSRC";*/
|
||||
static char rcsid[] = "yp.x,v 1.1 1994/08/04 19:01:55 wollman Exp";
|
||||
#endif /* not lint */
|
||||
|
||||
/* Default timeout can be changed using clnt_control() */
|
||||
static struct timeval TIMEOUT = { 25, 0 };
|
||||
|
||||
void *
|
||||
ypproc_null_2(argp, clnt)
|
||||
void *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static char res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_NULL, xdr_void, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return ((void *)&res);
|
||||
}
|
||||
|
||||
|
||||
bool_t *
|
||||
ypproc_domain_2(argp, clnt)
|
||||
domainname *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static bool_t res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_DOMAIN, xdr_domainname, argp, xdr_bool, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
bool_t *
|
||||
ypproc_domain_nonack_2(argp, clnt)
|
||||
domainname *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static bool_t res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_DOMAIN_NONACK, xdr_domainname, argp, xdr_bool, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
ypresp_val *
|
||||
ypproc_match_2(argp, clnt)
|
||||
ypreq_key *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static ypresp_val res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_MATCH, xdr_ypreq_key, argp, xdr_ypresp_val, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
ypresp_key_val *
|
||||
ypproc_first_2(argp, clnt)
|
||||
ypreq_key *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static ypresp_key_val res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_FIRST, xdr_ypreq_key, argp, xdr_ypresp_key_val, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
ypresp_key_val *
|
||||
ypproc_next_2(argp, clnt)
|
||||
ypreq_key *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static ypresp_key_val res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_NEXT, xdr_ypreq_key, argp, xdr_ypresp_key_val, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
ypresp_xfr *
|
||||
ypproc_xfr_2(argp, clnt)
|
||||
ypreq_xfr *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static ypresp_xfr res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_XFR, xdr_ypreq_xfr, argp, xdr_ypresp_xfr, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
ypproc_clear_2(argp, clnt)
|
||||
void *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static char res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_CLEAR, xdr_void, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return ((void *)&res);
|
||||
}
|
||||
|
||||
|
||||
ypresp_all *
|
||||
ypproc_all_2(argp, clnt)
|
||||
ypreq_nokey *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static ypresp_all res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_ALL, xdr_ypreq_nokey, argp, __xdr_ypresp_all, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
ypresp_master *
|
||||
ypproc_master_2(argp, clnt)
|
||||
ypreq_nokey *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static ypresp_master res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_MASTER, xdr_ypreq_nokey, argp, xdr_ypresp_master, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
ypresp_order *
|
||||
ypproc_order_2(argp, clnt)
|
||||
ypreq_nokey *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static ypresp_order res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_ORDER, xdr_ypreq_nokey, argp, xdr_ypresp_order, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
ypresp_maplist *
|
||||
ypproc_maplist_2(argp, clnt)
|
||||
domainname *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static ypresp_maplist res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPROC_MAPLIST, xdr_domainname, argp, xdr_ypresp_maplist, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
yppushproc_null_1(argp, clnt)
|
||||
void *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static char res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPUSHPROC_NULL, xdr_void, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return ((void *)&res);
|
||||
}
|
||||
|
||||
|
||||
yppushresp_xfr *
|
||||
yppushproc_xfrresp_1(argp, clnt)
|
||||
void *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static yppushresp_xfr res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPPUSHPROC_XFRRESP, xdr_void, argp, xdr_yppushresp_xfr, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
ypbindproc_null_2(argp, clnt)
|
||||
void *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static char res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPBINDPROC_NULL, xdr_void, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return ((void *)&res);
|
||||
}
|
||||
|
||||
|
||||
ypbind_resp *
|
||||
ypbindproc_domain_2(argp, clnt)
|
||||
domainname *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static ypbind_resp res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPBINDPROC_DOMAIN, xdr_domainname, argp, xdr_ypbind_resp, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
ypbindproc_setdom_2(argp, clnt)
|
||||
ypbind_setdom *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static char res;
|
||||
|
||||
bzero((char *)&res, sizeof(res));
|
||||
if (clnt_call(clnt, YPBINDPROC_SETDOM, xdr_ypbind_setdom, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
return ((void *)&res);
|
||||
}
|
||||
|
@ -1,272 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include "yp.h"
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)yp.x 2.1 88/08/01 4.0 RPCSRC";*/
|
||||
static char rcsid[] = "yp.x,v 1.1 1994/08/04 19:01:55 wollman Exp";
|
||||
#endif /* not lint */
|
||||
|
||||
static void ypprog_2();
|
||||
static void yppush_xfrrespprog_1();
|
||||
static void ypbindprog_2();
|
||||
extern void Perror __P((const char *, ...));
|
||||
|
||||
main()
|
||||
{
|
||||
SVCXPRT *transp;
|
||||
|
||||
(void)pmap_unset(YPPROG, YPVERS);
|
||||
(void)pmap_unset(YPPUSH_XFRRESPPROG, YPPUSH_XFRRESPVERS);
|
||||
(void)pmap_unset(YPBINDPROG, YPBINDVERS);
|
||||
|
||||
transp = svcudp_create(RPC_ANYSOCK);
|
||||
if (transp == NULL) {
|
||||
Perror("cannot create udp service.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, IPPROTO_UDP)) {
|
||||
Perror("unable to register (YPPROG, YPVERS, udp).\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!svc_register(transp, YPPUSH_XFRRESPPROG, YPPUSH_XFRRESPVERS, yppush_xfrrespprog_1, IPPROTO_UDP)) {
|
||||
Perror("unable to register (YPPUSH_XFRRESPPROG, YPPUSH_XFRRESPVERS, udp).\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!svc_register(transp, YPBINDPROG, YPBINDVERS, ypbindprog_2, IPPROTO_UDP)) {
|
||||
Perror("unable to register (YPBINDPROG, YPBINDVERS, udp).\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
transp = svctcp_create(RPC_ANYSOCK, 0, 0);
|
||||
if (transp == NULL) {
|
||||
Perror("cannot create tcp service.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, IPPROTO_TCP)) {
|
||||
Perror("unable to register (YPPROG, YPVERS, tcp).\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!svc_register(transp, YPPUSH_XFRRESPPROG, YPPUSH_XFRRESPVERS, yppush_xfrrespprog_1, IPPROTO_TCP)) {
|
||||
Perror("unable to register (YPPUSH_XFRRESPPROG, YPPUSH_XFRRESPVERS, tcp).\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!svc_register(transp, YPBINDPROG, YPBINDVERS, ypbindprog_2, IPPROTO_TCP)) {
|
||||
Perror("unable to register (YPBINDPROG, YPBINDVERS, tcp).\n");
|
||||
exit(1);
|
||||
}
|
||||
svc_run();
|
||||
Perror("svc_run returned\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
ypprog_2(rqstp, transp)
|
||||
struct svc_req *rqstp;
|
||||
SVCXPRT *transp;
|
||||
{
|
||||
union {
|
||||
domainname ypproc_domain_2_arg;
|
||||
domainname ypproc_domain_nonack_2_arg;
|
||||
ypreq_key ypproc_match_2_arg;
|
||||
ypreq_key ypproc_first_2_arg;
|
||||
ypreq_key ypproc_next_2_arg;
|
||||
ypreq_xfr ypproc_xfr_2_arg;
|
||||
ypreq_nokey ypproc_all_2_arg;
|
||||
ypreq_nokey ypproc_master_2_arg;
|
||||
ypreq_nokey ypproc_order_2_arg;
|
||||
domainname ypproc_maplist_2_arg;
|
||||
} argument;
|
||||
char *result;
|
||||
bool_t (*xdr_argument)(), (*xdr_result)();
|
||||
char *(*local)();
|
||||
|
||||
switch (rqstp->rq_proc) {
|
||||
case YPPROC_NULL:
|
||||
xdr_argument = xdr_void;
|
||||
xdr_result = xdr_void;
|
||||
local = (char *(*)()) ypproc_null_2;
|
||||
break;
|
||||
|
||||
case YPPROC_DOMAIN:
|
||||
xdr_argument = xdr_domainname;
|
||||
xdr_result = xdr_bool;
|
||||
local = (char *(*)()) ypproc_domain_2;
|
||||
break;
|
||||
|
||||
case YPPROC_DOMAIN_NONACK:
|
||||
xdr_argument = xdr_domainname;
|
||||
xdr_result = xdr_bool;
|
||||
local = (char *(*)()) ypproc_domain_nonack_2;
|
||||
break;
|
||||
|
||||
case YPPROC_MATCH:
|
||||
xdr_argument = xdr_ypreq_key;
|
||||
xdr_result = xdr_ypresp_val;
|
||||
local = (char *(*)()) ypproc_match_2;
|
||||
break;
|
||||
|
||||
case YPPROC_FIRST:
|
||||
xdr_argument = xdr_ypreq_key;
|
||||
xdr_result = xdr_ypresp_key_val;
|
||||
local = (char *(*)()) ypproc_first_2;
|
||||
break;
|
||||
|
||||
case YPPROC_NEXT:
|
||||
xdr_argument = xdr_ypreq_key;
|
||||
xdr_result = xdr_ypresp_key_val;
|
||||
local = (char *(*)()) ypproc_next_2;
|
||||
break;
|
||||
|
||||
case YPPROC_XFR:
|
||||
xdr_argument = xdr_ypreq_xfr;
|
||||
xdr_result = xdr_ypresp_xfr;
|
||||
local = (char *(*)()) ypproc_xfr_2;
|
||||
break;
|
||||
|
||||
case YPPROC_CLEAR:
|
||||
xdr_argument = xdr_void;
|
||||
xdr_result = xdr_void;
|
||||
local = (char *(*)()) ypproc_clear_2;
|
||||
break;
|
||||
|
||||
case YPPROC_ALL:
|
||||
xdr_argument = xdr_ypreq_nokey;
|
||||
xdr_result = __xdr_ypresp_all;
|
||||
local = (char *(*)()) ypproc_all_2;
|
||||
break;
|
||||
|
||||
case YPPROC_MASTER:
|
||||
xdr_argument = xdr_ypreq_nokey;
|
||||
xdr_result = xdr_ypresp_master;
|
||||
local = (char *(*)()) ypproc_master_2;
|
||||
break;
|
||||
|
||||
case YPPROC_ORDER:
|
||||
xdr_argument = xdr_ypreq_nokey;
|
||||
xdr_result = xdr_ypresp_order;
|
||||
local = (char *(*)()) ypproc_order_2;
|
||||
break;
|
||||
|
||||
case YPPROC_MAPLIST:
|
||||
xdr_argument = xdr_domainname;
|
||||
xdr_result = xdr_ypresp_maplist;
|
||||
local = (char *(*)()) ypproc_maplist_2;
|
||||
break;
|
||||
|
||||
default:
|
||||
svcerr_noproc(transp);
|
||||
return;
|
||||
}
|
||||
bzero((char *)&argument, sizeof(argument));
|
||||
if (!svc_getargs(transp, xdr_argument, &argument)) {
|
||||
svcerr_decode(transp);
|
||||
return;
|
||||
}
|
||||
result = (*local)(&argument, rqstp);
|
||||
if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
|
||||
svcerr_systemerr(transp);
|
||||
}
|
||||
if (!svc_freeargs(transp, xdr_argument, &argument)) {
|
||||
Perror("unable to free arguments\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
yppush_xfrrespprog_1(rqstp, transp)
|
||||
struct svc_req *rqstp;
|
||||
SVCXPRT *transp;
|
||||
{
|
||||
union {
|
||||
int fill;
|
||||
} argument;
|
||||
char *result;
|
||||
bool_t (*xdr_argument)(), (*xdr_result)();
|
||||
char *(*local)();
|
||||
|
||||
switch (rqstp->rq_proc) {
|
||||
case YPPUSHPROC_NULL:
|
||||
xdr_argument = xdr_void;
|
||||
xdr_result = xdr_void;
|
||||
local = (char *(*)()) yppushproc_null_1;
|
||||
break;
|
||||
|
||||
case YPPUSHPROC_XFRRESP:
|
||||
xdr_argument = xdr_void;
|
||||
xdr_result = xdr_yppushresp_xfr;
|
||||
local = (char *(*)()) yppushproc_xfrresp_1;
|
||||
break;
|
||||
|
||||
default:
|
||||
svcerr_noproc(transp);
|
||||
return;
|
||||
}
|
||||
bzero((char *)&argument, sizeof(argument));
|
||||
if (!svc_getargs(transp, xdr_argument, &argument)) {
|
||||
svcerr_decode(transp);
|
||||
return;
|
||||
}
|
||||
result = (*local)(&argument, rqstp);
|
||||
if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
|
||||
svcerr_systemerr(transp);
|
||||
}
|
||||
if (!svc_freeargs(transp, xdr_argument, &argument)) {
|
||||
Perror("unable to free arguments\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ypbindprog_2(rqstp, transp)
|
||||
struct svc_req *rqstp;
|
||||
SVCXPRT *transp;
|
||||
{
|
||||
union {
|
||||
domainname ypbindproc_domain_2_arg;
|
||||
ypbind_setdom ypbindproc_setdom_2_arg;
|
||||
} argument;
|
||||
char *result;
|
||||
bool_t (*xdr_argument)(), (*xdr_result)();
|
||||
char *(*local)();
|
||||
|
||||
switch (rqstp->rq_proc) {
|
||||
case YPBINDPROC_NULL:
|
||||
xdr_argument = xdr_void;
|
||||
xdr_result = xdr_void;
|
||||
local = (char *(*)()) ypbindproc_null_2;
|
||||
break;
|
||||
|
||||
case YPBINDPROC_DOMAIN:
|
||||
xdr_argument = xdr_domainname;
|
||||
xdr_result = xdr_ypbind_resp;
|
||||
local = (char *(*)()) ypbindproc_domain_2;
|
||||
break;
|
||||
|
||||
case YPBINDPROC_SETDOM:
|
||||
xdr_argument = xdr_ypbind_setdom;
|
||||
xdr_result = xdr_void;
|
||||
local = (char *(*)()) ypbindproc_setdom_2;
|
||||
break;
|
||||
|
||||
default:
|
||||
svcerr_noproc(transp);
|
||||
return;
|
||||
}
|
||||
bzero((char *)&argument, sizeof(argument));
|
||||
if (!svc_getargs(transp, xdr_argument, &argument)) {
|
||||
svcerr_decode(transp);
|
||||
return;
|
||||
}
|
||||
result = (*local)(&argument, rqstp);
|
||||
if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
|
||||
svcerr_systemerr(transp);
|
||||
}
|
||||
if (!svc_freeargs(transp, xdr_argument, &argument)) {
|
||||
Perror("unable to free arguments\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -1,145 +0,0 @@
|
||||
#include <rpc/rpc.h>
|
||||
#include "yp.h"
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)yp.x 2.1 88/08/01 4.0 RPCSRC";*/
|
||||
static char rcsid[] = "yp.x,v 1.1 1994/08/04 19:01:55 wollman Exp";
|
||||
#endif /* not lint */
|
||||
|
||||
extern void Perror __P((const char *, ...));
|
||||
|
||||
struct {
|
||||
union {
|
||||
int (*encoder)(char *, int, char **, int *, char **, int *);
|
||||
int (*decoder)(int, char *, int, char *, int, char *);
|
||||
} foreach;
|
||||
char *data;
|
||||
} *xdr_ypall_callback;
|
||||
|
||||
bool_t
|
||||
__xdr_ypstat(XDR *xdrs, ypstat *objp)
|
||||
{
|
||||
|
||||
if (!xdr_enum(xdrs, (enum_t *)objp)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
bool_t
|
||||
__xdr_valdat(XDR *xdrs, valdat *objp)
|
||||
{
|
||||
|
||||
if (!xdr_bytes(xdrs, (char **)&objp->valdat_val, (u_int *)&objp->valdat_len, YPMAXRECORD)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
bool_t
|
||||
__xdr_keydat(XDR *xdrs, keydat *objp)
|
||||
{
|
||||
|
||||
if (!xdr_bytes(xdrs, (char **)&objp->keydat_val, (u_int *)&objp->keydat_len, YPMAXRECORD)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
bool_t
|
||||
__xdr_ypresp_key_val(XDR *xdrs, ypresp_key_val *objp)
|
||||
{
|
||||
|
||||
if (!__xdr_ypstat(xdrs, &objp->stat)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!__xdr_valdat(xdrs, &objp->val)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!__xdr_keydat(xdrs, &objp->key)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
bool_t
|
||||
__xdr_ypresp_all(XDR *xdrs, ypresp_all *objp)
|
||||
{
|
||||
int CallAgain = 0;
|
||||
if (xdrs->x_op == XDR_DECODE) {
|
||||
while(1) {
|
||||
#if 1
|
||||
int s=objp->ypresp_all_u.val.stat;
|
||||
bzero((char *)objp, sizeof (*objp));
|
||||
objp->ypresp_all_u.val.stat=s;
|
||||
#endif
|
||||
if (!xdr_bool(xdrs, &objp->more)) {
|
||||
return (FALSE);
|
||||
}
|
||||
switch (objp->more) {
|
||||
case TRUE:
|
||||
if (!__xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (CallAgain==0) {
|
||||
CallAgain=(*(xdr_ypall_callback->foreach.decoder))(
|
||||
objp->ypresp_all_u.val.stat,
|
||||
objp->ypresp_all_u.val.key.keydat_val,
|
||||
objp->ypresp_all_u.val.key.keydat_len,
|
||||
objp->ypresp_all_u.val.val.valdat_val,
|
||||
objp->ypresp_all_u.val.val.valdat_len,
|
||||
xdr_ypall_callback->data);
|
||||
}
|
||||
break;
|
||||
case FALSE:
|
||||
return TRUE;
|
||||
}
|
||||
#if 0
|
||||
xdrs->x_op=XDR_FREE;
|
||||
if (!__xdr_ypresp_all(xdrs, objp)) {
|
||||
return FALSE;
|
||||
}
|
||||
xdrs->x_op=XDR_DECODE;
|
||||
#else
|
||||
xdr_free(__xdr_ypresp_all, (char *)objp);
|
||||
#endif
|
||||
}
|
||||
} else if (xdrs->x_op == XDR_ENCODE) {
|
||||
while(1) {
|
||||
if (!xdr_bool(xdrs, &(objp->more))) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!__xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val)) {
|
||||
Perror("__xdr_ypresp_key_val failed\n");
|
||||
return (FALSE);
|
||||
}
|
||||
if (objp->ypresp_all_u.val.stat!=YP_TRUE) {
|
||||
objp->more=FALSE;
|
||||
if (!xdr_bool(xdrs, &(objp->more))) {
|
||||
return (FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
objp->ypresp_all_u.val.stat =
|
||||
(enum ypstat)(*(xdr_ypall_callback->foreach.encoder))(
|
||||
objp->ypresp_all_u.val.key.keydat_val,
|
||||
objp->ypresp_all_u.val.key.keydat_len,
|
||||
&(objp->ypresp_all_u.val.key.keydat_val),
|
||||
&(objp->ypresp_all_u.val.key.keydat_len),
|
||||
&(objp->ypresp_all_u.val.val.valdat_val),
|
||||
&(objp->ypresp_all_u.val.val.valdat_len));
|
||||
}
|
||||
} else {
|
||||
#if 0
|
||||
bool_t more=objp->more;
|
||||
if (more==TRUE) {
|
||||
if (!xdr_bool(xdrs, &objp->more)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (!__xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val)) {
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
@ -1,233 +0,0 @@
|
||||
/*
|
||||
YPS-0.2, NIS-Server for Linux
|
||||
Copyright (C) 1994 Tobias Reber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Modified for use with FreeBSD 2.x by Bill Paul (wpaul@ctr.columbia.edu)
|
||||
|
||||
$Id: ypclnt.c,v 1.3 1995/03/31 05:45:21 wpaul Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/pmap_clnt.h>
|
||||
#include <rpcsvc/yp.h>
|
||||
/*
|
||||
* ypclnt.h does not have a definition for struct dom_binding,
|
||||
* although it is used there. It is defined in yp_prot.h, but
|
||||
* we cannot use it here.
|
||||
*/
|
||||
struct dom_binding {
|
||||
void * m;
|
||||
};
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
|
||||
static struct sockaddr_in ServerAddress;
|
||||
static CLIENT *UdpClient=NULL, *TcpClient=NULL;
|
||||
extern void Perror __P((const char *, ...));
|
||||
|
||||
#ifdef YPBROADCAST
|
||||
static bool_t
|
||||
eachresult( caddr_t resultsp, struct sockaddr_in *raddr)
|
||||
{
|
||||
bcopy(raddr, &ServerAddress, sizeof(ServerAddress));
|
||||
return((bool_t) TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct sockaddr_in *
|
||||
__do_ypbind(domainname d)
|
||||
{
|
||||
static struct sockaddr_in resp;
|
||||
int rc;
|
||||
ypbind_resp r;
|
||||
CLIENT *localBindClient;
|
||||
struct sockaddr_in localAddr;
|
||||
int s;
|
||||
struct timeval t={5,0}, tott={25,0};
|
||||
|
||||
s=RPC_ANYSOCK;
|
||||
bzero(&localAddr, sizeof localAddr);
|
||||
localAddr.sin_addr.s_addr=htonl(INADDR_LOOPBACK);
|
||||
localBindClient=clntudp_create(&localAddr, YPBINDPROG, YPBINDVERS, tott, &s);
|
||||
if (!localBindClient) {
|
||||
clnt_pcreateerror("");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc=clnt_call(localBindClient, YPBINDPROC_DOMAIN,
|
||||
xdr_domainname, (char *)&d, xdr_ypbind_resp, (char *)&r, t);
|
||||
if (rc) {
|
||||
clnt_perrno(rc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (r.ypbind_status) {
|
||||
case YPBIND_FAIL_VAL:
|
||||
switch(r.ypbind_resp_u.ypbind_error) {
|
||||
case YPBIND_ERR_ERR:
|
||||
Perror("YPBINDPROC_DOMAIN: Internal error\n");
|
||||
break;
|
||||
case YPBIND_ERR_NOSERV:
|
||||
Perror("YPBINDPROC_DOMAIN: No bound server for passed domain\n");
|
||||
break;
|
||||
case YPBIND_ERR_RESC:
|
||||
Perror("YPBINDPROC_DOMAIN: System resource allocation failure\n");
|
||||
break;
|
||||
default:
|
||||
Perror("YPBINDPROC_DOMAIN: Unknown error\n");
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
case YPBIND_SUCC_VAL:
|
||||
{
|
||||
struct ypbind_binding *y=&r.ypbind_resp_u.ypbind_bindinfo;
|
||||
bzero(&resp, sizeof resp);
|
||||
resp.sin_family=AF_INET;
|
||||
resp.sin_addr=*(struct in_addr *)(y->ypbind_binding_addr);
|
||||
return &resp;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
__yp_unbind(char *DomainName)
|
||||
{
|
||||
if (UdpClient) clnt_destroy(UdpClient);
|
||||
UdpClient=NULL;
|
||||
if (TcpClient) clnt_destroy(TcpClient);
|
||||
TcpClient=NULL;
|
||||
}
|
||||
|
||||
int
|
||||
_yp_bind(struct sockaddr_in *ServerAddress, char *DomainName)
|
||||
{
|
||||
struct sockaddr_in UdpServerAddress, TcpServerAddress;
|
||||
int UdpSockp, TcpSockp;
|
||||
static struct timeval Wait = { 5, 0 };
|
||||
|
||||
if (UdpClient || TcpClient) __yp_unbind(DomainName);
|
||||
|
||||
bcopy(ServerAddress, &UdpServerAddress, sizeof(*ServerAddress));
|
||||
UdpServerAddress.sin_port=0;
|
||||
UdpSockp=(RPC_ANYSOCK);
|
||||
bcopy(ServerAddress, &TcpServerAddress, sizeof(*ServerAddress));
|
||||
TcpServerAddress.sin_port=0;
|
||||
TcpSockp=(RPC_ANYSOCK);
|
||||
if ((UdpClient=clntudp_create(&UdpServerAddress, YPPROG, YPVERS,
|
||||
Wait, &UdpSockp))==NULL) {
|
||||
clnt_pcreateerror("UdpClient");
|
||||
return(YPERR_RPC);
|
||||
}
|
||||
if ((TcpClient=clnttcp_create(&TcpServerAddress, YPPROG, YPVERS,
|
||||
&TcpSockp, 0, 0))==NULL) {
|
||||
clnt_pcreateerror("TcpClient");
|
||||
return(YPERR_RPC);
|
||||
}
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
__yp_bind(char *DomainName)
|
||||
{
|
||||
# ifdef YPBROADCAST
|
||||
enum clnt_stat clnt_stat;
|
||||
static bool_t res;
|
||||
# endif
|
||||
static domainname domain;
|
||||
|
||||
domain=DomainName;
|
||||
# ifndef SOCKSERVER
|
||||
# ifdef YPBROADCAST
|
||||
bzero(&ServerAddress, sizeof ServerAddress);
|
||||
if ((clnt_stat=clnt_broadcast(YPPROG, YPVERS,
|
||||
YPPROC_DOMAIN_NONACK, xdr_domainname, (char *)&domain, xdr_bool,
|
||||
(char *)&res, eachresult))!=RPC_SUCCESS) {
|
||||
clnt_perrno(clnt_stat);
|
||||
return(YPERR_DOMAIN);
|
||||
}
|
||||
# else
|
||||
{
|
||||
struct sockaddr_in *s=__do_ypbind(DomainName);
|
||||
if (!s) return(YPERR_DOMAIN);
|
||||
ServerAddress=*s;
|
||||
}
|
||||
# endif
|
||||
# else
|
||||
bzero(&ServerAddress, sizeof ServerAddress);
|
||||
ServerAddress.sin_family=AF_INET;
|
||||
ServerAddress.sin_addr.s_addr=htonl(SOCKSERVER);
|
||||
# endif SOCKSERVER
|
||||
return (_yp_bind(&ServerAddress, DomainName));
|
||||
}
|
||||
|
||||
int
|
||||
__yp_all( char *DomainName, char *MapName, struct ypall_callback *CallBack)
|
||||
{
|
||||
static ypreq_nokey req;
|
||||
ypresp_all *resp;
|
||||
extern struct ypall_callback *xdr_ypall_callback;
|
||||
int Status;
|
||||
|
||||
do {
|
||||
if (TcpClient==NULL)
|
||||
if ((Status=__yp_bind(DomainName))) return(Status);
|
||||
|
||||
req.domain=DomainName;
|
||||
req.map=MapName;
|
||||
xdr_ypall_callback=CallBack;
|
||||
if ((resp=ypproc_all_2(&req, TcpClient))==NULL) {
|
||||
clnt_perror(TcpClient, "ypall");
|
||||
__yp_unbind(DomainName);
|
||||
}
|
||||
} while(resp==NULL);
|
||||
switch (resp->ypresp_all_u.val.stat) {
|
||||
case YP_TRUE:
|
||||
case YP_NOMORE:
|
||||
Status=0;
|
||||
break;
|
||||
default:
|
||||
Status=ypprot_err(resp->ypresp_all_u.val.stat);
|
||||
}
|
||||
clnt_freeres(TcpClient, xdr_ypresp_all, resp);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
int
|
||||
_yp_clear(char *DomainName)
|
||||
{
|
||||
void *resp;
|
||||
int Status;
|
||||
|
||||
do {
|
||||
if (UdpClient==NULL)
|
||||
if ((Status=yp_bind(DomainName))) return(Status);
|
||||
if ((resp=ypproc_clear_2(NULL, UdpClient))==NULL) {
|
||||
clnt_perror(UdpClient, "_yp_clear");
|
||||
__yp_unbind(DomainName);
|
||||
}
|
||||
} while(resp==NULL);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,199 +0,0 @@
|
||||
.\" Copyright (c) 1991, 1993, 1995
|
||||
.\" The Regents of the University of California. 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 the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" 4. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: ypxfr.8,v 1.2 1995/03/30 04:14:45 wpaul Exp $
|
||||
.\"
|
||||
.Dd February 5, 1995
|
||||
.Dt YPXFR 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm ypxfr
|
||||
.Nd "transfer NIS database from remote server to local host"
|
||||
.Sh SYNOPSIS
|
||||
.Nm ypxfr
|
||||
.Op Fl f
|
||||
.Op Fl c
|
||||
.Op Fl d Ar target domain
|
||||
.Op Fl h Ar source host
|
||||
.Op Fl s Ar source domain
|
||||
.Op Fl C Ar taskid program-number ipaddr port
|
||||
.Ar mapname
|
||||
.Sh DESCRIPTION
|
||||
.Nm ypxfr
|
||||
copies an NIS database (or
|
||||
.Pa map )
|
||||
from one NIS server to another using NIS services. In FreeBSD,
|
||||
.Nm ypxfr
|
||||
is generally invoked by
|
||||
.Xr ypserv 8
|
||||
when it receives a map transfer request from
|
||||
.Xr yppush 8 .
|
||||
.Nm ypxfr
|
||||
is used primarily in environments where several NIS servers
|
||||
are in use in a single domain. One server, the NIS master, maintains
|
||||
the canonical copies of all NIS maps, and all the other servers,
|
||||
the NIS slaves, copy new versions of the maps from the master whenever
|
||||
any updates are made (i.e. when a user updates their password via
|
||||
.Xr yppasswd 1
|
||||
).
|
||||
.Pp
|
||||
When run,
|
||||
.Nm ypxfr
|
||||
creates a temporary database file in
|
||||
.Pa /var/yp/[domainmame] ,
|
||||
and fills it with the contents of
|
||||
.Ar mapname
|
||||
as supplied by the specified
|
||||
.Ar source host .
|
||||
When the entire map has been transfered,
|
||||
.Nm ypxfr
|
||||
deletes the original copy of
|
||||
.Ar mapname
|
||||
and moves the temporary copy into its place. When the transfer is
|
||||
complete,
|
||||
.Nm ypxfr
|
||||
will attempt to send a 'clear current map' request to the local
|
||||
.Xr ypserv 8
|
||||
process to clear any possible references it may still have to the
|
||||
stale map.
|
||||
.Pp
|
||||
Note that all files created by
|
||||
.Nm ypxfr
|
||||
are owner readable and writable only for security reasons. Since the
|
||||
NIS maps and the directory in which they reside are normally owned by
|
||||
root, this prevents non-privleged users from making unauthorized
|
||||
modifications.
|
||||
.Pp
|
||||
In order to maintain consistency across all NIS servers,
|
||||
.Nm ypxfr
|
||||
can be run periodically in a
|
||||
.Xr cron 8
|
||||
job. Maps which change infrequently
|
||||
need only be updated once a day (preferably late at night when system
|
||||
usage is lowest), whereas those that are subject to frequent changes
|
||||
(such a
|
||||
.Pa passwd.byname
|
||||
and
|
||||
.Pa passwd.byuid )
|
||||
should be updated perhaps once every hour. Using
|
||||
.Xr cron 8
|
||||
to automatically
|
||||
update the NIS maps is not strictly mandatory since all updates should
|
||||
be propagated by
|
||||
.Xr yppush 8
|
||||
when
|
||||
.Pa /var/yp/Makefile
|
||||
is run on the NIS master server, however it is good practice
|
||||
on large networks where possible outages could cause NIS servers to
|
||||
fall out of sync with each other.
|
||||
.Pp
|
||||
When
|
||||
.Nm ypxfr
|
||||
is invoked without a controlling terminal, e.g. from inside
|
||||
.Xr ypserv 8 ,
|
||||
it logs all its output using the
|
||||
.Xr syslog 3
|
||||
facility.
|
||||
.Sh OPTIONS
|
||||
The following options and flags are supported by
|
||||
.Nm ypxfr :
|
||||
.Bl -tag -width flag
|
||||
.It Fl f
|
||||
Force a map transfer. Normally,
|
||||
.Nm ypxfr
|
||||
will not transfer a map if it determines that the NIS master's copy
|
||||
is not newer than the existing copy already on the local host: the
|
||||
.Fl f
|
||||
flag forces a transfer regardless of which server's version is more recent.
|
||||
.It Fl c
|
||||
Do not send a 'clear current map' request to the
|
||||
.Xr ypserv 8
|
||||
process running on the local host. This flag is normally used when
|
||||
invoking
|
||||
.Nm ypxfr
|
||||
manually on a machine that is not yet running
|
||||
.Xr ypserv 8 .
|
||||
Without this flag, failure to contact the local NIS server will cause
|
||||
.Nm ypxfr
|
||||
to abort the transfer.
|
||||
.It Fl d Ar target domain
|
||||
Specify a target domain other than the current NIS domain.
|
||||
.It Fl h Ar source host
|
||||
Specify the name of the host from which to copy the NIS maps. This option
|
||||
is used to insure that
|
||||
.Nm ypxfr
|
||||
only copies maps from the NIS master server.
|
||||
.It Fl s Ar source domain
|
||||
Specify the domain from which to transfer a map, in the event that
|
||||
the transfer is being done across two different NIS domains.
|
||||
.It Fl C Ar taskid program-number ipaddr port
|
||||
These options are used only when
|
||||
.Nm ypxfr
|
||||
is invoked by
|
||||
.Xr ypserv 8
|
||||
in response to a map transfer request initiated by
|
||||
.Xr yppush 8 .
|
||||
In this instance,
|
||||
.Nm ypxfr
|
||||
needs to 'callback' to the
|
||||
.Xr yppush 8
|
||||
process and interact with it, so
|
||||
.Xr yppush 8
|
||||
passes to it an IP address
|
||||
.Ar ipaddr ,
|
||||
port number
|
||||
.Ar port ,
|
||||
registered program number
|
||||
.Ar program-number
|
||||
and a transaction ID
|
||||
.Ar taskid
|
||||
that it can use to contact the waiting
|
||||
.Xr yppush 8
|
||||
process on the master server.
|
||||
.It Ar mapname
|
||||
The name of the map to transfer.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width Pa -compact
|
||||
.It Pa /var/yp/[domainname]/[maps]
|
||||
The NIS maps for a particular NIS domain.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr ypserv 8 ,
|
||||
.Xr ypxfr 8 ,
|
||||
.Xr yp 8
|
||||
.Sh LICENSE
|
||||
This program is covered by the GNU Public License version 2.
|
||||
.Sh AUTHOR
|
||||
Tobias Reber (original Linux version)
|
||||
.br
|
||||
Bill Paul <wpaul@ctr.columbia.edu> (port to FreeBSD and various
|
||||
changes)
|
@ -1,379 +0,0 @@
|
||||
/*
|
||||
YPS-0.2, NIS-Server for Linux
|
||||
Copyright (C) 1994 Tobias Reber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Modified for use with FreeBSD 2.x by Bill Paul (wpaul@ctr.columbia.edu)
|
||||
|
||||
$Id: ypxfr.c,v 1.5 1995/03/31 05:45:23 wpaul Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <paths.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <db.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
DB *db;
|
||||
|
||||
#ifndef _PATH_YP
|
||||
#define _PATH_YP "/var/yp/"
|
||||
#endif
|
||||
|
||||
#define PERM_SECURE (S_IRUSR|S_IWUSR)
|
||||
HASHINFO openinfo = {
|
||||
4096, /* bsize */
|
||||
32, /* ffactor */
|
||||
256, /* nelem */
|
||||
2048 * 1024, /* cachesize */
|
||||
NULL, /* hash */
|
||||
0 /* lorder */
|
||||
};
|
||||
|
||||
#include <rpcsvc/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 DATUM /* Otherwise ypclnt.h redefines datum */
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
/*
|
||||
* These are hooks to the ypclnt library in ../lib
|
||||
*/
|
||||
extern int _yp_bind(struct sockaddr_in *, char *);
|
||||
extern int _yp_clear( char *);
|
||||
extern void Perror __P((const char *, ...));
|
||||
int logflag = 0;
|
||||
char *progname;
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
#include <netdb.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
static char *SourceHost=NULL, *TargetDomain=NULL, *SourceDomain=NULL;
|
||||
static struct in_addr IpAddress;
|
||||
static int Force=0, NoClear=0, TaskId=0, ProgramNumber=0,
|
||||
PortNumber=0;
|
||||
|
||||
static char *
|
||||
ypxfr_err_string(enum ypxfrstat y) {
|
||||
switch(y) {
|
||||
case YPXFR_SUCC: return "Success";
|
||||
case YPXFR_AGE: return "Master's version not newer";
|
||||
case YPXFR_NOMAP: return "Can't find server for map";
|
||||
case YPXFR_NODOM: return "Domain not supported";
|
||||
case YPXFR_RSRC: return "Local resource alloc failure";
|
||||
case YPXFR_RPC: return "RPC failure talking to server";
|
||||
case YPXFR_MADDR: return "Can't get master address";
|
||||
case YPXFR_YPERR: return "YP server/map db error";
|
||||
case YPXFR_BADARGS: return "Request arguments bad";
|
||||
case YPXFR_DBM: return "Local dbm operation failed";
|
||||
case YPXFR_FILE: return "Local file I/O operation failed";
|
||||
case YPXFR_SKEW: return "Map version skew during transfer";
|
||||
case YPXFR_CLEAR: return "Can't send \"Clear\" req to local ypserv";
|
||||
case YPXFR_FORCE: return "No local order number in map use -f flag.";
|
||||
case YPXFR_XFRERR: return "ypxfr error";
|
||||
case YPXFR_REFUSED: return "Transfer request refused by ypserv";
|
||||
}
|
||||
}
|
||||
|
||||
ypxfr_foreach(int status, char *key, int keylen, char *val, int vallen,
|
||||
int *data)
|
||||
{
|
||||
|
||||
DBT outKey, outData;
|
||||
|
||||
if (status==YP_NOMORE)
|
||||
return 0;
|
||||
if (status!=YP_TRUE) {
|
||||
int s=ypprot_err(status);
|
||||
Perror("%s\n",yperr_string(s));
|
||||
return 1;
|
||||
}
|
||||
|
||||
outKey.data=key; outKey.size=(size_t)keylen;
|
||||
outData.data=val; outData.size=(size_t)vallen;
|
||||
(db->put)(db,&outKey,&outData,0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum ypxfrstat
|
||||
ypxfr(char *mapName) {
|
||||
|
||||
int localOrderNum=0;
|
||||
int masterOrderNum=0;
|
||||
char *masterName;
|
||||
struct sockaddr_in localHost;
|
||||
struct sockaddr_in masterHost;
|
||||
struct ypall_callback callback;
|
||||
char dbName[1024];
|
||||
char dbName2[1024];
|
||||
int y, masterSock;
|
||||
CLIENT *masterClient;
|
||||
|
||||
memset(&localHost, '\0', sizeof localHost);
|
||||
localHost.sin_family=AF_INET;
|
||||
localHost.sin_addr.s_addr=htonl(INADDR_LOOPBACK);
|
||||
|
||||
|
||||
if (!SourceHost) {
|
||||
if ((y=yp_master(SourceDomain, mapName, &masterName)))
|
||||
return YPXFR_MADDR;
|
||||
SourceHost=masterName;
|
||||
}
|
||||
|
||||
memset(&masterHost, '\0', sizeof masterHost);
|
||||
masterHost.sin_family=AF_INET;
|
||||
{
|
||||
struct hostent *h=gethostbyname(SourceHost);
|
||||
if (!h) {
|
||||
return YPXFR_MADDR;
|
||||
}
|
||||
memcpy(&masterHost.sin_addr, h->h_addr,
|
||||
sizeof masterHost.sin_addr);
|
||||
}
|
||||
|
||||
if ((y=_yp_bind(&masterHost, SourceDomain))) return YPXFR_RPC;
|
||||
|
||||
masterSock=RPC_ANYSOCK;
|
||||
masterClient=clnttcp_create(&masterHost, YPPROG, YPVERS, &masterSock, 0, 0);
|
||||
if (masterClient==NULL) {
|
||||
clnt_pcreateerror("");
|
||||
return YPXFR_RPC;
|
||||
}
|
||||
{
|
||||
static struct timeval tv = { 25, 0 };
|
||||
struct ypreq_nokey req;
|
||||
struct ypresp_order resp;
|
||||
int y;
|
||||
|
||||
req.domain=SourceDomain;
|
||||
req.map=mapName;
|
||||
y=clnt_call(masterClient, YPPROC_ORDER, xdr_ypreq_nokey,
|
||||
&req, xdr_ypresp_order, &resp, tv);
|
||||
if (y!=RPC_SUCCESS) {
|
||||
clnt_perror(masterClient, "masterOrderNum");
|
||||
masterOrderNum=0x7fffffff;
|
||||
} else {
|
||||
masterOrderNum=resp.ordernum;
|
||||
}
|
||||
xdr_free(xdr_ypresp_order, (char *)&resp);
|
||||
}
|
||||
|
||||
if (!Force) {
|
||||
DBT inKey, inVal;
|
||||
sprintf(dbName, "%s%s/%s", _PATH_YP, TargetDomain, mapName);
|
||||
if ((db = dbopen(dbName,O_RDWR|O_EXCL, PERM_SECURE,
|
||||
DB_HASH, &openinfo)) == NULL) {
|
||||
Perror("dbopen: %s\n", strerror(errno));
|
||||
Perror("%s: cannot open - ignored.\n", dbName);
|
||||
localOrderNum=0;
|
||||
} else {
|
||||
inKey.data="YP_LAST_MODIFIED"; inKey.size=strlen(inKey.data);
|
||||
(db->get)(db,&inKey,&inVal,0);
|
||||
if (inVal.data) {
|
||||
int i;
|
||||
char *d=inVal.data;
|
||||
for (i=0; i<inVal.size; i++, d++) {
|
||||
if (!isdigit(*d)) {
|
||||
(void)(db->close)(db);
|
||||
return YPXFR_SKEW;
|
||||
}
|
||||
}
|
||||
localOrderNum=atoi(inVal.data);
|
||||
}
|
||||
(void)(db->close)(db);
|
||||
}
|
||||
if (localOrderNum>=masterOrderNum) return YPXFR_AGE;
|
||||
}
|
||||
|
||||
sprintf(dbName, "%s%s/%s~", _PATH_YP, TargetDomain, mapName);
|
||||
if ((db = dbopen(dbName,O_RDWR|O_EXCL|O_CREAT, PERM_SECURE, DB_HASH,
|
||||
&openinfo)) == NULL) {
|
||||
Perror("%s: Cannot open\n", dbName);
|
||||
return YPXFR_DBM;
|
||||
}
|
||||
|
||||
{
|
||||
DBT outKey, outData;
|
||||
char orderNum[12];
|
||||
outKey.data="YP_MASTER_NAME"; outKey.size=strlen(outKey.data);
|
||||
outData.data=SourceHost; outData.size=strlen(outData.data);
|
||||
(db->put)(db,&outKey,&outData,0);
|
||||
sprintf(orderNum, "%d", masterOrderNum);
|
||||
outKey.data="YP_LAST_MODIFIED"; outKey.size=strlen(outKey.data);
|
||||
outData.data=orderNum; outData.size=strlen(outData.data);
|
||||
(db->put)(db,&outKey,&outData,0);
|
||||
}
|
||||
|
||||
|
||||
callback.foreach = ypxfr_foreach;
|
||||
callback.data = NULL;
|
||||
|
||||
/*
|
||||
* We have to use our own private version of yp_all() here since
|
||||
* the yp_all() in libc doesn't allow us to specify the server that
|
||||
* we want to talk to: it's imperative that we transfer data from
|
||||
* the NIS master server and no one else.
|
||||
*/
|
||||
y=__yp_all(SourceDomain, mapName, &callback);
|
||||
|
||||
(void)(db->close)(db);
|
||||
sprintf(dbName, "%s%s/%s~", _PATH_YP, TargetDomain, mapName);
|
||||
sprintf(dbName2, "%s%s/%s", _PATH_YP, TargetDomain, mapName);
|
||||
unlink(dbName2);
|
||||
rename(dbName, dbName2);
|
||||
|
||||
if (!NoClear) {
|
||||
memset(&localHost, '\0', sizeof localHost);
|
||||
localHost.sin_family=AF_INET;
|
||||
localHost.sin_addr.s_addr=htonl(INADDR_LOOPBACK);
|
||||
if (_yp_bind(&localHost, TargetDomain) ||
|
||||
_yp_clear(TargetDomain)) return YPXFR_CLEAR;
|
||||
}
|
||||
return y==0?YPXFR_SUCC:YPXFR_YPERR;
|
||||
}
|
||||
|
||||
void usage(progname)
|
||||
char *progname;
|
||||
{
|
||||
fprintf(stderr,"usage: %s [-f] [-c] [-d target domain] \
|
||||
[-h source host]\n [-s source domain] \
|
||||
[-C taskid program-number ipaddr port] mapname\n", progname);
|
||||
}
|
||||
|
||||
void
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
if (!isatty(2)) {
|
||||
openlog(argv[0], LOG_PID, LOG_DAEMON);
|
||||
logflag = 1;
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while(1) {
|
||||
int c=getopt(argc, argv, "fcd:h:s:C:S");
|
||||
if (c==EOF) break;
|
||||
switch (c) {
|
||||
case 'f':
|
||||
Force++;
|
||||
break;
|
||||
case 'c':
|
||||
NoClear++;
|
||||
break;
|
||||
case 'd':
|
||||
TargetDomain=optarg;
|
||||
break;
|
||||
case 'h':
|
||||
SourceHost=optarg;
|
||||
break;
|
||||
case 's':
|
||||
SourceDomain=optarg;
|
||||
break;
|
||||
case 'C':
|
||||
TaskId=atoi(optarg);
|
||||
ProgramNumber=atoi(argv[optind++]);
|
||||
IpAddress.s_addr=inet_addr(argv[optind++]);
|
||||
PortNumber=atoi(argv[optind++]);
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
argc-=optind;
|
||||
argv+=optind;
|
||||
|
||||
if (!TargetDomain) {
|
||||
yp_get_default_domain(&TargetDomain);
|
||||
}
|
||||
if (!SourceDomain) {
|
||||
SourceDomain=TargetDomain;
|
||||
}
|
||||
|
||||
for (; *argv; argv++) {
|
||||
enum ypxfrstat y;
|
||||
if ((y=ypxfr(*argv))!=YPXFR_SUCC) {
|
||||
Perror("%s\n", ypxfr_err_string(y));
|
||||
}
|
||||
if (TaskId) {
|
||||
struct sockaddr_in addr;
|
||||
struct timeval wait;
|
||||
CLIENT *clnt;
|
||||
int s;
|
||||
ypresp_xfr resp;
|
||||
static struct timeval tv={0,0};
|
||||
|
||||
memset(&addr, '\0', sizeof addr);
|
||||
addr.sin_addr=IpAddress;
|
||||
addr.sin_port=htons(PortNumber);
|
||||
addr.sin_family=AF_INET;
|
||||
wait.tv_sec=25; wait.tv_usec=0;
|
||||
s=RPC_ANYSOCK;
|
||||
|
||||
clnt=clntudp_create(&addr, ProgramNumber, 1, wait, &s);
|
||||
if (!clnt) {
|
||||
clnt_pcreateerror("ypxfr_callback");
|
||||
continue;
|
||||
}
|
||||
|
||||
resp.transid=TaskId;
|
||||
resp.xfrstat=y;
|
||||
switch (clnt_call(clnt, 1, xdr_ypresp_xfr, &resp,
|
||||
xdr_void, NULL, tv)) {
|
||||
case RPC_SUCCESS:
|
||||
case RPC_TIMEDOUT:
|
||||
break;
|
||||
default:
|
||||
clnt_perror(clnt, "ypxfr_callback");
|
||||
}
|
||||
|
||||
clnt_destroy(clnt);
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user