Skip to content

Commit

Permalink
cleanup:
Browse files Browse the repository at this point in the history
- console: renamed a temporary variable accordingly
- bsock, tlsopenssl: removed or renamed comments
  • Loading branch information
franku committed Oct 2, 2018
1 parent 1108e43 commit 8857ebf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
48 changes: 25 additions & 23 deletions core/src/console/console.cc
Expand Up @@ -749,49 +749,50 @@ static bool SelectDirector(const char *director, DirectorResource **ret_dir, Con
int numcon=0, numdir=0;
int i=0, item=0;
BareosSocket *UA_sock;
DirectorResource *director_resource = NULL;
ConsoleResource *console_resource = NULL;
DirectorResource *director_resource_tmp = NULL;
ConsoleResource *console_resource_tmp = NULL;

*ret_cons = NULL;
*ret_dir = NULL;

LockRes(my_config);
numdir = 0;
foreach_res(director_resource, R_DIRECTOR) {
foreach_res(director_resource_tmp, R_DIRECTOR) {
numdir++;
}
numcon = 0;
foreach_res(console_resource, R_CONSOLE) {
foreach_res(console_resource_tmp, R_CONSOLE) {
numcon++;
}
UnlockRes(my_config);

if (numdir == 1) { /* No choose */
director_resource = (DirectorResource *)my_config->GetNextRes(R_DIRECTOR, NULL);
director_resource_tmp = (DirectorResource *)my_config->GetNextRes(R_DIRECTOR, NULL);
}

if (director) { /* Command line choice overwrite the no choose option */
LockRes(my_config);
foreach_res(director_resource, R_DIRECTOR) {
if (bstrcmp(director_resource->name(), director)) {
foreach_res(director_resource_tmp, R_DIRECTOR) {
if (bstrcmp(director_resource_tmp->name(), director)) {
break;
}
}
UnlockRes(my_config);
if (!director_resource) { /* Can't find Director used as argument */
if (!director_resource_tmp) { /* Can't find Director used as argument */
ConsoleOutputFormat(_("Can't find %s in Director list\n"), director);
return 0;
}
}

if (!director_resource) { /* prompt for director */
if (!director_resource_tmp) { /* prompt for director */
UA_sock = New(BareosSocketTCP);
try_again:
ConsoleOutput(_("Available Directors:\n"));
LockRes(my_config);
numdir = 0;
foreach_res(director_resource, R_DIRECTOR) {
ConsoleOutputFormat( _("%2d: %s at %s:%d\n"), 1+numdir++, director_resource->name(), director_resource->address, director_resource->DIRport);
foreach_res(director_resource_tmp, R_DIRECTOR) {
ConsoleOutputFormat( _("%2d: %s at %s:%d\n"), 1+numdir++, director_resource_tmp->name(),
director_resource_tmp->address, director_resource_tmp->DIRport);
}
UnlockRes(my_config);
if (GetCmd(stdin, _("Select Director by entering a number: "), UA_sock, 600) < 0) {
Expand All @@ -812,7 +813,8 @@ static bool SelectDirector(const char *director, DirectorResource **ret_dir, Con
delete UA_sock;
LockRes(my_config);
for (i=0; i<item; i++) {
director_resource = (DirectorResource *)my_config->GetNextRes(R_DIRECTOR, (CommonResourceHeader *)director_resource);
director_resource_tmp = (DirectorResource *)my_config->GetNextRes(R_DIRECTOR,
(CommonResourceHeader *)director_resource_tmp);
}
UnlockRes(my_config);
}
Expand All @@ -822,35 +824,35 @@ static bool SelectDirector(const char *director, DirectorResource **ret_dir, Con
*/
LockRes(my_config);
for (i=0; i<numcon; i++) {
console_resource = (ConsoleResource *)my_config->GetNextRes(R_CONSOLE, (CommonResourceHeader *)console_resource);
if (console_resource->director && bstrcmp(console_resource->director, director_resource->name())) {
console_resource_tmp = (ConsoleResource *)my_config->GetNextRes(R_CONSOLE, (CommonResourceHeader *)console_resource_tmp);
if (console_resource_tmp->director && bstrcmp(console_resource_tmp->director, director_resource_tmp->name())) {
break;
}
console_resource = NULL;
console_resource_tmp = NULL;
}

/*
* Look for the first non-linked console
*/
if (console_resource == NULL) {
if (console_resource_tmp == NULL) {
for (i=0; i<numcon; i++) {
console_resource = (ConsoleResource *)my_config->GetNextRes(R_CONSOLE, (CommonResourceHeader *)console_resource);
if (console_resource->director == NULL)
console_resource_tmp = (ConsoleResource *)my_config->GetNextRes(R_CONSOLE, (CommonResourceHeader *)console_resource_tmp);
if (console_resource_tmp->director == NULL)
break;
console_resource = NULL;
console_resource_tmp = NULL;
}
}

/*
* If no console, take first one
*/
if (!console_resource) {
console_resource = (ConsoleResource *)my_config->GetNextRes(R_CONSOLE, (CommonResourceHeader *)NULL);
if (!console_resource_tmp) {
console_resource_tmp = (ConsoleResource *)my_config->GetNextRes(R_CONSOLE, (CommonResourceHeader *)NULL);
}
UnlockRes(my_config);

*ret_dir = director_resource;
*ret_cons = console_resource;
*ret_dir = director_resource_tmp;
*ret_cons = console_resource_tmp;

return 1;
}
Expand Down
5 changes: 2 additions & 3 deletions core/src/lib/bsock.cc
Expand Up @@ -459,10 +459,9 @@ void BareosSocket::ParameterizeTlsCert(Tls *tls_conn_init, TlsResource *tls_reso
tls_conn_init->SetCrlfile(tls_resource->tls_cert.crlfile ? *tls_resource->tls_cert.crlfile : empty);
tls_conn_init->SetCertfile(tls_resource->tls_cert.certfile ? *tls_resource->tls_cert.certfile : empty);
tls_conn_init->SetKeyfile(tls_resource->tls_cert.keyfile ? *tls_resource->tls_cert.keyfile : empty);
// tls_conn_init->SetPemCallback(TlsPemCallback); Ueb: --> Console Callback
// tls_conn_init->SetPemCallback(TlsPemCallback); Ueb: --> Feature not implemented: Console Callback
tls_conn_init->SetPemUserdata(tls_resource->tls_cert.pem_message);
tls_conn_init->SetDhFile(tls_resource->tls_cert.dhfile ? *tls_resource->tls_cert.dhfile
: empty); /* Ueb: was never used before */
tls_conn_init->SetDhFile(tls_resource->tls_cert.dhfile ? *tls_resource->tls_cert.dhfile : empty);
tls_conn_init->SetCipherList(tls_resource->tls_cert.cipherlist ? *tls_resource->tls_cert.cipherlist : empty);
tls_conn_init->SetVerifyPeer(tls_resource->tls_cert.VerifyPeer);
}
Expand Down
3 changes: 1 addition & 2 deletions core/src/lib/tls_openssl_private.cc
Expand Up @@ -112,7 +112,6 @@ bool TlsOpenSslPrivate::init()
/* At least one CA is required for peer verification */
Dmsg0(100, _("Either a certificate file or a directory must be"
" specified as a verification store\n"));
// return false; Ueb: do not return compatibility ?
}

#if (OPENSSL_VERSION_NUMBER >= 0x00907000L) && (OPENSSL_VERSION_NUMBER < 0x10100000L)
Expand Down Expand Up @@ -143,7 +142,7 @@ bool TlsOpenSslPrivate::init()
OpensslPostErrors(M_FATAL, _("Unable to open DH parameters file"));
return false;
}
DH *dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); // Ueb: bio richtig initialisieren
DH *dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); // Ueb: Init BIO correctly?
BIO_free(bio);
if (!dh) {
OpensslPostErrors(M_FATAL, _("Unable to load DH parameters from specified file"));
Expand Down

0 comments on commit 8857ebf

Please sign in to comment.