When relocating fds, update the debug fd if it is set so we are
guaranteed to get debugging output.
This commit is contained in:
@@ -570,3 +570,19 @@ sudo_debug_fd_get(void)
|
||||
{
|
||||
return sudo_debug_fd;
|
||||
}
|
||||
|
||||
/*
|
||||
* Setter for the debug descriptor.
|
||||
*/
|
||||
int
|
||||
sudo_debug_fd_set(int fd)
|
||||
{
|
||||
if (sudo_debug_fd != -1 && fd != sudo_debug_fd) {
|
||||
if (dup2(sudo_debug_fd, fd) == -1)
|
||||
return -1;
|
||||
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
close(sudo_debug_fd);
|
||||
sudo_debug_fd = fd;
|
||||
}
|
||||
return sudo_debug_fd;
|
||||
}
|
||||
|
Reference in New Issue
Block a user