1
0

Source code upload

This commit is contained in:
calmsacibis995
2022-09-29 17:59:04 +03:00
parent 72fa9da3d7
commit 8fc8fa8089
33399 changed files with 11964078 additions and 0 deletions

37
eoe/cmd/rpcbind/Makefile Normal file
View File

@@ -0,0 +1,37 @@
#
# Makefile for rpcbind, the SVR4 replacement for portmap
#
#ident $Revision: 1.10 $
include $(ROOT)/usr/include/make/commondefs
LCDEFS = -D_SVR4_TIRPC -DPORTMAP -DCHECK_LOCAL
LCOPTS =
LLDOPTS = -L. -Wl,-transitive_link,-T,10000000,-D,10040000 -Wl,-woff,85
LLDLIBS = -lnsl
LIBDMALLOC=dmalloc/libdmalloc.a
COMMONPREF=rpc_
SUBDIRS=dmalloc
CFILES = check_bound.c pmap_svc.c rpcb_svc.c rpcbind.c stricmp.c warmstart.c
LINTFLAGS=-woff 91,102
TARGETS = rpcbind
targets default: $(TARGETS)
$(LIBDMALLOC):
cd dmalloc; $(MAKE) libdmalloc.a
rpcbind: $(OBJECTS)
$(CCF) $(OBJECTS) $(LDFLAGS) -o $@
include $(COMMONRULES)
$(COMMONTARGS): $(COMMONPREF)$$@
$(SUBDIRS_MAKERULE)
install: default
$(INSTALL) -F /usr/etc -idb svr4net $(TARGETS)

View File

@@ -0,0 +1,371 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)rpcbind:check_bound.c 1.7.7.2"
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* PROPRIETARY NOTICE (Combined)
*
* This source code is unpublished proprietary information
* constituting, or derived under license from AT&T's UNIX(r) System V.
* In addition, portions of such source code were derived from Berkeley
* 4.3 BSD under license from the Regents of the University of
* California.
*
*
*
* Copyright Notice
*
* Notice of copyright on this source code product does not indicate
* publication.
*
* (c) 1986,1987,1988,1989,1990 Sun Microsystems, Inc
* (c) 1983,1984,1985,1986,1987,1988,1989,1990 AT&T.
* (c) 1990,1991 UNIX System Laboratories, Inc.
* All rights reserved.
*/
/*
* check_bound.c
* Checks to see whether the program is still bound to the
* claimed address and returns the univeral merged address
*
*/
#include <stdio.h>
#include <rpc/rpc.h>
#include <netconfig.h>
#include <netdir.h>
#ifdef sgi
#include <sys/xti.h>
#endif
#ifdef SYSLOG
#include <sys/syslog.h>
#else
#define LOG_DAEMON (3<<3)
#define LOG_CONS 0x02
#define LOG_ERR 3
#endif /* SYSLOG */
extern int t_errno;
extern char *t_errlist[];
struct fdlist {
int fd;
struct netconfig *nconf;
struct fdlist *next;
int check_binding;
};
static struct fdlist *fdhead; /* Link list of the check fd's */
static struct fdlist *fdtail;
extern char *nullstring;
/*
* Returns 1 if the given address is bound for the given addr & transport
* For all error cases, we assume that the address is bound
* Returns 0 for success.
*/
static bool_t
check_bound(fdl, uaddr)
struct fdlist *fdl; /* My FD list */
char *uaddr; /* the universal address */
{
int fd;
struct netbuf *na;
struct t_bind taddr, *baddr;
int ans;
if (fdl->check_binding == FALSE)
return (TRUE);
na = uaddr2taddr(fdl->nconf, uaddr);
if (!na)
return (TRUE); /* punt, should never happen */
fd = fdl->fd;
taddr.addr = *na;
taddr.qlen = 1;
baddr = (struct t_bind *)t_alloc(fd, T_BIND, T_ADDR);
if (baddr == NULL) {
netdir_free((char *)na, ND_ADDR);
return (TRUE);
}
if (t_bind(fd, &taddr, baddr) != 0) {
netdir_free((char *)na, ND_ADDR);
(void) t_free((char *)baddr, T_BIND);
return (TRUE);
}
ans = memcmp(taddr.addr.buf, baddr->addr.buf, baddr->addr.len);
netdir_free((char *)na, ND_ADDR);
(void) t_free((char *)baddr, T_BIND);
if (t_unbind(fd) != 0) {
/* Bad fd. Purge this fd */
(void) t_close(fd);
fdl->fd = t_open(fdl->nconf->nc_device, O_RDWR, NULL);
if (fdl->fd == -1)
fdl->check_binding = FALSE;
}
return (ans == 0 ? FALSE : TRUE);
}
/*
* Keep open one more file descriptor for this transport, which
* will be used to determine whether the given service is up
* or not by trying to bind to the registered address.
* We are ignoring errors here. It trashes taddr and baddr;
* but that perhaps should not matter.
*
* We check for the following conditions:
* 1. Is it possible for t_bind to fail in the case where
* we bind to an already bound address and have any
* other error number besides TNOADDR.
* 2. If a address is specified in bind addr, can I bind to
* the same address.
* 3. If NULL is specified in bind addr, can I bind to the
* address to which the fd finally got bound.
*/
int
add_bndlist(nconf, taddr, baddr)
struct netconfig *nconf;
struct t_bind *taddr, *baddr;
{
int fd;
struct fdlist *fdl;
struct netconfig *newnconf;
struct t_info tinfo;
struct t_bind tmpaddr;
char *uaddr;
newnconf = getnetconfigent(nconf->nc_netid);
if (newnconf == NULL)
return (-1);
fdl = (struct fdlist *)malloc((u_int)sizeof (struct fdlist));
if (fdl == NULL) {
syslog(LOG_ERR, "no memory!");
return (-1);
}
fdl->nconf = newnconf;
fdl->next = NULL;
if (fdhead == NULL) {
fdhead = fdl;
fdtail = fdl;
} else {
fdtail->next = fdl;
fdtail = fdl;
}
fdl->check_binding = FALSE;
if ((fdl->fd = t_open(nconf->nc_device, O_RDWR, &tinfo)) < 0) {
syslog(LOG_ERR, "%s: add_bndlist cannot open connection: %s",
nconf->nc_netid, t_errlist[t_errno]);
return (-1);
}
/* Set the qlen only for cots transports */
switch (tinfo.servtype) {
case T_COTS:
case T_COTS_ORD:
taddr->qlen = 1;
break;
case T_CLTS:
taddr->qlen = 0;
break;
default:
goto error;
}
if (t_bind(fdl->fd, taddr, baddr) != 0) {
if (t_errno == TNOADDR || t_errno == TADDRBUSY) { /* it's ok */
fdl->check_binding = TRUE;
return (0);
}
/* Perhaps condition #1 */
syslog(LOG_ERR, "%s: add_bndlist cannot bind: %s",
nconf->nc_netid, t_errlist[t_errno]);
/*
* uaddr = taddr2uaddr(nconf, &(taddr->addr));
* syslog(LOG_ERR, "%s: add_bndlist cannot bind address %s",
* nconf->nc_netid, uaddr);
*/
goto not_bound;
}
/* Condition #2 */
if (!memcmp(taddr->addr.buf, baddr->addr.buf,
(int)baddr->addr.len)) {
#ifdef BIND_DEBUG
fprintf(stderr, "Condition #2\n");
#endif
goto not_bound;
}
/* Condition #3 */
t_unbind(fdl->fd);
/* Set the qlen only for cots transports */
switch (tinfo.servtype) {
case T_COTS:
case T_COTS_ORD:
tmpaddr.qlen = 1;
break;
case T_CLTS:
tmpaddr.qlen = 0;
break;
default:
goto error;
}
tmpaddr.addr.len = tmpaddr.addr.maxlen = 0;
tmpaddr.addr.buf = NULL;
if (t_bind(fdl->fd, &tmpaddr, taddr) != 0) {
syslog(LOG_ERR, "%s: add_bndlist cannot bind: %s",
nconf->nc_netid, t_errlist[t_errno]);
goto error;
}
/* Now fdl->fd is bound to a transport chosen address */
if ((fd = t_open(nconf->nc_device, O_RDWR, &tinfo)) < 0) {
syslog(LOG_ERR, "%s: add_bndlist cannot open connection: %s",
nconf->nc_netid, t_errlist[t_errno]);
goto error;
}
if (t_bind(fd, taddr, baddr) != 0) {
syslog(LOG_ERR, "%s: add_bndlist cannot bind: %s",
nconf->nc_netid, t_errlist[t_errno]);
t_close(fd);
goto error;
}
t_close(fd);
if (!memcmp(taddr->addr.buf, baddr->addr.buf,
(int)baddr->addr.len)) {
switch (tinfo.servtype) {
case T_COTS:
case T_COTS_ORD:
if (baddr->qlen == 1) {
#ifdef BIND_DEBUG
fprintf(stderr, "Condition #3\n");
#endif
goto not_bound;
}
break;
case T_CLTS:
#ifdef BIND_DEBUG
fprintf(stderr, "Condition #3\n");
#endif
goto not_bound;
default:
goto error;
}
}
t_unbind(fdl->fd);
fdl->check_binding = TRUE;
return (0);
not_bound:
t_close(fdl->fd);
fdl->fd = -1;
return (1);
error:
t_close(fdl->fd);
fdl->fd = -1;
return (-1);
}
bool_t
is_bound(netid, uaddr)
char *netid;
char *uaddr;
{
struct fdlist *fdl;
for (fdl = fdhead; fdl; fdl = fdl->next)
if (strcmp(fdl->nconf->nc_netid, netid) == 0)
break;
if (fdl == NULL)
return (TRUE);
return (check_bound(fdl, uaddr));
}
/*
* Returns NULL if there was some system error.
* Returns "" if the address was not bound, i.e the server crashed.
* Returns the merged address otherwise.
*/
char *
mergeaddr(xprt, uaddr)
SVCXPRT *xprt;
char *uaddr;
{
struct fdlist *fdl;
char *netid = xprt->xp_netid;
struct nd_mergearg ma;
int stat;
for (fdl = fdhead; fdl; fdl = fdl->next)
if (strcmp(fdl->nconf->nc_netid, netid) == 0)
break;
if (fdl == NULL)
return (NULL);
if (check_bound(fdl, uaddr) == FALSE)
/* that server died */
return (nullstring);
ma.c_uaddr = taddr2uaddr(fdl->nconf, svc_getrpccaller(xprt));
if (ma.c_uaddr == NULL) {
syslog(LOG_ERR, "taddr2uaddr failed for %s: %s",
fdl->nconf->nc_netid, netdir_sperror());
return (NULL);
}
#ifdef ND_DEBUG
fprintf(stderr, "mergeaddr: client uaddr = %s\n", ma.c_uaddr);
#endif
ma.s_uaddr = uaddr;
stat = netdir_options(fdl->nconf, ND_MERGEADDR, 0, (char *)&ma);
(void) free(ma.c_uaddr); /* from lib.; assume not static nullstring */
if (stat) {
syslog(LOG_ERR, "netdir_merge failed for %s: %s",
fdl->nconf->nc_netid, netdir_sperror());
return (NULL);
}
#ifdef ND_DEBUG
fprintf(stderr, "mergeaddr: uaddr = %s, merged uaddr = %s\n",
uaddr, ma.m_uaddr);
#endif
return (ma.m_uaddr);
}
/*
* Returns a netconf structure from its internal list. This
* structure should not be freed.
*/
struct netconfig *
rpcbind_get_conf(netid)
char *netid;
{
struct fdlist *fdl;
for (fdl = fdhead; fdl; fdl = fdl->next)
if (strcmp(fdl->nconf->nc_netid, netid) == 0)
break;
if (fdl == NULL)
return (NULL);
return (fdl->nconf);
}
#ifdef BIND_DEBUG
syslog(a, msg, b, c, d)
int a;
char *msg;
caddr_t b, c, d;
{
char buf[1024];
sprintf(buf, msg, b, c, d);
fprintf(stderr, "Syslog: %s\n", buf);
}
#endif

