summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2012-12-10 17:56:51 +0000
committerjilles <jilles@FreeBSD.org>2012-12-10 17:56:51 +0000
commitc8062fa2a473cce32f1049fa8353dea6b9cdb3f2 (patch)
tree9f5cc2b7405bf9c939ab0a429b81f41e3fce190b /lib/libc
parent8f8a6363fa6769d8a9a530131101dfc5972b9cc9 (diff)
downloadFreeBSD-src-c8062fa2a473cce32f1049fa8353dea6b9cdb3f2.zip
FreeBSD-src-c8062fa2a473cce32f1049fa8353dea6b9cdb3f2.tar.gz
libc: Make various internal file descriptors close-on-exec.
These are obtained via fopen().
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/fmtmsg.c2
-rw-r--r--lib/libc/gen/getcap.c4
-rw-r--r--lib/libc/gen/getgrent.c8
-rw-r--r--lib/libc/gen/getnetgrent.c4
-rw-r--r--lib/libc/gen/getttyent.c2
-rw-r--r--lib/libc/gen/getusershell.c2
-rw-r--r--lib/libc/gen/getutxent.c2
7 files changed, 12 insertions, 12 deletions
diff --git a/lib/libc/gen/fmtmsg.c b/lib/libc/gen/fmtmsg.c
index c6ecbd5..d2c67a6 100644
--- a/lib/libc/gen/fmtmsg.c
+++ b/lib/libc/gen/fmtmsg.c
@@ -83,7 +83,7 @@ def:
if (output == NULL)
return (MM_NOCON);
if (*output != '\0') {
- if ((fp = fopen("/dev/console", "a")) == NULL) {
+ if ((fp = fopen("/dev/console", "ae")) == NULL) {
free(output);
return (MM_NOCON);
}
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
index c321d12..f2f3777 100644
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -654,7 +654,7 @@ cgetnext(char **bp, char **db_array)
if (dbp == NULL)
dbp = db_array;
- if (pfp == NULL && (pfp = fopen(*dbp, "r")) == NULL) {
+ if (pfp == NULL && (pfp = fopen(*dbp, "re")) == NULL) {
(void)cgetclose();
return (-1);
}
@@ -679,7 +679,7 @@ cgetnext(char **bp, char **db_array)
(void)cgetclose();
return (0);
} else if ((pfp =
- fopen(*dbp, "r")) == NULL) {
+ fopen(*dbp, "re")) == NULL) {
(void)cgetclose();
return (-1);
} else
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index 18f64a8..f9480c3 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -810,7 +810,7 @@ files_setgrent(void *retval, void *mdata, va_list ap)
if (st->fp != NULL)
rewind(st->fp);
else if (stayopen)
- st->fp = fopen(_PATH_GROUP, "r");
+ st->fp = fopen(_PATH_GROUP, "re");
break;
case ENDGRENT:
if (st->fp != NULL) {
@@ -861,7 +861,7 @@ files_group(void *retval, void *mdata, va_list ap)
if (*errnop != 0)
return (NS_UNAVAIL);
if (st->fp == NULL &&
- ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
+ ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
*errnop = errno;
return (NS_UNAVAIL);
}
@@ -1251,7 +1251,7 @@ compat_setgrent(void *retval, void *mdata, va_list ap)
if (st->fp != NULL)
rewind(st->fp);
else if (stayopen)
- st->fp = fopen(_PATH_GROUP, "r");
+ st->fp = fopen(_PATH_GROUP, "re");
set_setent(dtab, mdata);
(void)_nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgrent",
compatsrc, 0);
@@ -1335,7 +1335,7 @@ compat_group(void *retval, void *mdata, va_list ap)
if (*errnop != 0)
return (NS_UNAVAIL);
if (st->fp == NULL &&
- ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
+ ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
*errnop = errno;
rv = NS_UNAVAIL;
goto fin;
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index 51b3e37..4c56461 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -173,7 +173,7 @@ setnetgrent(const char *group)
if (((stat(_PATH_NETGROUP, &_yp_statp) < 0) &&
errno == ENOENT) || _yp_statp.st_size == 0)
_use_only_yp = _netgr_yp_enabled = 1;
- if ((netf = fopen(_PATH_NETGROUP,"r")) != NULL ||_use_only_yp){
+ if ((netf = fopen(_PATH_NETGROUP,"re")) != NULL ||_use_only_yp){
/*
* Icky: grab the first character of the netgroup file
* and turn on NIS if it's a '+'. rewind the stream
@@ -197,7 +197,7 @@ setnetgrent(const char *group)
return;
}
#else
- if ((netf = fopen(_PATH_NETGROUP, "r"))) {
+ if ((netf = fopen(_PATH_NETGROUP, "re"))) {
#endif
if (parse_netgrp(group))
endnetgrent();
diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c
index f2fc298..b82c30a 100644
--- a/lib/libc/gen/getttyent.c
+++ b/lib/libc/gen/getttyent.c
@@ -211,7 +211,7 @@ setttyent(void)
if (tf) {
rewind(tf);
return (1);
- } else if ( (tf = fopen(_PATH_TTYS, "r")) )
+ } else if ( (tf = fopen(_PATH_TTYS, "re")) )
return (1);
return (0);
}
diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c
index ce50069..53536e1 100644
--- a/lib/libc/gen/getusershell.c
+++ b/lib/libc/gen/getusershell.c
@@ -115,7 +115,7 @@ _local_initshells(rv, cb_data, ap)
sl_free(sl, 1);
sl = sl_init();
- if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
+ if ((fp = fopen(_PATH_SHELLS, "re")) == NULL)
return NS_UNAVAIL;
cp = line;
diff --git a/lib/libc/gen/getutxent.c b/lib/libc/gen/getutxent.c
index a2e938a..20e8859 100644
--- a/lib/libc/gen/getutxent.c
+++ b/lib/libc/gen/getutxent.c
@@ -71,7 +71,7 @@ setutxdb(int db, const char *file)
if (uf != NULL)
fclose(uf);
- uf = fopen(file, "r");
+ uf = fopen(file, "re");
if (uf == NULL)
return (-1);
OpenPOWER on IntegriCloud