From 3e0c7c536bb40f6dc6a2785613db545c3863d6dd Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Jul 31 2018 21:03:38 +0000 Subject: SSS_CERT: Close file descriptors after executing p11_child We can call cert_to_ssh_key_step from cert_to_ssh_key_done and thus p11_child can be executed more time. We created pipes for each call but destructor for state->io can close just last one. It's better to manually close pipes with macro PIPE_FD_CLOSE. that macro set file descriptor to -1 and destructor will not try to close them 2nd time. Destructor will cover just edge cases. Merges: https://pagure.io/SSSD/sssd/pull-request/3793 --- diff --git a/src/util/cert/cert_common_p11_child.c b/src/util/cert/cert_common_p11_child.c index 17e97ee..aacdb5c 100644 --- a/src/util/cert/cert_common_p11_child.c +++ b/src/util/cert/cert_common_p11_child.c @@ -255,6 +255,9 @@ static void cert_to_ssh_key_done(int child_status, int ret; bool valid = false; + PIPE_FD_CLOSE(state->io->read_from_child_fd); + PIPE_FD_CLOSE(state->io->write_to_child_fd); + if (WIFEXITED(child_status)) { if (WEXITSTATUS(child_status) != 0) { DEBUG(SSSDBG_OP_FAILURE,