diff options
| author | casper <none@none> | 2006-05-01 11:23:49 -0700 |
|---|---|---|
| committer | casper <none@none> | 2006-05-01 11:23:49 -0700 |
| commit | 004388ebfdfe2ed7dfd2d153a876dfcc22d2c006 (patch) | |
| tree | 9f3972760e2696f63065521871e50e1440bfbb75 /usr/src/lib/libnsl/rpc | |
| parent | 0ade2cf005fcaecc5255dacf7d76683de855a9da (diff) | |
| download | illumos-joyent-004388ebfdfe2ed7dfd2d153a876dfcc22d2c006.tar.gz | |
4916205 libcmd should not use file operation routines from C library
6234782 Kerberos and GSSAPI should not use fopen
6259671 vold won't be killed by TERM signal when several removable devices are managed
6386770 pam_authenticate can fail if open files are >= 255 and the soft fd limit is greater than 256
6414401 Remove shadow stdio implementation obsoleted by PSARC 2006/162
6414404 __rpc_openchild never called and not exported by library
6416815 ON needs to be hardened against the 32-bit fopen/255 problem
--HG--
rename : usr/src/lib/libnsl/common/nsl_stdio_prv.c => deleted_files/usr/src/lib/libnsl/common/nsl_stdio_prv.c
rename : usr/src/lib/libnsl/include/nsl_stdio_prv.h => deleted_files/usr/src/lib/libnsl/include/nsl_stdio_prv.h
rename : usr/src/lib/libnsl/rpc/openchild.c => deleted_files/usr/src/lib/libnsl/rpc/openchild.c
rename : usr/src/lib/libnsl/rpc/xdr_stdio_prv.c => deleted_files/usr/src/lib/libnsl/rpc/xdr_stdio_prv.c
rename : usr/src/lib/libresolv2/req.flg => deleted_files/usr/src/lib/libresolv2/req.flg
rename : usr/src/lib/nsswitch/compat/req.flg => deleted_files/usr/src/lib/nsswitch/compat/req.flg
rename : usr/src/lib/nsswitch/files/req.flg => deleted_files/usr/src/lib/nsswitch/files/req.flg
rename : usr/src/lib/nsswitch/req.flg => deleted_files/usr/src/lib/nsswitch/req.flg
rename : usr/src/lib/nsswitch/user/req.flg => deleted_files/usr/src/lib/nsswitch/user/req.flg
Diffstat (limited to 'usr/src/lib/libnsl/rpc')
| -rw-r--r-- | usr/src/lib/libnsl/rpc/clnt_generic.c | 16 | ||||
| -rw-r--r-- | usr/src/lib/libnsl/rpc/netnamer.c | 22 | ||||
| -rw-r--r-- | usr/src/lib/libnsl/rpc/openchild.c | 105 | ||||
| -rw-r--r-- | usr/src/lib/libnsl/rpc/rpc_mt.h | 5 | ||||
| -rw-r--r-- | usr/src/lib/libnsl/rpc/rpc_soc.c | 11 | ||||
| -rw-r--r-- | usr/src/lib/libnsl/rpc/svc_run.c | 15 | ||||
| -rw-r--r-- | usr/src/lib/libnsl/rpc/svc_vc.c | 33 | ||||
| -rw-r--r-- | usr/src/lib/libnsl/rpc/xdr_stdio_prv.c | 215 |
8 files changed, 26 insertions, 396 deletions
diff --git a/usr/src/lib/libnsl/rpc/clnt_generic.c b/usr/src/lib/libnsl/rpc/clnt_generic.c index f3507134ce..f89c1d5f75 100644 --- a/usr/src/lib/libnsl/rpc/clnt_generic.c +++ b/usr/src/lib/libnsl/rpc/clnt_generic.c @@ -307,8 +307,6 @@ clnt_create_service_timed(const char *host, const char *service, char *nettype = &nettype_array[0]; char *hostname, *serv; bool_t try_others; - extern int __rpc_minfd; - /* * handle const of netclass @@ -399,8 +397,7 @@ clnt_create_service_timed(const char *host, const char *service, continue; } - if (fd < __rpc_minfd) - fd = __rpc_raise_fd(fd); + RPC_RAISEFD(fd); __rpc_set_mac_options(fd, nconf, prog); @@ -609,7 +606,6 @@ _clnt_tli_create_timed(int fd, const struct netconfig *nconf, bool_t madefd; /* whether fd opened here */ t_scalar_t servtype; int retval; - extern int __rpc_minfd; if (fd == RPC_ANYFD) { if (nconf == NULL) { @@ -620,8 +616,7 @@ _clnt_tli_create_timed(int fd, const struct netconfig *nconf, fd = t_open(nconf->nc_device, O_RDWR, NULL); if (fd == -1) goto err; - if (fd < __rpc_minfd) - fd = __rpc_raise_fd(fd); + RPC_RAISEFD(fd); madefd = TRUE; __rpc_set_mac_options(fd, nconf, prog); if (t_bind(fd, NULL, NULL) == -1) @@ -761,17 +756,12 @@ err1: if (madefd) * a descriptor to a higher value. If we fail to do it, we continue * to use the old one (and hope for the best). */ -int __rpc_minfd = 3; - int __rpc_raise_fd(int fd) { int nfd; - if (fd >= __rpc_minfd) - return (fd); - - if ((nfd = fcntl(fd, F_DUPFD, __rpc_minfd)) == -1) + if ((nfd = fcntl(fd, F_DUPFD, RPC_MINFD)) == -1) return (fd); if (t_sync(nfd) == -1) { diff --git a/usr/src/lib/libnsl/rpc/netnamer.c b/usr/src/lib/libnsl/rpc/netnamer.c index 38f964ca44..ee54f94151 100644 --- a/usr/src/lib/libnsl/rpc/netnamer.c +++ b/usr/src/lib/libnsl/rpc/netnamer.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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 * or http://www.opensolaris.org/os/licensing. @@ -21,7 +20,7 @@ */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -64,7 +63,6 @@ #include <rpc/rpc.h> #include <rpcsvc/nis.h> #include <rpcsvc/ypclnt.h> -#include "nsl_stdio_prv.h" #include <nss_dbdefs.h> static const char OPSYS[] = "unix"; @@ -218,10 +216,10 @@ netname2user_files(int *err, char *netname, struct netid_userdata *argp) char *name; char *value; char *res; - __NSL_FILE *fd; + FILE *fd; - fd = __nsl_fopen(NETIDFILE, "r"); - if (fd == (__NSL_FILE *)0) { + fd = fopen(NETIDFILE, "rF"); + if (fd == NULL) { *err = __NSW_UNAVAIL; return (0); } @@ -231,8 +229,8 @@ netname2user_files(int *err, char *netname, struct netid_userdata *argp) * netid uid:grp,grp,grp # for users * netid 0:hostname # for hosts */ - while (!__nsl_feof(fd)) { - res = __nsl_fgets(buf, 512, fd); + while (!feof(fd)) { + res = fgets(buf, 512, fd); if (res == NULL) break; @@ -257,14 +255,14 @@ netname2user_files(int *err, char *netname, struct netid_userdata *argp) *value++ = '\0'; /* nul terminate the name */ if (strcasecmp(name, netname) == 0) { - (void) __nsl_fclose(fd); + (void) fclose(fd); while (isspace(*value)) value++; *err = parse_netid_str(value, argp); return (*err == __NSW_SUCCESS); } } - (void) __nsl_fclose(fd); + (void) fclose(fd); *err = __NSW_NOTFOUND; return (0); } diff --git a/usr/src/lib/libnsl/rpc/openchild.c b/usr/src/lib/libnsl/rpc/openchild.c deleted file mode 100644 index a3bd50f72d..0000000000 --- a/usr/src/lib/libnsl/rpc/openchild.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2006 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" - -/* - * Open two pipes to a child process, one for reading, one for writing. The - * pipes are accessed by FILE pointers. This is NOT a public interface, but - * for internal use only! - */ -#include "mt.h" -#include <stdio.h> -#include <sys/types.h> -#include <rpc/types.h> -#include <unistd.h> -#include <stdlib.h> -#include "rpc_mt.h" - - -/* - * returns pid, or -1 for failure - */ -int -__rpc_openchild(char *command, FILE **fto, FILE **ffrom) -{ - int pid; - int pdto[2]; - int pdfrom[2]; - - if (pipe(pdto) < 0) - goto error1; - if (pipe(pdfrom) < 0) - goto error2; - switch (pid = fork()) { - case -1: - goto error3; - - case 0: - /* - * child: read from pdto[0], write into pdfrom[1] - */ - (void) dup2(pdto[0], 0); - (void) dup2(pdfrom[1], 1); - closefrom(3); - (void) fflush(stderr); - (void) execlp(command, command, 0); - perror("exec"); - _exit(~0); - - default: - /* - * parent: write into pdto[1], read from pdfrom[0] - */ - *fto = fdopen(pdto[1], "w"); - (void) close(pdto[0]); - *ffrom = fdopen(pdfrom[0], "r"); - (void) close(pdfrom[1]); - break; - } - return (pid); - - /* - * error cleanup and return - */ -error3: - (void) close(pdfrom[0]); - (void) close(pdfrom[1]); -error2: - (void) close(pdto[0]); - (void) close(pdto[1]); -error1: - return (-1); -} diff --git a/usr/src/lib/libnsl/rpc/rpc_mt.h b/usr/src/lib/libnsl/rpc/rpc_mt.h index 75e93f390f..02dacdef2d 100644 --- a/usr/src/lib/libnsl/rpc/rpc_mt.h +++ b/usr/src/lib/libnsl/rpc/rpc_mt.h @@ -90,6 +90,11 @@ extern void rpc_fd_unlock(const void *handle, int fd); * way to avoid the warnings. */ +#define RPC_MINFD 3 + +#define RPC_RAISEFD(fd) if (fd < RPC_MINFD) \ + fd = __rpc_raise_fd(fd) + extern int __getpublickey_cached(char *, char *, int *); extern void __getpublickey_flush(const char *); extern int __can_use_af(sa_family_t); diff --git a/usr/src/lib/libnsl/rpc/rpc_soc.c b/usr/src/lib/libnsl/rpc/rpc_soc.c index 2dbf168273..1cb3f56b4e 100644 --- a/usr/src/lib/libnsl/rpc/rpc_soc.c +++ b/usr/src/lib/libnsl/rpc/rpc_soc.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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 * or http://www.opensolaris.org/os/licensing. @@ -21,7 +20,7 @@ */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -83,7 +82,6 @@ clnt_com_create(struct sockaddr_in *raddr, rpcprog_t prog, rpcvers_t vers, struct netconfig *nconf; int port; struct netbuf bindaddr; - extern int __rpc_minfd; bool_t locked = TRUE; (void) mutex_lock(&rpcsoc_lock); @@ -96,8 +94,7 @@ clnt_com_create(struct sockaddr_in *raddr, rpcprog_t prog, rpcvers_t vers, fd = t_open(nconf->nc_device, O_RDWR, &tinfo); if (fd == -1) goto syserror; - if (fd < __rpc_minfd) - fd = __rpc_raise_fd(fd); + RPC_RAISEFD(fd); madefd = TRUE; } else { if (t_getinfo(fd, &tinfo) == -1) diff --git a/usr/src/lib/libnsl/rpc/svc_run.c b/usr/src/lib/libnsl/rpc/svc_run.c index 2d0d5faad8..cb91ad6515 100644 --- a/usr/src/lib/libnsl/rpc/svc_run.c +++ b/usr/src/lib/libnsl/rpc/svc_run.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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 * or http://www.opensolaris.org/os/licensing. @@ -1035,7 +1034,6 @@ bool_t rpc_control(int op, void *info) { int tmp; - extern int __rpc_minfd; switch (op) { case RPC_SVC_MTMODE_SET: @@ -1075,15 +1073,6 @@ rpc_control(int op, void *info) return (TRUE); } return (FALSE); - case __RPC_CLNT_MINFD_SET: - tmp = *((int *)info); - if (tmp < 0) - return (FALSE); - __rpc_minfd = tmp; - return (TRUE); - case __RPC_CLNT_MINFD_GET: - *((int *)info) = __rpc_minfd; - return (TRUE); case RPC_SVC_CONNMAXREC_SET: tmp = __rpc_legal_connmaxrec(*(int *)info); if (tmp >= 0) { diff --git a/usr/src/lib/libnsl/rpc/svc_vc.c b/usr/src/lib/libnsl/rpc/svc_vc.c index 7bb9b35553..dced5a210c 100644 --- a/usr/src/lib/libnsl/rpc/svc_vc.c +++ b/usr/src/lib/libnsl/rpc/svc_vc.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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 * or http://www.opensolaris.org/os/licensing. @@ -789,34 +788,6 @@ do_accept(int srcfd, char *tpname, char *netid, struct t_call *tcp, (void) t_snddis(srcfd, tcp); return; } - if (destfd < 256) { - int nfd; - - nfd = fcntl(destfd, F_DUPFD, 256); - if (nfd != -1) { - if (t_close(destfd) == -1) { - char errorstr[100]; - - __tli_sys_strerror(errorstr, sizeof (errorstr), - t_errno, errno); - (void) syslog(LOG_ERR, - "could not t_close() old fd %d; mem & fd leak error: %s", - destfd, errorstr); - } - destfd = nfd; - if (t_sync(destfd) == -1) { - char errorstr[100]; - - __tli_sys_strerror(errorstr, sizeof (errorstr), - t_errno, errno); - (void) syslog(LOG_ERR, - "could not t_sync() duped fd %d: %s", - destfd, errorstr); - (void) t_snddis(srcfd, tcp); - return; - } - } - } if (RPC_FD_NOTIN_FDSET(destfd)) { (void) syslog(LOG_ERR, errstring, do_accept_str, svc_vc_fderr); diff --git a/usr/src/lib/libnsl/rpc/xdr_stdio_prv.c b/usr/src/lib/libnsl/rpc/xdr_stdio_prv.c deleted file mode 100644 index 4c5f7fd292..0000000000 --- a/usr/src/lib/libnsl/rpc/xdr_stdio_prv.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * XDR implementation on special standard i/o file. - * - * To avoid the file descriptor limitation in stdio, we implement - * a private version of the same routines from xdr_stdio.c using - * modified FILE structure. ( __NSL_FILE ) - * This set of routines implements a XDR on a special stdio stream. - * XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes - * from the stream. - */ - -#include "mt.h" -#include "rpc_mt.h" -#include <rpc/types.h> -#include <stdio.h> -#include <rpc/xdr.h> -#include <sys/types.h> -#include <inttypes.h> -#include "nsl_stdio_prv.h" - -static struct xdr_ops *__nsl_xdrstdio_ops(void); - -/* - * Initialize a stdio xdr stream. - * Sets the xdr stream handle xdrs for use on the stream file. - * Operation flag is set to op. - */ -void -__nsl_xdrstdio_create(XDR *xdrs, __NSL_FILE *file, enum xdr_op op) -{ - xdrs->x_op = op; - xdrs->x_ops = __nsl_xdrstdio_ops(); - xdrs->x_private = (caddr_t)file; - xdrs->x_handy = 0; - xdrs->x_base = 0; -} - -/* - * Destroy a stdio xdr stream. - * Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create. - */ -static void -__nsl_xdrstdio_destroy(XDR *xdrs) -{ - /* LINTED pointer cast */ - (void) __nsl_fflush((__NSL_FILE *)xdrs->x_private); - /* xx should we close the file ?? */ -} - - -static bool_t -__nsl_xdrstdio_getint32(XDR *xdrs, int32_t *lp) -{ - if (__nsl_fread((caddr_t)lp, sizeof (int32_t), 1, - /* LINTED pointer cast */ - (__NSL_FILE *)xdrs->x_private) != 1) - return (FALSE); - *lp = ntohl(*lp); - return (TRUE); -} - -static bool_t -__nsl_xdrstdio_putint32(XDR *xdrs, int32_t *lp) -{ - int32_t mycopy = htonl(*lp); - lp = &mycopy; - - if (__nsl_fwrite((caddr_t)lp, sizeof (int32_t), 1, - /* LINTED pointer cast */ - (__NSL_FILE *)xdrs->x_private) != 1) - return (FALSE); - return (TRUE); -} - -static bool_t -__nsl_xdrstdio_getlong(XDR *xdrs, long *lp) -{ - int32_t i; - - if (!__nsl_xdrstdio_getint32(xdrs, &i)) - return (FALSE); - *lp = (long)i; - return (TRUE); -} - -static bool_t -__nsl_xdrstdio_putlong(XDR *xdrs, long *lp) -{ - int32_t i; - -#if defined(_LP64) - if ((*lp > INT32_MAX) || (*lp < INT32_MIN)) - return (FALSE); -#endif - i = (int32_t)*lp; - - return (__nsl_xdrstdio_putint32(xdrs, &i)); -} - -static bool_t -__nsl_xdrstdio_getbytes(XDR *xdrs, caddr_t addr, int len) -{ - if ((len != 0) && - (__nsl_fread(addr, (int)len, 1, - /* LINTED pointer cast */ - (__NSL_FILE *)xdrs->x_private) != 1)) - return (FALSE); - return (TRUE); -} - -static bool_t -__nsl_xdrstdio_putbytes(XDR *xdrs, caddr_t addr, int len) -{ - if ((len != 0) && - (__nsl_fwrite(addr, (int)len, 1, - /* LINTED pointer cast */ - (__NSL_FILE *)xdrs->x_private) != 1)) - return (FALSE); - return (TRUE); -} - -static uint_t -__nsl_xdrstdio_getpos(XDR *xdrs) -{ - /* LINTED pointer cast */ - return ((uint_t)__nsl_ftell((__NSL_FILE *)xdrs->x_private)); -} - -static bool_t -__nsl_xdrstdio_setpos(XDR *xdrs, uint_t pos) -{ - /* LINTED pointer cast */ - return ((__nsl_fseek((__NSL_FILE *)xdrs->x_private, - (int)pos, 0) < 0) ? FALSE : TRUE); -} - -/* ARGSUSED */ -static rpc_inline_t * -__nsl_xdrstdio_inline(XDR *xdrs, int len) -{ - /* - * Must do some work to implement this: must insure - * enough data in the underlying stdio buffer, - * that the buffer is aligned so that we can indirect through a - * long *, and stuff this pointer in xdrs->x_buf. Doing - * a fread or fwrite to a scratch buffer would defeat - * most of the gains to be had here and require storage - * management on this buffer, so we don't do this. - */ - return (NULL); -} - -/* ARGSUSED */ -static bool_t -__nsl_xdrstdio_control(XDR *xdrs, int request, void *info) -{ - return (FALSE); -} - -static struct xdr_ops * -__nsl_xdrstdio_ops(void) -{ - static struct xdr_ops ops; - extern mutex_t ops_lock; - -/* VARIABLES PROTECTED BY ops_lock: ops */ - - (void) mutex_lock(&ops_lock); - if (ops.x_getlong == NULL) { - ops.x_getlong = __nsl_xdrstdio_getlong; - ops.x_putlong = __nsl_xdrstdio_putlong; - ops.x_getbytes = __nsl_xdrstdio_getbytes; - ops.x_putbytes = __nsl_xdrstdio_putbytes; - ops.x_getpostn = __nsl_xdrstdio_getpos; - ops.x_setpostn = __nsl_xdrstdio_setpos; - ops.x_inline = __nsl_xdrstdio_inline; - ops.x_destroy = __nsl_xdrstdio_destroy; - ops.x_control = __nsl_xdrstdio_control; -#if defined(_LP64) - ops.x_getint32 = __nsl_xdrstdio_getint32; - ops.x_putint32 = __nsl_xdrstdio_putint32; -#endif - } - (void) mutex_unlock(&ops_lock); - return (&ops); -} |
