diff options
author | 2013-04-29 00:28:23 +0000 | |
---|---|---|
committer | 2013-04-29 00:28:23 +0000 | |
commit | b779915b23e73132d60ea62cd95d1238b9bcde88 (patch) | |
tree | 416b7bd5c3c8e5e0d5bff4a206f8aceb8cb55ed5 | |
parent | use O_CLOEXEC with open() instead of open/fcntl; from David Hill (diff) | |
download | wireguard-openbsd-b779915b23e73132d60ea62cd95d1238b9bcde88.tar.xz wireguard-openbsd-b779915b23e73132d60ea62cd95d1238b9bcde88.zip |
use FD_CLOEXEC instead of 1; from David Hill
ok otto
-rw-r--r-- | bin/systrace/openbsd-syscalls.c | 4 | ||||
-rw-r--r-- | lib/libc/db/btree/bt_open.c | 4 | ||||
-rw-r--r-- | lib/libc/db/hash/hash.c | 4 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_page.c | 4 | ||||
-rw-r--r-- | lib/libc/gen/syslog_r.c | 4 | ||||
-rw-r--r-- | lib/libc/yp/yp_bind.c | 4 | ||||
-rw-r--r-- | lib/libevent/signal.c | 4 | ||||
-rw-r--r-- | lib/libutil/passwd.c | 4 | ||||
-rw-r--r-- | usr.bin/mail/lex.c | 6 | ||||
-rw-r--r-- | usr.bin/mail/names.c | 4 | ||||
-rw-r--r-- | usr.bin/mail/popen.c | 10 | ||||
-rw-r--r-- | usr.bin/nc/netcat.c | 4 | ||||
-rw-r--r-- | usr.bin/sudo/sudo.c | 2 | ||||
-rw-r--r-- | usr.bin/vi/common/exf.c | 4 | ||||
-rw-r--r-- | usr.sbin/apmd/apmd.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/chap.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/chat.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/command.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/exec.c | 4 |
19 files changed, 42 insertions, 42 deletions
diff --git a/bin/systrace/openbsd-syscalls.c b/bin/systrace/openbsd-syscalls.c index 534be838c28..e3bdc48fc28 100644 --- a/bin/systrace/openbsd-syscalls.c +++ b/bin/systrace/openbsd-syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openbsd-syscalls.c,v 1.42 2013/04/03 03:36:25 guenther Exp $ */ +/* $OpenBSD: openbsd-syscalls.c,v 1.43 2013/04/29 00:28:23 okan Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -164,7 +164,7 @@ obsd_open(void) goto out; } - if (fcntl(cfd, F_SETFD, 1) == -1) + if (fcntl(cfd, F_SETFD, FD_CLOEXEC) == -1) warn("fcntl(F_SETFD)"); out: diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index d837df88ae2..b49aa0413f8 100644 --- a/lib/libc/db/btree/bt_open.c +++ b/lib/libc/db/btree/bt_open.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bt_open.c,v 1.14 2007/09/17 07:07:23 moritz Exp $ */ +/* $OpenBSD: bt_open.c,v 1.15 2013/04/29 00:28:23 okan Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -204,7 +204,7 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, F_SET(t, B_INMEM); } - if (fcntl(t->bt_fd, F_SETFD, 1) == -1) + if (fcntl(t->bt_fd, F_SETFD, FD_CLOEXEC) == -1) goto err; if (fstat(t->bt_fd, &sb)) diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index f97cf4d1db9..4f428e86377 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.23 2010/07/02 16:46:28 guenther Exp $ */ +/* $OpenBSD: hash.c,v 1.24 2013/04/29 00:28:23 okan Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -117,7 +117,7 @@ __hash_open(const char *file, int flags, int mode, if (file) { if ((hashp->fp = open(file, flags, mode)) == -1) RETURN_ERROR(errno, error0); - (void)fcntl(hashp->fp, F_SETFD, 1); + (void)fcntl(hashp->fp, F_SETFD, FD_CLOEXEC); new_table = fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0 && (flags & O_ACCMODE) != O_RDONLY; } else diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index 05bc2734506..c8d633ba89d 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash_page.c,v 1.19 2008/05/11 22:21:25 millert Exp $ */ +/* $OpenBSD: hash_page.c,v 1.20 2013/04/29 00:28:23 okan Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -858,7 +858,7 @@ open_temp(HTAB *hashp) (void)sigprocmask(SIG_BLOCK, &set, &oset); if ((hashp->fp = mkstemp(path)) != -1) { (void)unlink(path); - (void)fcntl(hashp->fp, F_SETFD, 1); + (void)fcntl(hashp->fp, F_SETFD, FD_CLOEXEC); } (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); return (hashp->fp != -1 ? 0 : -1); diff --git a/lib/libc/gen/syslog_r.c b/lib/libc/gen/syslog_r.c index 2a966a4ba62..e74479f244d 100644 --- a/lib/libc/gen/syslog_r.c +++ b/lib/libc/gen/syslog_r.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslog_r.c,v 1.3 2011/05/30 18:48:33 martynas Exp $ */ +/* $OpenBSD: syslog_r.c,v 1.4 2013/04/29 00:28:23 okan Exp $ */ /* * Copyright (c) 1983, 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -279,7 +279,7 @@ connectlog_r(struct syslog_data *data) if (data->log_file == -1) { if ((data->log_file = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) return; - (void)fcntl(data->log_file, F_SETFD, 1); + (void)fcntl(data->log_file, F_SETFD, FD_CLOEXEC); } if (data->log_file != -1 && !data->connected) { memset(&SyslogAddr, '\0', sizeof(SyslogAddr)); diff --git a/lib/libc/yp/yp_bind.c b/lib/libc/yp/yp_bind.c index 80197adb674..42d87a5c407 100644 --- a/lib/libc/yp/yp_bind.c +++ b/lib/libc/yp/yp_bind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yp_bind.c,v 1.17 2009/06/05 17:19:00 schwarze Exp $ */ +/* $OpenBSD: yp_bind.c,v 1.18 2013/04/29 00:28:23 okan Exp $ */ /* * Copyright (c) 1992, 1993, 1996 Theo de Raadt <deraadt@theos.com> * All rights reserved. @@ -242,7 +242,7 @@ gotdata: ysd->dom_vers = -1; goto again; } - if (fcntl(ysd->dom_socket, F_SETFD, 1) == -1) + if (fcntl(ysd->dom_socket, F_SETFD, FD_CLOEXEC) == -1) perror("fcntl: F_SETFD"); if (new) { diff --git a/lib/libevent/signal.c b/lib/libevent/signal.c index 81f3ed461e5..5d2531c37af 100644 --- a/lib/libevent/signal.c +++ b/lib/libevent/signal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: signal.c,v 1.15 2010/07/12 18:03:38 nicm Exp $ */ +/* $OpenBSD: signal.c,v 1.16 2013/04/29 00:28:23 okan Exp $ */ /* * Copyright 2000-2002 Niels Provos <provos@citi.umich.edu> @@ -85,7 +85,7 @@ evsignal_cb(int fd, short what, void *arg) #ifdef HAVE_SETFD #define FD_CLOSEONEXEC(x) do { \ - if (fcntl(x, F_SETFD, 1) == -1) \ + if (fcntl(x, F_SETFD, FD_CLOEXEC) == -1) \ event_warn("fcntl(%d, F_SETFD)", x); \ } while (0) #else diff --git a/lib/libutil/passwd.c b/lib/libutil/passwd.c index cb2cd2ba269..11ee752e8a4 100644 --- a/lib/libutil/passwd.c +++ b/lib/libutil/passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: passwd.c,v 1.49 2006/12/20 23:07:36 ray Exp $ */ +/* $OpenBSD: passwd.c,v 1.50 2013/04/29 00:28:23 okan Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -107,7 +107,7 @@ pw_lock(int retries) fd = open(pw_lck, O_WRONLY|O_CREAT|O_EXCL, 0600); } save_errno = errno; - if (fd != -1 && fcntl(fd, F_SETFD, 1) == -1) { + if (fd != -1 && fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { close(fd); fd = -1; } diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c index 7690ce78330..ba19d21a2ab 100644 --- a/usr.bin/mail/lex.c +++ b/usr.bin/mail/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.34 2011/04/06 11:36:26 miod Exp $ */ +/* $OpenBSD: lex.c,v 1.35 2013/04/29 00:28:23 okan Exp $ */ /* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */ /* @@ -129,10 +129,10 @@ setfile(char *name) if ((fd = mkstemp(tempname)) == -1 || (otf = fdopen(fd, "w")) == NULL) err(1, "%s", tempname); - (void)fcntl(fileno(otf), F_SETFD, 1); + (void)fcntl(fileno(otf), F_SETFD, FD_CLOEXEC); if ((itf = fopen(tempname, "r")) == NULL) err(1, "%s", tempname); - (void)fcntl(fileno(itf), F_SETFD, 1); + (void)fcntl(fileno(itf), F_SETFD, FD_CLOEXEC); (void)rm(tempname); setptr(ibuf, (off_t)0); setmsize(msgCount); diff --git a/usr.bin/mail/names.c b/usr.bin/mail/names.c index e4f9caeafe2..7c0e9e0eef3 100644 --- a/usr.bin/mail/names.c +++ b/usr.bin/mail/names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: names.c,v 1.18 2009/10/27 23:59:40 deraadt Exp $ */ +/* $OpenBSD: names.c,v 1.19 2013/04/29 00:28:23 okan Exp $ */ /* $NetBSD: names.c,v 1.5 1996/06/08 19:48:32 christos Exp $ */ /* @@ -248,7 +248,7 @@ outof(struct name *names, FILE *fo, struct header *hp) (void)Fclose(fout); goto cant; } - (void)fcntl(image, F_SETFD, 1); + (void)fcntl(image, F_SETFD, FD_CLOEXEC); fprintf(fout, "From %s %s", myname, date); puthead(hp, fout, GTO|GSUBJECT|GCC|GNL); while ((c = getc(fo)) != EOF) diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c index ce4fb118e11..5a1cd561ef1 100644 --- a/usr.bin/mail/popen.c +++ b/usr.bin/mail/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.35 2009/10/27 23:59:40 deraadt Exp $ */ +/* $OpenBSD: popen.c,v 1.36 2013/04/29 00:28:23 okan Exp $ */ /* $NetBSD: popen.c,v 1.6 1997/05/13 06:48:42 mikel Exp $ */ /* @@ -69,7 +69,7 @@ Fopen(char *file, char *mode) if ((fp = fopen(file, mode)) != NULL) { register_file(fp, 0, 0); - (void)fcntl(fileno(fp), F_SETFD, 1); + (void)fcntl(fileno(fp), F_SETFD, FD_CLOEXEC); } return(fp); } @@ -81,7 +81,7 @@ Fdopen(int fd, char *mode) if ((fp = fdopen(fd, mode)) != NULL) { register_file(fp, 0, 0); - (void)fcntl(fileno(fp), F_SETFD, 1); + (void)fcntl(fileno(fp), F_SETFD, FD_CLOEXEC); } return(fp); } @@ -105,8 +105,8 @@ Popen(char *cmd, char *mode) if (pipe(p) < 0) return(NULL); - (void)fcntl(p[READ], F_SETFD, 1); - (void)fcntl(p[WRITE], F_SETFD, 1); + (void)fcntl(p[READ], F_SETFD, FD_CLOEXEC); + (void)fcntl(p[WRITE], F_SETFD, FD_CLOEXEC); if (*mode == 'r') { myside = p[READ]; hisside = fd0 = fd1 = p[WRITE]; diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c index 33246d7a747..571de9a7666 100644 --- a/usr.bin/nc/netcat.c +++ b/usr.bin/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.111 2013/03/20 09:27:56 sthen Exp $ */ +/* $OpenBSD: netcat.c,v 1.112 2013/04/29 00:28:23 okan Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * @@ -523,7 +523,7 @@ unix_connect(char *path) if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) return (-1); } - (void)fcntl(s, F_SETFD, 1); + (void)fcntl(s, F_SETFD, FD_CLOEXEC); memset(&sun, 0, sizeof(struct sockaddr_un)); sun.sun_family = AF_UNIX; diff --git a/usr.bin/sudo/sudo.c b/usr.bin/sudo/sudo.c index def74a2717d..33a440c0dc0 100644 --- a/usr.bin/sudo/sudo.c +++ b/usr.bin/sudo/sudo.c @@ -1128,7 +1128,7 @@ open_sudoers(sudoers, doedit, keepopen) if (fp != NULL) { rewind(fp); - (void) fcntl(fileno(fp), F_SETFD, 1); + (void) fcntl(fileno(fp), F_SETFD, FD_CLOEXEC); } set_perms(PERM_ROOT); /* change back to root */ diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c index 802debd2cc1..62259b72d07 100644 --- a/usr.bin/vi/common/exf.c +++ b/usr.bin/vi/common/exf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exf.c,v 1.26 2011/07/10 13:20:25 millert Exp $ */ +/* $OpenBSD: exf.c,v 1.27 2013/04/29 00:28:23 okan Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -1457,7 +1457,7 @@ file_lock(sp, name, fdp, fd, iswrite) return (LOCK_SUCCESS); /* Set close-on-exec flag so locks are not inherited by shell cmd. */ - if (fcntl(fd, F_SETFD, 1) == -1) + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) msgq_str(sp, M_SYSERR, name, "%s"); #ifdef HAVE_LOCK_FLOCK /* Hurrah! We've got flock(2). */ diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c index 6ddb2cfbfd3..1c157584ff1 100644 --- a/usr.sbin/apmd/apmd.c +++ b/usr.sbin/apmd/apmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmd.c,v 1.58 2012/03/26 20:17:45 deraadt Exp $ */ +/* $OpenBSD: apmd.c,v 1.59 2013/04/29 00:28:23 okan Exp $ */ /* * Copyright (c) 1995, 1996 John T. Kohl @@ -594,12 +594,12 @@ main(int argc, char *argv[]) if ((ctl_fd = open(fname, O_RDWR)) == -1) { if (errno != ENXIO && errno != ENOENT) error("cannot open device file `%s'", fname); - } else if (fcntl(ctl_fd, F_SETFD, 1) == -1) + } else if (fcntl(ctl_fd, F_SETFD, FD_CLOEXEC) == -1) error("cannot set close-on-exec for `%s'", fname); sock_fd = bind_socket(sockname); - if (fcntl(sock_fd, F_SETFD, 1) == -1) + if (fcntl(sock_fd, F_SETFD, FD_CLOEXEC) == -1) error("cannot set close-on-exec for the socket", NULL); power_status(ctl_fd, 1, &pinfo); diff --git a/usr.sbin/ppp/ppp/chap.c b/usr.sbin/ppp/ppp/chap.c index 9d4d87e20af..4bb7d3740bb 100644 --- a/usr.sbin/ppp/ppp/chap.c +++ b/usr.sbin/ppp/ppp/chap.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: chap.c,v 1.41 2005/07/09 01:45:08 brad Exp $ + * $OpenBSD: chap.c,v 1.42 2013/04/29 00:28:23 okan Exp $ */ #include <sys/param.h> @@ -312,7 +312,7 @@ chap_StartChild(struct chap *chap, char *prog, const char *name) } /* XXX using an fwalk()-like thing would be safer */ for (fd = getdtablesize(); fd > STDERR_FILENO; fd--) - fcntl(fd, F_SETFD, 1); + fcntl(fd, F_SETFD, FD_CLOEXEC); #ifndef NOSUID setuid(ID0realuid()); #endif diff --git a/usr.sbin/ppp/ppp/chat.c b/usr.sbin/ppp/ppp/chat.c index 52cf3e3f10b..79c4bf78fb7 100644 --- a/usr.sbin/ppp/ppp/chat.c +++ b/usr.sbin/ppp/ppp/chat.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: chat.c,v 1.21 2005/07/06 13:56:00 brad Exp $ + * $OpenBSD: chat.c,v 1.22 2013/04/29 00:28:23 okan Exp $ */ #include <sys/param.h> @@ -739,7 +739,7 @@ ExecStr(struct physical *physical, char *command, char *out, int olen) if (open(_PATH_TTY, O_RDWR) != 3) open(_PATH_DEVNULL, O_RDWR); /* Leave it closed if it fails... */ for (i = getdtablesize(); i > 3; i--) - fcntl(i, F_SETFD, 1); + fcntl(i, F_SETFD, FD_CLOEXEC); #ifndef NOSUID setuid(ID0realuid()); #endif diff --git a/usr.sbin/ppp/ppp/command.c b/usr.sbin/ppp/ppp/command.c index 5c45b9050c3..6422edc267f 100644 --- a/usr.sbin/ppp/ppp/command.c +++ b/usr.sbin/ppp/ppp/command.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: command.c,v 1.92 2008/03/02 18:46:32 miod Exp $ + * $OpenBSD: command.c,v 1.93 2013/04/29 00:28:23 okan Exp $ */ #include <sys/param.h> @@ -663,7 +663,7 @@ ShellCommand(struct cmdargs const *arg, int bg) dup2(fd, STDERR_FILENO); /* fwalk */ for (i = getdtablesize(); i > STDERR_FILENO; i--) - fcntl(i, F_SETFD, 1); + fcntl(i, F_SETFD, FD_CLOEXEC); #ifndef NOSUID setuid(ID0realuid()); diff --git a/usr.sbin/ppp/ppp/exec.c b/usr.sbin/ppp/ppp/exec.c index b9a517cca45..967192e17ff 100644 --- a/usr.sbin/ppp/ppp/exec.c +++ b/usr.sbin/ppp/ppp/exec.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: exec.c,v 1.18 2002/05/16 01:13:39 brian Exp $ + * $OpenBSD: exec.c,v 1.19 2013/04/29 00:28:23 okan Exp $ */ #include <sys/param.h> @@ -178,7 +178,7 @@ exec_Create(struct physical *p) dup2(fids[1], STDOUT_FILENO); dup2(fids[1], STDERR_FILENO); for (i = getdtablesize(); i > STDERR_FILENO; i--) - fcntl(i, F_SETFD, 1); + fcntl(i, F_SETFD, FD_CLOEXEC); execvp(*argv, argv); child_status = errno; /* Only works for vfork() */ |