/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* This contains YP server code which supplies the set of functions
* requested using rpc. The top level functions in this module
* are those which have symbols of the form YPPROC_xxxx defined in
* The latter exist to provide compatibility to the old version of the yp
* by invoking some other program.
*
* This module also contains functions which are used by (and only by) the
* top-level functions here.
*/
#include <dirent.h>
#include <limits.h>
#include <sys/systeminfo.h>
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include "ypsym.h"
#include "ypdefs.h"
#include <ctype.h>
/* Use shim version of DBM calls */
#include "shim.h"
#include "shim_hooks.h"
#ifndef YPXFR_PROC
#endif
#ifndef YPPUSH_PROC
#endif
struct yppriv_sym {
char *sym;
unsigned len;
};
/* For DNS forwarding */
extern bool dnsforward;
extern bool client_setup_failure;
extern int resolv_pid;
extern CLIENT *resolv_client;
extern char *resolv_tp;
/*
* This determines whether or not a passed domain is served by this
* server, and returns a boolean. Used by both old and new protocol
* versions.
*/
void
{
bool isserved;
(caddr_t)&pdomain_name)) {
return;
}
/*
* If the file /var/yp/securenets is present on the server, and if
* the hostname is present in the file, then let the client bind to
* the server.
*/
logprintf("Protocol incorrect\n");
return;
}
return;
}
if (isserved || always_respond) {
}
if (!isserved)
logprintf("Domain %s not supported\n",
} else {
/*
* This case is the one in which the domain is not
* supported, and in which we are not to respond in the
* unsupported case. We are going to make an error happen
* to allow the portmapper to end his wait without the
* normal timeout period. The assumption here is that
* the only process in the world which is using the function
* in its no-answer-if-nack form is the portmapper, which is
* doing the krock for pseudo-broadcast. If some poor fool
* calls this function as a single-cast message, the nack
* case will look like an incomprehensible error. Sigh...
* (The traditional Unix disclaimer)
*/
logprintf("Domain %s not supported (broadcast)\n",
}
}
/*
* This implements the yp "match" function.
*/
void
{
return;
}
/*
* sanity check the map name and to a DBM lookup
* also perform an access check...
*/
/* Check with the DBM database */
if (!silent)
printf("%s: dbm: %40.40s\n",
goto send_reply;
}
/*
* If we're being asked to match YP_SECURE or YP_INTERDOMAIN
* and we haven't found it in the dbm file, then we don't
* really want to waste any more time. Specifically, we don't
* want to ask DNS
*/
goto send_reply;
}
/* Let's try the YP_MULTI_ hack... */
#ifdef MINUS_C_OPTION
goto send_reply;
#else
goto send_reply;
#endif
/*
* Let's try DNS, but if client_setup_failure is set,
* we have tried DNS in the past and failed, there is
* no reason in forcing an infinite loop by turning
* off DNS in setup_resolv() only to turn it back on
* again here.
*/
if (!dnsforward && !client_setup_failure) {
dnsforward = TRUE;
}
if (dnsforward) {
if (!resolv_pid || !resolv_client) {
&resolv_client, resolv_tp, 0);
if (resolv_client == NULL)
}
goto free_args;
}
}
}
(char *)&req)) {
}
}
/*
* This implements the yp "get first" function.
*/
void
{
if (!svc_getargs(transp,
(char *)&req)) {
return;
}
}
if (!svc_sendreply(transp,
(char *)&resp)) {
}
(char *)&req)) {
}
}
/*
* This implements the yp "get next" function.
*/
void
{
return;
}
}
if (!svc_sendreply(transp,
(char *)&resp)) {
}
if (!svc_freeargs(transp,
(char *)&req)) {
}
}
/*
* This implements the "transfer map" function. It takes the domain
* and map names and the callback information provided by the
* requester (yppush on some node), and execs a ypxfr process to do
* the actual transfer.
*/
void
{
if (prog == YPPROC_NEWXFR) {
(char *)&newreq)) {
return;
}
#ifdef OPCOM_DEBUG
"\tmap_parms:\n"
"\t\tdomain: %s\n"
"\t\tmap: %s\n"
"\t\tordernum: %u\n"
"\t\towner: %s\n"
"\ttransid: %u\n"
"\tproto: %u\n"
"\tname: %s\n\n",
#endif
} else if (prog == YPPROC_XFR) {
if (!svc_getargs(transp,
(char *)&oldreq)) {
return;
}
#ifdef OPCOM_DEBUG
"\tmap_parms:\n"
"\t\tdomain: %s\n"
"\t\tmap: %s\n"
"\t\tordernum: %u\n"
"\t\towner: %s\n"
"\ttransid: %u\n"
"\tproto: %u\n"
"\tport: %u\n\n",
#endif
} else {
}
/* Check that the map exists and is accessible */
if (pid == -1) {
} else if (pid == 0) {
#ifdef OPCOM_DEBUG
"EXECL: %s, -d, %s, -C, %s, %s, %s, %s\n",
#endif
} else {
}
_exit(1);
}
} else {
}
}
if (prog == YPPROC_NEWXFR) {
if (!svc_freeargs(transp,
(char *)&newreq)) {
}
}
}
/*
* This implements the "get all" function.
*/
void
{
if (!svc_getargs(transp,
(char *)&req)) {
return;
}
if (pid) {
if (pid == -1) {
}
if (!svc_freeargs(transp,
(char *)&req)) {
}
return;
}
/*
* access control hack: If denied then invalidate the map name.
*/
}
/*
* This is the child process. The work gets done by xdrypserv_ypall/
* we must clear the "current map" first so that we do not
* share a seek pointer with the parent server.
*/
if (!svc_sendreply(transp,
(char *)&req)) {
}
if (!svc_freeargs(transp,
(char *)&req)) {
}
/*
* In yptol mode we may start a cache update thread within a child
* process. It is thus important that child processes do not exit,
* killing any such threads, before the thread has completed.
*/
if (yptol_mode) {
}
exit(0);
}
/*
* This implements the "get master name" function.
*/
void
{
if (!svc_getargs(transp,
(char *)&req)) {
return;
}
}
}
if (!svc_sendreply(transp,
(char *)&resp)) {
}
if (!svc_freeargs(transp,
(char *)&req)) {
}
}
/*
* This implements the "get order number" function.
*/
void
{
if (!svc_getargs(transp,
(char *)&req)) {
return;
}
}
}
if (!svc_sendreply(transp,
(char *)&resp)) {
}
if (!svc_freeargs(transp,
(char *)&req)) {
}
}
void
{
if (!svc_getargs(transp,
return;
}
if (!svc_sendreply(transp,
(char *)&maplist)) {
}
}
}
/*
* Ancillary functions used by the top-level functions within this
* module
*/
/*
* This returns TRUE if a given key is a yp-private symbol, otherwise
* FALSE
*/
static bool
{
return (FALSE);
}
return (TRUE);
}
/*
* This provides private-symbol filtration for the enumeration functions.
*/
static void
{
datum k;
if (inkey) {
*status = (unsigned)YP_BADARGS;
return;
}
} else {
k = dbm_firstkey(fdb);
}
k = dbm_nextkey(fdb);
}
return;
}
*outkey = k;
/*
* In N2L mode we must call a version of dbm_fetch() that either does
* or does not check for entry updates. In non N2L mode both of these
* will end up doing a normal dbm_fetch().
*/
if (update)
else
} else {
}
}
/*
* Serializes a stream of struct ypresp_key_val's. This is used
* only by the ypserv side of the transaction.
*/
static bool
{
return (FALSE);
}
return (FALSE);
}
}
}
return (FALSE);
}
return (FALSE);
}
return (FALSE);
}
return (TRUE);
}
/*
* Additions for sparc cluster support
*/
/*
* Check for special multihomed host cookie in the key. If there,
* collect the addresses from the comma separated list and return
* the one that's nearest the client.
*/
static int
{
/* default status is YP_NOKEY */
return (0);
} else {
/*
* Return whole line (for debugging) if YP_MULTI_hostnam
* is specified.
*/
return (1);
}
return (0);
/*
* This section handles multihomed IPv6 addresses.
* It returns all the IPv6 addresses one per line and only
* the requested hostname is returned. NO aliases will be
* returned. This is done exactly the same way DNS forwarding
* daemon handles multihomed hosts.
* New IPv6 enabled clients should be able to handle this
* information returned. The sorting is also the client's
* responsibility.
*/
return (0);
return (0);
}
return (0);
}
int bsize;
localbuf[0] = '\0';
while (cp) {
/* out of range */
break;
}
}
}
/* remove trailing newline */
}
return (1);
}
/*
* OK, now I have a netbuf structure which I'm supposed to
* treat as opaque... I hate transport independance!
* So, we're just gonna doit wrong... By wrong I mean that
* we assume that the buf part of the netbuf structure is going
* to be a sockaddr_in. We'll then check the assumed family
* member and hope that we find AF_INET in there... if not
* then we can't continue.
*/
return (0);
return (0);
return (0);
}
return (1);
}
/* V1 dispatch routines */
void
{
if (!svc_getargs(transp,
return;
}
}
if (dbmop_ok &&
!= NULL) &&
fdb))) {
/* Check with the DBM database */
if (!silent)
printf("%s: dbm: %s\n",
goto send_oldreply;
}
/*
* If we're being asked to match YP_SECURE or YP_INTERDOMAIN
* and we haven't found it in the dbm file, then we don't
* really want to waste any more time. Specifically, we don't
* want to ask DNS
*/
if (req.ypmatch_req_keysize == 0 ||
goto send_oldreply;
/* Let's try the YP_MULTI_ hack... */
#ifdef MINUS_C_OPTION
goto send_oldreply;
#else
goto send_oldreply;
#endif
/* Let's try DNS */
if (!dnsforward) {
dnsforward = TRUE;
}
if (dnsforward) {
if (!resolv_pid)
resolv_tp, 0);
}
return;
}
}
if (!svc_sendreply(transp,
}
if (!svc_freeargs(transp,
(char *)&req)) {
}
}
void
{
if (!svc_getargs(transp,
return;
}
}
if (dbmop_ok &&
!= NULL) &&
fdb)) {
} else {
}
} else {
}
}
if (!svc_sendreply(transp,
}
if (!svc_freeargs(transp,
}
}
void
{
if (!svc_getargs(transp,
return;
}
}
if (dbmop_ok &&
} else {
}
} else {
}
}
if (!svc_sendreply(transp,
}
if (!svc_freeargs(transp,
}
}
/*
* This retrieves the order number and master peer name from the map.
* The conditions for the various message fields are: domain is filled
* in iff the domain exists. map is filled in iff the map exists.
* order number is filled in iff it's in the map. owner is filled in
* iff the master peer is in the map.
*/
void
{
if (!svc_getargs(transp,
return;
}
/*
* Backward comatibility for 2.0 NIS servers
*/
} else {
switch ((int)error) {
case YP_BADDB:
/* Fall through to set the domain too. */
case YP_NOMAP:
break;
}
}
}
if (!svc_sendreply(transp,
}
if (!svc_freeargs(transp,
}
}
void
{
if (!svc_getargs(transp,
return;
}
}
if (pid == -1) {
} else if (pid == 0) {
}
_exit(1);
}
if (!svc_sendreply(transp,
}
if (!svc_freeargs(transp,
}
}
void
{
if (!svc_getargs(transp,
return;
}
}
if (pid == -1) {
} else if (pid == 0) {
}
_exit(1);
}
}
if (!svc_freeargs(transp,
}
}
void
{
if (!svc_getargs(transp,
return;
}
}
}
if (pid == -1) {
} else if (pid == 0) {
}
_exit(1);
}
}
if (!svc_freeargs(transp,
}
}
static int
{
return (0);
} else {
return (1);
}
return (0);
/*
* OK, now I have a netbuf structure which I'm supposed to treat
* as opaque... I hate transport independance! So, we're just
* gonna doit wrong... By wrong I mean that we assume that the
* buf part of the netbuf structure is going to be a sockaddr_in.
* We'll then check the assumed family member and hope that we
* find AF_INET in there... if not then we can't continue.
*/
return (0);
return (0);
return (0);
}
return (1);
}