Author: jilles
Date: Mon Dec 10 17:56:51 2012
New Revision: 244092
URL: http://svnweb.freebsd.org/changeset/base/244092

Log:
  libc: Make various internal file descriptors close-on-exec.
  
  These are obtained via fopen().

Modified:
  head/lib/libc/gen/fmtmsg.c
  head/lib/libc/gen/getcap.c
  head/lib/libc/gen/getgrent.c
  head/lib/libc/gen/getnetgrent.c
  head/lib/libc/gen/getttyent.c
  head/lib/libc/gen/getusershell.c
  head/lib/libc/gen/getutxent.c

Modified: head/lib/libc/gen/fmtmsg.c
==============================================================================
--- head/lib/libc/gen/fmtmsg.c  Mon Dec 10 17:34:33 2012        (r244091)
+++ head/lib/libc/gen/fmtmsg.c  Mon Dec 10 17:56:51 2012        (r244092)
@@ -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);
                        }

Modified: head/lib/libc/gen/getcap.c
==============================================================================
--- head/lib/libc/gen/getcap.c  Mon Dec 10 17:34:33 2012        (r244091)
+++ head/lib/libc/gen/getcap.c  Mon Dec 10 17:56:51 2012        (r244092)
@@ -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

Modified: head/lib/libc/gen/getgrent.c
==============================================================================
--- head/lib/libc/gen/getgrent.c        Mon Dec 10 17:34:33 2012        
(r244091)
+++ head/lib/libc/gen/getgrent.c        Mon Dec 10 17:56:51 2012        
(r244092)
@@ -810,7 +810,7 @@ files_setgrent(void *retval, void *mdata
                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, v
        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 *mdat
                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, 
        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;

Modified: head/lib/libc/gen/getnetgrent.c
==============================================================================
--- head/lib/libc/gen/getnetgrent.c     Mon Dec 10 17:34:33 2012        
(r244091)
+++ head/lib/libc/gen/getnetgrent.c     Mon Dec 10 17:56:51 2012        
(r244092)
@@ -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();

Modified: head/lib/libc/gen/getttyent.c
==============================================================================
--- head/lib/libc/gen/getttyent.c       Mon Dec 10 17:34:33 2012        
(r244091)
+++ head/lib/libc/gen/getttyent.c       Mon Dec 10 17:56:51 2012        
(r244092)
@@ -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);
 }

Modified: head/lib/libc/gen/getusershell.c
==============================================================================
--- head/lib/libc/gen/getusershell.c    Mon Dec 10 17:34:33 2012        
(r244091)
+++ head/lib/libc/gen/getusershell.c    Mon Dec 10 17:56:51 2012        
(r244092)
@@ -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;

Modified: head/lib/libc/gen/getutxent.c
==============================================================================
--- head/lib/libc/gen/getutxent.c       Mon Dec 10 17:34:33 2012        
(r244091)
+++ head/lib/libc/gen/getutxent.c       Mon Dec 10 17:56:51 2012        
(r244092)
@@ -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);
 
_______________________________________________
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