Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/providers/ad/ad_gpo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4701,16 +4701,6 @@ struct ad_gpo_process_cse_state {
static void gpo_cse_step(struct tevent_req *subreq);
static void gpo_cse_done(struct tevent_req *subreq);

static void handle_gpo_child_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval tv, void *pvt)
{
struct tevent_req *req = talloc_get_type(pvt, struct tevent_req);

DEBUG(SSSDBG_CRIT_FAILURE, "Timeout reached for gpo_child.\n");
tevent_req_error(req, EFAULT);
}

/*
* This cse-specific function (GP_EXT_GUID_SECURITY) sends the input smb uri
* components and cached_gpt_version to the gpo child, which, in turn,
Expand Down Expand Up @@ -4783,7 +4773,9 @@ ad_gpo_process_cse_send(TALLOC_CTX *mem_ctx,
GPO_CHILD_LOG_FILE, AD_GPO_CHILD_OUT_FILENO,
/* no SIGCHLD cb */ NULL, NULL,
timeout,
handle_gpo_child_timeout, req, true,
sss_child_handle_timeout,
sss_child_create_timeout_cb_pvt(req, EFAULT),
true,
&(state->io));
/* Note that timeout timer is allocated on 'state' context, so once
* request is completed and state is freed, timer is also cancelled
Expand Down
27 changes: 3 additions & 24 deletions src/providers/ad/ad_machine_pw_renewal.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,10 @@ static errno_t get_realm_extra_args(const char *ad_domain,
}

struct renewal_state {
int child_status;
struct tevent_context *ev;

struct child_io_fds *io;
};

static void ad_machine_account_password_renewal_done(struct tevent_req *subreq);
static void
ad_machine_account_password_renewal_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval tv, void *pvt);

static struct tevent_req *
ad_machine_account_password_renewal_send(TALLOC_CTX *mem_ctx,
Expand All @@ -219,9 +212,6 @@ ad_machine_account_password_renewal_send(TALLOC_CTX *mem_ctx,

renewal_data = talloc_get_type(pvt, struct renewal_data);

state->ev = ev;
state->child_status = EFAULT;

server_name = be_fo_get_active_server_name(be_ctx, AD_SERVICE_NAME);
talloc_zfree(renewal_data->extra_args[0]);
if ((renewal_data->renew_helper == RENEW_HELPER_ADCLI)
Expand All @@ -242,7 +232,9 @@ ad_machine_account_password_renewal_send(TALLOC_CTX *mem_ctx,
/* no log file */ NULL, STDERR_FILENO,
/* no SIGCHLD cb */ NULL, NULL,
(unsigned)(be_ptask_get_timeout(be_ptask)),
ad_machine_account_password_renewal_timeout, req, true,
sss_child_handle_timeout,
sss_child_create_timeout_cb_pvt(req, ERR_RENEWAL_CHILD),
true,
&(state->io));
if (ret != EOK) {
goto done;
Expand Down Expand Up @@ -298,19 +290,6 @@ static void ad_machine_account_password_renewal_done(struct tevent_req *subreq)
return;
}

static void
ad_machine_account_password_renewal_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval tv, void *pvt)
{
struct tevent_req *req = talloc_get_type(pvt, struct tevent_req);
struct renewal_state *state = tevent_req_data(req, struct renewal_state);

DEBUG(SSSDBG_CRIT_FAILURE, "Timeout reached for AD renewal child.\n");
state->child_status = ETIMEDOUT;
tevent_req_error(req, ERR_RENEWAL_CHILD);
}

