db/hash: Use O_CLOEXEC instead of separate fcntl() call.
In particular, a hash db is used by getpwnam() and getpwuid(). MFC after: 1 week
This commit is contained in:
parent
f24deb02bd
commit
46d71747f6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=254222
@ -121,9 +121,8 @@ __hash_open(const char *file, int flags, int mode,
|
|||||||
hashp->flags = flags;
|
hashp->flags = flags;
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
if ((hashp->fp = _open(file, flags, mode)) == -1)
|
if ((hashp->fp = _open(file, flags | O_CLOEXEC, mode)) == -1)
|
||||||
RETURN_ERROR(errno, error0);
|
RETURN_ERROR(errno, error0);
|
||||||
(void)_fcntl(hashp->fp, F_SETFD, 1);
|
|
||||||
new_table = _fstat(hashp->fp, &statbuf) == 0 &&
|
new_table = _fstat(hashp->fp, &statbuf) == 0 &&
|
||||||
statbuf.st_size == 0 && (flags & O_ACCMODE) != O_RDONLY;
|
statbuf.st_size == 0 && (flags & O_ACCMODE) != O_RDONLY;
|
||||||
} else
|
} else
|
||||||
|
Loading…
Reference in New Issue
Block a user