-/* $OpenBSD: logwtmp.c,v 1.9 2005/08/02 21:46:23 espie Exp $ */
+/* $OpenBSD: logwtmp.c,v 1.10 2016/08/30 14:44:45 guenther Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
struct utmp ut;
int fd;
- if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
+ if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND|O_CLOEXEC)) < 0)
return;
if (fstat(fd, &buf) == 0) {
(void) strncpy(ut.ut_line, line, sizeof(ut.ut_line));
-/* $OpenBSD: pty.c,v 1.19 2013/05/21 19:07:02 matthew Exp $ */
+/* $OpenBSD: pty.c,v 1.20 2016/08/30 14:44:45 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* Use /dev/ptm and the PTMGET ioctl to get a properly set up and
* owned pty/tty pair.
*/
- fd = open(PATH_PTMDEV, O_RDWR, 0);
+ fd = open(PATH_PTMDEV, O_RDWR|O_CLOEXEC);
if (fd == -1)
return (-1);
if ((ioctl(fd, PTMGET, &ptm) == -1)) {
-/* $OpenBSD: readlabel.c,v 1.13 2015/01/16 16:48:52 deraadt Exp $ */
+/* $OpenBSD: readlabel.c,v 1.14 2016/08/30 14:44:45 guenther Exp $ */
/*
* Copyright (c) 1996, Jason Downs. All rights reserved.
/* Perform disk mapping if device is given as a DUID. */
if (isduid(device, 0)) {
- if ((fd = open("/dev/diskmap", O_RDONLY)) != -1) {
+ if ((fd = open("/dev/diskmap", O_RDONLY|O_CLOEXEC)) != -1) {
bzero(&dm, sizeof(struct dk_diskmap));
strlcpy(rpath, device, sizeof(rpath));
part = rpath[strlen(rpath) - 1];
}
/* If rpath doesn't exist, change that partition back. */
- fd = open(rpath, O_RDONLY);
+ fd = open(rpath, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
if (errno == ENOENT) {
rpath[strlen(rpath) - 1] = part;
- fd = open(rpath, O_RDONLY);
+ fd = open(rpath, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
if (verbose)
warn("%s", rpath);
-/* $OpenBSD: uucplock.c,v 1.17 2015/11/11 01:12:09 deraadt Exp $ */
+/* $OpenBSD: uucplock.c,v 1.18 2016/08/30 14:44:45 guenther Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
(long)pid);
(void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT,
ttyname);
- if ((tmpfd = open(lcktmpname, O_CREAT | O_TRUNC | O_WRONLY, 0664)) < 0)
+ tmpfd = open(lcktmpname, O_CREAT|O_TRUNC|O_WRONLY|O_CLOEXEC, 0664);
+ if (tmpfd < 0)
GORET(0, UU_LOCK_CREAT_ERR);
for (i = 0; i < MAXTRIES; i++) {
* check to see if the process holding the lock
* still exists
*/
- if ((fd = open(lckname, O_RDONLY)) < 0)
+ if ((fd = open(lckname, O_RDONLY | O_CLOEXEC)) < 0)
GORET(1, UU_LOCK_OPEN_ERR);
if ((pid_old = get_pid(fd, &err)) == -1)
snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, ttyname);
- if ((fd = open(lckname, O_RDWR)) < 0)
+ if ((fd = open(lckname, O_RDWR | O_CLOEXEC)) < 0)
return UU_LOCK_OWNER_ERR;
if (get_pid(fd, &err) != getpid())
ret = UU_LOCK_OWNER_ERR;