From: Kern Sibbald Date: Mon, 21 May 2007 18:22:59 +0000 (+0000) Subject: Make sure authentication messages are displayed in bat X-Git-Tag: Release-2.2.0~426 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3345ea7f52a5b61979cff31e82d3ee583187086e;p=bacula%2Fbacula Make sure authentication messages are displayed in bat git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4868 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/console/authenticate.cpp b/bacula/src/qt-console/console/authenticate.cpp index 566718865f..d702e2ce85 100644 --- a/bacula/src/qt-console/console/authenticate.cpp +++ b/bacula/src/qt-console/console/authenticate.cpp @@ -52,7 +52,8 @@ static char OKhello[] = "1000 OK:"; /* * Authenticate Director */ -bool Console::authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons) +bool Console::authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons, + char *msg, int msglen) { BSOCK *dir = jcr->dir_bsock; int tls_local_need = BNET_TLS_NONE; @@ -62,6 +63,7 @@ bool Console::authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons) char *password; TLS_CONTEXT *tls_ctx = NULL; + msg[0] = 0; /* * Send my name to the Director then do authentication */ @@ -101,14 +103,14 @@ bool Console::authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons) if (!cram_md5_respond(dir, password, &tls_remote_need, &compatible) || /* Now challenge dir */ !cram_md5_challenge(dir, password, tls_local_need, compatible)) { - display_textf(_("Director authorization problem at \"%s:%d\"\n"), + bsnprintf(msg, msglen, _("Director authorization problem 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) { - display_textf(_("Authorization problem:" + bsnprintf(msg, msglen, _("Authorization problem:" " Remote server at \"%s:%d\" did not advertise required TLS support.\n"), dir->host(), dir->port()); goto bail_out; @@ -116,7 +118,7 @@ bool Console::authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons) /* 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) { - display_textf(_("Authorization problem with Director at \"%s:%d\":" + bsnprintf(msg, msglen, _("Authorization problem with Director at \"%s:%d\":" " Remote server requires TLS.\n"), dir->host(), dir->port()); @@ -128,7 +130,7 @@ bool Console::authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons) 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)) { - display_textf(_("TLS negotiation failed with Director at \"%s:%d\"\n"), + bsnprintf(msg, msglen, _("TLS negotiation failed with Director at \"%s:%d\"\n"), dir->host(), dir->port()); goto bail_out; } @@ -138,7 +140,7 @@ bool Console::authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons) Dmsg1(6, ">dird: %s", dir->msg); if (dir->recv() <= 0) { stop_bsock_timer(tid); - display_textf(_("Bad response to Hello command: ERR=%s\n" + bsnprintf(msg, msglen, _("Bad response to Hello command: ERR=%s\n" "The Director at \"%s:%d\" is probably not running.\n"), dir->bstrerror(), dir->host(), dir->port()); return false; @@ -147,17 +149,17 @@ bool Console::authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons) stop_bsock_timer(tid); Dmsg1(10, "msg); if (strncmp(dir->msg, OKhello, sizeof(OKhello)-1) != 0) { - display_textf(_("Director at \"%s:%d\" rejected Hello command\n"), + bsnprintf(msg, msglen, _("Director at \"%s:%d\" rejected Hello command\n"), dir->host(), dir->port()); return false; } else { - display_text(dir->msg); + bsnprintf(msg, msglen, "%s", dir->msg); } return true; bail_out: stop_bsock_timer(tid); - display_textf(_("Authorization problem with Director at \"%s:%d\"\n" + bsnprintf(msg, msglen, _("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 validation error during the TLS handshake.\n" "Please see http://www.bacula.org/rel-manual/faq.html#AuthorizationErrors for help.\n"), diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index c7ab58d7ce..725972a719 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -97,6 +97,7 @@ void Console::connect() { JCR jcr; utime_t heart_beat; + char buf[1024]; m_textEdit = textEdit; /* our console screen */ @@ -122,7 +123,6 @@ void Console::connect() CONRES *cons = (CONRES *)GetNextRes(R_CONSOLE, NULL); UnlockRes(); - char buf[1024]; /* Initialize Console TLS context */ if (cons && (cons->tls_enable || cons->tls_require)) { /* Generate passphrase prompt */ @@ -189,10 +189,13 @@ void Console::connect() jcr.dir_bsock = m_sock; - if (!authenticate_director(&jcr, m_dir, cons)) { - display_text(m_sock->msg); + if (!authenticate_director(&jcr, m_dir, cons, buf, sizeof(buf))) { + display_text(buf); return; } + if (buf[0]) { + display_text(buf); + } /* Give GUI a chance */ app->processEvents(); @@ -758,7 +761,7 @@ bool Console::preventInUseConnect() message += m_dir->name(); message += " is curerntly busy\n Please complete restore or other " " operation !! This is a limitation that will be resolved before a beta" -" release. This is currently an alpa release."; +" release. This is currently an alpha release."; QMessageBox::warning(this, tr("Bat"), tr(message.toUtf8().data()), QMessageBox::Ok ); return false; diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index ec54da8a9b..f27ec02afa 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -80,7 +80,8 @@ public: bool dir_cmd(QString &cmd, QStringList &results); bool sql_cmd(const char *cmd, QStringList &results); bool sql_cmd(QString &cmd, QStringList &results); - bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons); + bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons, + char *buf, int buflen); bool is_connected() { return m_sock != NULL; }; bool is_connectedGui(); bool preventInUseConnect();