Skip to content

Commit

Permalink
dird: refactored sd_cmds.cc due to failed tls_duplicate_job_test
Browse files Browse the repository at this point in the history
- ConnectToStorageDaemon is now the only function deletes the
  BareosSocket for the storage daemon upon failure during handshake
  using a std::unique_ptr
- all other functions now use TerminateAndCloseJcrStoreSocket to shutdown
  a socket on errors that happen after the connection has been established
- the function call to AuthenticateWithStorageDaemon has now the
  BareosSocket* as argument, not the hidden jcr->store_bsock, that
  could be altered in this function

- replaced NULL with nullptr
- removed obvious comments
- renamed a function name to match its purpose
  • Loading branch information
franku committed Oct 8, 2018
1 parent 9eb229f commit 4dc8754
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 135 deletions.
5 changes: 2 additions & 3 deletions core/src/dird/authenticate.cc
Expand Up @@ -32,6 +32,7 @@

#include "include/bareos.h"
#include "dird.h"
#include "dird/authenticate.h"
#include "dird/fd_cmds.h"
#include "dird/client_connection_handshake_mode.h"
#include "dird/dird_globals.h"
Expand Down Expand Up @@ -62,7 +63,7 @@ static char Dir_sorry[] = "1999 You are not authorized.\n";
/**
* Authenticate with a remote Storage daemon
*/
bool AuthenticateWithStorageDaemon(JobControlRecord *jcr, StorageResource *store)
bool AuthenticateWithStorageDaemon(BareosSocket* sd, JobControlRecord *jcr, StorageResource *store)
{
std::string qualified_resource_name;
if (!my_config->GetQualifiedResourceNameTypeConverter()->ResourceToString(me->hdr.name, my_config->r_own_,
Expand All @@ -71,8 +72,6 @@ bool AuthenticateWithStorageDaemon(JobControlRecord *jcr, StorageResource *store
return false;
}

BareosSocket *sd = jcr->store_bsock;

if (!sd->DoTlsHandshake(TlsConfigBase::BNET_TLS_AUTO, store, false, qualified_resource_name.c_str(),
store->password.value, jcr)) {
Dmsg0(100, "Could not DoTlsHandshake() with a storage daemon\n");
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/authenticate.h
Expand Up @@ -24,7 +24,7 @@

namespace directordaemon {

bool AuthenticateWithStorageDaemon(JobControlRecord *jcr, StorageResource *store);
bool AuthenticateWithStorageDaemon(BareosSocket *sd, JobControlRecord *jcr, StorageResource *store);
bool AuthenticateWithFileDaemon(JobControlRecord *jcr);
bool AuthenticateFileDaemon(BareosSocket *fd, char *client_name);
bool AuthenticateUserAgent(UaContext *ua);
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/msgchan.cc
Expand Up @@ -166,7 +166,7 @@ bool StartStorageDaemonJob(JobControlRecord *jcr, alist *rstore, alist *wstore,
/*
* Before actually starting a new Job on the SD make sure we send any specific plugin options for this Job.
*/
if (!DoStoragePluginOptions(jcr)) {
if (!SendStoragePluginOptions(jcr)) {
Jmsg(jcr, M_FATAL, 0, _("Storage daemon rejected Plugin Options command: %s\n"), sd->msg);
return false;
}
Expand Down

0 comments on commit 4dc8754

Please sign in to comment.