ypxfrd_svc.c revision a506a34ceb0e9dcc6c61bf0560202f8538928650
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This source was formally rpcgen generated, but has been
* checked in.
*/
#include "ypxfrd.h"
#include <stdio.h>
#include <stdlib.h> /* getenv, exit */
#include <signal.h>
#include <string.h> /* strcmp */
#include <unistd.h> /* setsid */
#include <memory.h>
#include <stropts.h>
#include <netconfig.h>
#include <syslog.h>
#include <ndbm.h>
#include "shim.h"
#include "yptol.h"
#ifndef SIG_PF
#define SIG_PF void(*)(int)
#endif
#ifdef DEBUG
#define RPC_SVC_FG
#endif
#define _RPCSVC_CLOSEDOWN 120
/*
* Copyr 1989 Sun Micro
* #ident "@(#)ypxfrd.x 1.2 00/05/01 SMI"
* This is NOT source code!
* DO NOT EDIT THIS FILE!
*/
static int _rpcpmstart; /* Started by a port monitor ? */
/* States a server can be in wrt request */
#define _IDLE 0
#define _SERVED 1
static int _rpcsvccount = 0; /* Number of requests being serviced */
static void
{
#ifdef RPC_SVC_FG
if (_rpcpmstart)
else
#else
#endif
}
static void
{
int size;
int i, openfd = 0;
if (svc_pollfd[i].fd >= 0)
openfd++;
if (openfd <= 1)
exit(0);
} else
}
static void
{
union {
} argument;
char *result;
_rpcsvccount++;
case NULLPROC:
(void) svc_sendreply(transp,
_rpcsvccount--;
return;
case getdbm:
break;
default:
_rpcsvccount--;
return;
}
_rpcsvccount--;
return;
}
}
_msgout("unable to free arguments");
exit(1);
}
_rpcsvccount--;
}
int
main()
{
int i;
int stat;
/*
* If stdin looks like a TLI endpoint, we assume
* that we were started by a port monitor. If
* t_getstate fails with TBADF, this is not a
* TLI endpoint.
*/
char *netid;
int pmclose;
_rpcpmstart = 1;
/* started from inetd */
pmclose = 1;
} else {
_msgout("cannot get transport info");
}
_msgout("cannot create server handle");
exit(1);
}
if (nconf)
_msgout("unable to register (YPXFRD, V1).");
exit(1);
}
if (pmclose) {
}
if (yptol_mode) {
if (stat == 1) {
_msgout("NIS to LDAP mapping inactive.");
} else if (stat != 0) {
_msgout("Aborting after NIS to LDAP "
"mapping error.");
exit(1);
}
}
svc_run();
exit(1);
/* NOTREACHED */
} else {
#ifndef RPC_SVC_FG
extern void closefrom();
int size;
if (pid < 0) {
perror("cannot fork");
exit(1);
}
if (pid)
exit(0);
closelog();
closefrom(0);
else {
exit(1);
for (i = 0; i < size; i++)
(void) close(i);
}
(void) dup2(i, 1);
(void) dup2(i, 2);
setsid();
#endif
}
if (yptol_mode) {
if (stat == 1) {
_msgout("NIS to LDAP mapping inactive.");
} else if (stat != 0) {
_msgout("Aborting after NIS to LDAP mapping error.");
exit(1);
}
}
_msgout("unable to create (YPXFRD, V1) for visible.");
exit(1);
}
svc_run();
_msgout("svc_run returned");
exit(1);
/* NOTREACHED */
}