Skip to content

Commit

Permalink
console: avoid crash if TLS connection cannot be established
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz committed Jan 31, 2020
1 parent 530a0cd commit b867b2d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/src/console/connect_to_director.cc
@@ -1,7 +1,7 @@
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2018-2018 Bareos GmbH & Co. KG
Copyright (C) 2018-2020 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -40,6 +40,7 @@ BareosSocket* ConnectToDirector(JobControlRecord& jcr,
director_resource->address, NULL,
director_resource->DIRport, false)) {
delete UA_sock;
UA_sock = nullptr;
return nullptr;
}
jcr.dir_bsock = UA_sock;
Expand All @@ -65,13 +66,17 @@ BareosSocket* ConnectToDirector(JobControlRecord& jcr,
if (!my_config->GetQualifiedResourceNameTypeConverter()->ResourceToString(
name, my_config->r_own_, qualified_resource_name)) {
delete UA_sock;
UA_sock = nullptr;
jcr.dir_bsock = nullptr;
return nullptr;
}

if (!UA_sock->DoTlsHandshake(TlsPolicy::kBnetTlsAuto, local_tls_resource,
false, qualified_resource_name.c_str(),
password->value, &jcr)) {
delete UA_sock;
UA_sock = nullptr;
jcr.dir_bsock = nullptr;
return nullptr;
}
} /* IsTlsConfigured */
Expand All @@ -83,6 +88,8 @@ BareosSocket* ConnectToDirector(JobControlRecord& jcr,
&jcr, name, *password, director_resource, own_qualified_name,
response_args, response_id)) {
delete UA_sock;
UA_sock = nullptr;
jcr.dir_bsock = nullptr;
return nullptr;
}
return UA_sock;
Expand Down

0 comments on commit b867b2d

Please sign in to comment.