diff options
author | jilles <jilles@FreeBSD.org> | 2013-08-28 21:10:37 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2013-08-28 21:10:37 +0000 |
commit | baaacfdc28bae3ef25b6e173c058f66a64c7f18d (patch) | |
tree | 8dda6bdc0191b6bd5008300355e35de43cca06e6 /lib/libutil/quotafile.c | |
parent | 609f43ab7f3c398c0c3a4d8f093fe380c9e04b82 (diff) | |
download | FreeBSD-src-baaacfdc28bae3ef25b6e173c058f66a64c7f18d.zip FreeBSD-src-baaacfdc28bae3ef25b6e173c058f66a64c7f18d.tar.gz |
libutil: Use O_CLOEXEC for internal file descriptors from open().
Diffstat (limited to 'lib/libutil/quotafile.c')
-rw-r--r-- | lib/libutil/quotafile.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libutil/quotafile.c b/lib/libutil/quotafile.c index 03e3de4..6b5a44d 100644 --- a/lib/libutil/quotafile.c +++ b/lib/libutil/quotafile.c @@ -137,7 +137,7 @@ quota_open(struct fstab *fs, int quotatype, int openflags) goto error; } qf->accmode = openflags & O_ACCMODE; - if ((qf->fd = open(qf->qfname, qf->accmode)) < 0 && + if ((qf->fd = open(qf->qfname, qf->accmode|O_CLOEXEC)) < 0 && (openflags & O_CREAT) != O_CREAT) goto error; /* File open worked, so process it */ @@ -168,7 +168,8 @@ quota_open(struct fstab *fs, int quotatype, int openflags) /* not reached */ } /* open failed, but O_CREAT was specified, so create a new file */ - if ((qf->fd = open(qf->qfname, O_RDWR|O_CREAT|O_TRUNC, 0)) < 0) + if ((qf->fd = open(qf->qfname, O_RDWR|O_CREAT|O_TRUNC|O_CLOEXEC, 0)) < + 0) goto error; qf->wordsize = 64; memset(&dqh, 0, sizeof(dqh)); @@ -534,7 +535,8 @@ quota_convert(struct quotafile *qf, int wordsize) free(newqf); return (-1); } - if ((newqf->fd = open(qf->qfname, O_RDWR|O_CREAT|O_TRUNC, 0)) < 0) { + if ((newqf->fd = open(qf->qfname, O_RDWR|O_CREAT|O_TRUNC|O_CLOEXEC, + 0)) < 0) { serrno = errno; goto error; } |