libc: Make various internal file descriptors close-on-exec.

These are obtained via fopen().
This commit is contained in:
Jilles Tjoelker 2012-12-10 17:56:51 +00:00
parent 1652751915
commit 1084b38bea
7 changed files with 12 additions and 12 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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);
}

View File

@ -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;

View File

@ -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);