From 6fa5c415aa0acdbeb8a8b9beba390518489304ab Mon Sep 17 00:00:00 2001 From: guenther <> Date: Mon, 15 Sep 2014 06:15:48 +0000 Subject: When fopen()ing internal to libc (the API doesn't support the use of the resulting FILE *), then pass fopen() the 'e' mode letter to mark it close-on-exec. ok miod@ --- src/lib/libc/net/ethers.c | 6 +++--- src/lib/libc/net/getnetent.c | 6 +++--- src/lib/libc/net/getprotoent.c | 6 +++--- src/lib/libc/net/getservent.c | 6 +++--- src/lib/libc/net/ruserok.c | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libc/net/ethers.c b/src/lib/libc/net/ethers.c index af31bb8e60..07f1da3306 100644 --- a/src/lib/libc/net/ethers.c +++ b/src/lib/libc/net/ethers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ethers.c,v 1.21 2013/11/24 23:51:28 deraadt Exp $ */ +/* $OpenBSD: ethers.c,v 1.22 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1998 Todd C. Miller @@ -112,7 +112,7 @@ ether_ntohost(char *hostname, struct ether_addr *e) trylen = strlen(trybuf); #endif - f = fopen(_PATH_ETHERS, "r"); + f = fopen(_PATH_ETHERS, "re"); if (f == NULL) return (-1); while ((p = fgetln(f, &len)) != NULL) { @@ -165,7 +165,7 @@ ether_hostton(const char *hostname, struct ether_addr *e) int hostlen = strlen(hostname); #endif - f = fopen(_PATH_ETHERS, "r"); + f = fopen(_PATH_ETHERS, "re"); if (f==NULL) return (-1); diff --git a/src/lib/libc/net/getnetent.c b/src/lib/libc/net/getnetent.c index 57fe459e2b..14c39f1482 100644 --- a/src/lib/libc/net/getnetent.c +++ b/src/lib/libc/net/getnetent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getnetent.c,v 1.13 2012/04/10 16:41:10 eric Exp $ */ +/* $OpenBSD: getnetent.c,v 1.14 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -48,7 +48,7 @@ void setnetent(int f) { if (netf == NULL) - netf = fopen(_PATH_NETWORKS, "r" ); + netf = fopen(_PATH_NETWORKS, "re" ); else rewind(netf); _net_stayopen |= f; @@ -70,7 +70,7 @@ getnetent(void) char *p, *cp, **q; size_t len; - if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL) + if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "re" )) == NULL) return (NULL); again: if ((p = fgetln(netf, &len)) == NULL) diff --git a/src/lib/libc/net/getprotoent.c b/src/lib/libc/net/getprotoent.c index f0705e0765..87060b7b3c 100644 --- a/src/lib/libc/net/getprotoent.c +++ b/src/lib/libc/net/getprotoent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getprotoent.c,v 1.10 2007/09/02 15:19:17 deraadt Exp $ */ +/* $OpenBSD: getprotoent.c,v 1.11 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -42,7 +42,7 @@ void setprotoent_r(int f, struct protoent_data *pd) { if (pd->fp == NULL) - pd->fp = fopen(_PATH_PROTOCOLS, "r" ); + pd->fp = fopen(_PATH_PROTOCOLS, "re" ); else rewind(pd->fp); pd->stayopen |= f; @@ -71,7 +71,7 @@ getprotoent_r(struct protoent *pe, struct protoent_data *pd) long l; int serrno; - if (pd->fp == NULL && (pd->fp = fopen(_PATH_PROTOCOLS, "r" )) == NULL) + if (pd->fp == NULL && (pd->fp = fopen(_PATH_PROTOCOLS, "re" )) == NULL) return (-1); again: if ((p = fgetln(pd->fp, &len)) == NULL) diff --git a/src/lib/libc/net/getservent.c b/src/lib/libc/net/getservent.c index c81a4cf3e2..7e3293389d 100644 --- a/src/lib/libc/net/getservent.c +++ b/src/lib/libc/net/getservent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getservent.c,v 1.12 2007/09/02 15:19:17 deraadt Exp $ */ +/* $OpenBSD: getservent.c,v 1.13 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -42,7 +42,7 @@ void setservent_r(int f, struct servent_data *sd) { if (sd->fp == NULL) - sd->fp = fopen(_PATH_SERVICES, "r" ); + sd->fp = fopen(_PATH_SERVICES, "re" ); else rewind(sd->fp); sd->stayopen |= f; @@ -71,7 +71,7 @@ getservent_r(struct servent *se, struct servent_data *sd) long l; int serrno; - if (sd->fp == NULL && (sd->fp = fopen(_PATH_SERVICES, "r" )) == NULL) + if (sd->fp == NULL && (sd->fp = fopen(_PATH_SERVICES, "re" )) == NULL) return (-1); again: if ((p = fgetln(sd->fp, &len)) == NULL) diff --git a/src/lib/libc/net/ruserok.c b/src/lib/libc/net/ruserok.c index 21646c156b..4d0adfbe4e 100644 --- a/src/lib/libc/net/ruserok.c +++ b/src/lib/libc/net/ruserok.c @@ -118,7 +118,7 @@ iruserok_sa(const void *raddr, int rlen, int superuser, const char *ruser, sa = (struct sockaddr *)raddr; first = 1; - hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r"); + hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "re"); again: if (hostf) { if (__ivaliduser_sa(hostf, sa, rlen, luser, ruser) == 0) { @@ -144,7 +144,7 @@ again: */ uid = geteuid(); (void)seteuid(pwd->pw_uid); - hostf = fopen(pbuf, "r"); + hostf = fopen(pbuf, "re"); (void)seteuid(uid); if (hostf == NULL) -- cgit v1.2.3-55-g6feb