summaryrefslogtreecommitdiffstats
path: root/src/providers/krb5
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 20:16:20 +0100
commit093ac8b41e4baefd2c1102fb897367318de12fb3 (patch)
tree18395b2c03a1bbc8493a4a40b2ebcb7ac593d075 /src/providers/krb5
parent954637494fc8453f71e2b5d93b3d1ea97e31d646 (diff)
downloadsssd-093ac8b41e4baefd2c1102fb897367318de12fb3.tar.gz
sssd-093ac8b41e4baefd2c1102fb897367318de12fb3.tar.xz
sssd-093ac8b41e4baefd2c1102fb897367318de12fb3.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/krb5')
-rw-r--r--src/providers/krb5/krb5_child_handler.c38
1 files changed, 2 insertions, 36 deletions
diff --git a/src/providers/krb5/krb5_child_handler.c b/src/providers/krb5/krb5_child_handler.c
index 114e72a33..4ba939deb 100644
--- a/src/providers/krb5/krb5_child_handler.c
+++ b/src/providers/krb5/krb5_child_handler.c
@@ -41,11 +41,6 @@
#define TIME_T_MAX LONG_MAX
#define int64_to_time_t(val) ((time_t)((val) < TIME_T_MAX ? val : TIME_T_MAX))
-struct io {
- int read_from_child_fd;
- int write_to_child_fd;
-};
-
struct handle_child_state {
struct tevent_context *ev;
struct krb5child_req *kr;
@@ -55,38 +50,9 @@ struct handle_child_state {
struct tevent_timer *timeout_handler;
pid_t child_pid;
- struct io *io;
+ struct child_io_fds *io;
};
-static int child_io_destructor(void *ptr)
-{
- int ret;
- struct 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 pack_authtok(struct io_buffer *buf, size_t *rp,
struct sss_auth_token *tok)
{
@@ -391,7 +357,7 @@ struct tevent_req *handle_child_send(TALLOC_CTX *mem_ctx,
state->child_pid = -1;
state->timeout_handler = NULL;
- 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;