View File

@@ -0,0 +1,96 @@
#!smake
########
# Defs...
#
HFILES = \
dmalloc.h \
stacktrace.h \
$(NULL)
CFILES = \
dmalloc.c \
dmalloc_q.c \
stacktrace.c \
$(NULL)
ASFILES = \
stacktrace_s.s \
$(NULL)
#
# Note, due to bug #308776, everything must be
# in the very first member of _RLD_LIST,
# so we can't just let the subdir make its own .so.
#
#OSPATCHES = ospatches/dmalloc_patches.a
# but there aren't any currently, and ld doesn't like an empty archive...
#OSPATCHES =
LLDLIBS = $(OSPATCHES) -lmpc -lexc $(LIBMLD) -lmangle
# -init is not understood by cc, so encode it with -Wl to get it to ld
LLDOPTS = -Wl,-init,_malloc_init
LCDEFS = -DRELEASE_MAJOR=$(RELEASE_MAJOR)
TARGETS = \
libdmalloc.a \
libdmalloc.so \
libdmalloc.-g.a \
libdmalloc.-g.so \
$(NULL)
LDIRT = main *.bak tags
# -mips2 is the default on 6.2 systems, but we want
# to be able to run on R3000 5.3 systems, so make mips1 the default
include $(ROOT)/usr/include/make/releasedefs
include versiondefs
# Keep commondefs from including releasedefs again...
# NO_RELEASEDEFS=
include $(ROOT)/usr/include/make/commondefs
#if !defined(LIBBITSUF) || empty(LIBBITSUF)
#LIBMLD = -lmld
#else
LIBMLD =
#endif
########
# Rules...
#
libdmalloc.a: $@($(OBJECTS) ) MAKELIB
libdmalloc.-g.a: $@($(OBJECTS:.o=.-g.o)) MAKELIB
.SUFFIXES: .-g.o .a .so
#
# Rule for making a -g.o from a .c or .s
#
.c.-g.o .s.-g.o:
$(CCF:N-O*) -g -c $< -o $@
#
# Rule for making a .so from a .c, .s, .o, or .a
#
.c.so .s.so .o.so .a.so:
$(CCF) $(LDOPTS) $(LDDSOOPTS) $< $(LDLIBS) $(ENDIAN) -o $@
# ARGH! to keep it from trying to make libc.so from libc.a...
$(ROOT)/usr/lib$(LIBBITSUF)/libc.so:
just make sure there's a command here, it need not make sense
#
# The links to libmutex (the smallest DSO I could find)
# serves as stubs so that N32 and N64 programs can run
# when _RLD_LIST is set, since there is no N32 or N64 libdmalloc.
#
$(COMMONPREF)install! $(COMMONPREF)default
$(INSTALL) -idb dmalloc.eoe.dsos -F /usr/lib$(LIBBITSUF) -m 444 -O $(TARGETS:M*.so)
$(INSTALL) -idb dmalloc.dev.static -F /usr/lib$(LIBBITSUF) -m 444 $(TARGETS:M*.a)
#if !defined(LIBBITSUF) || empty(LIBBITSUF)
$(INSTALL) -idb dmalloc.dev.headers -F /usr/include -m 444 $(HFILES)
$(INSTALL) -idb dmalloc.src.dmalloc -m 755 -dir /usr/share/src/dmalloc/src
$(INSTALL) -idb dmalloc.src.dmalloc -f /usr/share/src/dmalloc/src -m 644 $(SOURCES) Makefile versiondefs
#endif
include $(COMMONRULES)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,68 @@
/*
* Copyright 1996, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
*
* UNPUBLISHED -- Rights reserved under the copyright laws of the United
* States. Use of a copyright notice is precautionary only and does not
* imply publication or disclosure.
*
* U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
* in similar or successor clauses in the FAR, or the DOD or NASA FAR
* Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
* 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that (i) the above copyright notices and this
* permission notice appear in all copies of the software and related
* documentation, and (ii) the name of Silicon Graphics may not be
* used in any advertising or publicity relating to the software
* without the specific, prior written permission of Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL,
* INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY
* THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE
* OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* dmalloc.h
*/
#ifndef __dmalloc_h_
#define __dmalloc_h_
# ifdef __cplusplus
extern "C" {
# endif
extern void malloc_reset();
extern void malloc_info(int show_nonleaks, int stacktrace_depth);
extern void malloc_info_cleanup();
extern void malloc_failed();
extern void malloc_init_function();
extern int malloc_stacktrace_get_depth;
extern int malloc_fillarea;
extern int malloc_check();
extern int malloc_check_during(char *during);
extern int malloc_isgoodblock(void *);
extern int malloc_isgoodblock_during(void *, char *during);
extern void malloc_of_interest();
extern void malloc_bad();
# ifdef __cplusplus
};
# endif
#endif /* __dmalloc_h_ */

View File

