nis_service.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
* This module contains the dispatch functions for the NIS+ service. At one
* time it was generated by rpcgen, however, due to the requirement that it
* be able to compile to a 4.1/sockets version or a 5.0/tli version and the
* desire to collect statistics about the time spent in the service functions,
* it is now "real" source. Changes to the .x file will have to be reconciled
* with this file.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h> /* getenv, exit */
#include <syslog.h>
#include <signal.h>
#include <memory.h>
#include <stropts.h>
#include <netconfig.h>
#include <string.h>
#include <netdir.h>
#include "nis_proc.h"
#include "nis_svc.h"
#include <nisdb_mt.h>
#include <ldap_util.h>
extern int _rpcpmstart; /* Started by a port monitor ? */
extern int _rpcfdtype; /* Whether Stream or Datagram ? */
extern int _rpcsvcdirty; /* Still serving ? */
/*
* Private object name checking and printing functions for NIS+
*/
#define NIS_SVCARG_NOCHECK 0x00000000
#define NIS_SVCARG_NULLPTR 0x00000001
#define NIS_SVCARG_EMPTYSTRING 0x00000002
#define NIS_SVCARG_TRAILINGDOT 0x00000004
#define NIS_SVCARG_MAXLEN 0x00000008
#define NIS_SVCARG_ROOTOBJECT 0x00000010
/*
* NIS_SVCARG_ROOTOBJECT is not included in the CHECKALL set (below) as
* in effect it is in reverse sense to the TRAILINGDOT check.
* In addition, we only want to check for the ROOTOBJECT in a few
* particular cases.
*/
#define NIS_SVCARG_CHECKALL (NIS_SVCARG_NULLPTR | \
/*
* NIS Version 2 (YP) Dispatch table
*/
extern int *ypproc_domain_svc();
extern int *ypproc_domain_nonack_svc();
extern struct ypresp_master *ypproc_master_svc();
extern struct ypresp_val *ypproc_match_svc();
extern struct ypresp_key_val *ypproc_first_svc();
extern struct ypresp_key_val *ypproc_next_svc();
extern struct ypresp_all *ypproc_all_svc();
extern struct ypresp_maplist *ypproc_maplist_svc();
extern bool xdr_ypresp_all();
void
{
union {
struct ypreq_key ypproc_match_svc_arg;
struct ypreq_nokey ypproc_first_svc_arg;
struct ypreq_key ypproc_next_svc_arg;
struct ypreq_nokey ypproc_all_svc_arg;
struct ypreq_nokey ypproc_master_svc_arg;
} argument;
char *result;
bool (*xdr_argument)(), (*xdr_result)();
char *(*local)();
_rpcsvcdirty = 1;
case NULLPROC:
_rpcsvcdirty = 0;
return;
case YPPROC_DOMAIN:
xdr_result = (bool (*)()) xdr_bool;
local = (char *(*)()) ypproc_domain_svc;
break;
case YPPROC_DOMAIN_NONACK:
xdr_result = (bool (*)()) xdr_bool;
local = (char *(*)()) ypproc_domain_nonack_svc;
break;
case YPPROC_MATCH:
local = (char *(*)()) ypproc_match_svc;
break;
case YPPROC_FIRST:
local = (char *(*)()) ypproc_first_svc;
break;
case YPPROC_NEXT:
local = (char *(*)()) ypproc_next_svc;
break;
case YPPROC_ALL:
local = (char *(*)()) ypproc_all_svc;
break;
case YPPROC_MASTER:
local = (char *(*)()) ypproc_master_svc;
break;
case YPPROC_MAPLIST:
local = (char *(*)()) ypproc_maplist_svc;
break;
default:
_rpcsvcdirty = 0;
return;
}
_rpcsvcdirty = 0;
return;
}
result)) {
}
exit(1);
}
_rpcsvcdirty = 0;
}
static void
start_stat(p)
ulong_t p;
{
if ((p > 0) && (p < 24)) {
nisopstats[p].calls++;
__start_clock(7);
}
}
static void
stop_stat(p, e)
ulong_t p;
int e;
{
if ((p > 0) && (p < 24)) {
os = &(nisopstats[p]);
if (e)
}
}
/*
* NIS Version 3 (NIS+) dispatch function.
*/
void
{
union {
} argument;
char *result;
char *(*local)();
char *ipaddrp;
_rpcsvcdirty = 1;
if (verbose) {
"Request %d from %s",
}
}
}
case NULLPROC:
_rpcsvcdirty = 0;
return;
case NIS_LOOKUP:
local = (char *(*)()) nis_lookup_svc;
break;
case NIS_ADD:
local = (char *(*)()) nis_add_svc;
break;
case NIS_MODIFY:
local = (char *(*)()) nis_modify_svc;
break;
case NIS_REMOVE:
local = (char *(*)()) nis_remove_svc;
break;
case NIS_IBLIST:
local = (char *(*)()) nis_iblist_svc;
break;
case NIS_IBADD:
local = (char *(*)()) nis_ibadd_svc;
break;
case NIS_IBMODIFY:
local = (char *(*)()) nis_ibmodify_svc;
break;
case NIS_IBREMOVE:
local = (char *(*)()) nis_ibremove_svc;
break;
case NIS_IBFIRST:
local = (char *(*)()) nis_ibfirst_svc;
break;
case NIS_IBNEXT:
local = (char *(*)()) nis_ibnext_svc;
break;
case NIS_FINDDIRECTORY:
local = (char *(*)()) nis_finddirectory_svc;
break;
case NIS_STATUS:
local = (char *(*)()) nis_status_svc;
break;
case NIS_DUMPLOG:
local = (char *(*)()) nis_dumplog_svc;
break;
case NIS_DUMP:
local = (char *(*)()) nis_dump_svc;
break;
case NIS_CALLBACK:
local = (char *(*)()) nis_callback_svc;
break;
case NIS_CPTIME:
local = (char *(*)()) nis_cptime_svc;
/*
* Setup docheck with the NIS_SVCARG_ROOTOBJECT flag so that
* objects called 'root.object' can have their time checked.
*/
break;
case NIS_CHECKPOINT:
local = (char *(*)()) nis_checkpoint_svc;
break;
case NIS_PING:
local = (char *(*)()) nis_ping_svc;
/*
* Setup docheck with the NIS_SVCARG_ROOTOBJECT flag so that
* objects called 'root.object' can be 'pinged'.
*/
break;
case NIS_SERVSTATE:
local = (char *(*)()) nis_servstate_svc;
break;
case NIS_MKDIR:
local = (char *(*)()) nis_mkdir_svc;
break;
case NIS_RMDIR:
local = (char *(*)()) nis_rmdir_svc;
break;
default:
_rpcsvcdirty = 0;
return;
}
_rpcsvcdirty = 0;
return;
}
} else {
/*
* Service routine expects an object name argument, but
* the name supplied was bad.
*/
if (verbose)
}
}
exit(1);
}
_rpcsvcdirty = 0;
/* If the DB deferred an object deletion, perform it now */
{
if (tsd != 0) {
if (res == 0) {
"Deferred nis_remove(\"%s\") => NULL",
"Deferred nis_remove(\"%s\") => %s",
}
if (res != 0)
"Deferred nis_rmdir(\"%s\") => %s",
"<NIL>");
}
}
tsd->objDelList = 0;
}
}
}
/*
* check_object_name()
*
* Return TRUE if the following assertions hold for "name", FALSE otherwise:
*
* - Not a NULL pointer
*
* - Not the empty string
*
* - Does not exceed the maximum allowed length for a nis_name
*
* - Ends with trailing dot.
*
*/
static bool_t
{
if (docheck == NIS_SVCARG_NOCHECK)
return (TRUE);
return (FALSE);
else
/* NULL pointer allowed and present; no more checks */
return (TRUE);
if (namelen == 0)
if ((docheck & NIS_SVCARG_EMPTYSTRING) ==
return (FALSE);
else
/* Empty string allowed and present; no more checks */
return (TRUE);
return (FALSE);
/*
* Check for ROOT_OBJECT (root.object) as a valid name. Only
* usually set for special cases when dealing with pinging &
* checking times on root objects.
*/
return (TRUE);
return (FALSE);
return (TRUE);
}
/*
* safe_object_name()
*
* Returns a version of the nis_name argument that is safe to pass to
* printf et al.
*
*/
static nis_name
{
return (nullname);
return (emptyname);
else if (namelen >= NIS_MAXNAMELEN)
return (toolongname);
else
return (name);
}