From: Kern Sibbald Date: Thu, 3 Jul 2014 09:32:54 +0000 (+0200) Subject: Tweak bsock error messages X-Git-Tag: Release-7.0.5~32 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c85939df89d2976688af4be4df8e8db5ae757317;p=bacula%2Fbacula Tweak bsock error messages --- diff --git a/bacula/src/lib/bsock.c b/bacula/src/lib/bsock.c index 1caba11d1c..eb9041cee1 100644 --- a/bacula/src/lib/bsock.c +++ b/bacula/src/lib/bsock.c @@ -132,7 +132,7 @@ bail_out: * Finish initialization of the packet structure. */ void BSOCK::fin_init(JCR * jcr, int sockfd, const char *who, const char *host, int port, - struct sockaddr *lclient_addr) + struct sockaddr *lclient_addr) { Dmsg3(100, "who=%s host=%s port=%d\n", who, host, port); m_fd = sockfd; @@ -174,7 +174,7 @@ void BSOCK::set_source_address(dlist *src_addr_list) * Returns BSOCK * pointer on success */ bool BSOCK::open(JCR *jcr, const char *name, char *host, char *service, - int port, utime_t heart_beat, int *fatal) + int port, utime_t heart_beat, int *fatal) { int sockfd = -1; dlist *addr_list; @@ -199,7 +199,6 @@ bool BSOCK::open(JCR *jcr, const char *name, char *host, char *service, } remove_duplicate_addresses(addr_list); - foreach_dlist(ipaddr, addr_list) { ipaddr->set_port_net(htons(port)); char allbuf[256 * 10]; @@ -1051,7 +1050,7 @@ static char OKhello[] = "1000 OK:"; * Authenticate Director */ bool BSOCK::authenticate_director(const char *name, const char *password, - TLS_CONTEXT *tls_ctx, char *response, int response_len) + TLS_CONTEXT *tls_ctx, char *errmsg, int errmsg_len) { int tls_local_need = BNET_TLS_NONE; int tls_remote_need = BNET_TLS_NONE; @@ -1059,7 +1058,7 @@ bool BSOCK::authenticate_director(const char *name, const char *password, char bashed_name[MAX_NAME_LENGTH]; BSOCK *dir = this; /* for readability */ - response[0] = 0; + *errmsg = 0; /* * Send my name to the Director then do authentication */ @@ -1076,14 +1075,14 @@ bool BSOCK::authenticate_director(const char *name, const char *password, if (!cram_md5_respond(dir, password, &tls_remote_need, &compatible) || /* Now challenge dir */ !cram_md5_challenge(dir, password, tls_local_need, compatible)) { - bsnprintf(response, response_len, _("Director authorization problem at \"%s:%d\"\n"), + bsnprintf(errmsg, errmsg_len, _("Director authorization error at \"%s:%d\"\n"), dir->host(), dir->port()); goto bail_out; } /* Verify that the remote host is willing to meet our TLS requirements */ if (tls_remote_need < tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) { - bsnprintf(response, response_len, _("Authorization problem:" + bsnprintf(errmsg, errmsg_len, _("Authorization error:" " Remote server at \"%s:%d\" did not advertise required TLS support.\n"), dir->host(), dir->port()); goto bail_out; @@ -1091,7 +1090,7 @@ bool BSOCK::authenticate_director(const char *name, const char *password, /* Verify that we are willing to meet the remote host's requirements */ if (tls_remote_need > tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) { - bsnprintf(response, response_len, _("Authorization problem with Director at \"%s:%d\":" + bsnprintf(errmsg, errmsg_len, _("Authorization error with Director at \"%s:%d\":" " Remote server requires TLS.\n"), dir->host(), dir->port()); @@ -1103,7 +1102,7 @@ bool BSOCK::authenticate_director(const char *name, const char *password, if (tls_local_need >= BNET_TLS_OK && tls_remote_need >= BNET_TLS_OK) { /* Engage TLS! Full Speed Ahead! */ if (!bnet_tls_client(tls_ctx, dir, NULL)) { - bsnprintf(response, response_len, _("TLS negotiation failed with Director at \"%s:%d\"\n"), + bsnprintf(errmsg, errmsg_len, _("TLS negotiation failed with Director at \"%s:%d\"\n"), dir->host(), dir->port()); goto bail_out; } @@ -1113,8 +1112,8 @@ bool BSOCK::authenticate_director(const char *name, const char *password, Dmsg1(6, ">dird: %s", dir->msg); if (dir->recv() <= 0) { dir->stop_timer(); - bsnprintf(response, response_len, _("Bad response to Hello command: ERR=%s\n" - "The Director at \"%s:%d\" is probably not running.\n"), + bsnprintf(errmsg, errmsg_len, _("Bad errmsg to Hello command: ERR=%s\n" + "The Director at \"%s:%d\" may not be running.\n"), dir->bstrerror(), dir->host(), dir->port()); return false; } @@ -1122,17 +1121,17 @@ bool BSOCK::authenticate_director(const char *name, const char *password, dir->stop_timer(); Dmsg1(10, "msg); if (strncmp(dir->msg, OKhello, sizeof(OKhello)-1) != 0) { - bsnprintf(response, response_len, _("Director at \"%s:%d\" rejected Hello command\n"), + bsnprintf(errmsg, errmsg_len, _("Director at \"%s:%d\" rejected Hello command\n"), dir->host(), dir->port()); return false; } else { - bsnprintf(response, response_len, "%s", dir->msg); + bsnprintf(errmsg, errmsg_len, "%s", dir->msg); } return true; bail_out: dir->stop_timer(); - bsnprintf(response, response_len, _("Authorization problem with Director at \"%s:%d\"\n" + bsnprintf(errmsg, errmsg_len, _("Authorization error 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 validation error during the TLS handshake.\n" "Please see " MANUAL_AUTH_URL " for help.\n"),