@@ -0,0 +1,52 @@
/*
* Copyright 1996, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
*
* UNPUBLISHED -- Rights reserved under the copyright laws of the United
* States. Use of a copyright notice is precautionary only and does not
* imply publication or disclosure.
*
* U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
* in similar or successor clauses in the FAR, or the DOD or NASA FAR
* Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
* 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that (i) the above copyright notices and this
* permission notice appear in all copies of the software and related
* documentation, and (ii) the name of Silicon Graphics may not be
* used in any advertising or publicity relating to the software
* without the specific, prior written permission of Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL,
* INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY
* THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE
* OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* dmalloc_q.c
*
* Function that gets called right before the first malloc.
* We quarantine this function so that the application
* can redefine it without getting a warning from the linker.
*/
#include "dmalloc.h"
extern void
malloc_init_function()
{
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
/*
* Copyright 1996, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
*
* UNPUBLISHED -- Rights reserved under the copyright laws of the United
* States. Use of a copyright notice is precautionary only and does not
* imply publication or disclosure.
*
* U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
* in similar or successor clauses in the FAR, or the DOD or NASA FAR
* Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
* 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that (i) the above copyright notices and this
* permission notice appear in all copies of the software and related
* documentation, and (ii) the name of Silicon Graphics may not be
* used in any advertising or publicity relating to the software
* without the specific, prior written permission of Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL,
* INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY
* THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE
* OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* stacktrace.h
*/
#ifndef __stacktrace_h_
#define __stacktrace_h_
# ifdef __cplusplus
extern "C" {
# endif
/* XXX some of this is defunct */
extern void initstacktrace(char **argv);
extern int stacktrace (char *filename, int startpc, int startsp,
int regs[], int (*getword)(unsigned));
extern int stacktrace_print(int skip);
extern int stacktrace_get(int skip, int n, void *trace[]);
extern int simple_stacktrace_write(int fd, char *fmt, char *executable,
int n, void *trace[]);
extern int simple_stacktrace_print(int fd, char *fmt, int skip, int n);
extern void stacktrace_cleanup();
extern char *stacktrace_get_argv0();
extern void stacktrace_set_argv0(const char *);
extern char *stacktrace_get_executable();
extern void stacktrace_set_executable(const char *);
extern void stacktrace_get_ffl(void *pc,
char *fun, char *file, int *line,
int funbufsiz, int filebufsiz);
# ifdef __cplusplus
}
# endif
#endif /* __stacktrace_h_ */

View File

@@ -0,0 +1,101 @@
/*
* Copyright 1996, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
*
* UNPUBLISHED -- Rights reserved under the copyright laws of the United
* States. Use of a copyright notice is precautionary only and does not
* imply publication or disclosure.
*
* U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
* in similar or successor clauses in the FAR, or the DOD or NASA FAR
* Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
* 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that (i) the above copyright notices and this
* permission notice appear in all copies of the software and related
* documentation, and (ii) the name of Silicon Graphics may not be
* used in any advertising or publicity relating to the software
* without the specific, prior written permission of Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL,
* INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY
* THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE
* OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* stacktrace_s.s
*/
#include <sys/regdef.h>
#include <sys/asm.h>
/*
void *_stacktrace_get_pc();
*/
LEAF(_stacktrace_get_pc)
move v0,ra /* our ra is pc of the caller, I hope */
j ra
END(_stacktrace_get_pc)
/*
void *_stacktrace_get_sp();
*/
LEAF(_stacktrace_get_sp)
move v0,sp /* this is a leaf so sp doesn't change, I hope */
j ra
END(_stacktrace_get_sp)
/*
void _stacktrace_get_regs(void *regs[32]);
*/
LEAF(_stacktrace_get_regs)
sw $31, 31*4(a0) /* XXX not right, but this app doesn't care */
sw $30, 30*4(a0)
sw $29, 29*4(a0)
sw $28, 28*4(a0)
sw $27, 27*4(a0)
sw $26, 26*4(a0)
sw $25, 25*4(a0)
sw $24, 24*4(a0)
sw $23, 23*4(a0)
sw $22, 22*4(a0)
sw $21, 21*4(a0)
sw $20, 20*4(a0)
sw $19, 19*4(a0)
sw $18, 18*4(a0)
sw $17, 17*4(a0)
sw $16, 16*4(a0)
sw $15, 15*4(a0)
sw $14, 14*4(a0)
sw $13, 13*4(a0)
sw $12, 12*4(a0)
sw $11, 11*4(a0)
sw $10, 10*4(a0)
sw $9, 9*4(a0)
sw $8, 8*4(a0)
sw $7, 7*4(a0)
sw $6, 6*4(a0)
sw $5, 5*4(a0)
sw $4, 4*4(a0)
sw $3, 3*4(a0)
sw $2, 2*4(a0)
/* sw $1, 1*4(a0) */
sw $0, 0*4(a0)
j ra
END(_stacktrace_get_regs)

View File

@@ -0,0 +1,6 @@
# -mips2 is the default on 6.2 systems, but we want
# to be able to run on R3000 5.3 systems, so make mips1 the default
DEF_OBJECT_STYLE=32_M1
# and since commondefs doesn't know about mips1 any more...
DEF_CSTYLE=$(CSTYLE_32_M2:S/-mips2/-mips1/)
DEF_GLDOPTS=$(GLDOPTS_32_M2:S/-mips2/-mips1/)

562
eoe/cmd/rpcbind/pmap_svc.c Normal file
View File

@@ -0,0 +1,562 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)rpcbind:pmap_svc.c 1.4.5.2"
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* PROPRIETARY NOTICE (Combined)
*
* This source code is unpublished proprietary information
* constituting, or derived under license from AT&T's UNIX(r) System V.
* In addition, portions of such source code were derived from Berkeley
* 4.3 BSD under license from the Regents of the University of
* California.
*
*
*
* Copyright Notice
*
* Notice of copyright on this source code product does not indicate
* publication.
*
* (c) 1986,1987,1988,1989,1990 Sun Microsystems, Inc
* (c) 1983,1984,1985,1986,1987,1988,1989,1990 AT&T.
* (c) 1990,1991 UNIX System Laboratories, Inc.
* All rights reserved.
*/
/*
* pmap_svc.c
* The server procedure for the version 2 portmaper.
* All the portmapper related interface from the portmap side.
*/
#ifdef PORTMAP
#include <stdio.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <rpc/rpcb_prot.h>
#ifdef CHECK_LOCAL
#include <syslog.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
#include <net/if.h> /* to find local addresses */
#include <net/route.h>
#include <sys/sysctl.h>
#define BSD_COMP /* XXX - so that it includes <sys/sockio.h> */
#include <sys/ioctl.h>
#include <sys/socket.h>
#include "rpcbind.h"
#ifndef INADDR_LOOPBACK /* Some <netinet/in.h> files do not have this */
#define INADDR_LOOPBACK (u_long)0x7F000001
#endif
#endif /* CHECK_LOCAL */
static PMAPLIST *find_service();
static bool_t pmapproc_change();
static bool_t pmapproc_getport();
static bool_t pmapproc_dump();
static void pmapproc_callit();
/*
* Called for all the version 2 inquiries.
*/
void
pmap_service(rqstp, xprt)
struct svc_req *rqstp;
SVCXPRT *xprt;
{
#ifndef sgi
if (verbose)
fprintf(stderr, "portmap: request for proc %d\n",
rqstp->rq_proc);
#else
struct sockaddr_in *who;
struct netbuf *nbuf;
int local;
nbuf = svc_getrpccaller(xprt);
who = (struct sockaddr_in *)nbuf->buf;
if (verbose)
fprintf(stderr, "portmap: %s request for proc %u\n",
inet_ntoa(who->sin_addr), rqstp->rq_proc);
local = chklocal(who->sin_addr);
if (xprt == m_xprt) {
/*
* Ignore (supposedly) local requests that arrived via
* multicast in case they come from a bad guy on the Internet
* sending poison packets to the universe.
*/
if (local) {
if (verbose)
syslog(LOG_INFO|LOG_AUTH,
"ignore multicast proc %u call"
" from local %s",
rqstp->rq_proc,
inet_ntoa(who->sin_addr));
return;
}
/*
* Ignore unauthorized all multicasts to avoid melting
* multicast forwarders with rejections.
*/
if ((num_oknets > 0 || Aflag) &&
!chknet(who->sin_addr)) {
if (verbose)
syslog(LOG_INFO|LOG_AUTH,
"ignore multicast proc %u call from %s",
rqstp->rq_proc,
inet_ntoa(who->sin_addr));
return;
}
} else {
/*
* Allow "null" procedure requests from anybody since
* it returns no port information.
*/
if ((num_oknets > 0 || Aflag) && !bflag &&
!local && rqstp->rq_proc != PMAPPROC_NULL &&
!chknet(who->sin_addr)) {
if (verbose)
syslog(LOG_INFO|LOG_AUTH,
"rejected proc %u call from %s",
rqstp->rq_proc,
inet_ntoa(who->sin_addr));
svcerr_auth(xprt, AUTH_FAILED);
return;
}
}
#endif
switch (rqstp->rq_proc) {
case PMAPPROC_NULL:
/*
* Null proc call
*/
#ifdef DEBUG
fprintf(stderr, "PMAPPROC_NULL\n");
#endif
if ((!svc_sendreply(xprt, xdr_void, NULL)) && debugging) {
rpcbind_abort();
}
break;
case PMAPPROC_SET:
/*
* Set a program, version to port mapping
*/
#ifdef DEBUG
fprintf(stderr, "PMAPPROC_SET\n");
#endif
if (Secure && xprt != ludp_xprt && xprt != ltcp_xprt) {
syslog(LOG_ERR, "non-local attempt to set");
svcerr_weakauth(xprt);
return;
}
pmapproc_change(rqstp, xprt, rqstp->rq_proc);
break;
case PMAPPROC_UNSET:
/*
* Remove a program, version to port mapping.
*/
#ifdef DEBUG
fprintf(stderr, "PMAPPROC_UNSET \n");
#endif
if (Secure && xprt != ludp_xprt && xprt != ltcp_xprt) {
syslog(LOG_ERR, "non-local attempt to unset");
svcerr_weakauth(xprt);
return;
}
pmapproc_change(rqstp, xprt, rqstp->rq_proc);
break;
case PMAPPROC_GETPORT:
/*
* Lookup the mapping for a program, version and return its
* port number.
*/
#ifdef DEBUG
fprintf(stderr, "PMAPPROC_GETPORT\n");
#endif
pmapproc_getport(rqstp, xprt);
break;
case PMAPPROC_DUMP:
/*
* Return the current set of mapped program, version
*/
#ifdef DEBUG
fprintf(stderr, "PMAPPROC_DUMP\n");
#endif
pmapproc_dump(rqstp, xprt);
break;
case PMAPPROC_CALLIT:
/*
* Calls a procedure on the local machine. If the requested
* procedure is not registered this procedure does not return
* error information!!
* This procedure is only supported on rpc/udp and calls via
* rpc/udp. It passes null authentication parameters.
*/
#ifdef DEBUG
fprintf(stderr, "PMAPPROC_CALLIT\n");
#endif
pmapproc_callit(rqstp, xprt);
break;
default:
svcerr_noproc(xprt);
break;
}
}
/*
* returns the item with the given program, version number. If that version
* number is not found, it returns the item with that program number, so that
* the port number is now returned to the caller. The caller when makes a
* call to this program, version number, the call will fail and it will
* return with PROGVERS_MISMATCH. The user can then determine the highest
* and the lowest version number for this program using clnt_geterr() and
* use those program version numbers.
*/
static PMAPLIST *
find_service(prog, vers, prot)
u_long prog;
u_long vers;
u_long prot;
{
register PMAPLIST *hit = NULL;
register PMAPLIST *pml;
for (pml = list_pml; pml != NULL; pml = pml->pml_next) {
if ((pml->pml_map.pm_prog != prog) ||
(pml->pml_map.pm_prot != prot))
continue;
hit = pml;
if (pml->pml_map.pm_vers == vers)
break;
}
return (hit);
}
static bool_t
pmapproc_change(rqstp, xprt, op)
struct svc_req *rqstp;
register SVCXPRT *xprt;
unsigned long op;
{
PMAP reg;
RPCB rpcbreg;
int ans;
struct sockaddr_in *who;
extern bool_t map_set(), map_unset();
if (!svc_getargs(xprt, xdr_pmap, &reg)) {
svcerr_decode(xprt);
return (FALSE);
}
who = svc_getcaller(xprt);
#ifdef CHECK_LOCAL
/*
* To check whether the request came from a local server. If this
* cannot be tested, we assign that call as "unknown".
*/
if (chklocal(ntohl(who->sin_addr)) == FALSE) {
ans = FALSE;
goto done_change;
}
if (ntohs(who->sin_port) >= IPPORT_RESERVED)
rpcbreg.r_owner = "unknown";
else
rpcbreg.r_owner = "superuser";
#else
rpcbreg.r_owner = "unknown";
#endif
if ((op == PMAPPROC_SET) && (reg.pm_port < IPPORT_RESERVED) &&
(ntohs(who->sin_port) >= IPPORT_RESERVED)) {
ans = FALSE;
goto done_change;
}
rpcbreg.r_prog = reg.pm_prog;
rpcbreg.r_vers = reg.pm_vers;
if (op == PMAPPROC_SET) {
char buf[32];
sprintf(buf, "0.0.0.0.%d.%d", reg.pm_port >> 8 & 0xff,
reg.pm_port & 0xff);
rpcbreg.r_addr = buf;
if (reg.pm_prot == IPPROTO_UDP) {
rpcbreg.r_netid = udptrans;
} else if (reg.pm_prot == IPPROTO_TCP) {
rpcbreg.r_netid = tcptrans;
} else {
ans = FALSE;
goto done_change;
}
ans = map_set(&rpcbreg, rpcbreg.r_owner);
} else if (op == PMAPPROC_UNSET) {
bool_t ans1, ans2;
rpcbreg.r_addr = NULL;
rpcbreg.r_netid = tcptrans;
ans1 = map_unset(&rpcbreg, rpcbreg.r_owner);
rpcbreg.r_netid = udptrans;
ans2 = map_unset(&rpcbreg, rpcbreg.r_owner);
ans = ans1 || ans2;
} else {
ans = FALSE;
}
done_change:
if ((!svc_sendreply(xprt, xdr_long, (caddr_t) &ans)) &&
debugging) {
fprintf(stderr, "portmap: svc_sendreply\n");
rpcbind_abort();
}
return (TRUE);
}
/* ARGSUSED */
static bool_t
pmapproc_getport(rqstp, xprt)
struct svc_req *rqstp;
register SVCXPRT *xprt;
{
PMAP reg;
int port;
PMAPLIST *fnd;
if (!svc_getargs(xprt, xdr_pmap, &reg)) {
svcerr_decode(xprt);
return (FALSE);
}
fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot);
if (fnd) {
char serveuaddr[32], *ua;
int h1, h2, h3, h4, p1, p2;
char *netid;
if (reg.pm_prot == IPPROTO_UDP) {
ua = udp_uaddr;
netid = udptrans;
} else {
ua = tcp_uaddr; /* To get the len */
netid = tcptrans;
}
sscanf(ua, "%d.%d.%d.%d.%d.%d", &h1, &h2, &h3,
&h4, &p1, &p2);
p1 = (fnd->pml_map.pm_port >> 8) & 0xff;
p2 = (fnd->pml_map.pm_port) & 0xff;
sprintf(serveuaddr, "%d.%d.%d.%d.%d.%d",
h1, h2, h3, h4, p1, p2);
if (is_bound(netid, serveuaddr))
port = fnd->pml_map.pm_port;
else { /* this service is dead; delete it */
RPCB rpcbreg;
rpcbreg.r_prog = reg.pm_prog;
rpcbreg.r_vers = reg.pm_vers;
rpcbreg.r_addr = NULL;
rpcbreg.r_netid = netid;
map_unset(&rpcbreg, "superuser");
port = 0;
}
} else {
port = 0;
}
if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&port)) &&
debugging) {
(void) fprintf(stderr, "portmap: svc_sendreply\n");
rpcbind_abort();
}
return (TRUE);
}
/* ARGSUSED */
static bool_t
pmapproc_dump(rqstp, xprt)
struct svc_req *rqstp;
register SVCXPRT *xprt;
{
if (!svc_getargs(xprt, xdr_void, NULL)) {
svcerr_decode(xprt);
return (FALSE);
}
if ((!svc_sendreply(xprt, xdr_pmaplist,
(caddr_t)&list_pml)) && debugging) {
(void) fprintf(stderr, "portmap: svc_sendreply\n");
rpcbind_abort();
}
return (TRUE);
}
#ifdef CHECK_LOCAL
static struct timeval when_local;
int num_local = 0;
union addrs *addrs;
static size_t addrs_size = 0;
void
getlocal(void)
{
int i;
struct oknet *n;
size_t needed;
struct timeval now;
int mib[6];
struct if_msghdr *ifm;
struct ifa_msghdr *ifam, *ifam_lim, *ifam2;
struct sockaddr *sa;
/*
* Get current addresses periodically, in case interfaces change.
*/
gettimeofday(&now,0);
if (addrs_size > 0 && now.tv_sec < when_local.tv_sec+60)
return;
when_local = now;
num_local = 0;
/*
* Fetch the interface list, without too many system calls
* since we do it repeatedly.
*/
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0;
mib[3] = AF_INET;
mib[4] = NET_RT_IFLIST;
mib[5] = 0;
for (;;) {
if ((needed = addrs_size) != 0) {
if (sysctl(mib, 6, addrs,&needed, 0, 0) >= 0)
break;
if (errno != ENOMEM && errno != EFAULT) {
perror("sysctl");
exit(1);
}
free(addrs);
needed = 0;
}
if (sysctl(mib, 6, 0, &needed, 0, 0) < 0) {
perror("sysctl-estimate");
exit(1);
}
addrs = (union addrs *)malloc(addrs_size = needed);
}
n = &addrs->a[0];
ifam_lim = (struct ifa_msghdr *)(addrs->buf + needed);
for (ifam = (struct ifa_msghdr *)addrs->buf; ifam < ifam_lim; ifam = ifam2) {
ifam2 = (struct ifa_msghdr*)((char*)ifam + ifam->ifam_msglen);
if (ifam->ifam_type == RTM_IFINFO) {
ifm = (struct if_msghdr *)ifam;
continue;
}
if (ifam->ifam_type != RTM_NEWADDR) {
syslog(LOG_ERR, "out of sync");
abort();
}
if (!(ifm->ifm_flags & IFF_UP))
continue;
/*
* Find the interface address among the other addresses.
*/
n->mask.s_addr = 0xffffffff;
sa = (struct sockaddr *)(ifam+1);
for (i = 0;
i <= RTAX_IFA && sa < (struct sockaddr *)ifam2;
i++) {
if ((ifam->ifam_addrs & (1 << i)) == 0)
continue;
if (i == RTAX_NETMASK
&& !(ifm->ifm_flags & IFF_POINTOPOINT))
n->mask = ((struct sockaddr_in *)sa)->sin_addr;
else if (i == RTAX_IFA)
break;
#define SAROUNDUP(a) ((a) > 0 ? (1 + (((a) - 1) | (sizeof(__uint64_t) - 1))) \
: sizeof(__uint64_t))
#ifdef _HAVE_SA_LEN
sa = (struct sockaddr *)((char*)sa
+ SAROUNDUP(sa->sa_len));
#else
sa = (struct sockaddr *
)((char*)sa + SAROUNDUP(_FAKE_SA_LEN_DST(sa)));
#endif
}
if (i > RTAX_IFA
#ifdef _HAVE_SA_LEN
|| sa->sa_len == 0
#endif
|| sa >= (struct sockaddr *)ifam2
|| sa->sa_family != AF_INET)
continue;
n->match = ((struct sockaddr_in *)sa)->sin_addr;
n++;
num_local++;
}
if (debugging)
fprintf(stderr, "%d local addresses detected\n",
num_local);
}
bool_t
chklocal(struct in_addr addr)
{
int i;
struct oknet *n;
if (addr.s_addr == INADDR_LOOPBACK)
return (TRUE);
getlocal();
for (i = num_local, n = &addrs->a[0]; i != 0; i--, n++) {
if (addr.s_addr == n->match.s_addr)
return (TRUE);
}
return (FALSE);
}
#endif /* CHECK_LOCAL */
/*
* Call a remote procedure service
* This procedure is very quiet when things go wrong.
* The proc is written to support broadcast rpc. In the broadcast case,
* a machine should shut-up instead of complain, less the requestor be
* overrun with complaints at the expense of not hearing a valid reply ...
*/
static void
pmapproc_callit(rqstp, xprt)
struct svc_req *rqstp;
SVCXPRT *xprt;
{
rpcbproc_callit_common(rqstp, xprt, PMAP_TYPE);
}
#endif /* PORTMAP */

