make more descriptors that we open as close-on-exec

This commit is contained in:
christos 2014-09-18 13:58:20 +00:00
parent 9e4a361214
commit 9a513d9643
20 changed files with 74 additions and 71 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fmtmsg.c,v 1.5 2012/03/20 16:36:05 matt Exp $ */
/* $NetBSD: fmtmsg.c,v 1.6 2014/09/18 13:58:20 christos Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: fmtmsg.c,v 1.5 2012/03/20 16:36:05 matt Exp $");
__RCSID("$NetBSD: fmtmsg.c,v 1.6 2014/09/18 13:58:20 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <fmtmsg.h>
@ -213,7 +213,7 @@ fmtmsg(long classification, const char *label, int severity,
}
/* Similar to MM_PRINT but ignoring $MSGVERB. */
if (classification & MM_CONSOLE) {
if ((console = fopen(_PATH_CONSOLE, "w")) != NULL) {
if ((console = fopen(_PATH_CONSOLE, "we")) != NULL) {
if (writeit(console, MM_VERBALL,
label, sevstr, text, action, tag) < 0)
result |= MM_NOCON;

View File

@ -1,4 +1,4 @@
/* $NetBSD: fts.c,v 1.46 2012/09/26 15:33:43 msaitoh Exp $ */
/* $NetBSD: fts.c,v 1.47 2014/09/18 13:58:20 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#else
__RCSID("$NetBSD: fts.c,v 1.46 2012/09/26 15:33:43 msaitoh Exp $");
__RCSID("$NetBSD: fts.c,v 1.47 2014/09/18 13:58:20 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -601,7 +601,7 @@ fts_children(FTS *sp, int instr)
ISSET(FTS_NOCHDIR))
return (sp->fts_child = fts_build(sp, instr));
if ((fd = open(".", O_RDONLY, 0)) == -1)
if ((fd = open(".", O_RDONLY | O_CLOEXEC, 0)) == -1)
return (sp->fts_child = NULL);
sp->fts_child = fts_build(sp, instr);
if (fchdir(fd)) {
@ -1211,7 +1211,7 @@ fts_safe_changedir(const FTS *sp, const FTSENT *p, int fd, const char *path)
if (ISSET(FTS_NOCHDIR))
return 0;
if (oldfd < 0 && (fd = open(path, O_RDONLY)) == -1)
if (oldfd < 0 && (fd = open(path, O_RDONLY | O_CLOEXEC)) == -1)
return -1;
if (fstat(fd, &sb) == -1)

View File

@ -1,4 +1,4 @@
/* $NetBSD: getcap.c,v 1.53 2014/06/26 20:14:32 christos Exp $ */
/* $NetBSD: getcap.c,v 1.54 2014/09/18 13:58:20 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
#else
__RCSID("$NetBSD: getcap.c,v 1.53 2014/06/26 20:14:32 christos Exp $");
__RCSID("$NetBSD: getcap.c,v 1.54 2014/09/18 13:58:20 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -322,8 +322,8 @@ getent(char **cap, size_t *len, const char * const *db_array, int fd,
size_t clen;
(void)snprintf(pbuf, sizeof(pbuf), "%s.db", *db_p);
if ((capdbp = dbopen(pbuf, O_RDONLY, 0, DB_HASH, 0))
!= NULL) {
if ((capdbp = dbopen(pbuf, O_RDONLY | O_CLOEXEC, 0,
DB_HASH, 0)) != NULL) {
free(record);
retval = cdbget(capdbp, &record, name);
if (retval < 0) {
@ -352,7 +352,7 @@ getent(char **cap, size_t *len, const char * const *db_array, int fd,
} else
#endif
{
fd = open(*db_p, O_RDONLY, 0);
fd = open(*db_p, O_RDONLY | O_CLOEXEC, 0);
if (fd < 0) {
/* No error on unfound file. */
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: getpass.c,v 1.28 2014/06/16 16:29:30 christos Exp $ */
/* $NetBSD: getpass.c,v 1.29 2014/09/18 13:58:20 christos Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: getpass.c,v 1.28 2014/06/16 16:29:30 christos Exp $");
__RCSID("$NetBSD: getpass.c,v 1.29 2014/09/18 13:58:20 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -107,7 +107,8 @@ getpassfd(const char *prompt, char *buf, size_t len, int *fd, int flags,
* and write to stderr.
*/
fd = fdc;
if ((fd[0] = fd[1] = fd[2] = open(_PATH_TTY, O_RDWR)) == -1) {
if ((fd[0] = fd[1] = fd[2] = open(_PATH_TTY,
O_RDWR | O_CLOEXEC)) == -1) {
fd[0] = STDIN_FILENO;
fd[1] = fd[2] = STDERR_FILENO;
} else

View File

@ -1,4 +1,4 @@
/* $NetBSD: nlist.c,v 1.24 2012/03/21 15:32:26 christos Exp $ */
/* $NetBSD: nlist.c,v 1.25 2014/09/18 13:58:20 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@ -66,7 +66,7 @@
#if 0
static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: nlist.c,v 1.24 2012/03/21 15:32:26 christos Exp $");
__RCSID("$NetBSD: nlist.c,v 1.25 2014/09/18 13:58:20 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -119,7 +119,7 @@ nlist(const char *name, struct nlist *list)
_DIAGASSERT(name != NULL);
_DIAGASSERT(list != NULL);
fd = open(name, O_RDONLY, 0);
fd = open(name, O_RDONLY | O_CLOEXEC, 0);
if (fd < 0)
return (-1);
n = __fdnlist(fd, list);

View File

@ -1,4 +1,4 @@
/* $NetBSD: syslog.c,v 1.53 2012/10/11 17:09:55 christos Exp $ */
/* $NetBSD: syslog.c,v 1.54 2014/09/18 13:58:20 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95";
#else
__RCSID("$NetBSD: syslog.c,v 1.53 2012/10/11 17:09:55 christos Exp $");
__RCSID("$NetBSD: syslog.c,v 1.54 2014/09/18 13:58:20 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -457,7 +457,8 @@ vsyslogp_r(int pri, struct syslog_data *data, const char *msgid,
* Make sure the error reported is the one from the syslogd failure.
*/
if (tries == MAXTRIES && (data->log_stat & LOG_CONS) &&
(fd = open(_PATH_CONSOLE, O_WRONLY|O_NONBLOCK, 0)) >= 0) {
(fd = open(_PATH_CONSOLE,
O_WRONLY | O_NONBLOCK | O_CLOEXEC, 0)) >= 0) {
iov[iovcnt].iov_base = __UNCONST(CRLF);
iov[iovcnt].iov_len = 2;
(void)writev(fd, iov, iovcnt + 1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: utmpx.c,v 1.31 2013/09/05 17:35:11 pooka Exp $ */
/* $NetBSD: utmpx.c,v 1.32 2014/09/18 13:58:20 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: utmpx.c,v 1.31 2013/09/05 17:35:11 pooka Exp $");
__RCSID("$NetBSD: utmpx.c,v 1.32 2014/09/18 13:58:20 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -122,8 +122,8 @@ getutxent(void)
struct stat st;
if ((fp = fopen(utfile, "re+")) == NULL)
if ((fp = fopen(utfile, "w+")) == NULL) {
if ((fp = fopen(utfile, "r")) == NULL)
if ((fp = fopen(utfile, "we+")) == NULL) {
if ((fp = fopen(utfile, "re")) == NULL)
goto fail;
else
readonly = 1;
@ -343,10 +343,10 @@ updwtmpx(const char *file, const struct utmpx *utx)
_DIAGASSERT(file != NULL);
_DIAGASSERT(utx != NULL);
fd = open(file, O_WRONLY|O_APPEND|O_SHLOCK);
fd = open(file, O_WRONLY|O_APPEND|O_SHLOCK|O_CLOEXEC);
if (fd == -1) {
if ((fd = open(file, O_CREAT|O_WRONLY|O_EXLOCK, 0644)) == -1)
if ((fd = open(file, O_CREAT|O_WRONLY|O_EXLOCK|O_CLOEXEC, 0644)) == -1)
return -1;
(void)memset(&ut, 0, sizeof(ut));
ut.ut_type = SIGNATURE;
@ -432,7 +432,7 @@ getlastlogx(const char *fname, uid_t uid, struct lastlogx *ll)
_DIAGASSERT(fname != NULL);
_DIAGASSERT(ll != NULL);
db = dbopen(fname, O_RDONLY|O_SHLOCK, 0, DB_HASH, NULL);
db = dbopen(fname, O_RDONLY|O_SHLOCK|O_CLOEXEC, 0, DB_HASH, NULL);
if (db == NULL)
return NULL;
@ -471,7 +471,7 @@ updlastlogx(const char *fname, uid_t uid, struct lastlogx *ll)
_DIAGASSERT(fname != NULL);
_DIAGASSERT(ll != NULL);
db = dbopen(fname, O_RDWR|O_CREAT|O_EXLOCK, 0644, DB_HASH, NULL);
db = dbopen(fname, O_RDWR|O_CREAT|O_EXLOCK|O_CLOEXEC, 0644, DB_HASH, NULL);
if (db == NULL)
return -1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: gmon.c,v 1.34 2012/03/13 21:13:37 christos Exp $ */
/* $NetBSD: gmon.c,v 1.35 2014/09/18 13:58:20 christos Exp $ */
/*
* Copyright (c) 2003, 2004 Wasabi Systems, Inc.
@ -69,7 +69,7 @@
#if 0
static char sccsid[] = "@(#)gmon.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: gmon.c,v 1.34 2012/03/13 21:13:37 christos Exp $");
__RCSID("$NetBSD: gmon.c,v 1.35 2014/09/18 13:58:20 christos Exp $");
#endif
#endif
@ -432,13 +432,14 @@ _mcleanup(void)
proffile = "gmon.out";
}
fd = open(proffile , O_CREAT|O_TRUNC|O_WRONLY, 0666);
#define OPEN_FLAGS (O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC)
fd = open(proffile, OPEN_FLAGS, 0666);
if (fd < 0) {
warn("%s: Cannot open `%s'", __func__, proffile);
return;
}
#ifdef DEBUG
logfd = open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664);
logfd = open("gmon.log", OPEN_FLAGS, 0664);
if (logfd < 0) {
warn("%s: Cannot open `%s'", __func__, "gmon.log");
(void)close(fd);

View File

@ -1,4 +1,4 @@
/* $NetBSD: hashhl.c,v 1.4 2010/01/17 23:10:20 wiz Exp $ */
/* $NetBSD: hashhl.c,v 1.5 2014/09/18 13:58:20 christos Exp $ */
/*
* ----------------------------------------------------------------------------
@ -97,7 +97,7 @@ FNPREFIX(FileChunk)(const char *filename, char *buf, off_t off, off_t len)
FNPREFIX(Init)(&ctx);
if ((fd = open(filename, O_RDONLY)) < 0)
if ((fd = open(filename, O_RDONLY | O_CLOEXEC)) < 0)
return (NULL);
if (len == 0) {
if (fstat(fd, &sb) == -1) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: mdXhl.c,v 1.10 2012/06/25 22:32:44 abs Exp $ */
/* $NetBSD: mdXhl.c,v 1.11 2014/09/18 13:58:20 christos Exp $ */
/*
* ----------------------------------------------------------------------------
@ -81,7 +81,7 @@ MDNAME(File)(const char *filename, char *buf)
/* buf may be NULL */
MDNAME(Init)(&ctx);
f = open(filename, O_RDONLY, 0666);
f = open(filename, O_RDONLY | O_CLOEXEC, 0666);
if (f < 0)
return NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ethers.c,v 1.24 2014/06/19 15:09:07 christos Exp $ */
/* $NetBSD: ethers.c,v 1.25 2014/09/18 13:58:20 christos Exp $ */
/*
* ethers(3N) a la Sun.
@ -9,7 +9,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: ethers.c,v 1.24 2014/06/19 15:09:07 christos Exp $");
__RCSID("$NetBSD: ethers.c,v 1.25 2014/09/18 13:58:20 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -97,7 +97,7 @@ ether_ntohost(char *hostname, const struct ether_addr *e)
e->ether_addr_octet[4], e->ether_addr_octet[5]);
#endif
f = fopen(_PATH_ETHERS, "r");
f = fopen(_PATH_ETHERS, "re");
if (f == NULL)
return -1;
for (p = NULL;;) {
@ -150,7 +150,7 @@ ether_hostton(const char *hostname, struct ether_addr *e)
_DIAGASSERT(hostname != NULL);
_DIAGASSERT(e != NULL);
f = fopen(_PATH_ETHERS, "r");
f = fopen(_PATH_ETHERS, "re");
if (f == NULL)
return -1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: hesiod.c,v 1.27 2012/03/20 17:44:18 matt Exp $ */
/* $NetBSD: hesiod.c,v 1.28 2014/09/18 13:58:20 christos Exp $ */
/* Copyright (c) 1996 by Internet Software Consortium.
*
@ -51,7 +51,7 @@ __IDSTRING(rcsid_hesiod_p_h,
"#Id: hesiod_p.h,v 1.1 1996/12/08 21:39:37 ghudson Exp #");
__IDSTRING(rcsid_hescompat_c,
"#Id: hescompat.c,v 1.1.2.1 1996/12/16 08:37:45 ghudson Exp #");
__RCSID("$NetBSD: hesiod.c,v 1.27 2012/03/20 17:44:18 matt Exp $");
__RCSID("$NetBSD: hesiod.c,v 1.28 2014/09/18 13:58:20 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -320,7 +320,7 @@ read_config_file(struct hesiod_p *ctx, const char *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);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nsdispatch.c,v 1.37 2012/03/13 21:13:42 christos Exp $ */
/* $NetBSD: nsdispatch.c,v 1.38 2014/09/18 13:58:20 christos Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc.
@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: nsdispatch.c,v 1.37 2012/03/13 21:13:42 christos Exp $");
__RCSID("$NetBSD: nsdispatch.c,v 1.38 2014/09/18 13:58:20 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -519,7 +519,7 @@ _nsconfigure(void)
*/
rwlock_wrlock(&_nslock);
_nsyyin = fopen(_PATH_NS_CONF, "r");
_nsyyin = fopen(_PATH_NS_CONF, "re");
if (_nsyyin == NULL) {
/*
* Unable to open nsswitch.conf; behave as though the

View File

@ -1,4 +1,4 @@
/* $NetBSD: rcmd.c,v 1.69 2014/05/28 14:39:02 christos Exp $ */
/* $NetBSD: rcmd.c,v 1.70 2014/09/18 13:58:20 christos Exp $ */
/*
* Copyright (c) 1983, 1993, 1994
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#else
__RCSID("$NetBSD: rcmd.c,v 1.69 2014/05/28 14:39:02 christos Exp $");
__RCSID("$NetBSD: rcmd.c,v 1.70 2014/09/18 13:58:20 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -670,7 +670,7 @@ iruserok_sa(const void *raddr, int rlen, int superuser, const char *ruser,
__rcmd_errstr = NULL;
hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r");
hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "re");
if (hostf) {
if (__ivaliduser_sa(hostf, sa, (socklen_t)rlen, luser,
@ -700,7 +700,7 @@ iruserok_sa(const void *raddr, int rlen, int superuser, const char *ruser,
(void)setegid(pwd->pw_gid);
(void)initgroups(pwd->pw_name, pwd->pw_gid);
(void)seteuid(pwd->pw_uid);
hostf = fopen(pbuf, "r");
hostf = fopen(pbuf, "re");
if (hostf != NULL) {
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: getnetconfig.c,v 1.21 2013/03/11 20:19:29 tron Exp $ */
/* $NetBSD: getnetconfig.c,v 1.22 2014/09/18 13:58:20 christos Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -36,7 +36,7 @@
#if 0
static char sccsid[] = "@(#)getnetconfig.c 1.12 91/12/19 SMI";
#else
__RCSID("$NetBSD: getnetconfig.c,v 1.21 2013/03/11 20:19:29 tron Exp $");
__RCSID("$NetBSD: getnetconfig.c,v 1.22 2014/09/18 13:58:20 christos Exp $");
#endif
#endif
@ -449,7 +449,7 @@ getnetconfigent(const char *netid)
return(NULL);
}
if ((file = fopen(NETCONFIG, "r")) == NULL)
if ((file = fopen(NETCONFIG, "re")) == NULL)
return (NULL);
if ((linep = malloc(MAXNETCONFIGLINE)) == NULL) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: malloc.c,v 1.55 2012/12/30 21:23:20 dholland Exp $ */
/* $NetBSD: malloc.c,v 1.56 2014/09/18 13:58:20 christos Exp $ */
/*
* ----------------------------------------------------------------------------
@ -90,7 +90,7 @@ void utrace(struct ut *, int);
#include <sys/cdefs.h>
#include "extern.h"
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: malloc.c,v 1.55 2012/12/30 21:23:20 dholland Exp $");
__RCSID("$NetBSD: malloc.c,v 1.56 2014/09/18 13:58:20 christos Exp $");
#endif /* LIBC_SCCS and not lint */
int utrace(const char *, void *, size_t);
@ -107,7 +107,7 @@ static mutex_t thread_lock = MUTEX_INITIALIZER;
static int fdzero;
# define MMAP_FD fdzero
# define INIT_MMAP() \
{ if ((fdzero = open(_PATH_DEVZERO, O_RDWR, 0000)) == -1) \
{ if ((fdzero = open(_PATH_DEVZERO, O_RDWR | O_CLOEXEC, 0000)) == -1) \
wrterror("open of /dev/zero"); }
#endif /* __sparc__ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: getdate.c,v 1.2 2009/11/22 18:07:39 mbalmer Exp $ */
/* $NetBSD: getdate.c,v 1.3 2014/09/18 13:58:20 christos Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
@ -82,7 +82,7 @@ getdate(const char *str)
return (NULL);
}
if ((fp = fopen(datemsk, "r")) == NULL) {
if ((fp = fopen(datemsk, "re")) == NULL) {
getdate_err = 2;
return (NULL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: localtime.c,v 1.85 2014/08/16 16:22:21 christos Exp $ */
/* $NetBSD: localtime.c,v 1.86 2014/09/18 13:58:20 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@ -10,7 +10,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.17";
#else
__RCSID("$NetBSD: localtime.c,v 1.85 2014/08/16 16:22:21 christos Exp $");
__RCSID("$NetBSD: localtime.c,v 1.86 2014/09/18 13:58:20 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -61,10 +61,10 @@ static time_t const time_t_max =
*/
#ifdef O_BINARY
#define OPEN_MODE (O_RDONLY | O_BINARY)
#define OPEN_MODE (O_RDONLY | O_BINARY | O_CLOEXEC)
#endif /* defined O_BINARY */
#ifndef O_BINARY
#define OPEN_MODE O_RDONLY
#define OPEN_MODE (O_RDONLY | O_CLOEXEC)
#endif /* !defined O_BINARY */
#ifndef WILDABBR

View File

@ -1,4 +1,4 @@
/* $NetBSD: strftime.c,v 1.31 2014/08/15 11:04:07 christos Exp $ */
/* $NetBSD: strftime.c,v 1.32 2014/09/18 13:58:20 christos Exp $ */
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
@ -6,7 +6,7 @@
static char elsieid[] = "@(#)strftime.c 7.64";
static char elsieid[] = "@(#)strftime.c 8.3";
#else
__RCSID("$NetBSD: strftime.c,v 1.31 2014/08/15 11:04:07 christos Exp $");
__RCSID("$NetBSD: strftime.c,v 1.32 2014/09/18 13:58:20 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -714,7 +714,7 @@ _loc(void)
goto no_locale;
oldsun = 0;
(void) sprintf(filename, "%s/%s/%s", locale_home, name, lc_time);
fd = open(filename, O_RDONLY);
fd = open(filename, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
/*
** Old Sun systems have a different naming and data convention.
@ -722,7 +722,7 @@ _loc(void)
oldsun = 1;
(void) sprintf(filename, "%s/%s/%s", locale_home,
lc_time, name);
fd = open(filename, O_RDONLY);
fd = open(filename, O_RDONLY | O_CLOEXEC);
if (fd < 0)
goto no_locale;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: yplib.c,v 1.45 2012/03/20 16:30:26 matt Exp $ */
/* $NetBSD: yplib.c,v 1.46 2014/09/18 13:58:20 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: yplib.c,v 1.45 2012/03/20 16:30:26 matt Exp $");
__RCSID("$NetBSD: yplib.c,v 1.46 2014/09/18 13:58:20 christos Exp $");
#endif
#include "namespace.h"
@ -115,7 +115,7 @@ _yp_dobind(const char *dom, struct dom_binding **ypdb)
/*
* test if YP is running or not
*/
if ((fd = open(YPBINDLOCK, O_RDONLY)) == -1)
if ((fd = open(YPBINDLOCK, O_RDONLY | O_CLOEXEC)) == -1)
return YPERR_YPBIND;
if (!(flock(fd, LOCK_EX | LOCK_NB) == -1 && errno == EWOULDBLOCK)) {
(void)close(fd);
@ -155,7 +155,7 @@ again:
if (ysd->dom_vers == 0) {
(void) snprintf(path, sizeof(path), "%s/%s.%d",
BINDINGDIR, dom, 2);
if ((fd = open(path, O_RDONLY)) == -1) {
if ((fd = open(path, O_RDONLY | O_CLOEXEC)) == -1) {
/*
* no binding file, YP is dead, or not yet fully
* alive.