]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/bnet.c
- Add Version, ConfigDir, and WorkingDir as Python attributes
[bacula/bacula] / bacula / src / lib / bnet.c
index 204fbe755cc1fd89a712a1a5e7e4185c55cdda57..79c337692f4a65d8e27b9cf4bd121af95ee75aaa 100644 (file)
@@ -9,22 +9,17 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2004 Kern Sibbald
+   Copyright (C) 2000-2005 Kern Sibbald
 
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as ammended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
-   This library is distributed in the hope that it will be useful,
+   This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -505,6 +500,17 @@ err:
    bsock->tls = NULL;
    return 0;
 }
+#else
+int bnet_tls_server(TLS_CONTEXT *ctx, BSOCK * bsock, alist *verify_list)
+{
+   Jmsg(bsock->jcr, M_ABORT, 0, _("TLS not configured.\n"));
+   return 0;
+}
+int bnet_tls_client(TLS_CONTEXT *ctx, BSOCK * bsock)
+{
+   Jmsg(bsock->jcr, M_ABORT, 0, _("TLS not configured.\n"));
+   return 0;
+}
 #endif /* HAVE_TLS */
 
 /*
@@ -554,19 +560,17 @@ int bnet_wait_data_intr(BSOCK * bsock, int sec)
    FD_SET((unsigned)bsock->fd, &fdset);
    tv.tv_sec = sec;
    tv.tv_usec = 0;
-   for (;;) {
-      switch (select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) {
-      case 0:                      /* timeout */
-         bsock->b_errno = 0;
-         return 0;
-      case -1:
-         bsock->b_errno = errno;
-         return -1;                /* error return */
-      default:
-         bsock->b_errno = 0;
-         return 1;
-      }
+   switch (select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) {
+   case 0:                      /* timeout */
+      bsock->b_errno = 0;
+      return 0;
+   case -1:
+      bsock->b_errno = errno;
+      return -1;                /* error return */
+   default:
+      bsock->b_errno = 0;
    }
+   return 1;
 }
 
 #ifndef NETDB_INTERNAL
@@ -594,9 +598,10 @@ int bnet_wait_data_intr(BSOCK * bsock, int sec)
 static const char *gethost_strerror()
 {
    const char *msg;
+   berrno be;
    switch (h_errno) {
    case NETDB_INTERNAL:
-      msg = strerror(errno);
+      msg = be.strerror();
       break;
    case NETDB_SUCCESS:
       msg = "No problem.";
@@ -977,12 +982,14 @@ int bnet_set_nonblocking (BSOCK *bsock) {
 
    /* Get current flags */
    if((oflags = fcntl(bsock->fd, F_GETFL, 0)) < 0) {
-      Emsg1(M_ABORT, 0, "fcntl F_GETFL error. ERR=%s\n", strerror(errno));
+      berrno be;
+      Emsg1(M_ABORT, 0, "fcntl F_GETFL error. ERR=%s\n", be.strerror());
    }
 
    /* Set O_NONBLOCK flag */
    if((fcntl(bsock->fd, F_SETFL, oflags|O_NONBLOCK)) < 0) {
-      Emsg1(M_ABORT, 0, "fcntl F_SETFL error. ERR=%s\n", strerror(errno));
+      berrno be;
+      Emsg1(M_ABORT, 0, "fcntl F_SETFL error. ERR=%s\n", be.strerror());
    }
 
    bsock->blocking = 0;
@@ -1008,12 +1015,14 @@ int bnet_set_blocking (BSOCK *bsock) {
    int oflags;
    /* Get current flags */
    if((oflags = fcntl(bsock->fd, F_GETFL, 0)) < 0) {
-      Emsg1(M_ABORT, 0, "fcntl F_GETFL error. ERR=%s\n", strerror(errno));
+      berrno be;
+      Emsg1(M_ABORT, 0, "fcntl F_GETFL error. ERR=%s\n", be.strerror());
    }
 
    /* Set O_NONBLOCK flag */
    if((fcntl(bsock->fd, F_SETFL, oflags & ~O_NONBLOCK)) < 0) {
-      Emsg1(M_ABORT, 0, "fcntl F_SETFL error. ERR=%s\n", strerror(errno));
+      berrno be;
+      Emsg1(M_ABORT, 0, "fcntl F_SETFL error. ERR=%s\n", be.strerror());
    }
 
    bsock->blocking = 1;
@@ -1036,7 +1045,8 @@ int bnet_set_blocking (BSOCK *bsock) {
 void bnet_restore_blocking (BSOCK *bsock, int flags) {
 #ifndef WIN32
    if((fcntl(bsock->fd, F_SETFL, flags)) < 0) {
-      Emsg1(M_ABORT, 0, "fcntl F_SETFL error. ERR=%s\n", strerror(errno));
+      berrno be;
+      Emsg1(M_ABORT, 0, "fcntl F_SETFL error. ERR=%s\n", be.strerror());
    }
 
    bsock->blocking = (flags & O_NONBLOCK);