1537
eoe/cmd/rpcbind/rpcb_svc.c Normal file

File diff suppressed because it is too large Load Diff

872
eoe/cmd/rpcbind/rpcbind.c Normal file
View File

@@ -0,0 +1,872 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)rpcbind:rpcbind.c 1.14.9.2"
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* PROPRIETARY NOTICE (Combined)
*
* This source code is unpublished proprietary information
* constituting, or derived under license from AT&T's UNIX(r) System V.
* In addition, portions of such source code were derived from Berkeley
* 4.3 BSD under license from the Regents of the University of
* California.
*
*
*
* Copyright Notice
*
* Notice of copyright on this source code product does not indicate
* publication.
*
* (c) 1986,1987,1988,1989,1990 Sun Microsystems, Inc
* (c) 1983,1984,1985,1986,1987,1988,1989,1990 AT&T.
* (c) 1990,1991 UNIX System Laboratories, Inc.
* All rights reserved.
*/
/*
* rpcbind.c
* Implements the program, version to address mapping for rpc.
*
*/
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/rpcb_prot.h>
#include <netconfig.h>
#include <netdir.h>
#include <sys/wait.h>
#include <signal.h>
#include <fmtmsg.h>
#ifdef PORTMAP
#include <netinet/in.h>
#include <rpc/pmap_prot.h>
#endif
#include "rpcbind.h"
#include <sys/termios.h>
#ifdef SYSLOG
#include <sys/syslog.h>
#else
#define LOG_DAEMON (3<<3)
#define LOG_CONS 0x02
#define LOG_ERR 3
#endif /* SYSLOG */
#ifdef sgi
#include <string.h>
/* #include <sys/stream.h> #include <sys/tihdr.h> #include <sys/stropts.h> */
#include <tiuser.h>
#endif
extern void *malloc();
extern char *strdup();
#ifdef PORTMAP
extern void pmap_service();
#endif
extern int rpcb_service();
#ifdef WAIT3
void reap();
#endif
static void terminate();
static void detachfromtty();
static void parseargs();
static int init_transport();
extern void read_warmstart();
extern void write_warmstart();
/* Global variables */
int debugging = 0; /* Tell me what's going on */
#ifdef sgi
int verbose = 0; /* report errors */
int do_mcast = 0; /* register for UDP multicasts */
SVCXPRT *m_xprt;
int max_forks = 10; /* maximum number of callits at once */
#endif
RPCBLIST *list_rbl; /* A list of version 3 rpcbind services */
char *loopback_dg; /* Datagram loopback transport, for set and unset */
char *loopback_vc; /* COTS loopback transport, for set and unset */
char *loopback_vc_ord; /* COTS_ORD loopback transport, for set and unset */
int Secure = 1;
/* Local Variable */
static int warmstart = 0; /* Grab a old copy of registrations */
#ifdef PORTMAP
PMAPLIST *list_pml; /* A list of version 2 rpcbind services */
char *udptrans = ""; /* Name of UDP transport */
char *tcptrans = ""; /* Name of TCP transport */
char *udp_uaddr; /* Universal UDP address */
char *tcp_uaddr; /* Universal TCP address */
SVCXPRT *ludp_xprt = NULL; /* loopback udp transport */
SVCXPRT *ltcp_xprt = NULL; /* loopback tcp transport */
#endif
static char servname[] = "rpcbind";
static char superuser[] = "superuser";
extern int t_errno;
extern char *t_errlist[];
#ifdef sgi
/*
* Simple access control to restrict any request for useful information
* to a limited set of addresses. The first match in the array of
* mask-match pairs allows the request to be processed. Any address
* for this host is always allowed.
*/
#define MAX_OKNETS 50
struct oknet oknets[MAX_OKNETS];
int num_oknets;
int Aflag;
int bflag;
#endif
main(argc, argv)
int argc;
char *argv[];
{
struct netconfig *nconf;
void *nc_handle; /* Net config handle */
openlog("rpcbind", LOG_CONS, LOG_DAEMON);
parseargs(argc, argv);
if (geteuid()) { /* This command allowed only to root */
(void) fprintf(stderr, "must be root to run %s\n", argv[0]);
exit(1);
}
#ifdef sgi
if (!Secure)
(void) fmtmsg(MM_CONSOLE, "rpcbind", MM_WARNING, "The -C option provides backward compatibility for broken applications. It also exposes a widely known security problem.", NULL, NULL);
#endif
nc_handle = setnetconfig(); /* open netconfig file */
if (nc_handle == NULL) {
syslog(LOG_ERR, "could not read /etc/netconfig");
exit(1);
}
loopback_dg = "";
loopback_vc = "";
loopback_vc_ord = "";
{ struct rlimit rl;
rl.rlim_cur = 1024;
rl.rlim_max = 1024;
(void) setrlimit(RLIMIT_NOFILE, &rl); /* SCA */
}
while (nconf = getnetconfig(nc_handle)) {
init_transport(nconf);
}
endnetconfig(nc_handle);
if ((loopback_dg[0] == NULL) && (loopback_vc[0] == NULL) &&
(loopback_vc_ord[0] == NULL)) {
syslog(LOG_ERR, "could not find loopback transports");
exit(1);
}
(void) signal(SIGCHLD, SIG_IGN); /* XXX see reap below */
(void) signal(SIGINT, terminate);
if (warmstart) {
read_warmstart();
}
if (debugging) {
printf("rpcbind debugging enabled -- will abort on errors!\n");
} else {
detachfromtty();
}
my_svc_run();
syslog(LOG_ERR, "svc_run returned unexpectedly");
rpcbind_abort();
/* NOTREACHED */
}
#ifdef sgi
int
rpcb_setsockopt(
int fd,
int level,
int optname,
void *optval,
int optlen)
{
int retval;
struct t_optmgmt reqt;
struct {
struct opthdr hdr;
char optbytes[1000];
} buf;
buf.hdr.level = level;
buf.hdr.name = optname;
buf.hdr.len = optlen;
(void)memcpy(buf.optbytes, optval, optlen);
reqt.opt.maxlen = reqt.opt.len = sizeof buf.hdr + optlen;
reqt.opt.buf = (char *)&buf;
reqt.flags = T_NEGOTIATE;
retval = t_optmgmt(fd, &reqt, &reqt);
return retval;
}
void
add_mcast( int fd )
{
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = htonl(PMAP_MULTICAST_INADDR);
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
if (rpcb_setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&mreq, sizeof mreq)) {
fprintf(stderr, "cannot enable multicast reception: %s\n",
t_errlist[t_errno]);
}
}
#endif
/*
* Adds the entry into the rpcbind database.
* If PORTMAP, then for UDP and TCP, it adds the entries for version 2 also
* Returns 0 if succeeds, else fails
*/
static int
init_transport(nconf)
struct netconfig *nconf; /* Transport provider info */
{
int fd;
struct t_bind *taddr, *baddr;
RPCBLIST *rbl;
SVCXPRT *my_xprt, *l_xprt;
struct nd_addrlist *nas;
struct nd_hostserv hs;
int status; /* bound checking ? */
if ((nconf->nc_semantics != NC_TPI_CLTS) &&
(nconf->nc_semantics != NC_TPI_COTS) &&
(nconf->nc_semantics != NC_TPI_COTS_ORD))
return (1); /* not my type */
if (verbose) {
int i;
char **s;
(void) fprintf(stderr, "%s: %d lookup routines :\n",
nconf->nc_netid, nconf->nc_nlookups);
for (i = 0, s = nconf->nc_lookups; i < nconf->nc_nlookups; i++, s++)
fprintf(stderr, "[%d] - %s\n", i, *s);
}
if ((fd = t_open(nconf->nc_device, O_RDWR, NULL)) < 0) {
syslog(LOG_ERR, "%s: cannot open connection: %s",
nconf->nc_netid, t_errlist[t_errno]);
return (1);
}
taddr = (struct t_bind *)t_alloc(fd, T_BIND, T_ADDR);
baddr = (struct t_bind *)t_alloc(fd, T_BIND, T_ADDR);
if ((baddr == NULL) || (taddr == NULL)) {
syslog(LOG_ERR, "%s: cannot allocate netbuf: %s",
nconf->nc_netid, t_errlist[t_errno]);
exit(1);
}
/* Get rpcbind's address on this transport */
hs.h_host = HOST_SELF;
hs.h_serv = servname;
if (0 != (status = netdir_getbyname(nconf, &hs, &nas))) {
if (verbose)
(void)fprintf(stderr,
"rpcbind : netdir_getbyname returned %d\n", status);
goto error;
}
/* Copy the address */
taddr->addr.len = nas->n_addrs->len;
memcpy(taddr->addr.buf, nas->n_addrs->buf, (int)nas->n_addrs->len);
if (verbose) {
/* for debugging print out our universal address */
char *uaddr;
uaddr = taddr2uaddr(nconf, nas->n_addrs);
(void) fprintf(stderr, "rpcbind : my address is %s\n", uaddr);
(void) free(uaddr);
}
netdir_free((char *)nas, ND_ADDRLIST);
if (nconf->nc_semantics == NC_TPI_CLTS)
taddr->qlen = 0;
else
taddr->qlen = 8; /* should be enough */
if (t_bind(fd, taddr, baddr) != 0) {
syslog(LOG_ERR, "%s: cannot bind: %s",
nconf->nc_netid, t_errlist[t_errno]);
goto error;
}
if (memcmp(taddr->addr.buf, baddr->addr.buf, (int)baddr->addr.len)) {
syslog(LOG_ERR, "%s: address in use", nconf->nc_netid);
goto error;
}
my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, baddr, 0, 0);
if (my_xprt == (SVCXPRT *)NULL) {
syslog(LOG_ERR, "%s: could not create service",
nconf->nc_netid);
goto error;
}
#ifdef PORTMAP
/*
* Register both the versions for tcp/ip and udp/ip
*/
if ((strcmp(nconf->nc_protofmly, NC_INET) == 0) &&
((strcmp(nconf->nc_proto, NC_TCP) == 0) ||
(strcmp(nconf->nc_proto, NC_UDP) == 0))) {
PMAPLIST *pml;
int lfd, on = 1, tcp = (strcmp(nconf->nc_proto, NC_TCP) == 0);
char laddr[32];
struct t_bind *ltaddr, *lbaddr;
struct netbuf *nb;
struct in_addr la = { htonl(INADDR_LOOPBACK) };
if (!svc_register(my_xprt, PMAPPROG, PMAPVERS,
pmap_service, NULL)) {
syslog(LOG_ERR, "could not register on %s",
nconf->nc_netid);
goto error;
}
pml = (PMAPLIST *)malloc((u_int)sizeof (PMAPLIST));
if (pml == (PMAPLIST *)NULL) {
syslog(LOG_ERR, "no memory!");
exit(1);
}
pml->pml_map.pm_prog = PMAPPROG;
pml->pml_map.pm_vers = PMAPVERS;
pml->pml_map.pm_port = PMAPPORT;
if (tcp) {
if (tcptrans[0]) {
syslog(LOG_ERR,
"cannot have more than one TCP transport");
goto error;
}
tcptrans = strdup(nconf->nc_netid);
pml->pml_map.pm_prot = IPPROTO_TCP;
/* Let's snarf the universal address */
/* "h1.h2.h3.h4.p1.p2" */
tcp_uaddr = taddr2uaddr(nconf, &baddr->addr);
} else {
if (udptrans[0]) {
syslog(LOG_ERR,
"cannot have more than one UDP transport");
goto error;
}
udptrans = strdup(nconf->nc_netid);
pml->pml_map.pm_prot = IPPROTO_UDP;
/* Let's snarf the universal address */
/* "h1.h2.h3.h4.p1.p2" */
udp_uaddr = taddr2uaddr(nconf, &baddr->addr);
#ifdef sgi
/*
* Listen to multicast.
*/
if (do_mcast) {
int mfd;
char maddr[15+8+1];
struct t_bind *mtaddr, *mbaddr;
struct in_addr ma = {PMAP_MULTICAST_INADDR};
if ((mfd = t_open(nconf->nc_device,
O_RDWR, NULL)) < 0) {
syslog(LOG_ERR,
"%s: cannot open multicast"
" connection: %s",
nconf->nc_netid,
t_errlist[t_errno]);
goto mcast_out;
}
mtaddr = (struct t_bind *)t_alloc(mfd, T_BIND,
T_ADDR);
mbaddr = (struct t_bind *)t_alloc(mfd, T_BIND,
T_ADDR);
sprintf(maddr, "%s.%u.%u", inet_ntoa(ma),
PMAPPORT>>8, PMAPPORT&0xff);
nb = uaddr2taddr(nconf, maddr);
memcpy(mtaddr->addr.buf, nb->buf,
mtaddr->addr.len = nb->len);
free(nb);
(void)rpcb_setsockopt(mfd,SOL_SOCKET,
SO_REUSEADDR,
&on, sizeof(on));
add_mcast(mfd);
if (t_bind(mfd, mtaddr, mbaddr) != 0) {
syslog(LOG_ERR,
"%s: cannot multicast bind: %s",
nconf->nc_netid,
t_errlist[t_errno]);
goto mcast_out;
}
m_xprt = (SVCXPRT *)svc_tli_create(mfd, nconf,
mbaddr,0,0);
if (m_xprt == 0) {
syslog(LOG_ERR, "%s: could not create"
" mulicast service",
nconf->nc_netid);
goto mcast_out;
}
if (!svc_register(m_xprt,PMAPPROG,PMAPVERS,
pmap_service, NULL)) {
syslog(LOG_ERR,
"could not register on %s",
nconf->nc_netid);
goto mcast_out;
}
/* version 3 registration */
if (!svc_reg(m_xprt, RPCBPROG, RPCBVERS,
rpcb_service, NULL)) {
syslog(LOG_ERR, "could not multicast"
" register %s version 3",
nconf->nc_netid);
goto mcast_out;
}
svc_versquiet(m_xprt);
mcast_out:
(void) t_free((char *)mtaddr, T_BIND);
(void) t_free((char *)mbaddr, T_BIND);
}
#endif
}
pml->pml_next = list_pml;
list_pml = pml;
/* Add version 3 information */
pml = (PMAPLIST *)malloc((u_int)sizeof (PMAPLIST));
if (pml == (PMAPLIST *)NULL) {
syslog(LOG_ERR, "no memory!");
exit(1);
}
pml->pml_map = list_pml->pml_map;
pml->pml_map.pm_vers = RPCBVERS;
pml->pml_next = list_pml;
list_pml = pml;
/* Also add version 2 stuff to rpcbind list */
rbl = (RPCBLIST *)malloc((u_int)sizeof (RPCBLIST));
if (rbl == (RPCBLIST *)NULL) {
syslog(LOG_ERR, "no memory!");
exit(1);
}
rbl->rpcb_map.r_prog = PMAPPROG;
rbl->rpcb_map.r_vers = PMAPVERS; /* Version 2 */
rbl->rpcb_map.r_netid = strdup(nconf->nc_netid);
rbl->rpcb_map.r_addr = taddr2uaddr(nconf, &baddr->addr);
rbl->rpcb_map.r_owner = superuser;
rbl->rpcb_next = list_rbl; /* Attach to global list */
list_rbl = rbl;
if ( Secure ) {
/* Create the udp/tcp loopback service port so we
identify connections that actually used the loopback
interface to connect vs those spoofing the loopback
source address. We exit on any failures because
we will not be able to set/unset portmap services
in pmap_service without these service ports defined */
if ((lfd = t_open(nconf->nc_device,O_RDWR,NULL)) <0) {
syslog(LOG_ERR,
"%s: cannot open loopback connection: %s",
nconf->nc_netid, t_errlist[t_errno]);
exit(1);
}
ltaddr = (struct t_bind *)t_alloc(lfd, T_BIND, T_ADDR);
lbaddr = (struct t_bind *)t_alloc(lfd, T_BIND, T_ADDR);
if (ltaddr == NULL || lbaddr == NULL) {
syslog(LOG_ERR,
"%s: cannot allocate local netbuf: %s",
nconf->nc_netid, t_errlist[t_errno]);
exit(1);
}
sprintf(laddr, "%s.%u.%u", inet_ntoa(la),
PMAPPORT>>8, PMAPPORT&0xff);
nb = uaddr2taddr(nconf, laddr);
memcpy(ltaddr->addr.buf, nb->buf,
ltaddr->addr.len = nb->len);
free(nb);
(void)rpcb_setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR,
&on, sizeof(on));
if (t_bind(lfd, ltaddr, lbaddr) != 0) {
syslog(LOG_ERR, "%s: cannot loopback bind: %s",
nconf->nc_netid, t_errlist[t_errno]);
exit(1);
}
l_xprt = (SVCXPRT *)svc_tli_create(lfd, nconf, lbaddr,
0,0);
if (l_xprt == 0) {
syslog(LOG_ERR, "%s: could not create"
" loopback service", nconf->nc_netid);
exit(1);
}
if (!svc_register(l_xprt, PMAPPROG, PMAPVERS,
pmap_service, NULL)) {
syslog(LOG_ERR, "could not register loopback"
" pmap_service %s", nconf->nc_netid);
exit(1);
}
svc_versquiet(l_xprt);
if (tcp)
ltcp_xprt = l_xprt;
else
ludp_xprt = l_xprt;
(void) t_free((char *)ltaddr, T_BIND);
(void) t_free((char *)lbaddr, T_BIND);
}
}
#endif
/* version 3 registration */
if (!svc_reg(my_xprt, RPCBPROG, RPCBVERS, rpcb_service, NULL)) {
syslog(LOG_ERR, "could not register %s version 3",
nconf->nc_netid);
goto error;
}
rbl = (RPCBLIST *)malloc((u_int)sizeof (RPCBLIST));
if (rbl == (RPCBLIST *)NULL) {
syslog(LOG_ERR, "no memory!");
exit(1);
}
rbl->rpcb_map.r_prog = RPCBPROG;
rbl->rpcb_map.r_vers = RPCBVERS; /* The new version number */
rbl->rpcb_map.r_netid = strdup(nconf->nc_netid);
rbl->rpcb_map.r_addr = taddr2uaddr(nconf, &baddr->addr);
rbl->rpcb_map.r_owner = superuser;
rbl->rpcb_next = list_rbl; /* Attach to global list */
list_rbl = rbl;
/*
* Tell RPC library to shut up about version mismatches so that new
* revs of broadcast protocols don't cause all the old servers to
* say: "wrong version".
*/
svc_versquiet(my_xprt);
/*
* In case of loopback transports, negotiate for
* returning of the uid of the caller.
*/
if (strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) {
if (nconf->nc_semantics == NC_TPI_CLTS)
loopback_dg = strdup(nconf->nc_netid);
else if (nconf->nc_semantics == NC_TPI_COTS)
loopback_vc = strdup(nconf->nc_netid);
else if (nconf->nc_semantics == NC_TPI_COTS_ORD)
loopback_vc_ord = strdup(nconf->nc_netid);
if (_rpc_negotiate_uid(fd)) {
syslog(LOG_ERR,
"could not negotiate with loopback tranport %s",
nconf->nc_netid);
}
}
/* decide if bound checking works for this transport */
status = add_bndlist(nconf, taddr, baddr);
#ifdef BIND_DEBUG
if (status < 0) {
fprintf(stderr, "Error in finding bind status for %s\n",
nconf->nc_netid);
} else if (status == 0) {
fprintf(stderr, "check binding for %s\n",
nconf->nc_netid);
} else if (status > 0) {
fprintf(stderr, "No check binding for %s\n",
nconf->nc_netid);
}
#endif
(void) t_free((char *)taddr, T_BIND);
(void) t_free((char *)baddr, T_BIND);
return (0);
error:
(void) t_free((char *)taddr, T_BIND);
(void) t_free((char *)baddr, T_BIND);
(void) t_close(fd);
return (1);
}
/*
* XXX this should be fixed to reap our children rather than ignoring the
* signal like we do for now ...
*/
#ifdef WAIT3
static void
reap()
{
while (wait3(NULL, WNOHANG, NULL) > 0);
}
#endif
/*
* Catch the signal and die
*/
static void
terminate()
{
syslog(LOG_ERR, "terminating on signal");
write_warmstart(); /* Dump yourself */
exit(2);
}
void
rpcbind_abort()
{
write_warmstart(); /* Dump yourself */
abort();
}
/*
* detach from tty
*/
static void
detachfromtty()
{
close(0);
close(1);
close(2);
switch (fork()) {
case (pid_t)-1:
perror("fork");
break;
case 0:
break;
default:
exit(0);
}
setsid();
(void)open("/dev/null", O_RDWR, 0);
dup(0);
dup(0);
}
/* get command line options */
static void
parseargs(argc, argv)
int argc;
char *argv[];
#ifndef sgi
{
int c;
while ((c = getopt(argc, argv, "dwC")) != EOF) {
switch (c) {
case 'd':
debugging = 1;
break;
case 'w':
warmstart = 1;
break;
case 'C':
Secure = 0;
break;
default: /* error */
fprintf(stderr, "usage: rpcbind -[dwC]\n");
exit (1);
}
}
}
#else
{
int t;
int argerr = 0;
extern int optind, opterr;
extern char *optarg;
opterr = 0;
while ((t = getopt(argc, argv, "a:Abdf:mvwC")) != EOF) {
switch (t) {
case 'a': {
char *cp;
struct oknet n;
/*
* Option formats: "mask,match" or "network", where
* mask, match and network are valid IP address/network
* numbers. "network" is a shorthand for specifying the
* default mask and match appropriate for the
* network's address class.
*/
if (cp = strchr(optarg, ',')) {
*cp++ = '\0';
if (!inet_isaddr(optarg, &n.mask.s_addr)) {
fprintf(stderr,
"%s: illegal IP address for mask\n",
optarg);
argerr = 1;
break;
}
if (!inet_isaddr(cp, &n.match.s_addr)) {
fprintf(stderr,
"%s: illegal IP address for match\n",
cp);
argerr = 1;
break;
}
} else {
/*
* Treat arg as a network address,
* host part of address is ignored.
*/
if (!inet_isaddr(optarg, &n.match.s_addr)) {
fprintf(stderr,
"%s: illegal network address\n",
optarg);
argerr = 1;
break;
}
if (IN_CLASSA(n.match.s_addr))
n.mask.s_addr = IN_CLASSA_NET;
else if (IN_CLASSB(n.match.s_addr))
n.mask.s_addr = IN_CLASSB_NET;
else if (IN_CLASSC(n.match.s_addr))
n.mask.s_addr = IN_CLASSC_NET;
else {
fprintf(stderr,
"%s: illegal network address class\n",
optarg);
argerr = 1;
break;
}
n.match.s_addr &= n.mask.s_addr;
}
if (num_oknets < MAX_OKNETS)
oknets[num_oknets++] = n;
else
fprintf(stderr,
"too many nets, extra ignored\n");
break;
}
case 'A':
/*
* Trust all directly connected networks.
*/
Aflag = 1;
break;
case 'b':
/*
* Trust non-multicast including broadcast sources
* because we are behind a firewall.
*/
bflag = 1;
break;
/*
* NB: rpcbind doesn't presently fork for PMAPPROC_CALLIT
* so this option is ignored. It is parsed for command
* line compatibility with portmap.
*/
case 'f': {
int max = atoi(optarg);
if (max < 1) {
fprintf(stderr,
"%s: illegal value for fork limit, ignored\n",
optarg);
argerr = 1;
} else
max_forks = max;
break;
}
case 'm':
do_mcast = 1;
break;
case 'd':
debugging = 1;
/* fall thru */
case 'v':
verbose = 1;
break;
case 'w':
warmstart = 1;
break;
case 'C':
Secure = 0;
break;
default:
case '?':
fprintf(stderr,"unknown option: %s\n", argv[optind -1]);
argerr = 1;
break;
}
}
if (argerr) {
/* -d option just for testing, don't show it */
/* do not mention -f since it is not supported */
fprintf(stderr,
"usage: rpcbind [-vmAbwC] [-a mask,match | -a match]\n");
exit(1);
}
}
/*
* Return 1 if the address is accepted, 0 otherwise.
*/
int
chknet(struct in_addr addr)
{
register struct oknet *n;
register int i;
for (n = oknets, i = 0; i < num_oknets; n++, i++) {
if ((addr.s_addr & n->mask.s_addr) == n->match.s_addr)
return 1;
}
/*
* If it was not in the explicit list and if allowed, check
* the implicit list.
*/
if (Aflag) {
getlocal();
for (i = num_local, n = &addrs->a[0]; i != 0; i--, n++) {
if (0 == ((addr.s_addr ^ n->mask.s_addr)
& n->match.s_addr))
return 1;
}
}
return 0;
}
#endif /* sgi */

