ypupdated.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 2000 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"
#ifndef lint
static char sccsid[] = "@(#)rpc.ypupdated.c 1.9 87/10/30 Copyr 1986 Sun Micro";
#endif
/*
* YP update service
*/
#include <stdio.h>
#include <stdlib.h>
#include <netdir.h>
#include <stropts.h>
#ifdef SYSLOG
#include <syslog.h>
#else
#define LOG_ERR 1
#define openlog(a, b, c)
#endif
#ifdef DEBUG
#define RPC_SVC_FG
#else
#endif
static char UPDATEFILE[] = "/var/yp/updaters";
#define _RPCSVC_CLOSEDOWN 120
static int addr2netname();
static void closedown();
static void ypupdate_prog();
static void msgout();
static int update();
static int insecure;
static int _rpcpmstart; /* Started by a port monitor ? */
static int _rpcsvcdirty; /* Still serving ? */
extern unsigned int alarm();
extern void exit();
extern int close();
extern long fork();
extern int free();
extern struct netconfig *getnetconfigent();
extern int strcmp();
extern int strcpy();
extern int syslog();
extern void *signal();
extern int setsid();
extern int t_getinfo();
extern int user2netname();
extern int _openchild();
int argc;
char *argv[];
{
char *cmd;
if (geteuid() != 0) {
exit(1);
}
switch (argc) {
case 0:
cmd = "ypupdated";
break;
case 1:
break;
case 2:
insecure++;
break;
}
default:
break;
}
exit(1);
}
/*
* Started from port monitor: use 0 as fd
*/
char *netid;
int pmclose;
extern char *getenv();
_rpcpmstart = 1;
msgout("cannot get transport name");
}
msgout("cannot get transport info");
}
msgout("could not get the right module");
exit(1);
}
}
msgout("cannot create update server handle");
exit(1);
}
msgout("unable to register (YPBINDPROG, YPBINDVERS).");
exit(1);
}
if (nconf)
if (pmclose) {
(void) alarm(_RPCSVC_CLOSEDOWN);
}
svc_run();
exit(1);
}
#ifndef RPC_SVC_FG
/*
* Started from shell; background thyself and run
*/
if (pid < 0) {
perror("cannot fork");
exit(1);
}
if (pid)
exit(0);
closefrom(0);
(void) setsid();
#endif
msgout("unable to create (YPU_PROG, YPU_VERS) for netpath.");
exit(1);
}
svc_run();
msgout("svc_run returned");
exit(1);
/* NOTREACHED */
}
static void
{
struct ypupdate_args args;
char *netname;
struct authunix_parms *aup;
case NULLPROC:
return;
case YPU_CHANGE:
op = YPOP_CHANGE;
break;
case YPU_DELETE:
op = YPOP_DELETE;
break;
case YPU_INSERT:
op = YPOP_INSERT;
break;
case YPU_STORE:
op = YPOP_STORE;
break;
default:
return;
}
#ifdef DEBUG
#endif
case AUTH_DES:
netname = ((struct authdes_cred *)
break;
case AUTH_UNIX:
if (insecure) {
"addr2netname failing for %d\n",
return;
}
} else {
!= 0) {
"user2netname failing for %d\n",
return;
}
}
break;
}
default:
return;
}
return;
}
#ifdef DEBUG
#endif
debug("svc_sendreply failed");
}
debug("svc_freeargs failed");
}
}
/*
* Determine if requester is allowed to update the given map,
* and update it if so. Returns the yp status, which is zero
* if there is no access violation.
*/
static
char *requester;
char *mapname;
char *key;
char *data;
{
int status;
int yperrno = 0;
int pid;
#ifdef DEBUG
#endif
if (pid < 0) {
debug("openpipes failed");
return (YPERR_YPERR);
}
/*
* Write to child
*/
/*
* Read from child
*/
return (YPERR_YPERR);
}
return (yperrno);
}
static void
char *msg;
{
if (_rpcpmstart)
else
}
void
{
if (_rpcsvcdirty == 0) {
int i, openfd;
exit(0);
if (svc_pollfd[i].fd >= 0)
openfd++;
if (openfd <= 1)
exit(0);
}
(void) alarm(_RPCSVC_CLOSEDOWN);
}
static int
char *namebuf;
{
return (-1);
return (-1);
(void) freenetconfigent(nconf);
return (-1);
}
msgout("ypupdated: netdir_getbyaddr failed\n");
} else {
}
(void) freenetconfigent(nconf);
return (0);
}