[ 1474749 ] blank/null hostname in a spectre job
This commit is contained in:
parent
ac8f720f87
commit
3cef14bd90
1 changed files with 26 additions and 19 deletions
|
|
@ -369,15 +369,21 @@ sub runJob {
|
|||
my ($kernel, $self, $job, $session) = @_[KERNEL, OBJECT, ARG0, SESSION];
|
||||
$self->debug("Preparing to run a scheduled job ".$job->{taskId}.".");
|
||||
POE::Component::Client::UserAgent->new;
|
||||
my $url = "http://".$job->{sitename}.':'.$self->config->get("webguiPort").'/';
|
||||
my $request = POST $url, [op=>"runCronJob", taskId=>$job->{taskId}];
|
||||
my $cookie = $self->{_cookies}{$job->{sitename}};
|
||||
$request->header("Cookie","wgSession=".$cookie) if (defined $cookie);
|
||||
$request->header("User-Agent","Spectre");
|
||||
$request->header("X-taskId",$job->{taskId});
|
||||
$self->debug("Posting schedule job ".$job->{taskId}." to $url.");
|
||||
$kernel->post( useragent => 'request', { request => $request, response => $session->postback('runJobResponse') });
|
||||
$self->debug("Cron job ".$job->{taskId}." posted.");
|
||||
if ($job->{sitename} eq "" || $job->{config} eq "" || $job->{taskId} eq "") {
|
||||
$self->error("Warning: A scheduled task has corrupt information and is nat able to be run. Skipping execution.");
|
||||
$kernel->yield("deleteJob",{config=>$job->{config}, taskId=>$job->{taskId}}) if ($job->{config} ne "" && $job->{taskId} ne "");
|
||||
} else {
|
||||
my $url = "http://".$job->{sitename}.':'.$self->config->get("webguiPort").'/';
|
||||
my $request = POST $url, [op=>"runCronJob", taskId=>$job->{taskId}];
|
||||
my $cookie = $self->{_cookies}{$job->{sitename}};
|
||||
$request->header("Cookie","wgSession=".$cookie) if (defined $cookie);
|
||||
$request->header("User-Agent","Spectre");
|
||||
$request->header("X-taskId",$job->{taskId});
|
||||
$request->header("X-config",$job->{config});
|
||||
$self->debug("Posting schedule job ".$job->{taskId}." to $url.");
|
||||
$kernel->post( useragent => 'request', { request => $request, response => $session->postback('runJobResponse') });
|
||||
$self->debug("Cron job ".$job->{taskId}." posted.");
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -393,33 +399,34 @@ sub runJobResponse {
|
|||
$self->debug("Retrieving response from scheduled job.");
|
||||
my ($request, $response, $entry) = @{$_[ARG1]};
|
||||
my $taskId = $request->header("X-taskId"); # got to figure out how to get this from the request, cuz the response may die
|
||||
$self->debug("Response retrieved is for scheduled task $taskId.");
|
||||
my $job = $self->{_jobs}{$taskId};
|
||||
my $config = $request->header("X-config"); # got to figure out how to get this from the request, cuz the response may die
|
||||
$self->debug("Response retrieved is for scheduled task $config / $taskId.");
|
||||
my $job = $self->{_jobs}{$config}{$taskId};
|
||||
if ($response->is_success) {
|
||||
$self->debug("Response for scheduled task $taskId retrieved successfully.");
|
||||
$self->debug("Response for scheduled task $config / $taskId retrieved successfully.");
|
||||
if ($response->header("Cookie") ne "") {
|
||||
$self->debug("Storing cookie for $taskId for later use.");
|
||||
$self->debug("Storing cookie for $config / $taskId for later use.");
|
||||
my $cookie = $response->header("Set-Cookie");
|
||||
$cookie =~ s/wgSession=([a-zA-Z0-9\_\-]{22})/$1/;
|
||||
$self->{_cookies}{$self->{_jobs}{$taskId}{sitename}} = $cookie;
|
||||
$self->{_cookies}{$job->{sitename}} = $cookie;
|
||||
}
|
||||
my $state = $response->content;
|
||||
if ($state eq "done") {
|
||||
$self->debug("Scheduled task $taskId is now complete.");
|
||||
$self->debug("Scheduled task $config / $taskId is now complete.");
|
||||
if ($job->{runOnce}) {
|
||||
$kernel->yield("deleteJob",{config=>$job->{config}, taskId=>$job->{taskId}});
|
||||
}
|
||||
} elsif ($state eq "error") {
|
||||
$self->debug("Got an error response for scheduled task $taskId, will try again in ".$self->config->get("suspensionDelay")." seconds.");
|
||||
$self->debug("Got an error response for scheduled task $config / $taskId, will try again in ".$self->config->get("suspensionDelay")." seconds.");
|
||||
$kernel->delay_set("runJob",$self->config->get("suspensionDelay"),$job);
|
||||
} else {
|
||||
$self->error("Something bad happened on the return of scheduled task $taskId, will try again in ".$self->config->get("suspensionDelay").". ".$response->error_as_HTML);
|
||||
$self->error("Something bad happened on the return of scheduled task $config / $taskId, will try again in ".$self->config->get("suspensionDelay").". ".$response->error_as_HTML);
|
||||
$kernel->delay_set("runJob",$self->config->get("suspensionDelay"),$job);
|
||||
}
|
||||
} elsif ($response->is_redirect) {
|
||||
$self->debug("Response for $taskId was redirected.");
|
||||
$self->debug("Response for $config / $taskId was redirected.");
|
||||
} elsif ($response->is_error) {
|
||||
$self->error("Response for scheduled task $taskId had a communications error. ".$response->error_as_HTML);
|
||||
$self->error("Response for scheduled task $config / $taskId had a communications error. ".$response->error_as_HTML);
|
||||
$kernel->delay_set("runJob",$self->config->get("suspensionDelay"),$job);
|
||||
# we should probably log something
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue