Skip to content

Commit

Permalink
cleanup: renamed variables to better match their purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Nov 5, 2018
1 parent caeb22d commit 510d3e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions core/src/console/console.cc
Expand Up @@ -864,7 +864,7 @@ static bool SelectDirector(const char *director, DirectorResource **ret_dir, Con
}

namespace console {
BareosSocket *ConnectToDirector(JobControlRecord &jcr, utime_t heart_beat, char *errmsg, int errmsg_len, uint32_t &response)
BareosSocket *ConnectToDirector(JobControlRecord &jcr, utime_t heart_beat, char *errmsg, int errmsg_len, uint32_t &response_id)
{
BareosSocketTCP *UA_sock = New(BareosSocketTCP);
if (!UA_sock->connect(NULL, 5, 15, heart_beat, "Director daemon", director_resource->address, NULL,
Expand Down Expand Up @@ -910,7 +910,7 @@ BareosSocket *ConnectToDirector(JobControlRecord &jcr, utime_t heart_beat, char
}

if (!UA_sock->ConsoleAuthenticateWithDirector(&jcr, name, *password, errmsg,
errmsg_len, director_resource, response)) {
errmsg_len, director_resource, response_id)) {
ConsoleOutput(errmsg);
TerminateConsole(0);
return nullptr;
Expand Down Expand Up @@ -1110,15 +1110,15 @@ int main(int argc, char *argv[])
heart_beat = 0;
}

uint32_t response;
UA_sock = ConnectToDirector(jcr, heart_beat, errmsg, errmsg_len, response);
uint32_t response_id;
UA_sock = ConnectToDirector(jcr, heart_beat, errmsg, errmsg_len, response_id);
if (!UA_sock) { return 1; }

UA_sock->OutputCipherMessageString(ConsoleOutput);

ConsoleOutput(errmsg);

if (response == kMessageIdPamRequired) {
if (response_id == kMessageIdPamRequired) {
#if defined(HAVE_PAM)
ExaminePamAuthentication(use_pam_credentials_file, pam_credentials_filename);
#else
Expand Down
18 changes: 9 additions & 9 deletions core/src/lib/bsock.cc
Expand Up @@ -325,15 +325,15 @@ static char hello[] = "Hello %s calling\n";
bool BareosSocket::ConsoleAuthenticateWithDirector(JobControlRecord *jcr,
const char *identity,
s_password &password,
char *response,
char *response_text,
int response_len,
TlsResource *tls_resource,
uint32_t &response_id)
{
char bashed_name[MAX_NAME_LENGTH];
BareosSocket *dir = this; /* for readability */

response[0] = 0;
response_text[0] = 0;

bstrncpy(bashed_name, identity, sizeof(bashed_name));
BashSpaces(bashed_name);
Expand All @@ -353,7 +353,7 @@ bool BareosSocket::ConsoleAuthenticateWithDirector(JobControlRecord *jcr,
BStringList args;
if (ReceiveAndEvaluateResponseMessage(dir, message_id, args)) {
response_id = message_id;
Bsnprintf(response, response_len, "%s\n", args.JoinReadable().c_str());
Bsnprintf(response_text, response_len, "%s\n", args.JoinReadable().c_str());
return true;
}
Dmsg0(100, "Wrong Message Protocol ID\n");
Expand All @@ -363,7 +363,7 @@ bool BareosSocket::ConsoleAuthenticateWithDirector(JobControlRecord *jcr,
bool BareosSocket::AuthenticateWithDirector(JobControlRecord *jcr,
const char *identity,
s_password &password,
char *response,
char *response_text,
int response_len,
TlsResource *tls_resource)
{
Expand All @@ -372,7 +372,7 @@ bool BareosSocket::AuthenticateWithDirector(JobControlRecord *jcr,
char bashed_name[MAX_NAME_LENGTH];
BareosSocket *dir = this; /* for readability */

response[0] = 0;
response_text[0] = 0;

/*
* Send my name to the Director then do authentication
Expand All @@ -388,7 +388,7 @@ bool BareosSocket::AuthenticateWithDirector(JobControlRecord *jcr,
Dmsg1(6, ">dird: %s", dir->msg);
if (dir->recv() <= 0) {
dir->StopTimer();
Bsnprintf(response, response_len,
Bsnprintf(response_text, response_len,
_("Bad response to Hello command: ERR=%s\n"
"The Director at \"%s:%d\" is probably not running.\n"),
dir->bstrerror(), dir->host(), dir->port());
Expand All @@ -398,18 +398,18 @@ bool BareosSocket::AuthenticateWithDirector(JobControlRecord *jcr,
dir->StopTimer();
Dmsg1(10, "<dird: %s", dir->msg);
if (!bstrncmp(dir->msg, OKAnswerFromDirector, sizeof(OKAnswerFromDirector) - 1)) {
Bsnprintf(response, response_len, _("Director at \"%s:%d\" rejected Hello command\n"), dir->host(),
Bsnprintf(response_text, response_len, _("Director at \"%s:%d\" rejected Hello command\n"), dir->host(),
dir->port());
return false;
} else {
Bsnprintf(response, response_len, "%s", dir->msg);
Bsnprintf(response_text, response_len, "%s", dir->msg);
}

return true;

bail_out:
dir->StopTimer();
Bsnprintf(response, response_len,
Bsnprintf(response_text, response_len,
_("Authorization problem with Director at \"%s:%d\"\n"
"Most likely the passwords do not agree.\n"
"If you are using TLS, there may have been a certificate "
Expand Down

0 comments on commit 510d3e1

Please sign in to comment.