From 3ec755f9b2db95fa05cd38ca32a0dddb255014f8 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 7 Jan 2015 10:42:09 +0100 Subject: [PATCH 155/160] GPO: Don't use stdout for output in gpo_child Resolves: https://fedorahosted.org/sssd/ticket/2544 Use a dedicated fd instead to work around https://bugzilla.samba.org/show_bug.cgi?id=11036 Reviewed-by: Sumit Bose (cherry picked from commit f00a61b6079d8de81432077a59daf015d85800d2) --- src/providers/ad/ad_gpo.c | 7 ++++--- src/providers/ad/ad_gpo.h | 4 ++++ src/providers/ad/ad_gpo_child.c | 7 ++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/providers/ad/ad_gpo.c b/src/providers/ad/ad_gpo.c index 1ae62e7c4727702d5338258046e89e4b654904eb..083fc8c2cde36bb15d1a1becd3ddac383a4008fe 100644 --- a/src/providers/ad/ad_gpo.c +++ b/src/providers/ad/ad_gpo.c @@ -3961,9 +3961,10 @@ gpo_fork_child(struct tevent_req *req) pid = fork(); if (pid == 0) { /* child */ - err = exec_child(state, - pipefd_to_child, pipefd_from_child, - GPO_CHILD, gpo_child_debug_fd); + err = exec_child_ex(state, + pipefd_to_child, pipefd_from_child, + GPO_CHILD, gpo_child_debug_fd, NULL, + STDIN_FILENO, AD_GPO_CHILD_OUT_FILENO); DEBUG(SSSDBG_CRIT_FAILURE, "Could not exec gpo_child: [%d][%s].\n", err, strerror(err)); return err; diff --git a/src/providers/ad/ad_gpo.h b/src/providers/ad/ad_gpo.h index 77051aadaed7858cce808b5c6c51f0be515d9800..9fd590a2b262b66c1efd493d8736774bdfa61b40 100644 --- a/src/providers/ad/ad_gpo.h +++ b/src/providers/ad/ad_gpo.h @@ -23,6 +23,10 @@ #ifndef AD_GPO_H_ #define AD_GPO_H_ +#include "providers/ad/ad_access.h" + +#define AD_GPO_CHILD_OUT_FILENO 3 + /* * This pair of functions provides client-side GPO processing. * diff --git a/src/providers/ad/ad_gpo_child.c b/src/providers/ad/ad_gpo_child.c index c6eb52f06b1daadb083bd4c9efb299a12031d4d5..27f0db3ec2504e55886094a35cda1f536a7494ee 100644 --- a/src/providers/ad/ad_gpo_child.c +++ b/src/providers/ad/ad_gpo_child.c @@ -33,6 +33,7 @@ #include "util/util.h" #include "util/child_common.h" #include "providers/dp_backend.h" +#include "providers/ad/ad_gpo.h" #include "sss_cli.h" #define SMB_BUFFER_SIZE 65536 @@ -778,7 +779,7 @@ main(int argc, const char *argv[]) errno = 0; - written = sss_atomic_write_s(STDOUT_FILENO, resp->buf, resp->size); + written = sss_atomic_write_s(AD_GPO_CHILD_OUT_FILENO, resp->buf, resp->size); if (written == -1) { ret = errno; DEBUG(SSSDBG_CRIT_FAILURE, "write failed [%d][%s].\n", ret, @@ -793,13 +794,13 @@ main(int argc, const char *argv[]) } DEBUG(SSSDBG_TRACE_FUNC, "gpo_child completed successfully\n"); - close(STDOUT_FILENO); + close(AD_GPO_CHILD_OUT_FILENO); talloc_free(main_ctx); return EXIT_SUCCESS; fail: DEBUG(SSSDBG_CRIT_FAILURE, "gpo_child failed!\n"); - close(STDOUT_FILENO); + close(AD_GPO_CHILD_OUT_FILENO); talloc_free(main_ctx); return EXIT_FAILURE; } -- 2.1.0