summaryrefslogtreecommitdiffstats
path: root/src/providers/ad/ad_gpo.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2014-10-21 12:29:55 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-11-05 19:55:09 +0100
commit06f10b2a0ebb26f2460cd445f8040e9205de7500 (patch)
tree06f5b2bda73bc2042abe72498924a709f5aa8159 /src/providers/ad/ad_gpo.c
parent936940720b1b0e701a2317abc4c2d05a78338f33 (diff)
downloadsssd-06f10b2a0ebb26f2460cd445f8040e9205de7500.tar.gz
sssd-06f10b2a0ebb26f2460cd445f8040e9205de7500.tar.xz
sssd-06f10b2a0ebb26f2460cd445f8040e9205de7500.zip
UTIL: Remove code duplication of struct io
We had struct io and the associated destructor copied twice in the code already and need it again in the SELinux provider. Instead of adding another copy, move the code to a shared subtree under util/ Reviewed-by: Michal Židek <mzidek@redhat.com>
Diffstat (limited to 'src/providers/ad/ad_gpo.c')
-rw-r--r--src/providers/ad/ad_gpo.c43
1 files changed, 3 insertions, 40 deletions
diff --git a/src/providers/ad/ad_gpo.c b/src/providers/ad/ad_gpo.c
index 4dfbd4b69..80b0d45c2 100644
--- a/src/providers/ad/ad_gpo.c
+++ b/src/providers/ad/ad_gpo.c
@@ -3756,46 +3756,9 @@ struct ad_gpo_process_cse_state {
pid_t child_pid;
uint8_t *buf;
ssize_t len;
- struct io *io;
+ struct child_io_fds *io;
};
-struct io {
- int read_from_child_fd;
- int write_to_child_fd;
-};
-
-static errno_t
-gpo_child_io_destructor(void *ptr)
-{
- int ret;
- struct io *io;
-
- io = talloc_get_type(ptr, struct io);
- if (io == NULL) return EOK;
-
- if (io->write_to_child_fd != -1) {
- ret = close(io->write_to_child_fd);
- io->write_to_child_fd = -1;
- if (ret != EOK) {
- ret = errno;
- DEBUG(SSSDBG_CRIT_FAILURE,
- "close failed [%d][%s].\n", ret, strerror(ret));
- }
- }
-
- if (io->read_from_child_fd != -1) {
- ret = close(io->read_from_child_fd);
- io->read_from_child_fd = -1;
- if (ret != EOK) {
- ret = errno;
- DEBUG(SSSDBG_CRIT_FAILURE,
- "close failed [%d][%s].\n", ret, strerror(ret));
- }
- }
-
- return EOK;
-}
-
static errno_t gpo_fork_child(struct tevent_req *req);
static void gpo_cse_step(struct tevent_req *subreq);
static void gpo_cse_done(struct tevent_req *subreq);
@@ -3849,7 +3812,7 @@ ad_gpo_process_cse_send(TALLOC_CTX *mem_ctx,
state->gpo_guid = gpo_guid;
state->smb_path = smb_path;
state->smb_cse_suffix = smb_cse_suffix;
- state->io = talloc(state, struct io);
+ state->io = talloc(state, struct child_io_fds);
if (state->io == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "talloc failed.\n");
ret = ENOMEM;
@@ -3858,7 +3821,7 @@ ad_gpo_process_cse_send(TALLOC_CTX *mem_ctx,
state->io->write_to_child_fd = -1;
state->io->read_from_child_fd = -1;
- talloc_set_destructor((void *) state->io, gpo_child_io_destructor);
+ talloc_set_destructor((void *) state->io, child_io_destructor);
/* prepare the data to pass to child */
ret = create_cse_send_buffer(state, smb_server, smb_share, smb_path,