mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
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:
@@ -1024,15 +1024,15 @@ libzfs_init(void)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR|O_EXCL)) < 0) {
|
||||
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR|O_EXCL|O_CLOEXEC)) < 0) {
|
||||
free(hdl);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SETMNTENT
|
||||
if ((hdl->libzfs_mnttab = setmntent(MNTTAB, "r")) == NULL) {
|
||||
if ((hdl->libzfs_mnttab = setmntent(MNTTAB, "re")) == NULL) {
|
||||
#else
|
||||
if ((hdl->libzfs_mnttab = fopen(MNTTAB, "r")) == NULL) {
|
||||
if ((hdl->libzfs_mnttab = fopen(MNTTAB, "re")) == NULL) {
|
||||
#endif
|
||||
(void) close(hdl->libzfs_fd);
|
||||
free(hdl);
|
||||
|
||||
Reference in New Issue
Block a user