104
eoe/cmd/rpcbind/rpcbind.h Normal file
View File

@@ -0,0 +1,104 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)rpcbind:rpcbind.h 1.2.5.2"
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* PROPRIETARY NOTICE (Combined)
*
* This source code is unpublished proprietary information
* constituting, or derived under license from AT&T's UNIX(r) System V.
* In addition, portions of such source code were derived from Berkeley
* 4.3 BSD under license from the Regents of the University of
* California.
*
*
*
* Copyright Notice
*
* Notice of copyright on this source code product does not indicate
* publication.
*
* (c) 1986,1987,1988,1989,1990 Sun Microsystems, Inc
* (c) 1983,1984,1985,1986,1987,1988,1989,1990 AT&T.
* (c) 1990,1991 UNIX System Laboratories, Inc.
* All rights reserved.
*/
/*
* rpcbind.h
* The common header declarations
*/
/* Global variables */
extern int debugging;
#ifdef sgi
extern int verbose; /* report errors */
extern int do_mcast; /* register for UDP multicasts */
extern int max_forks; /* maximum number of callits at once */
#else
#define verbose debugging
#endif
extern RPCBLIST *list_rbl; /* A list of version 3 rpcbind services */
extern char *loopback_dg; /* CLTS loopback transport, for set/unset */
extern char *loopback_vc; /* COTS loopback transport, for set/unset */
extern char *loopback_vc_ord; /* COTS_ORD loopback transport, for set/unset */
extern int Secure;
#ifdef PORTMAP
extern PMAPLIST *list_pml; /* A list of version 2 rpcbind services */
extern char *udptrans; /* Name of UDP transport */
extern char *tcptrans; /* Name of TCP transport */
extern char *udp_uaddr; /* Universal UDP address */
extern char *tcp_uaddr; /* Universal TCP address */
#endif
extern char *mergeaddr();
extern int add_bndlist();
extern bool_t is_bound();
extern void rpcbproc_callit_common();
extern struct netconfig *rpcbind_get_conf();
extern void rpcbind_abort();
#define PMAP_TYPE 1
#define RPCB_TYPE 2
#ifdef sgi
#include <syslog.h>
#ifndef DEBUG
/* an extremely ugly hack, but it works */
# define perror(string) syslog(LOG_DEBUG, "%s: %m", string)
# define fprintf syslog
# undef stderr
# define stderr LOG_DEBUG
# define SYSLOG syslog
#endif /* DEBUG */
struct oknet {
struct in_addr mask;
struct in_addr match;
};
extern struct oknet oknets[];
extern int num_oknets;
extern int Aflag;
extern int bflag;
extern int num_local;
extern union addrs {
char buf[1];
struct oknet a[1];
} *addrs;
extern SVCXPRT *m_xprt;
extern SVCXPRT *ludp_xprt, *ltcp_xprt;
extern bool_t chklocal(struct in_addr taddr);
extern void getlocal(void);
extern int chknet(struct in_addr addr);
#endif /* SGI */

