]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/bnet.c
More changes to ensure that during thread switches the jcr
[bacula/bacula] / bacula / src / lib / bnet.c
index 16736a7b7ee8357cc561608fdd620c32ff8cbd65..9cc236998c382e0d1fd2c1fb8c8384b4e7215a10 100644 (file)
@@ -1,14 +1,14 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
 
    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
-   License as published by the Free Software Foundation plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
 
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,7 @@
    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.
@@ -41,8 +41,6 @@
 #include "jcr.h"
 #include <netdb.h>
 
-extern time_t watchdog_time;
-
 #ifndef   INADDR_NONE
 #define   INADDR_NONE    -1
 #endif
@@ -110,7 +108,7 @@ int32_t write_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes)
 {
    int32_t nleft, nwritten;
 
-   if (bsock->m_spool) {
+   if (bsock->is_spooling()) {
       nwritten = fwrite(ptr, 1, nbytes, bsock->m_spool_fd);
       if (nwritten != nbytes) {
          berrno be;
@@ -238,6 +236,7 @@ bool bnet_send(BSOCK *bsock)
 bool bnet_tls_server(TLS_CONTEXT *ctx, BSOCK * bsock, alist *verify_list)
 {
    TLS_CONNECTION *tls;
+   JCR *jcr = bsock->jcr();
    
    tls = new_tls_connection(ctx, bsock->m_fd);
    if (!tls) {
@@ -254,13 +253,14 @@ bool bnet_tls_server(TLS_CONTEXT *ctx, BSOCK * bsock, alist *verify_list)
    }
 
    if (verify_list) {
-      if (!tls_postconnect_verify_cn(tls, verify_list)) {
+      if (!tls_postconnect_verify_cn(jcr, tls, verify_list)) {
          Qmsg1(bsock->jcr(), M_FATAL, 0, _("TLS certificate verification failed."
                                          " Peer certificate did not match a required commonName\n"),
                                          bsock->host());
          goto err;
       }
    }
+   Dmsg0(50, "TLS server negotiation established.\n");
    return true;
 
 err:
@@ -277,6 +277,7 @@ err:
 bool bnet_tls_client(TLS_CONTEXT *ctx, BSOCK * bsock, alist *verify_list)
 {
    TLS_CONNECTION *tls;
+   JCR *jcr = bsock->jcr();
 
    tls  = new_tls_connection(ctx, bsock->m_fd);
    if (!tls) {
@@ -294,20 +295,20 @@ bool bnet_tls_client(TLS_CONTEXT *ctx, BSOCK * bsock, alist *verify_list)
    /* If there's an Allowed CN verify list, use that to validate the remote
     * certificate's CN. Otherwise, we use standard host/CN matching. */
    if (verify_list) {
-      if (!tls_postconnect_verify_cn(tls, verify_list)) {
+      if (!tls_postconnect_verify_cn(jcr, tls, verify_list)) {
          Qmsg1(bsock->jcr(), M_FATAL, 0, _("TLS certificate verification failed."
                                          " Peer certificate did not match a required commonName\n"),
                                          bsock->host());
          goto err;
       }
    } else {
-      if (!tls_postconnect_verify_host(tls, bsock->host())) {
-         Qmsg1(bsock->jcr(), M_FATAL, 0, _("TLS host certificate verification failed. Host %s did not match presented certificate\n"), 
+      if (!tls_postconnect_verify_host(jcr, tls, bsock->host())) {
+         Qmsg1(bsock->jcr(), M_FATAL, 0, _("TLS host certificate verification failed. Host name \"%s\" did not match presented certificate\n"), 
                bsock->host());
          goto err;
       }
    }
-
+   Dmsg0(50, "TLS client negotiation established.\n");
    return true;
 
 err:
@@ -686,7 +687,7 @@ BSOCK *init_bsock(JCR * jcr, int sockfd, const char *who, const char *host, int
    return bsock;
 }
 
-BSOCK *dup_bsock(BSOCK * osock)
+BSOCK *dup_bsock(BSOCK *osock)
 {
    BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK));
    memcpy(bsock, osock, sizeof(BSOCK));
@@ -698,7 +699,7 @@ BSOCK *dup_bsock(BSOCK * osock)
    if (osock->host()) {
       bsock->set_host(bstrdup(osock->host()));
    }
-   bsock->m_duped = true;
+   bsock->set_duped();
    return bsock;
 }