static errno_t
ad_machine_account_password_renewal_recv(struct tevent_req *req)
{
Expand Down
28 changes: 6 additions & 22 deletions src/providers/be_dyndns.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,18 +1184,13 @@ nsupdate_get_addrs_recv(struct tevent_req *req,
struct nsupdate_child_state {
Comment thread
thalman marked this conversation as resolved.
struct tevent_context *ev;
struct child_io_fds *io;
struct tevent_timer *timeout_handler;
bool read_done;
bool process_finished;
errno_t result;

int child_status;
};

static void
nsupdate_child_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval tv, void *pvt);
static void
nsupdate_child_handler(int child_status,
struct tevent_signal *sige,
Expand Down Expand Up @@ -1224,12 +1219,16 @@ nsupdate_child_send(TALLOC_CTX *mem_ctx,
state->read_done = false;
state->process_finished = false;
state->result = ERR_DYNDNS_FAILED;
state->child_status = ETIMEDOUT;

ret = sss_child_start(state, ev,
NSUPDATE_PATH, args, true,
NULL, STDERR_FILENO,
nsupdate_child_handler, req,
DYNDNS_TIMEOUT, nsupdate_child_timeout, req, true,
DYNDNS_TIMEOUT,
sss_child_handle_timeout,
sss_child_create_timeout_cb_pvt(req, ERR_DYNDNS_TIMEOUT),
true,
&(state->io));
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, "sss_child_start() failed\n");
Expand Down Expand Up @@ -1257,21 +1256,6 @@ nsupdate_child_send(TALLOC_CTX *mem_ctx,
return req;
}

static void
nsupdate_child_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval tv, void *pvt)
{
struct tevent_req *req =
talloc_get_type(pvt, struct tevent_req);
struct nsupdate_child_state *state =
tevent_req_data(req, struct nsupdate_child_state);

DEBUG(SSSDBG_CRIT_FAILURE, "Timeout reached for dynamic DNS update\n");
state->child_status = ETIMEDOUT;
tevent_req_error(req, ERR_DYNDNS_TIMEOUT);
}

static void
nsupdate_child_stdin_done(struct tevent_req *subreq)
{
Expand Down Expand Up @@ -1320,7 +1304,7 @@ void nsupdate_child_read_done(struct tevent_req *subreq)
struct nsupdate_child_state *state =
tevent_req_data(req, struct nsupdate_child_state);

talloc_zfree(state->timeout_handler);
talloc_zfree(state->io->timeout_handler);

ret = read_pipe_recv(subreq, state, &buf, &buf_len);
talloc_zfree(subreq);
Expand Down
28 changes: 3 additions & 25 deletions src/providers/idp/oidc_child_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,9 @@ struct handle_oidc_child_state {
uint8_t *buf;
ssize_t len;

pid_t child_pid;

struct child_io_fds *io;
};

/* TODO: krb5_child_handler.c is using similar */
static void oidc_child_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval tv, void *pvt)
{
struct tevent_req *req = talloc_get_type(pvt, struct tevent_req);
struct handle_oidc_child_state *state = tevent_req_data(req,
struct handle_oidc_child_state);

/* No I/O expected anymore, make sure sockets are closed properly */
state->io->in_use = false;

DEBUG(SSSDBG_IMPORTANT_INFO,
"Timeout for child [%d] reached. In case IdP is distant or network "
"is slow you may consider increasing value of idp_request_timeout.\n",
state->child_pid);

tevent_req_error(req, ETIMEDOUT);
}

static errno_t create_send_buffer(struct idp_req *idp_req,
struct io_buffer **io_buf)
{
Expand Down Expand Up @@ -121,7 +99,6 @@ struct tevent_req *handle_oidc_child_send(TALLOC_CTX *mem_ctx,
state->idp_req = idp_req;
state->buf = NULL;
state->len = 0;
state->child_pid = -1;

if (send_buffer == NULL) {
ret = create_send_buffer(idp_req, &buf);
Expand All @@ -139,7 +116,9 @@ struct tevent_req *handle_oidc_child_send(TALLOC_CTX *mem_ctx,
OIDC_CHILD_LOG_FILE, STDOUT_FILENO,
sss_child_handle_exited, NULL,
dp_opt_get_int(idp_req->idp_options, IDP_REQ_TIMEOUT),
oidc_child_timeout, req, true,
sss_child_handle_timeout,
sss_child_create_timeout_cb_pvt(req, ETIMEDOUT),
true,
&(state->io));
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, "sss_child_start() failed.\n");
Expand All @@ -148,7 +127,6 @@ struct tevent_req *handle_oidc_child_send(TALLOC_CTX *mem_ctx,

/* Steal the io pair so it can outlive this request if needed. */
talloc_steal(idp_req->idp_options, state->io);
state->child_pid = state->io->pid;
state->io->in_use = true;
subreq = write_pipe_send(state, ev, buf->data, buf->size,
state->io->write_to_child_fd);
Expand Down
27 changes: 3 additions & 24 deletions src/providers/krb5/krb5_child_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ struct handle_child_state {
uint8_t *buf;
ssize_t len;

pid_t child_pid;

struct child_io_fds *io;
};

Expand Down Expand Up @@ -253,25 +251,6 @@ static errno_t create_send_buffer(struct krb5child_req *kr,
return EOK;
}

static void krb5_child_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval tv, void *pvt)
{
struct tevent_req *req = talloc_get_type(pvt, struct tevent_req);
struct handle_child_state *state = tevent_req_data(req,
struct handle_child_state);

/* No I/O expected anymore, make sure sockets are closed properly */
state->io->in_use = false;

DEBUG(SSSDBG_IMPORTANT_INFO,
"Timeout for child [%d] reached. In case KDC is distant or network "
"is slow you may consider increasing value of krb5_auth_timeout.\n",
state->child_pid);

tevent_req_error(req, ETIMEDOUT);
}

errno_t set_extra_args(TALLOC_CTX *mem_ctx, struct krb5_ctx *krb5_ctx,
struct sss_domain_info *domain,
const char ***krb5_child_extra_args)
Expand Down Expand Up @@ -456,7 +435,9 @@ static errno_t start_krb5_child(struct tevent_req *req)
KRB5_CHILD_LOG_FILE, STDOUT_FILENO,
sss_child_handle_exited, NULL,
dp_opt_get_int(kr->krb5_ctx->opts, KRB5_AUTH_TIMEOUT),
krb5_child_timeout, req, true,
sss_child_handle_timeout,
sss_child_create_timeout_cb_pvt(req, ETIMEDOUT),
true,
&io);
if (ret != EOK) {
goto done;
Expand Down Expand Up @@ -491,7 +472,6 @@ static errno_t start_krb5_child(struct tevent_req *req)
/* Steal 'io' so it can outlive this request if needed. */
talloc_steal(kr->krb5_ctx->io_table, io);

child_state->child_pid = io->pid;
child_state->io = io;
ret = EOK;

Expand Down Expand Up @@ -531,7 +511,6 @@ struct tevent_req *handle_child_send(TALLOC_CTX *mem_ctx,
state->kr = kr;
state->buf = NULL;
state->len = 0;
state->child_pid = -1;

ret = create_send_buffer(kr, &buf);
if (ret != EOK) {
Expand Down
1 change: 0 additions & 1 deletion src/providers/proxy/proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ struct pc_init_ctx {
struct sbus_connection *conn;
};

#define PROXY_CHILD_PIPE "private/proxy_child"
#define DEFAULT_BUFSIZE 4096
#define MAX_BUF_SIZE 1024*1024 /* max 1MiB */

Expand Down
31 changes: 11 additions & 20 deletions src/providers/proxy/proxy_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@

#include <signal.h>

#include "providers/proxy/proxy.h"
#include "sss_iface/sss_iface_async.h"
#include "util/sss_chain_id.h"
#include "util/sss_prctl.h"
#include "util/child_common.h"
#include "sss_iface/sss_iface_async.h"
#include "providers/proxy/proxy.h"


struct pc_init_ctx;

Expand Down Expand Up @@ -155,9 +158,6 @@ static int pc_init_destructor (TALLOC_CTX *ctx)
static void pc_init_sig_handler(struct tevent_context *ev,
struct tevent_signal *sige, int signum,
int count, void *__siginfo, void *pvt);
static void pc_init_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval t, void *ptr);
static struct tevent_req *proxy_child_init_send(TALLOC_CTX *mem_ctx,
struct proxy_child_ctx *child_ctx,
struct proxy_auth_ctx *auth_ctx)
Expand All @@ -180,11 +180,12 @@ static struct tevent_req *proxy_child_init_send(TALLOC_CTX *mem_ctx,
state->command = talloc_asprintf(req,
"%s/proxy_child -d %#.4x --debug-timestamps=%d "
"--debug-microseconds=%d --logger=%s --domain %s --id %d "
"--chain-id=%lu",
"--chain-id=%lu --dumpable=%d --backtrace=%d",
SSSD_LIBEXEC_PATH, debug_level, debug_timestamps,
debug_microseconds, sss_logger_str[sss_logger],
auth_ctx->be->domain->name,
child_ctx->id, sss_chain_id_get());
child_ctx->id, sss_chain_id_get(), sss_prctl_get_dumpable(),
sss_get_debug_backtrace_enable() ? 1 : 0);
if (state->command == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "talloc_asprintf failed.\n");
return NULL;
Expand Down Expand Up @@ -243,8 +244,9 @@ static struct tevent_req *proxy_child_init_send(TALLOC_CTX *mem_ctx,
* be faster here.
*/
tv = tevent_timeval_current_ofs(6, 0);
state->timeout = tevent_add_timer(auth_ctx->be->ev, req,
tv, pc_init_timeout, req);
state->timeout = tevent_add_timer(auth_ctx->be->ev, req, tv,
sss_child_handle_timeout,
sss_child_create_timeout_cb_pvt(req, ETIMEDOUT));
Comment thread
thalman marked this conversation as resolved.

/* processing will continue once the connection is received
* in proxy_client_init()
Expand Down Expand Up @@ -312,17 +314,6 @@ static void pc_init_sig_handler(struct tevent_context *ev,
}
}

static void pc_init_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval t, void *ptr)
{
struct tevent_req *req;

DEBUG(SSSDBG_OP_FAILURE, "Client timed out before Identification!\n");
req = talloc_get_type(ptr, struct tevent_req);
tevent_req_error(req, ETIMEDOUT);
}

static errno_t proxy_child_init_recv(struct tevent_req *req,
pid_t *pid,
struct sbus_connection **conn)
Expand Down
18 changes: 4 additions & 14 deletions src/responder/ifp/ifp_users.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,9 +1047,6 @@ struct ifp_users_find_by_valid_cert_state {
const char *path;
};

static void p11_child_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval tv, void *pvt);
static void
ifp_users_find_by_valid_cert_step(int child_status,
struct tevent_signal *sige,
Expand Down Expand Up @@ -1150,7 +1147,10 @@ ifp_users_find_by_valid_cert_send(TALLOC_CTX *mem_ctx,
state->extra_args, false, state->logfile,
-1, /* ifp cares only about exit code, so no 'io' */
ifp_users_find_by_valid_cert_step, req,
state->timeout, p11_child_timeout, req, true,
state->timeout,
sss_child_handle_timeout,
sss_child_create_timeout_cb_pvt(req, ERR_P11_CHILD_TIMEOUT),
true,
NULL);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, "sss_child_start failed [%d]: %s\n",
Expand All @@ -1167,16 +1167,6 @@ ifp_users_find_by_valid_cert_send(TALLOC_CTX *mem_ctx,
return req;
}

static void p11_child_timeout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval tv, void *pvt)
{
struct tevent_req *req = talloc_get_type(pvt, struct tevent_req);

DEBUG(SSSDBG_CRIT_FAILURE, "p11_child timed out\n");
tevent_req_error(req, ERR_P11_CHILD);
}

static void
ifp_users_find_by_valid_cert_step(int child_status,
struct tevent_signal *sige,
Expand Down
Loading