libzfs{,_core}: set O_CLOEXEC on persistent (ZFS_DEV and MNTTAB) fds

These were fd 3, 4, and 5 by the time zfs change-key hit
execute_key_fob()

glibc appends "e" to setmntent() mode, but musl's just returns fopen()

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11866
This commit is contained in:
наб
2021-03-10 00:00:43 +01:00
committed by Tony Hutter
parent a559c3d0f4
commit f831d1377f
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ libzfs_core_init(void)
{
(void) pthread_mutex_lock(&g_lock);
if (g_refcount == 0) {
g_fd = open(ZFS_DEV, O_RDWR);
g_fd = open(ZFS_DEV, O_RDWR|O_CLOEXEC);
if (g_fd < 0) {
(void) pthread_mutex_unlock(&g_lock);
return (errno);