]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/cram-md5.c
First cut of bat rerun a Job from Jobs Run
[bacula/bacula] / bacula / src / lib / cram-md5.c
index f2eefa66d60a29dc2819861193c5d6a9b8789cd5..35651af0292b02210bed89d434597dfa04287608 100644 (file)
@@ -6,7 +6,7 @@
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Bacula® is a registered trademark of John Walker.
+   Bacula® is a registered trademark of Kern Sibbald.
    The licensor of Bacula is the Free Software Foundation Europe
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
@@ -37,6 +37,8 @@
 
 #include "bacula.h"
 
+const int dbglvl = 50;
+
 /* Authorize other end
  * Codes that tls_local_need and tls_remote_need can take:
  *   BNET_TLS_NONE     I cannot do tls
@@ -68,23 +70,23 @@ bool cram_md5_challenge(BSOCK *bs, const char *password, int tls_local_need, int
    /* Send challenge -- no hashing yet */
    bsnprintf(chal, sizeof(chal), "<%u.%u@%s>", (uint32_t)random(), (uint32_t)time(NULL), host);
    if (compatible) {
-      Dmsg2(50, "send: auth cram-md5 %s ssl=%d\n", chal, tls_local_need);
+      Dmsg2(dbglvl, "send: auth cram-md5 %s ssl=%d\n", chal, tls_local_need);
       if (!bs->fsend("auth cram-md5 %s ssl=%d\n", chal, tls_local_need)) {
-         Dmsg1(50, "Bnet send challenge error.\n", bs->bstrerror());
+         Dmsg1(dbglvl, "Bnet send challenge comm error. ERR=%s\n", bs->bstrerror());
          return false;
       }
    } else {
       /* Old non-compatible system */
-      Dmsg2(50, "send: auth cram-md5 %s ssl=%d\n", chal, tls_local_need);
+      Dmsg2(dbglvl, "send: auth cram-md5 %s ssl=%d\n", chal, tls_local_need);
       if (!bs->fsend("auth cram-md5 %s ssl=%d\n", chal, tls_local_need)) {
-         Dmsg1(50, "Bnet send challenge error.\n", bs->bstrerror());
+         Dmsg1(dbglvl, "Bnet send challenge comm error. ERR=%s\n", bs->bstrerror());
          return false;
       }
    }
 
    /* Read hashed response to challenge */
    if (bs->wait_data(180) <= 0 || bs->recv() <= 0) {
-      Dmsg1(50, "Bnet receive challenge response error.\n", bs->bstrerror());
+      Dmsg1(dbglvl, "Bnet receive challenge response comm error. ERR=%s\n", bs->bstrerror());
       bmicrosleep(5, 0);
       return false;
    }
@@ -94,18 +96,18 @@ bool cram_md5_challenge(BSOCK *bs, const char *password, int tls_local_need, int
    bin_to_base64(host, sizeof(host), (char *)hmac, 16, compatible);
    ok = strcmp(bs->msg, host) == 0;
    if (ok) {
-      Dmsg1(50, "Authenticate OK %s\n", host);
+      Dmsg1(dbglvl, "Authenticate OK %s\n", host);
    } else {
       bin_to_base64(host, sizeof(host), (char *)hmac, 16, false);     
       ok = strcmp(bs->msg, host) == 0;
       if (!ok) {
-         Dmsg2(50, "Authenticate NOT OK: wanted %s, got %s\n", host, bs->msg);
+         Dmsg2(dbglvl, "Authenticate NOT OK: wanted %s, got %s\n", host, bs->msg);
       }
    }
    if (ok) {
       bs->fsend("1000 OK auth\n");
    } else {
-      Dmsg1(50, "Auth failed PW: %s\n", password);
+      Dmsg1(dbglvl, "Auth failed PW: %s\n", password);
       bs->fsend(_("1999 Authorization failed.\n"));
       bmicrosleep(5, 0);
    }
@@ -124,7 +126,7 @@ bool cram_md5_respond(BSOCK *bs, const char *password, int *tls_remote_need, int
       return false;
    }
    if (bs->msglen >= MAXSTRING) {
-      Dmsg1(50, "Msg too long wanted auth cram... Got: %s", bs->msg);
+      Dmsg1(dbglvl, "Msg too long wanted auth cram... Got: %s", bs->msg);
       bmicrosleep(5, 0);
       return false;
    }
@@ -133,7 +135,7 @@ bool cram_md5_respond(BSOCK *bs, const char *password, int *tls_remote_need, int
       *compatible = true;
    } else if (sscanf(bs->msg, "auth cram-md5 %s ssl=%d", chal, tls_remote_need) != 2) {
       if (sscanf(bs->msg, "auth cram-md5 %s\n", chal) != 1) {
-         Dmsg1(50, "Cannot scan challenge: %s", bs->msg);
+         Dmsg1(dbglvl, "Cannot scan challenge: %s", bs->msg);
          bs->fsend(_("1999 Authorization failed.\n"));
          bmicrosleep(5, 0);
          return false;
@@ -144,19 +146,19 @@ bool cram_md5_respond(BSOCK *bs, const char *password, int *tls_remote_need, int
    bs->msglen = bin_to_base64(bs->msg, 50, (char *)hmac, 16, *compatible) + 1;
 // Dmsg3(100, "get_auth: chal=%s pw=%s hmac=%s\n", chal, password, bs->msg);
    if (!bs->send()) {
-      Dmsg1(50, "Send challenge failed. ERR=%s\n", bs->bstrerror());
+      Dmsg1(dbglvl, "Send challenge failed. ERR=%s\n", bs->bstrerror());
       return false;
    }
    Dmsg1(99, "sending resp to challenge: %s\n", bs->msg);
    if (bs->wait_data(180) <= 0 || bs->recv() <= 0) {
-      Dmsg1(50, "Receive chanllenge response failed. ERR=%s\n", bs->bstrerror());
+      Dmsg1(dbglvl, "Receive chanllenge response failed. ERR=%s\n", bs->bstrerror());
       bmicrosleep(5, 0);
       return false;
    }
    if (strcmp(bs->msg, "1000 OK auth\n") == 0) {
       return true;
    }
-   Dmsg1(50, "Received bad response: %s\n", bs->msg);
+   Dmsg1(dbglvl, "Received bad response: %s\n", bs->msg);
    bmicrosleep(5, 0);
    return false;
 }