]> git.sur5r.net Git - bacula/bacula/commitdiff
Make sure authentication messages are displayed in bat
authorKern Sibbald <kern@sibbald.com>
Mon, 21 May 2007 18:22:59 +0000 (18:22 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 21 May 2007 18:22:59 +0000 (18:22 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4868 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/console/authenticate.cpp
bacula/src/qt-console/console/console.cpp
bacula/src/qt-console/console/console.h

index 566718865ffd027cbdc779542a8fdbf300417651..d702e2ce853e7323318d2e2ecdaa5c2c7595174a 100644 (file)
@@ -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, "<dird: %s", dir->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"), 
index c7ab58d7ce38d9cba15be6d34072db1e091c0a34..725972a719786625142ce0596b95508670d212b5 100644 (file)
@@ -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;
index ec54da8a9b5d5181f374db892117e2645d87af6e..f27ec02afa3a25a0a7fe24183713a232ee9f235a 100644 (file)
@@ -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();