100
eoe/cmd/rpcbind/stricmp.c Normal file
View File

@@ -0,0 +1,100 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)rpcbind:stricmp.c 1.1.5.2"
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* PROPRIETARY NOTICE (Combined)
*
* This source code is unpublished proprietary information
* constituting, or derived under license from AT&T's UNIX(r) System V.
* In addition, portions of such source code were derived from Berkeley
* 4.3 BSD under license from the Regents of the University of
* California.
*
*
*
* Copyright Notice
*
* Notice of copyright on this source code product does not indicate
* publication.
*
* (c) 1986,1987,1988,1989,1990 Sun Microsystems, Inc
* (c) 1983,1984,1985,1986,1987,1988,1989,1990 AT&T.
* (c) 1990,1991 UNIX System Laboratories, Inc.
* All rights reserved.
*/
#ifndef lint
static char sccsid[] = "@(#)stricmp.c 1.7 88/09/14 SMI"; /* from UCB 1.3 8/3/87 */
#endif
/*
* This array is designed for mapping upper and lower case letter
* together for a case independent comparison. The mappings are
* based upon ascii character sequences.
*/
static char charmap[] = {
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
'\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
'\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
};
strcasecmp(s1, s2)
register char *s1, *s2;
{
register char *cm = charmap;
while (cm[*s1] == cm[*s2++])
if (*s1++ == '\0')
return (0);
return (cm[*s1] - cm[*--s2]);
}
strncasecmp(s1, s2, n)
register char *s1, *s2;
register int n;
{
register char *cm = charmap;
while (--n >= 0 && cm[*s1] == cm[*s2++])
if (*s1++ == '\0')
return (0);
return (n < 0 ? 0 : cm[*s1] - cm[*--s2]);
}

