Author: jilles
Date: Fri Aug 23 13:59:47 2013
New Revision: 254700
URL: http://svnweb.freebsd.org/changeset/base/254700

Log:
  libc: Make various internal file descriptors from fopen() close-on-exec.

Modified:
  head/lib/libc/net/ether_addr.c
  head/lib/libc/net/eui64.c
  head/lib/libc/net/getaddrinfo.c
  head/lib/libc/net/gethostbyht.c
  head/lib/libc/net/getnetbyht.c
  head/lib/libc/net/getprotoent.c
  head/lib/libc/net/getservent.c
  head/lib/libc/net/hesiod.c
  head/lib/libc/net/nsdispatch.c
  head/lib/libc/net/rcmd.c
  head/lib/libc/posix1e/mac.c
  head/lib/libc/resolv/res_init.c
  head/lib/libc/resolv/res_query.c

Modified: head/lib/libc/net/ether_addr.c
==============================================================================
--- head/lib/libc/net/ether_addr.c      Fri Aug 23 13:47:41 2013        
(r254699)
+++ head/lib/libc/net/ether_addr.c      Fri Aug 23 13:59:47 2013        
(r254700)
@@ -148,7 +148,7 @@ ether_ntohost(char *hostname, const stru
        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, stru
        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] == '#')

Modified: head/lib/libc/net/eui64.c
==============================================================================
--- head/lib/libc/net/eui64.c   Fri Aug 23 13:47:41 2013        (r254699)
+++ head/lib/libc/net/eui64.c   Fri Aug 23 13:59:47 2013        (r254700)
@@ -227,7 +227,7 @@ eui64_ntohost(char *hostname, size_t len
        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, stru
        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)) {

Modified: head/lib/libc/net/getaddrinfo.c
==============================================================================
--- head/lib/libc/net/getaddrinfo.c     Fri Aug 23 13:47:41 2013        
(r254699)
+++ head/lib/libc/net/getaddrinfo.c     Fri Aug 23 13:59:47 2013        
(r254700)
@@ -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 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)))

Modified: head/lib/libc/net/gethostbyht.c
==============================================================================
--- head/lib/libc/net/gethostbyht.c     Fri Aug 23 13:47:41 2013        
(r254699)
+++ head/lib/libc/net/gethostbyht.c     Fri Aug 23 13:59:47 2013        
(r254700)
@@ -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 
        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);
        }

Modified: head/lib/libc/net/getnetbyht.c
==============================================================================
--- head/lib/libc/net/getnetbyht.c      Fri Aug 23 13:47:41 2013        
(r254699)
+++ head/lib/libc/net/getnetbyht.c      Fri Aug 23 13:59:47 2013        
(r254700)
@@ -63,7 +63,7 @@ _setnethtent(int f, struct netent_data *
 {
 
        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 ne
        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);

Modified: head/lib/libc/net/getprotoent.c
==============================================================================
--- head/lib/libc/net/getprotoent.c     Fri Aug 23 13:47:41 2013        
(r254699)
+++ head/lib/libc/net/getprotoent.c     Fri Aug 23 13:59:47 2013        
(r254700)
@@ -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, str
        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)

Modified: head/lib/libc/net/getservent.c
==============================================================================
--- head/lib/libc/net/getservent.c      Fri Aug 23 13:47:41 2013        
(r254699)
+++ head/lib/libc/net/getservent.c      Fri Aug 23 13:59:47 2013        
(r254700)
@@ -335,7 +335,7 @@ files_servent(void *retval, void *mdata,
        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 *mda
        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;

Modified: head/lib/libc/net/hesiod.c
==============================================================================
--- head/lib/libc/net/hesiod.c  Fri Aug 23 13:47:41 2013        (r254699)
+++ head/lib/libc/net/hesiod.c  Fri Aug 23 13:59:47 2013        (r254700)
@@ -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);

Modified: head/lib/libc/net/nsdispatch.c
==============================================================================
--- head/lib/libc/net/nsdispatch.c      Fri Aug 23 13:47:41 2013        
(r254699)
+++ head/lib/libc/net/nsdispatch.c      Fri Aug 23 13:59:47 2013        
(r254700)
@@ -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),

Modified: head/lib/libc/net/rcmd.c
==============================================================================
--- head/lib/libc/net/rcmd.c    Fri Aug 23 13:47:41 2013        (r254699)
+++ head/lib/libc/net/rcmd.c    Fri Aug 23 13:59:47 2013        (r254700)
@@ -458,7 +458,7 @@ iruserok_sa(ra, rlen, superuser, ruser, 
        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)

Modified: head/lib/libc/posix1e/mac.c
==============================================================================
--- head/lib/libc/posix1e/mac.c Fri Aug 23 13:47:41 2013        (r254699)
+++ head/lib/libc/posix1e/mac.c Fri Aug 23 13:59:47 2013        (r254700)
@@ -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);
 

Modified: head/lib/libc/resolv/res_init.c
==============================================================================
--- head/lib/libc/resolv/res_init.c     Fri Aug 23 13:47:41 2013        
(r254699)
+++ head/lib/libc/resolv/res_init.c     Fri Aug 23 13:59:47 2013        
(r254700)
@@ -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 */

Modified: head/lib/libc/resolv/res_query.c
==============================================================================
--- head/lib/libc/resolv/res_query.c    Fri Aug 23 13:47:41 2013        
(r254699)
+++ head/lib/libc/resolv/res_query.c    Fri Aug 23 13:59:47 2013        
(r254700)
@@ -457,7 +457,7 @@ res_hostalias(const res_state statp, con
        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';
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to