summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc
diff options
context:
space:
mode:
authorcasper <none@none>2006-05-01 11:23:49 -0700
committercasper <none@none>2006-05-01 11:23:49 -0700
commit004388ebfdfe2ed7dfd2d153a876dfcc22d2c006 (patch)
tree9f3972760e2696f63065521871e50e1440bfbb75 /usr/src/lib/libc
parent0ade2cf005fcaecc5255dacf7d76683de855a9da (diff)
downloadillumos-gate-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/libc')
-rw-r--r--usr/src/lib/libc/inc/nsswitch_priv.h28
-rw-r--r--usr/src/lib/libc/port/gen/crypt.c11
-rw-r--r--usr/src/lib/libc/port/gen/fmtmsg.c9
-rw-r--r--usr/src/lib/libc/port/gen/getgrnam_r.c19
-rw-r--r--usr/src/lib/libc/port/gen/getpw.c9
-rw-r--r--usr/src/lib/libc/port/gen/getusershell.c4
-rw-r--r--usr/src/lib/libc/port/gen/getut.c9
-rw-r--r--usr/src/lib/libc/port/gen/getutx.c11
-rw-r--r--usr/src/lib/libc/port/gen/nsparse.c233
-rw-r--r--usr/src/lib/libc/port/gen/nss_common.c9
-rw-r--r--usr/src/lib/libc/port/gen/priv_str_xlate.c11
-rw-r--r--usr/src/lib/libc/port/gen/ttyslot.c9
-rw-r--r--usr/src/lib/libc/port/regex/wordexp.c9
-rw-r--r--usr/src/lib/libc/port/stdio/getpass.c9
14 files changed, 119 insertions, 261 deletions
diff --git a/usr/src/lib/libc/inc/nsswitch_priv.h b/usr/src/lib/libc/inc/nsswitch_priv.h
index 4dc8027dd0..70baa39fb3 100644
--- a/usr/src/lib/libc/inc/nsswitch_priv.h
+++ b/usr/src/lib/libc/inc/nsswitch_priv.h
@@ -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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -94,23 +93,6 @@ extern "C" {
#define __NSW_STR_FOREVER "forever"
#ifdef __NSS_PRIVATE_INTERFACE
-#define __NSL_FILE_BUF_SIZE 1024
-
-/* To avoid the 256 file descriptor limitation in stdio, we use our own */
-/* private version of stdio functions. A modified FILE structure is used */
-/* in our private stdio functions. We support only read mode access in */
-/* this private stdio implementation. */
-
-typedef struct {
- unsigned char *_nsl_base; /* __NSL_FILE_BUF_SIZE */
- int _nsl_file; /* an integer datatype to hold */
- /* the file pointer */
-
- int _nsl_cnt; /* number of bytes available to read */
- /* in the buffer */
-
- unsigned char *_nsl_ptr; /* location of next byte in buffer to read */
-} __NSL_FILE;
struct __nsw_lookup_v1 {
char *service_name;
@@ -142,10 +124,6 @@ struct __nsw_switchconfig_v1 *__nsw_getconfig_v1
int __nsw_freeconfig_v1(struct __nsw_switchconfig_v1 *);
action_t __nsw_extended_action_v1(struct __nsw_lookup_v1 *, int);
-extern __NSL_FILE *__nsl_c_fopen(const char *filename, const char *mode);
-extern int __nsl_c_fclose(__NSL_FILE *stream);
-extern char *__nsl_c_fgets(char *s, int n, __NSL_FILE *stream);
-
#endif /* __NSS_PRIVATE_INTERFACE */
#ifdef __cplusplus
diff --git a/usr/src/lib/libc/port/gen/crypt.c b/usr/src/lib/libc/port/gen/crypt.c
index f24c732924..52286d4822 100644
--- a/usr/src/lib/libc/port/gen/crypt.c
+++ b/usr/src/lib/libc/port/gen/crypt.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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -374,7 +373,7 @@ getcryptpolicy(void)
char line[BUFSIZ];
struct crypt_policy_s *policy;
- if ((pconf = fopen(POLICY_CONF_FILE, "r")) == NULL) {
+ if ((pconf = fopen(POLICY_CONF_FILE, "rF")) == NULL) {
return (NULL);
}
@@ -539,7 +538,7 @@ getalgbyname(const char *algname, boolean_t *found)
goto cleanup;
}
- if ((fconf = fdopen(configfd, "r")) == NULL) {
+ if ((fconf = fdopen(configfd, "rF")) == NULL) {
syslog(LOG_ALERT, "crypt: fdopen(%d) failed: %s",
configfd, strerror(errno));
goto cleanup;
diff --git a/usr/src/lib/libc/port/gen/fmtmsg.c b/usr/src/lib/libc/port/gen/fmtmsg.c
index 0d55d9f6b5..50a0fdbabb 100644
--- a/usr/src/lib/libc/port/gen/fmtmsg.c
+++ b/usr/src/lib/libc/port/gen/fmtmsg.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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -1150,7 +1149,7 @@ const char *text, const char *action, const char *tag)
/* Write the message to the console if requested */
if (class & MM_CONSOLE) {
- if ((console = fopen(CONNAME, "w")) != NULL) {
+ if ((console = fopen(CONNAME, "wF")) != NULL) {
clearerr(console);
(void) fputs(message2, console);
if (ferror(console))
diff --git a/usr/src/lib/libc/port/gen/getgrnam_r.c b/usr/src/lib/libc/port/gen/getgrnam_r.c
index 8dc3d85111..adaa8ce918 100644
--- a/usr/src/lib/libc/port/gen/getgrnam_r.c
+++ b/usr/src/lib/libc/port/gen/getgrnam_r.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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -48,10 +47,6 @@
#include <sys/param.h>
#include <sys/mman.h>
-#define __NSS_PRIVATE_INTERFACE
-#include "nsswitch_priv.h"
-#undef __NSS_PRIVATE_INTERFACE
-
extern int _getgroupsbymember(const char *, gid_t[], int, int);
int str2group(const char *, int, void *,
char *, int);
@@ -467,7 +462,7 @@ _getgroupsbymember(const char *username, gid_t gid_array[],
{
struct nss_groupsbymem arg;
char defval[BUFSIZ];
- __NSL_FILE *defl;
+ FILE *defl;
arg.username = username;
arg.gid_array = gid_array;
@@ -496,15 +491,15 @@ _getgroupsbymember(const char *username, gid_t gid_array[],
* link ourselfs against libcmd, so instead we just do it by hand
*/
- if ((defl = __nsl_c_fopen(__NSW_DEFAULT_FILE, "r")) != NULL) {
- while (__nsl_c_fgets(defval, sizeof (defval), defl) != NULL) {
+ if ((defl = fopen(__NSW_DEFAULT_FILE, "rF")) != NULL) {
+ while (fgets(defval, sizeof (defval), defl) != NULL) {
if (strncmp(USE_NETID_STR, defval,
sizeof (USE_NETID_STR) - 1) == 0) {
arg.force_slow_way = 0;
break;
}
}
- (void) __nsl_c_fclose(defl);
+ (void) fclose(defl);
}
(void) nss_search(&db_root, _nss_initf_group,
diff --git a/usr/src/lib/libc/port/gen/getpw.c b/usr/src/lib/libc/port/gen/getpw.c
index bcef781b48..9155894497 100644
--- a/usr/src/lib/libc/port/gen/getpw.c
+++ b/usr/src/lib/libc/port/gen/getpw.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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -57,7 +56,7 @@ getpw(uid_t uid, char buf[])
rmutex_t *lk;
if (pwf == NULL) {
- fp = fopen(PASSWD, "r");
+ fp = fopen(PASSWD, "rF");
lmutex_lock(&_pwlock);
if (pwf == NULL) {
if ((pwf = fp) == NULL) {
diff --git a/usr/src/lib/libc/port/gen/getusershell.c b/usr/src/lib/libc/port/gen/getusershell.c
index b7edd9e4dd..289ae3c4a2 100644
--- a/usr/src/lib/libc/port/gen/getusershell.c
+++ b/usr/src/lib/libc/port/gen/getusershell.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -113,7 +113,7 @@ initshells(void)
if (strings != NULL)
(void) free(strings);
strings = NULL;
- if ((fp = fopen(SHELLS, "r")) == (FILE *)0)
+ if ((fp = fopen(SHELLS, "rF")) == (FILE *)0)
return ((char **)okshells);
/*
* The +1 in the malloc() below is needed to handle the final
diff --git a/usr/src/lib/libc/port/gen/getut.c b/usr/src/lib/libc/port/gen/getut.c
index 87b4a660f2..e60a041b23 100644
--- a/usr/src/lib/libc/port/gen/getut.c
+++ b/usr/src/lib/libc/port/gen/getut.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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -705,7 +704,7 @@ gdebug(const char *fmt, ...)
int errnum;
va_list ap;
- if ((fp = fopen("/etc/dbg.getut", "a+")) == NULL)
+ if ((fp = fopen("/etc/dbg.getut", "a+F")) == NULL)
return;
va_start(ap, fmt);
(void) vfprintf(fp, fmt, ap);
diff --git a/usr/src/lib/libc/port/gen/getutx.c b/usr/src/lib/libc/port/gen/getutx.c
index 73a1c5cf32..c091a27013 100644
--- a/usr/src/lib/libc/port/gen/getutx.c
+++ b/usr/src/lib/libc/port/gen/getutx.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.
*/
@@ -226,7 +225,7 @@ getutxent_frec(void)
if ((fd = open(utmpxfile, O_RDONLY)) < 0)
return (NULL);
- if ((fp = fopen(utmpxfile, "r")) == NULL) {
+ if ((fp = fopen(utmpxfile, "rF")) == NULL) {
(void) close(fd);
fd = -1;
return (NULL);
@@ -236,7 +235,7 @@ getutxent_frec(void)
/*
* Get the stream pointer
*/
- if ((fp = fopen(utmpxfile, "r+")) == NULL) {
+ if ((fp = fopen(utmpxfile, "r+F")) == NULL) {
(void) close(fd);
fd = -1;
return (NULL);
diff --git a/usr/src/lib/libc/port/gen/nsparse.c b/usr/src/lib/libc/port/gen/nsparse.c
index ab879934cf..6af1f25278 100644
--- a/usr/src/lib/libc/port/gen/nsparse.c
+++ b/usr/src/lib/libc/port/gen/nsparse.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.
@@ -20,26 +19,27 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "synonyms.h"
+#include "file64.h"
#include "mtlib.h"
#include "libc.h"
#include <synch.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
+#include <stdio_ext.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <dlfcn.h>
-#include <fcntl.h>
-#include <unistd.h>
#include <errno.h>
+#include "stdiom.h"
#define __NSS_PRIVATE_INTERFACE
#include "nsswitch_priv.h"
@@ -489,37 +489,63 @@ syslog_warning(const char *dbase)
dbase, __NSW_CONFIG_FILE);
}
+/*
+ * Since we cannot call malloc() or lock any of the ordinary mutexes
+ * while we hold an lmutex_lock(), we open the file outside the lock
+ * and disable locking on the file; the latter is fine because we're
+ * reading the fp only from a single thread.
+ */
+static FILE *
+open_conf(void)
+{
+ FILE *fp = fopen(__NSW_CONFIG_FILE, "rF");
+
+ if (fp != NULL) {
+ if (_findbuf(fp) == NULL) {
+ (void) fclose(fp);
+ return (NULL);
+ }
+ SET_IONOLOCK(fp);
+ }
+ return (fp);
+}
+
struct __nsw_switchconfig_v1 *
__nsw_getconfig_v1(const char *dbase, enum __nsw_parse_err *errp)
{
struct __nsw_switchconfig_v1 *cfp, *retp = NULL;
int syslog_error = 0;
- __NSL_FILE *fp;
+ FILE *fp = NULL;
char *linep;
char lineq[BUFSIZ];
- /*
- * ==== I don't feel entirely comfortable disabling signals for the
- * duration of this, but maybe we have to. Or maybe we should
- * use mutex_trylock to detect recursion? (Not clear what's
- * the right thing to do when it happens, though).
- */
lmutex_lock(&serialize_config_v1);
-
+top:
if (cfp = scrounge_cache_v1(dbase)) {
*errp = __NSW_CONF_PARSE_SUCCESS;
lmutex_unlock(&serialize_config_v1);
+ if (fp != NULL)
+ (void) fclose(fp);
return (cfp);
}
- if ((fp = __nsl_c_fopen(__NSW_CONFIG_FILE, "r")) == NULL) {
- *errp = __NSW_CONF_PARSE_NOFILE;
+ if (fp == NULL) {
+ struct cons_cell_v1 *cp = concell_list_v1;
+
lmutex_unlock(&serialize_config_v1);
- return (NULL);
+ /* open_conf() must be called w/o locks held */
+ if ((fp = open_conf()) == NULL) {
+ *errp = __NSW_CONF_PARSE_NOFILE;
+ return (NULL);
+ }
+ lmutex_lock(&serialize_config_v1);
+ /* Cache changed? */
+ if (cp != concell_list_v1)
+ goto top;
}
*errp = __NSW_CONF_PARSE_NOPOLICY;
- while (linep = __nsl_c_fgets(lineq, BUFSIZ, fp)) {
+ while (linep = fgets(lineq, BUFSIZ, fp)) {
enum __nsw_parse_err line_err;
char *tokenp, *comment;
@@ -572,11 +598,11 @@ __nsw_getconfig_v1(const char *dbase, enum __nsw_parse_err *errp)
*/
}
}
- (void) __nsl_c_fclose(fp);
lmutex_unlock(&serialize_config_v1);
/*
- * We have to drop the lock before calling syslog().
+ * We have to drop the lock before calling fclose()/syslog().
*/
+ (void) fclose(fp);
if (syslog_error)
syslog_warning(dbase);
return (retp);
@@ -587,32 +613,36 @@ __nsw_getconfig(const char *dbase, enum __nsw_parse_err *errp)
{
struct __nsw_switchconfig *cfp, *retp = NULL;
int syslog_error = 0;
- __NSL_FILE *fp;
+ FILE *fp = NULL;
char *linep;
char lineq[BUFSIZ];
- /*
- * ==== I don't feel entirely comfortable disabling signals for the
- * duration of this, but maybe we have to. Or maybe we should
- * use mutex_trylock to detect recursion? (Not clear what's
- * the right thing to do when it happens, though).
- */
lmutex_lock(&serialize_config);
-
+top:
if (cfp = scrounge_cache(dbase)) {
*errp = __NSW_CONF_PARSE_SUCCESS;
lmutex_unlock(&serialize_config);
+ if (fp != NULL)
+ (void) fclose(fp);
return (cfp);
}
- if ((fp = __nsl_c_fopen(__NSW_CONFIG_FILE, "r")) == NULL) {
- *errp = __NSW_CONF_PARSE_NOFILE;
+ if (fp == NULL) {
+ struct cons_cell *cp = concell_list;
+ /* open_conf() must be called w/o locks held */
lmutex_unlock(&serialize_config);
- return (NULL);
+ if ((fp = open_conf()) == NULL) {
+ *errp = __NSW_CONF_PARSE_NOFILE;
+ return (NULL);
+ }
+ lmutex_lock(&serialize_config);
+ /* Cache changed? */
+ if (cp != concell_list)
+ goto top;
}
*errp = __NSW_CONF_PARSE_NOPOLICY;
- while (linep = __nsl_c_fgets(lineq, BUFSIZ, fp)) {
+ while (linep = fgets(lineq, BUFSIZ, fp)) {
enum __nsw_parse_err line_err;
char *tokenp, *comment;
@@ -665,11 +695,11 @@ __nsw_getconfig(const char *dbase, enum __nsw_parse_err *errp)
*/
}
}
- (void) __nsl_c_fclose(fp);
lmutex_unlock(&serialize_config);
/*
- * We have to drop the lock before calling syslog().
+ * We have to drop the lock before calling fclose()/syslog().
*/
+ (void) fclose(fp);
if (syslog_error)
syslog_warning(dbase);
return (retp);
@@ -918,138 +948,3 @@ alldigits(char *s)
return (0);
return (1);
}
-
-
-/*
- * To avoid the 256 open file descriptor limitation in stdio,
- * we are using a private limited implementation of stdio calls.
- * The private implementation is closely based on the implementation
- * in the standard C library.
- * To simplify, certain assumptions are made:
- * - a file may be opened only in read mode.
- * - Only sequential reads allowed
- * - file descriptors should not be shared between threads
- */
-
-static int
-_raise_fd(int fd)
-{
- int nfd;
- static const int min_fd = 256;
-
- if (fd >= min_fd)
- return (fd);
-
- if ((nfd = fcntl(fd, F_DUPFD, min_fd)) == -1) {
- /*
- * If the shell limits [See limit(1)] the
- * descriptors to 256, fcntl will fail
- * and errno will be set to EINVAL. Since
- * the intention is to ignore fcntl failures
- * and continue working with 'fd', we should
- * reset errno to _prevent_ apps relying on errno
- * to treat this as an error.
- */
- errno = 0;
- return (fd);
- }
-
- (void) close(fd);
-
- return (nfd);
-}
-
-__NSL_FILE *
-__nsl_c_fopen(const char *filename, const char *mode)
-{
- int fd;
- __NSL_FILE *stream;
- void *buf;
-
- if (mode == NULL || filename == NULL) {
- return (NULL);
- }
-
- if (strcmp(mode, "r") != 0) {
- return (NULL);
- }
-
- fd = open(filename, O_RDONLY | O_LARGEFILE, 0666);
- if (fd < 0)
- return (NULL);
-
- stream = libc_malloc(sizeof (__NSL_FILE));
- buf = lmalloc(__NSL_FILE_BUF_SIZE);
- if (stream != NULL && buf != NULL) {
- stream->_nsl_base = buf;
- stream->_nsl_file = _raise_fd(fd);
- stream->_nsl_cnt = 0;
- stream->_nsl_ptr = stream->_nsl_base;
- } else {
- (void) close(fd);
- if (buf)
- lfree(buf, __NSL_FILE_BUF_SIZE);
- if (stream)
- libc_free(stream);
- stream = NULL;
- }
-
- return (stream);
-}
-
-int
-__nsl_c_fclose(__NSL_FILE *stream)
-{
- int res = 0;
-
- if (stream == NULL)
- return (EOF);
-
- if (close(stream->_nsl_file) < 0)
- res = EOF;
-
- lfree(stream->_nsl_base, __NSL_FILE_BUF_SIZE);
- libc_free(stream);
-
- return (res);
-}
-
-char *
-__nsl_c_fgets(char *buf, int size, __NSL_FILE *stream)
-{
- char *ptr = buf;
- char *p;
- int n;
- int res;
-
- size--; /* room for '\0' */
- while (size > 0) {
- if (stream->_nsl_cnt == 0) {
- stream->_nsl_ptr = stream->_nsl_base;
-
- if ((res = read(stream->_nsl_file, stream->_nsl_base,
- __NSL_FILE_BUF_SIZE)) > 0) {
- stream->_nsl_cnt = res;
- } else {
- stream->_nsl_cnt = 0;
- break;
- }
- }
- n = (int)(size < stream->_nsl_cnt ? size : stream->_nsl_cnt);
- if ((p = memccpy(ptr, (char *)stream->_nsl_ptr, '\n',
- (size_t)n)) != NULL)
- n = (int)(p - ptr);
- ptr += n;
- stream->_nsl_cnt -= n;
- stream->_nsl_ptr += n;
- if (p != NULL)
- break; /* newline found */
- size -= n;
- }
-
- if (ptr == buf) /* never read anything */
- return (NULL);
-
- *ptr = '\0';
- return (buf);
-}
diff --git a/usr/src/lib/libc/port/gen/nss_common.c b/usr/src/lib/libc/port/gen/nss_common.c
index a233cbd40b..ad27e0f807 100644
--- a/usr/src/lib/libc/port/gen/nss_common.c
+++ b/usr/src/lib/libc/port/gen/nss_common.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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -206,7 +205,7 @@ set_option(struct option *opt, char *name, char *val)
break;
#ifdef DEBUG
case OPT_FILE:
- fp = fopen(val, "w");
+ fp = fopen(val, "wF");
*((FILE **)opt->address) = fp;
break;
#endif
diff --git a/usr/src/lib/libc/port/gen/priv_str_xlate.c b/usr/src/lib/libc/port/gen/priv_str_xlate.c
index 90e16ee580..4fa3e86f9d 100644
--- a/usr/src/lib/libc/port/gen/priv_str_xlate.c
+++ b/usr/src/lib/libc/port/gen/priv_str_xlate.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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -364,11 +363,11 @@ priv_gettext(const char *priv)
if (snprintf(file, sizeof (file),
_DFLT_LOC_PATH "%s/LC_MESSAGES/priv_names", loc) < sizeof (file))
- namefp = fopen(file, "r");
+ namefp = fopen(file, "rF");
/* If the path is too long or can't be opened, punt to default */
if (namefp == NULL)
- namefp = fopen("/etc/security/priv_names", "r");
+ namefp = fopen("/etc/security/priv_names", "rF");
if (namefp == NULL)
return (NULL);
diff --git a/usr/src/lib/libc/port/gen/ttyslot.c b/usr/src/lib/libc/port/gen/ttyslot.c
index 2a3e2b3423..f8921bac65 100644
--- a/usr/src/lib/libc/port/gen/ttyslot.c
+++ b/usr/src/lib/libc/port/gen/ttyslot.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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -75,7 +74,7 @@ ttyslot(void)
console = TRUE;
s = 0;
- if ((fp = fopen(UTMPX_FILE, "r")) == NULL)
+ if ((fp = fopen(UTMPX_FILE, "rF")) == NULL)
return (-1);
while ((fread(&ubuf, sizeof (ubuf), 1, fp)) == 1) {
if ((ubuf.ut_type == INIT_PROCESS ||
diff --git a/usr/src/lib/libc/port/regex/wordexp.c b/usr/src/lib/libc/port/regex/wordexp.c
index 812889826b..ec83da4dee 100644
--- a/usr/src/lib/libc/port/regex/wordexp.c
+++ b/usr/src/lib/libc/port/regex/wordexp.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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -206,7 +205,7 @@ wordexp(const char *word, wordexp_t *wp, int flags)
(void) close(pv[1]);
- if ((fp = fdopen(pv[0], "rb")) == NULL) {
+ if ((fp = fdopen(pv[0], "rF")) == NULL) {
serrno = errno;
(void) close(pv[0]);
errno = serrno;
diff --git a/usr/src/lib/libc/port/stdio/getpass.c b/usr/src/lib/libc/port/stdio/getpass.c
index 379fe24238..b25ef5efa6 100644
--- a/usr/src/lib/libc/port/stdio/getpass.c
+++ b/usr/src/lib/libc/port/stdio/getpass.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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -81,7 +80,7 @@ __getpass(const char *prompt, int size)
rmutex_t *lk;
if (pbuf == NULL ||
- (fi = fopen("/dev/tty", "r")) == NULL)
+ (fi = fopen("/dev/tty", "rF")) == NULL)
return (NULL);
setbuf(fi, NULL);
sig = signal(SIGINT, catch);