158
eoe/cmd/rpcbind/warmstart.c Normal file
View File

@@ -0,0 +1,158 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)rpcbind:warmstart.c 1.1.1.2"
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* PROPRIETARY NOTICE (Combined)
*
* This source code is unpublished proprietary information
* constituting, or derived under license from AT&T's UNIX(r) System V.
* In addition, portions of such source code were derived from Berkeley
* 4.3 BSD under license from the Regents of the University of
* California.
*
*
*
* Copyright Notice
*
* Notice of copyright on this source code product does not indicate
* publication.
*
* (c) 1986,1987,1988,1989,1990 Sun Microsystems, Inc
* (c) 1983,1984,1985,1986,1987,1988,1989,1990 AT&T.
* (c) 1990,1991 UNIX System Laboratories, Inc.
* All rights reserved.
*/
/*
* warmstart.c
* Allows for gathering of registrations from a earlier dumped file.
*
*/
#include <stdio.h>
#include <rpc/rpc.h>
#include <rpc/rpcb_prot.h>
#include <sys/stat.h>
#ifdef PORTMAP
#include <netinet/in.h>
#include <rpc/pmap_prot.h>
#endif
#include "rpcbind.h"
#ifdef SYSLOG
#include <sys/syslog.h>
#else
#define LOG_DAEMON (3<<3)
#define LOG_CONS 0x02
#define LOG_ERR 3
#endif /* SYSLOG */
/* These files keep the pmap_list and rpcb_list in XDR format */
#define RPCBFILE "/tmp/rpcbind.file"
#ifdef PORTMAP
#define PMAPFILE "/tmp/portmap.file"
#endif
static bool_t write_struct();
static bool_t read_struct();
static bool_t
write_struct(filename, structproc, list)
char *filename;
xdrproc_t structproc;
void *list;
{
FILE *fp;
XDR xdrs;
fp = fopen(filename, "w");
if (fp == NULL) {
syslog(LOG_ERR, "cannot open file = %s for writing", filename);
syslog(LOG_ERR, "cannot save any registration");
return (FALSE);
}
xdrstdio_create(&xdrs, fp, XDR_ENCODE);
if (structproc(&xdrs, list) == FALSE) {
syslog(LOG_ERR, "rpcbind: xdr_%s: failed", filename);
fclose(fp);
return (FALSE);
}
XDR_DESTROY(&xdrs);
fclose(fp);
chmod(filename, S_IREAD|S_IWRITE);
return (TRUE);
}
static bool_t
read_struct(filename, structproc, list)
char *filename;
xdrproc_t structproc;
void *list;
{
FILE *fp;
XDR xdrs;
fp = fopen(filename, "r");
if (fp == NULL) {
fprintf(stderr,
"rpcbind: cannot open file = %s for reading\n", filename);
fprintf(stderr, "rpcbind: Will start from scratch\n");
return (FALSE);
}
xdrstdio_create(&xdrs, fp, XDR_DECODE);
if (structproc(&xdrs, list) == FALSE) {
fprintf(stderr, "rpcbind: xdr_%s: failed\n", filename);
fclose(fp);
return (FALSE);
}
XDR_DESTROY(&xdrs);
fclose(fp);
return (TRUE);
}
void
write_warmstart()
{
(void) write_struct(RPCBFILE, xdr_rpcblist, &list_rbl);
#ifdef PORTMAP
(void) write_struct(PMAPFILE, xdr_pmaplist, &list_pml);
#endif
}
void
read_warmstart()
{
RPCBLIST *tmp_rpcbl = NULL;
#ifdef PORTMAP
PMAPLIST *tmp_pmapl = NULL;
#endif
int ok1, ok2 = TRUE;
ok1 = read_struct(RPCBFILE, xdr_rpcblist, &tmp_rpcbl);
if (ok1 == FALSE)
return;
#ifdef PORTMAP
ok2 = read_struct(PMAPFILE, xdr_pmaplist, &tmp_pmapl);
#endif
if (ok2 == FALSE) {
xdr_free(xdr_rpcblist, &tmp_rpcbl);
return;
}
xdr_free(xdr_rpcblist, &list_rbl);
list_rbl = tmp_rpcbl;
#ifdef PORTMAP
xdr_free(xdr_pmaplist, &list_pml);
list_pml = tmp_pmapl;
#endif
}