summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-08-23 13:59:47 +0000
committerjilles <jilles@FreeBSD.org>2013-08-23 13:59:47 +0000
commitd2eb50cd0ca5fb81f2abdfd917bf5c0ce0fe9ac7 (patch)
treed650118b386b9cb389244a97e437c1de9f858ca2 /lib
parent6d81dda61eb6274ed572fd3fdecf93ea3d0c679f (diff)
downloadFreeBSD-src-d2eb50cd0ca5fb81f2abdfd917bf5c0ce0fe9ac7.zip
FreeBSD-src-d2eb50cd0ca5fb81f2abdfd917bf5c0ce0fe9ac7.tar.gz
libc: Make various internal file descriptors from fopen() close-on-exec.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/ether_addr.c4
-rw-r--r--lib/libc/net/eui64.c4
-rw-r--r--lib/libc/net/getaddrinfo.c4
-rw-r--r--lib/libc/net/gethostbyht.c4
-rw-r--r--lib/libc/net/getnetbyht.c4
-rw-r--r--lib/libc/net/getprotoent.c4
-rw-r--r--lib/libc/net/getservent.c4
-rw-r--r--lib/libc/net/hesiod.c2
-rw-r--r--lib/libc/net/nsdispatch.c2
-rw-r--r--lib/libc/net/rcmd.c4
-rw-r--r--lib/libc/posix1e/mac.c2
-rw-r--r--lib/libc/resolv/res_init.c2
-rw-r--r--lib/libc/resolv/res_query.c2
13 files changed, 21 insertions, 21 deletions
diff --git a/lib/libc/net/ether_addr.c b/lib/libc/net/ether_addr.c
index d769f27..5d72606 100644
--- a/lib/libc/net/ether_addr.c
+++ b/lib/libc/net/ether_addr.c
@@ -148,7 +148,7 @@ ether_ntohost(char *hostname, const struct ether_addr *e)
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_ETHERS, "r")) == NULL)
+ if ((fp = fopen(_PATH_ETHERS, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
if (buf[0] == '#')
@@ -197,7 +197,7 @@ ether_hostton(const char *hostname, struct ether_addr *e)
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_ETHERS, "r")) == NULL)
+ if ((fp = fopen(_PATH_ETHERS, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
if (buf[0] == '#')
diff --git a/lib/libc/net/eui64.c b/lib/libc/net/eui64.c
index 5085167..d9ed76c 100644
--- a/lib/libc/net/eui64.c
+++ b/lib/libc/net/eui64.c
@@ -227,7 +227,7 @@ eui64_ntohost(char *hostname, size_t len, const struct eui64 *id)
char eui64_a[24];
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_EUI64, "r")) == NULL)
+ if ((fp = fopen(_PATH_EUI64, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
@@ -277,7 +277,7 @@ eui64_hostton(const char *hostname, struct eui64 *id)
int resultlen;
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_EUI64, "r")) == NULL)
+ if ((fp = fopen(_PATH_EUI64, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index d11ff78..c6af6d8 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -2240,7 +2240,7 @@ static void
_sethtent(FILE **hostf)
{
if (!*hostf)
- *hostf = fopen(_PATH_HOSTS, "r");
+ *hostf = fopen(_PATH_HOSTS, "re");
else
rewind(*hostf);
}
@@ -2264,7 +2264,7 @@ _gethtent(FILE **hostf, const char *name, const struct addrinfo *pai)
const char *addr;
char hostbuf[8*1024];
- if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "r")))
+ if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "re")))
return (NULL);
again:
if (!(p = fgets(hostbuf, sizeof hostbuf, *hostf)))
diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c
index 4253d49..1468afb 100644
--- a/lib/libc/net/gethostbyht.c
+++ b/lib/libc/net/gethostbyht.c
@@ -72,7 +72,7 @@ void
_sethosthtent(int f, struct hostent_data *hed)
{
if (!hed->hostf)
- hed->hostf = fopen(_PATH_HOSTS, "r");
+ hed->hostf = fopen(_PATH_HOSTS, "re");
else
rewind(hed->hostf);
hed->stayopen = f;
@@ -96,7 +96,7 @@ gethostent_p(struct hostent *he, struct hostent_data *hed, int mapped,
int af, len;
char hostbuf[BUFSIZ + 1];
- if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "r"))) {
+ if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "re"))) {
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
return (-1);
}
diff --git a/lib/libc/net/getnetbyht.c b/lib/libc/net/getnetbyht.c
index d2df570..bee00e8 100644
--- a/lib/libc/net/getnetbyht.c
+++ b/lib/libc/net/getnetbyht.c
@@ -63,7 +63,7 @@ _setnethtent(int f, struct netent_data *ned)
{
if (ned->netf == NULL)
- ned->netf = fopen(_PATH_NETWORKS, "r");
+ ned->netf = fopen(_PATH_NETWORKS, "re");
else
rewind(ned->netf);
ned->stayopen |= f;
@@ -89,7 +89,7 @@ getnetent_p(struct netent *ne, struct netent_data *ned)
char line[BUFSIZ + 1];
if (ned->netf == NULL &&
- (ned->netf = fopen(_PATH_NETWORKS, "r")) == NULL)
+ (ned->netf = fopen(_PATH_NETWORKS, "re")) == NULL)
return (-1);
again:
p = fgets(line, sizeof line, ned->netf);
diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c
index 0cfca45..114069a 100644
--- a/lib/libc/net/getprotoent.c
+++ b/lib/libc/net/getprotoent.c
@@ -342,7 +342,7 @@ void
__setprotoent_p(int f, struct protoent_data *ped)
{
if (ped->fp == NULL)
- ped->fp = fopen(_PATH_PROTOCOLS, "r");
+ ped->fp = fopen(_PATH_PROTOCOLS, "re");
else
rewind(ped->fp);
ped->stayopen |= f;
@@ -365,7 +365,7 @@ __getprotoent_p(struct protoent *pe, struct protoent_data *ped)
char *cp, **q, *endp;
long l;
- if (ped->fp == NULL && (ped->fp = fopen(_PATH_PROTOCOLS, "r")) == NULL)
+ if (ped->fp == NULL && (ped->fp = fopen(_PATH_PROTOCOLS, "re")) == NULL)
return (-1);
again:
if ((p = fgets(ped->line, sizeof ped->line, ped->fp)) == NULL)
diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c
index 3228bdc..005de98 100644
--- a/lib/libc/net/getservent.c
+++ b/lib/libc/net/getservent.c
@@ -335,7 +335,7 @@ files_servent(void *retval, void *mdata, va_list ap)
if (st->fp == NULL)
st->compat_mode_active = 0;
- if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "r")) == NULL) {
+ if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "re")) == NULL) {
*errnop = errno;
return (NS_UNAVAIL);
}
@@ -449,7 +449,7 @@ files_setservent(void *retval, void *mdata, va_list ap)
case SETSERVENT:
f = va_arg(ap,int);
if (st->fp == NULL)
- st->fp = fopen(_PATH_SERVICES, "r");
+ st->fp = fopen(_PATH_SERVICES, "re");
else
rewind(st->fp);
st->stayopen |= f;
diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c
index 2413727..4258993 100644
--- a/lib/libc/net/hesiod.c
+++ b/lib/libc/net/hesiod.c
@@ -286,7 +286,7 @@ read_config_file(ctx, filename)
ctx->classes[1] = C_HS;
/* Try to open the configuration file. */
- fp = fopen(filename, "r");
+ fp = fopen(filename, "re");
if (!fp) {
/* Use compiled in default domain names. */
ctx->lhs = strdup(DEF_LHS);
diff --git a/lib/libc/net/nsdispatch.c b/lib/libc/net/nsdispatch.c
index 9b7c29b..4fbc9ba 100644
--- a/lib/libc/net/nsdispatch.c
+++ b/lib/libc/net/nsdispatch.c
@@ -361,7 +361,7 @@ nss_configure(void)
if (result != 0)
goto fin2;
}
- _nsyyin = fopen(path, "r");
+ _nsyyin = fopen(path, "re");
if (_nsyyin == NULL)
goto fin;
VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap),
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c
index 990289a..2885dc3 100644
--- a/lib/libc/net/rcmd.c
+++ b/lib/libc/net/rcmd.c
@@ -458,7 +458,7 @@ iruserok_sa(ra, rlen, superuser, ruser, luser)
raddr = (struct sockaddr *)&ss;
first = 1;
- hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r");
+ hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "re");
again:
if (hostf) {
if (__ivaliduser_sa(hostf, raddr, rlen, luser, ruser) == 0) {
@@ -481,7 +481,7 @@ again:
*/
uid = geteuid();
(void)seteuid(pwd->pw_uid);
- hostf = fopen(pbuf, "r");
+ hostf = fopen(pbuf, "re");
(void)seteuid(uid);
if (hostf == NULL)
diff --git a/lib/libc/posix1e/mac.c b/lib/libc/posix1e/mac.c
index 62a74ee..6bc9b77 100644
--- a/lib/libc/posix1e/mac.c
+++ b/lib/libc/posix1e/mac.c
@@ -179,7 +179,7 @@ mac_init_internal(int ignore_errors)
filename = getenv("MAC_CONFFILE");
else
filename = MAC_CONFFILE;
- file = fopen(filename, "r");
+ file = fopen(filename, "re");
if (file == NULL)
return (0);
diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c
index 661e880..5193c1d 100644
--- a/lib/libc/resolv/res_init.c
+++ b/lib/libc/resolv/res_init.c
@@ -304,7 +304,7 @@ __res_vinit(res_state statp, int preinit) {
line[sizeof(name) - 1] == '\t'))
nserv = 0;
- if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
+ if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) {
/* read the config file */
while (fgets(buf, sizeof(buf), fp) != NULL) {
/* skip comments */
diff --git a/lib/libc/resolv/res_query.c b/lib/libc/resolv/res_query.c
index 746a2be..854909c 100644
--- a/lib/libc/resolv/res_query.c
+++ b/lib/libc/resolv/res_query.c
@@ -457,7 +457,7 @@ res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) {
if (issetugid())
return (NULL);
file = getenv("HOSTALIASES");
- if (file == NULL || (fp = fopen(file, "r")) == NULL)
+ if (file == NULL || (fp = fopen(file, "re")) == NULL)
return (NULL);
setbuf(fp, NULL);
buf[sizeof(buf) - 1] = '\0';
OpenPOWER on IntegriCloud