Blame SOURCES/0045-SSS_CERT-Close-file-descriptors-after-executing-p11_.patch

cdf651
From a195869e527df27451bee8b68108abd005976b2d Mon Sep 17 00:00:00 2001
cdf651
From: Lukas Slebodnik <lslebodn@redhat.com>
cdf651
Date: Tue, 31 Jul 2018 21:03:38 +0000
cdf651
Subject: [PATCH] SSS_CERT: Close file descriptors after executing p11_child
cdf651
cdf651
We can call cert_to_ssh_key_step from cert_to_ssh_key_done and thus
cdf651
p11_child can be executed more time. We created pipes for each call
cdf651
but destructor for state->io can close just last one.
cdf651
cdf651
It's better to manually close pipes with macro PIPE_FD_CLOSE.
cdf651
that macro set file descriptor to -1 and destructor will not try
cdf651
to close them 2nd time. Destructor will cover just edge cases.
cdf651
cdf651
Merges: https://pagure.io/SSSD/sssd/pull-request/3793
cdf651
cdf651
Resolves:
cdf651
https://pagure.io/SSSD/sssd/issue/3794
cdf651
cdf651
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
cdf651
(cherry picked from commit a76f96ac143128c11bdb975293d667aca861cd91)
cdf651
cdf651
DOWNSTREAM:
cdf651
Resolves: rhbz#1610667 - sssd_ssh leaks file descriptors when more than one certificate is converted into an SSH key
cdf651
---
cdf651
 src/util/cert/cert_common_p11_child.c | 3 +++
cdf651
 1 file changed, 3 insertions(+)
cdf651
cdf651
diff --git a/src/util/cert/cert_common_p11_child.c b/src/util/cert/cert_common_p11_child.c
cdf651
index 17e97eeeeb1956ca6d2bbf048445117029b10dde..aacdb5c475274234fd18d5eca23ee5f9c9288c3e 100644
cdf651
--- a/src/util/cert/cert_common_p11_child.c
cdf651
+++ b/src/util/cert/cert_common_p11_child.c
cdf651
@@ -255,6 +255,9 @@ static void cert_to_ssh_key_done(int child_status,
cdf651
     int ret;
cdf651
     bool valid = false;
cdf651
 
cdf651
+    PIPE_FD_CLOSE(state->io->read_from_child_fd);
cdf651
+    PIPE_FD_CLOSE(state->io->write_to_child_fd);
cdf651
+
cdf651
     if (WIFEXITED(child_status)) {
cdf651
         if (WEXITSTATUS(child_status) != 0) {
cdf651
             DEBUG(SSSDBG_OP_FAILURE,
cdf651
-- 
cdf651
2.17.1
cdf651