mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
Ensure zed _finish_daemonize() leaves fds 0-2 open
In zed's _finish_daemonize(), /dev/null is open()d onto a temporary file descriptor which is then dup()d onto stdin, stdout, and stderr. But if file descriptors 0, 1, or 2 are not already open at the start of this function, then the temporary file descriptor will fall within this range and be inadvertently closed when the function cleans up. This commit adds a check to prevent inadvertently closing this (presumably temporary) file descriptor when it shouldn't. Signed-off-by: Chris Dunlap <cdunlap@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #4384
This commit is contained in:
parent
272be6834c
commit
048bb5bd49
@ -199,7 +199,7 @@ _finish_daemonize(void)
|
||||
zed_log_die("Failed to dup /dev/null onto stderr: %s",
|
||||
strerror(errno));
|
||||
|
||||
if (close(devnull) < 0)
|
||||
if ((devnull > STDERR_FILENO) && (close(devnull) < 0))
|
||||
zed_log_die("Failed to close /dev/null: %s", strerror(errno));
|
||||
|
||||
/* Notify parent that daemonization is complete. */
|
||||
|
Loading…
Reference in New Issue
Block a user