From: Samanta Navarro Date: Fri, 5 May 2023 11:59:07 +0000 (+0000) Subject: commonio_open: Remove fcntl call X-Git-Tag: 4.14.0-rc1~88 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=627631bf9a403d39663a3c33a8e4b13147996639;p=thirdparty%2Fshadow.git commonio_open: Remove fcntl call The fcntl call to set FD_CLOEXEC can be performed directly with the previously performed open call by using the O_CLOEXEC flag. O_CLOEXEC is required by POSIX.1-2008. Signed-off-by: Samanta Navarro --- diff --git a/lib/commonio.c b/lib/commonio.c index d95266b79..ce043f718 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -462,7 +462,7 @@ int commonio_open (struct commonio_db *db, int mode) fd = open (db->filename, (db->readonly ? O_RDONLY : O_RDWR) - | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW); + | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW | O_CLOEXEC); saved_errno = errno; db->fp = NULL; if (fd >= 0) { @@ -493,9 +493,6 @@ int commonio_open (struct commonio_db *db, int mode) return 0; } - /* Do not inherit fd in spawned processes (e.g. nscd) */ - fcntl (fileno (db->fp), F_SETFD, FD_CLOEXEC); - buflen = BUFLEN; buf = MALLOCARRAY (buflen, char); if (NULL == buf) {