Skip to content

Commit

Permalink
stored: enabled immediate tls connection with storage and filed
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Sep 20, 2018
1 parent 72a4c20 commit 7dcb10d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions core/src/stored/dir_cmd.cc
Expand Up @@ -62,6 +62,7 @@
#include "lib/bnet.h"
#include "lib/edit.h"
#include "lib/parse_bsr.h"
#include "lib/qualified_resource_name_type_converter.h"
#include "include/jcr.h"

/* Imported variables */
Expand Down Expand Up @@ -1584,6 +1585,8 @@ static bool ReplicateCmd(JobControlRecord *jcr)
PoolMem sd_auth_key(PM_MESSAGE);
BareosSocket *dir = jcr->dir_bsock;
BareosSocket *sd; /* storage daemon bsock */
std::string qualified_resource_name;
TlsResource *tls_resource;

sd = New(BareosSocketTCP);
if (me->nokeepalive) {
Expand Down Expand Up @@ -1635,6 +1638,16 @@ static bool ReplicateCmd(JobControlRecord *jcr)
}
Dmsg0(110, "Connection OK to SD.\n");

if (!my_config->GetQualifiedResourceNameTypeConverter()->ResourceToString(
jcr->Job, R_JOB, jcr->JobId, qualified_resource_name)) {
goto bail_out;
}

tls_resource = dynamic_cast<TlsResource *>(me);
if (!sd->DoTlsHandshake(4, tls_resource, false, qualified_resource_name.c_str(), jcr->sd_auth_key, jcr)) {
goto bail_out;
}

jcr->store_bsock = sd;

sd->fsend("Hello Start Storage Job %s\n", JobName);
Expand Down Expand Up @@ -1681,6 +1694,8 @@ static bool PassiveCmd(JobControlRecord *jcr)
char filed_addr[MAX_NAME_LENGTH];
BareosSocket *dir = jcr->dir_bsock;
BareosSocket *fd; /* file daemon bsock */
std::string qualified_resource_name;
TlsResource *tls_resource;

Dmsg1(100, "PassiveClientCmd: %s", dir->msg);
if (sscanf(dir->msg, passiveclientcmd, filed_addr, &filed_port, &enable_ssl) != 3) {
Expand Down Expand Up @@ -1717,6 +1732,16 @@ static bool PassiveCmd(JobControlRecord *jcr)
}
Dmsg0(110, "Connection OK to FD.\n");

if (!my_config->GetQualifiedResourceNameTypeConverter()->ResourceToString(
jcr->Job, R_JOB, jcr->JobId, qualified_resource_name)) {
goto bail_out;
}

tls_resource = dynamic_cast<TlsResource *>(me);
if (!fd->DoTlsHandshake(4, tls_resource, false, qualified_resource_name.c_str(), jcr->sd_auth_key, jcr)) {
goto bail_out;
}

jcr->file_bsock = fd;
fd->fsend("Hello Storage calling Start Job %s\n", jcr->Job);
if (!AuthenticateWithFiledaemon(jcr)) {
Expand Down

0 comments on commit 7dcb10d

Please sign in to comment.