ypxfr.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * CDDL HEADER START
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * The contents of this file are subject to the terms of the
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Common Development and Distribution License, Version 1.0 only
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * (the "License"). You may not use this file except in compliance
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * with the License.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * See the License for the specific language governing permissions
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * and limitations under the License.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * When distributing Covered Code, include this CDDL HEADER in each
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * If applicable, add the following below this CDDL HEADER, with the
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * fields enclosed by brackets "[]" replaced with your own identifying
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * information: Portions Copyright [yyyy] [name of copyright owner]
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * CDDL HEADER END
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Use is subject to license terms.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx/* All Rights Reserved */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Portions of this source code were derived from Berkeley
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * under license from the Regents of the University of
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * California.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#pragma ident "%Z%%M% %I% %E% SMI"
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This is a user command which gets a NIS data base from some running
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * server, and gets it to the local site by using the normal NIS client
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * enumeration functions. The map is copied to a temp name, then the real
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * map is removed and the temp map is moved to the real name. ypxfr then
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * sends a "YPPROC_CLEAR" message to the local server to insure that he will
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * not hold a removed map open, so serving an obsolete version.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * ypxfr [ -h <host> ] [ -d <domainname> ]
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * [ -s <domainname> ] [-f] [-c] [-C tid prot name] map
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * If the host is ommitted, ypxfr will attempt to discover the master by
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * using normal NIS services. If it can't get the record, it will use
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * the address of the callback, if specified. If the host is specified
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * as an internet address, no NIS services need to be locally available.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * If the domain is not specified, the default domain of the local machine
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * is used.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * If the -f flag is used, the transfer will be done even if the master's
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * copy is not newer than the local copy.
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China * The -c flag suppresses the YPPROC_CLEAR request to the local ypserv. It
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * may be used if ypserv isn't currently running to suppress the error message.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * The -C flag is used to pass callback information to ypxfr when it is
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * activated by ypserv. The callback information is used to send a
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * yppushresp_xfr message with transaction id "tid" to a yppush process
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * speaking a transient protocol number "prot". The yppush program is
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * running on the host "name".
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * The -s option is used to specify a source domain which may be
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * different from the destination domain, for transfer of maps
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * that are identical in different domains (e.g. services.byname)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China#include <ctype.h>
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#define PARANOID 1 /* make sure maps have the right # entries */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#define CALLINTER_TRY 10 /* Seconds between callback tries */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#define CALLTIMEOUT CALLINTER_TRY*6 /* Total timeout for callback */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx/* ypxfr never uses N2L mode */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * The name of the xfer peer as specified as a
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * -h option, -C name option or from querying the NIS
c533a883a71cff9ff32df1c53c31201e1cbf371fhxunsigned int master_prog_vers; /* YPVERS (barfs at YPOLDVERS !) */
c533a883a71cff9ff32df1c53c31201e1cbf371fhxchar *master_name = NULL; /* Map's master as contained in the map */
c533a883a71cff9ff32df1c53c31201e1cbf371fhxunsigned *master_version = NULL; /* Order number as contained in the map */
c533a883a71cff9ff32df1c53c31201e1cbf371fhxchar *master_ascii_version; /* ASCII order number as contained in the map */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * TRUE only if there's no order number in
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * the map, and the user specified -f
c533a883a71cff9ff32df1c53c31201e1cbf371fhxbool logging = FALSE; /* TRUE iff no tty, but log file exists */
c533a883a71cff9ff32df1c53c31201e1cbf371fhxbool check_count = FALSE; /* TRUE causes counts to be checked */
c533a883a71cff9ff32df1c53c31201e1cbf371fhxbool send_clear = TRUE; /* FALSE iff user specified -c flag */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * TRUE iff -C flag set. tid, proto and name
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * will be set to point to the command line args.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxbool secure_map = FALSE; /* TRUE if there is yp_secure in the map */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * TRUE if there is yp_interdomain in either
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * the local or the master version of the map
c533a883a71cff9ff32df1c53c31201e1cbf371fhxint interdomain_sz = 0; /* Size of the interdomain value */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#define UDPINTER_TRY 10 /* Seconds between tries for udp */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#define UDPTIMEOUT UDPINTER_TRY*4 /* Total timeout for udp */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#define CALLINTER_TRY 10 /* Seconds between callback tries */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#define CALLTIMEOUT CALLINTER_TRY*6 /* Total timeout for callback */
c533a883a71cff9ff32df1c53c31201e1cbf371fhxstruct timeval tcp_timeout = { 180, 0}; /* Timeout for map enumeration */
c533a883a71cff9ff32df1c53c31201e1cbf371fhxchar *interdomain_value; /* place to store the interdomain value */
c533a883a71cff9ff32df1c53c31201e1cbf371fhxstatic char err_usage[] =
c533a883a71cff9ff32df1c53c31201e1cbf371fhxypxfr [-f] [ -h host ] [ -d domainname ]\n\
c533a883a71cff9ff32df1c53c31201e1cbf371fhx [ -s domainname ] [-c] [-C tid prot servname ] map\n\n\
c533a883a71cff9ff32df1c53c31201e1cbf371fhx -f forces transfer even if the master's copy is not newer.\n\
c533a883a71cff9ff32df1c53c31201e1cbf371fhx host is the server from where the map should be transfered\n\
c533a883a71cff9ff32df1c53c31201e1cbf371fhx -d domainname is specified if other than the default domain\n\
c533a883a71cff9ff32df1c53c31201e1cbf371fhx -s domainname is a source for the map that is same across domains\n\
c533a883a71cff9ff32df1c53c31201e1cbf371fhx -c inhibits sending a \"Clear map\" message to the local ypserv.\n\
c533a883a71cff9ff32df1c53c31201e1cbf371fhx -C is for use only by ypserv to pass callback information.\n";
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "%s argument is bad.\n";
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Can't get %s back from system call.\n";
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "%s hasn't been set on this machine.\n";
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Can't set up a udp connection to ypserv on host %s.\n";
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing Chinaextern int errno;
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China * This is the mainline for the ypxfr process.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Inter-process lock synchronization structure. Since slave servers
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * get their maps from another NIS server rather than LDAP they can
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * never run in N2L mode. We thus do not have to init the update
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * locking mechanism.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * if we were unable to get the master name, either from
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * the -h option or from -C "name" option or from NIS,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * we are doomed !
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (!get_private_recs(&status)) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China xfr_exit(status);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (!master_version) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China master_version = &big;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China fake_master_version = TRUE;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China"Can't get order number for map %s from server at %s: use the -f flag.\n",
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China map, master);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China xfr_exit(YPPUSH_FORCE);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (!move_map(&status)) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China xfr_exit(status);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (send_clear && !send_ypclear(&status)) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China xfr_exit(status);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (logging) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China logprintf("Transferred map %s from %s (%d entries).\n",
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China map, master, entry_count);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China xfr_exit(YPPUSH_SUCC);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China /* NOTREACHED */
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China * This decides whether we're being run interactively or not, and, if not,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * whether we're supposed to be logging or not. If we are logging, it sets
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * up stderr to point to the log file, and sets the "logging"
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * variable. If there's no logging, the output goes in the bit bucket.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Logging output differs from interactive output in the presence of a
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * timestamp, present only in the log file. stderr is reset, too, because it
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * it's used by various library functions, including clnt_perror.
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (!isatty(1)) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This constructs a logging record.
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing Chinalogprintf(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
6f12def440a1ce798ab128210a43414d173669f0pengcheng chen - Sun Microsystems - Beijing China/*VARARGS*/
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China struct timeval t;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx (void) fprintf(stderr, (char *)arg1, arg2, arg3, arg4, arg5,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This does the command line argument processing.
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China logprintf(err_usage);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx while (--argc) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx case 'f': {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx case 'D': {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx case 'T': {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx case 'P': {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx case 'W': {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx case 'c': {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx case 'h': {
09539a3c2da6fef054f5306232ef0480de261eabpengcheng chen - Sun Microsystems - Beijing China xfr_exit(YPPUSH_BADARGS);
09539a3c2da6fef054f5306232ef0480de261eabpengcheng chen - Sun Microsystems - Beijing China argc -= 3;
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China logprintf(err_usage);
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China xfr_exit(YPPUSH_BADARGS);
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China case 'b': {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx default: {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This tries to get the master name for the named map, from any
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * server's version, using the vanilla NIS client interface. If we get a
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * name back, the global "master" gets pointed to it.
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (err = __yp_master_rsvdport(source, map, &master)) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China logprintf("Can't get master of %s. Reason: %s.\n", map,
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China yperr_string(err));
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China yp_unbind(source);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China#ifdef TREEPUSH
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing Chinachk_treepush(name)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China char inmap[256];
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China char inkey[256];
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China int inkeylen;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China char *outval;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China int outvallen;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China outval = NULL;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China inkey[0] = 0;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China strcpy(inmap, "ypslaves.");
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China strcat(inmap, name);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China inkeylen = strlen(inkey);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China err = yp_match(source, inmap, inkey, inkeylen, &outval, &outvallen);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return (err);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China * This sets up a udp connection to speak the correct program and version
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China * to a NIS server. vers is set to YPVERS, doesn't give a damn about
c533a883a71cff9ff32df1c53c31201e1cbf371fhx unsigned int *vers;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This sets up a UDP channel to a server which is assumed to speak an input
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China * version of YPPROG. The channel is tested by pinging the server. In all
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China * error cases except "Program Version Number Mismatch", the error is
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * reported, and in all error cases, the client handle is destroyed and the
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * socket associated with the channel is closed.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx unsigned int vers;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if ((pdomb->dom_client = __yp_clnt_create_rsvdport(host, YPPROG, vers,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx 0, 0, 0)) != 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * if we are on a c2 system, we should only accept data
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * from a server which is on a reserved port.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * NUKE this for 5.0DR.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * if (issecure() &&
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * (pdomb->dom_server_addr.sin_family != AF_INET ||
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * pdomb->dom_server_addr.sin_port >= IPPORT_RESERVED)) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * clnt_destroy(pdomb->dom_client);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * close(pdomb->dom_socket);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * (void) logprintf("bind_to_server: \
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * server is not using a privileged port\n");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * *status = YPPUSH_YPERR;
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China * return (FALSE);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "ypxfr: bind_to_server clnt_call error");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This gets values for the YP_LAST_MODIFIED and YP_MASTER_NAME keys from the
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * master server's version of the map. Values are held in static variables
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * here. In the success cases, global pointer variables are set to point at
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * the local statics.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx static unsigned number;
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if (get_order(anumber, &number, &status)) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China master_version = &number;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China if (status != 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "ypxfr: Couldn't get map's master version number, \
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China return (FALSE);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (get_master_name(name, &status)) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (status != 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "ypxfr: Couldn't get map's master name, status was %d\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "ypxfr: Getting private records from master.\n");
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China if (get_misc_recs(&status)) {
43439c96b8398c01c375889c79bed72d78fb4c39hx "ypxfr: Masters map %s secure and %s an interdomain map.\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (status != 0) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China "ypxfr: Couldn't get state of secure and interdomain flags in map.\n");
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return (FALSE);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This gets the map's order number from the master server
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing Chinaget_order(an, n, pushstat)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China int *pushstat;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return (FALSE);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing Chinaget_v2order(an, n, pushstat)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx unsigned *n;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Get the map''s order number, null-terminate it and store it,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * and convert it to binary and store it again.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "(info) Can't get order number from ypserv at %s. Reason: %s.\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx (char *)&resp);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx logprintf("ypxfr(get_v2order) RPC call to %s failed", master);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Pick up the state of the YP_SECURE and YP_INTERDOMAIN records from the
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * master. Only works on 4.0 V2 masters that will match a YP_ private key
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * when asked to explicitly.
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China req.keydat.dptr = yp_secure;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China req.keydat.dsize = yp_secure_sz;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China resp.valdat.dptr = NULL;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Get the value of the IS_SECURE key in the map.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx fprintf(stderr, "ypxfr: Checking masters secure key.\n");
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China fprintf(stderr, "ypxfr: SECURE\n");
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China secure_map = TRUE;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China retval = TRUE;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China } else if ((resp.status != YP_NOKEY) &&
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China (resp.status != YP_VERS) &&
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "(info) Can't get secure flag from ypserv at %s. Reason: %s.\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx (char *)&resp);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx logprintf("ypxfr(get_misc_recs) RPC call to %s failed", master);
d62cb7fff63265824a8e6725a3bcef698f6134c9hx fprintf(stderr, "ypxfr: Checking masters INTERDOMAIN key.\n");
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China resp.valdat.dptr = NULL;
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China resp.valdat.dsize = 0;
d62cb7fff63265824a8e6725a3bcef698f6134c9hx * Get the value of the INTERDOMAIN key in the map.
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China fprintf(stderr, "ypxfr: INTERDOMAIN\n");
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China interdomain_map = TRUE;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China interdomain_value = (char *)malloc(resp.valdat.dsize+1);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China (void) memmove(interdomain_value, resp.valdat.dptr,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "(info) Can't get interdomain flag from ypserv at %s. Reason: %s.\n",
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China CLNT_FREERES(master_server.dom_client,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx (char *)&resp);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx logprintf("ypxfr(get_misc_recs) RPC call to %s failed", master);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return (retval);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China * This gets the map's master name from the master server
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China struct ypreq_nokey req;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China struct ypresp_master resp;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China int retval;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China req.domain = source;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China req.map = map;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China resp.master = NULL;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China retval = FALSE;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China if ((enum clnt_stat) clnt_call(master_server.dom_client,
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China YPPROC_MASTER, (xdrproc_t)xdr_ypreq_nokey, (char *)&req,
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China (xdrproc_t)xdr_ypresp_master, (char *)&resp,
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China udp_timeout) == RPC_SUCCESS) {
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China if (resp.status == YP_TRUE) {
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China strcpy(name, resp.master);
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China retval = TRUE;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China } else if (resp.status != YP_BADDB) {
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China *pushstat = ypprot_err(resp.status);
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China if (!logging) {
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China logprintf(
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China"(info) Can't get master name from ypserv at %s. Reason: %s.\n",
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China master, yperr_string(
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China ypprot_err(resp.status)));
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China CLNT_FREERES(master_server.dom_client,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx (char *)&resp);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "ypxfr(get_v2master_name) RPC call to %s failed", master);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This does the work of transferring the map.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx unsigned n;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "ypxfr: Local version of map '%s' is %d\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Map %s at %s is not more recent than local.\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if ((hgstatus = ypxfrd_getdbm(tmp_name, master, source, map)) < 0)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx"(info) %s %s %s ypxfrd getdbm failed (reason = %d) -- using ypxfr\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx db = dbm_open(tmp_name, O_RDWR + O_CREAT + O_TRUNC, 0644);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Decide whether the map just transferred is a secure map.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * If we already know the local version was secure, we do not
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * need to check this version.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Can't do dbm close operation on temp map %s.\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (n != *master_version) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Version skew at %s while transferring map %s.\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /* touch up the map */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Decide whether the map just transferred is a secure map.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * If we already know the local version was secure, we do not
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * need to check this version.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Can't do dbm close operation on temp map %s.\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Rename error: couldn't mv %s to %s.\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Rename error: check that old %s is still intact.\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Rename error: check that old %s is still intact.\n",
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China if (unlock_map(map_name) == 0)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This tries to get the order number out of the local version of the map.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * If the attempt fails for any version, the function will return "0"
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return (0);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "ypxfr: Map does exist, checking version now.\n");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return (0);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return (0);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return (0);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /* Now save this value while we have it available */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Now check to see if it is 'secure'. If we haven't already
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * determined that it is secure in get_private_recs() then we check
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * the local map here.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Now check to see if interdomain requests are made of the local
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * map. Keep the value around if they are.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This constructs a file name for a map, minus its dbm_dir
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * or dbm_pag extensions
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /* Work out if we are in yptol mode */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx len = strlen(domain) + strlen(map) + strlen(ypdbpath) + 3;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China if (len > (MAXNAMLEN + 1)) {
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China (void) strcat(ppath, "/");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This returns a temporary name for a map transfer minus its dbm_dir or
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * dbm_pag extensions.
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China (void) strcat(xfr_name, map);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This deletes the .pag and .dir files which implement a map.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Note: No error checking is done here for a garbage input file name or for
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * failed unlink operations.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This creates <pname>.dir and <pname>.pag
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China (void) strcpy(dbfile, pname);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if ((f = open(dbfile, (O_WRONLY | O_CREAT | O_TRUNC), 0600)) >= 0) {
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China (void) close(f);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China (void) strcpy(dbfile, pname);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx 0600)) >= 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx (void) close(f);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China int status;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Error from ypserv on %s (ypall_callback) = %s.\n",
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China * This counts the entries in the dbm file after the transfer to
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * make sure that the dbm file was built correctly.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Returns TRUE if everything is OK, FALSE if they mismatch.
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China struct ypall_callback cbinfo;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China struct ypreq_nokey allreq;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#endif /* REALLY_PARANOID */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "*** Count mismatch in dbm file %s: old=%d, new=%d ***\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if ((domb.dom_client = __yp_clnt_create_rsvdport(master, YPPROG,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "tcp6", 0, 0)) == 0 &&
c533a883a71cff9ff32df1c53c31201e1cbf371fhx (domb.dom_client = __yp_clnt_create_rsvdport(master, YPPROG,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "tcp", 0, 0)) == 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "create failure");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx s = clnt_call(domb.dom_client, YPPROC_ALL, xdr_ypreq_nokey,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (tmpstat == 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "ypxfr (get_map/all) - RPC clnt_call (TCP) failure");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "*** Count mismatch after enumerate %s: old=%d, new=%d ***\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#endif /* REALLY_PARANOID */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This sets up a TCP connection to the master server, and either gets
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * ypall_callback to do all the work of writing it to the local dbm file
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * (if the ypserv is current version), or does it itself for an old ypserv.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int i, lastnetid = (sizeof (netid)/sizeof (netid[0])) - 1;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx svcaddr = (struct netbuf *)calloc(1, sizeof (struct netbuf));
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (i = 0; i <= lastnetid; i++) {
43439c96b8398c01c375889c79bed72d78fb4c39hx if (rpcb_getaddr(YPPROG, master_prog_vers, nconf, svcaddr,
43439c96b8398c01c375889c79bed72d78fb4c39hx if ((domb.dom_client = __nis_clnt_create(fd, nconf, 0, svcaddr,
43439c96b8398c01c375889c79bed72d78fb4c39hx "ypxfr (get_map) - TCP channel create failure");
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China s = clnt_call(domb.dom_client, YPPROC_ALL,
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China (xdrproc_t)xdr_ypreq_nokey,
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China (char *)&allreq, (xdrproc_t)xdr_ypall, (char *)&cbinfo,
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China tcp_timeout);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China if (tmpstat == 0) {
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China clnt_perror(domb.dom_client,
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China "ypxfr (get_map/all) - RPC clnt_call (TCP) failure");
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China *pushstat = YPPUSH_RPC;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China *pushstat = tmpstat;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China retval = FALSE; /* barf again at YPOLDVERS */
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China clnt_destroy(domb.dom_client);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China return (retval);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China * This sticks each key-value pair into the current map. It returns FALSE as
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China * long as it wants to keep getting called back, and TRUE on error conditions
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China * and "No more k-v pairs".
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing Chinaypall_callback(status, key, kl, val, vl, pushstat)
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China int status;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China char *key;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China char *val;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China int *pushstat;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China datum keydat;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China if (status != YP_TRUE) {
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China if (status != YP_NOMORE) {
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China logprintf(
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China "Error from ypserv on %s (ypall_callback) = %s.\n",
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China master, yperr_string(ypprot_err(status)));
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China *pushstat = map_yperr_to_pusherr(status);
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China return (TRUE);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China keydat.dptr = key;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China keydat.dsize = kl;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China valdat.dptr = val;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China valdat.dsize = vl;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China entry_count++;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China/* way too many fetches */
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China#ifdef PARANOID
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China test = dbm_fetch(db, keydat);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China if (test.dptr != NULL) {
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China logprintf("Duplicate key %s in map %s\n", key, map);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China *pushstat = YPPUSH_DBM;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China return (TRUE);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China#endif /* PARANOID */
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China "Can't do dbm store into temp map %s.\n", map);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China#ifdef PARANOID
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China test = dbm_fetch(db, keydat);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China if (test.dptr == NULL) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#endif /* PARANOID */
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China *pushstat = YPPUSH_DBM;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China return (TRUE);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This maps a YP_xxxx error code into a YPPUSH_xxxx error code
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing Chinamap_yperr_to_pusherr(yperr)
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China int yperr;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx switch (yperr) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China case YP_NOMAP:
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China reason = YPPUSH_NOMAP;
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China reason = YPPUSH_NODOM;
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China reason = YPPUSH_YPERR;
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China case YP_BADARGS:
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China reason = YPPUSH_BADARGS;
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China reason = YPPUSH_YPERR;
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China reason = YPPUSH_XFRERR;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China * This writes the last-modified and master entries into the new dbm file
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing Chinaadd_private_entries(pname)
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if (!fake_master_version) {
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China val.dsize = strlen(master_ascii_version);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if (dbm_store(db, key, val, 1) < 0) {
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China "Can't do dbm store into temp map %s.\n",
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if (master_name) {
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China key.dptr = yp_master_name;
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China key.dsize = yp_master_name_sz;
43439c96b8398c01c375889c79bed72d78fb4c39hx "Can't do dbm store into temp map %s.\n",
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Can't do dbm store into temp map %s.\n",
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China return (FALSE);
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China entry_count++;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China key.dsize = yp_secure_sz;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China val.dptr = yp_secure;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China val.dsize = yp_secure_sz;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China if (dbm_store(db, key, val, 1) < 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx "Can't do dbm store into temp map %s.\n",
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China entry_count++;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return (TRUE);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China * This sends a YPPROC_CLEAR message to the local ypserv process.
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing Chinasend_ypclear(pushstat)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China int *pushstat;
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China struct dom_binding domb;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China char local_host_name[256];
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China unsigned int progvers;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (gethostname(local_host_name, 256)) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China logprintf("Can't get local machine name.\n");
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China *pushstat = YPPUSH_RSRC;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return (FALSE);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (!bind_to_server(local_host_name, &domb,
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China &progvers, &status)) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China *pushstat = YPPUSH_CLEAR;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return (FALSE);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if ((enum clnt_stat) clnt_call(domb.dom_client,
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China logprintf(
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China "Can't send ypclear message to ypserv on the local machine.\n");
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China xfr_exit(YPPUSH_CLEAR);
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China return (TRUE);
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China * This decides if send_callback has to get called, and does the process exit.
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing Chinaxfr_exit(status)
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China int status;
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China if (callback) {
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China send_callback(&status);
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China if (status == YPPUSH_SUCC) {
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China#ifdef TREEPUSH
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China if (treepush) {
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China if (debug)
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China execlp("./yppush", "yppush", "-T", map, 0);
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China execlp("/usr/etc/yp/yppush", "yppush", "-T", map, 0);
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China perror("yppush");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This sets up a UDP connection to the yppush process which contacted our
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * parent ypserv, and sends him a status on the requested transfer.
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China resp.transid = (unsigned long) atoi(tid);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China resp.status = (unsigned long) *status;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if ((domb.dom_client = __yp_clnt_create_rsvdport(pushhost,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx 0, 0, 0)) == NULL) {
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if ((enum clnt_stat) clnt_call(domb.dom_client,
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China YPPUSHPROC_XFRRESP, (xdrproc_t)xdr_yppushresp_xfr,
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China (char *)&resp, xdr_void, 0,
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China udp_timeout) != RPC_SUCCESS) {
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China *status = YPPUSH_RPC;
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China * FUNCTION: is_yptol_mode();
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China * DESCRIPTION: Determines if we should run in N2L or traditional mode based
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China * on the presence of the N2L mapping file.
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China * This is a copy of a function from libnisdb. If more than this
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China * one function become required it may be worth linking the
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China * INPUTS: Nothing
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China * OUTPUTS: TRUE = Run in N2L mode
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China * FALSE = Run in traditional mode.
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China struct stat filestat;