]> git.sur5r.net Git - bacula/bacula/commitdiff
- Landon Fuller committed his TLS patch.
authorKern Sibbald <kern@sibbald.com>
Fri, 22 Apr 2005 10:12:46 +0000 (10:12 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 22 Apr 2005 10:12:46 +0000 (10:12 +0000)
- Fixed two minor warnings in console.c with TLS turned off.
- Updated the Makefile.in for wx-windows and tray-monitor
  to handle TLS. I can only build the tray-monitor.
- Fix bscan to open tape in read-only mode (actually fix
  it so that it doesn't use the standard open routine).

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1948 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/console/console.c
bacula/src/stored/butil.c
bacula/src/stored/dvd.c
bacula/src/tray-monitor/Makefile.in
bacula/src/version.h
bacula/src/wx-console/Makefile.in

index e8d0299ea4673c0136172d595b282ce47b6c91b5..0af666a9b1d12c6f656eff54255de0c033f82d9c 100644 (file)
@@ -26,8 +26,15 @@ Autochangers:
      and possibly manipulating the autochanger (much asked for).
 -    Make "update slots" when pointing to Autochanger, remove
      all Volumes from other drives.  "update slots all-drives"?
+
+Idea:
+- Use non-blocking network I/O but if no data is available, use
+  select().
+- Use gather write() for network I/O.
   
 For 1.37:
+- If drive is opened read/write, close it and re-open
+  read-only if doing a restore, and vice-versa.
 - Fix FD JobType to be set before RunBeforeJob in FD.
 - SD crashes after a tape restore then doing a backup. 
 - Look at dird_conf.c:1000: warning: `int size' 
index b97887a96c5585354827c3cfcbbb25244c035827..f6a6d98510653a8e035901d9bf6ab28de2b390dc 100644 (file)
@@ -323,7 +323,6 @@ int main(int argc, char *argv[])
    int ch, i, item;
    bool no_signals = false;
    bool test_config = false;
-   char buf[1024];
    JCR jcr;
 
    init_stack_dump();
@@ -456,6 +455,7 @@ try_again:
    senditf(_("Connecting to Director %s:%d\n"), dir->address,dir->DIRport);
 
 #ifdef HAVE_TLS
+   char buf[1024];
    /* Initialize Console TLS context */
    if (cons && (cons->tls_enable || cons->tls_require)) {
       /* Generate passphrase prompt */
@@ -466,13 +466,13 @@ try_again:
        * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
       cons->tls_ctx = new_tls_context(cons->tls_ca_certfile,
          cons->tls_ca_certdir, cons->tls_certfile,
-        cons->tls_keyfile, tls_pem_callback, &buf, NULL, true);
+         cons->tls_keyfile, tls_pem_callback, &buf, NULL, true);
 
       if (!cons->tls_ctx) {
-        senditf(_("Failed to initialize TLS context for Console \"%s\".\n"),
-           dir->hdr.name);
-        terminate_console(0);
-        return 1;
+         senditf(_("Failed to initialize TLS context for Console \"%s\".\n"),
+            dir->hdr.name);
+         terminate_console(0);
+         return 1;
       }
 
    }
@@ -487,13 +487,13 @@ try_again:
        * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
       dir->tls_ctx = new_tls_context(dir->tls_ca_certfile,
          dir->tls_ca_certdir, dir->tls_certfile,
-        dir->tls_keyfile, tls_pem_callback, &buf, NULL, true);
+         dir->tls_keyfile, tls_pem_callback, &buf, NULL, true);
 
       if (!dir->tls_ctx) {
-        senditf(_("Failed to initialize TLS context for Director \"%s\".\n"),
-           dir->hdr.name);
-        terminate_console(0);
-        return 1;
+         senditf(_("Failed to initialize TLS context for Director \"%s\".\n"),
+            dir->hdr.name);
+         terminate_console(0);
+         return 1;
       }
    }
 #endif /* HAVE_TLS */
@@ -570,7 +570,6 @@ static void terminate_console(int sig)
 static int check_resources()
 {
    bool OK = true;
-   CONRES *cons;
    DIRRES *director;
 
    LockRes();
@@ -582,38 +581,39 @@ static int check_resources()
 #ifdef HAVE_TLS
       /* tls_require implies tls_enable */
       if (director->tls_require) {
-        director->tls_enable = true;
+         director->tls_enable = true;
       }
 
       if ((!director->tls_ca_certfile && !director->tls_ca_certdir) && director->tls_enable) {
-        Emsg2(M_FATAL, 0, _("Neither \"TLS CA Certificate\""
-                            " or \"TLS CA Certificate Dir\" are defined for Director \"%s\" in %s."
-                            " At least one CA certificate store is required.\n"),
-                            director->hdr.name, configfile);
-        OK = false;
+         Emsg2(M_FATAL, 0, _("Neither \"TLS CA Certificate\""
+                             " or \"TLS CA Certificate Dir\" are defined for Director \"%s\" in %s."
+                             " At least one CA certificate store is required.\n"),
+                             director->hdr.name, configfile);
+         OK = false;
       }
 #endif /* HAVE_TLS */
    }
    
    if (numdir == 0) {
       Emsg1(M_FATAL, 0, _("No Director resource defined in %s\n"
-                         "Without that I don't how to speak to the Director :-(\n"), configfile);
+                          "Without that I don't how to speak to the Director :-(\n"), configfile);
       OK = false;
    }
 
 #ifdef HAVE_TLS
+   CONRES *cons;
    /* Loop over Consoles */
    foreach_res(cons, R_CONSOLE) {
       /* tls_require implies tls_enable */
       if (cons->tls_require) {
-        cons->tls_enable = true;
+         cons->tls_enable = true;
       }
 
       if ((!cons->tls_ca_certfile && !cons->tls_ca_certdir) && cons->tls_enable) {
-        Emsg2(M_FATAL, 0, _("Neither \"TLS CA Certificate\""
-                            " or \"TLS CA Certificate Dir\" are defined for Console \"%s\" in %s.\n"),
-                            cons->hdr.name, configfile);
-        OK = false;
+         Emsg2(M_FATAL, 0, _("Neither \"TLS CA Certificate\""
+                             " or \"TLS CA Certificate Dir\" are defined for Console \"%s\" in %s.\n"),
+                             cons->hdr.name, configfile);
+         OK = false;
       }
    }
 #endif /* HAVE_TLS */
index 47b42a51468e1c802b693419d9e6973fadb7eac3..2d11d912866be6f1b171df874154dc67124e5d72 100644 (file)
@@ -74,7 +74,7 @@ char *rec_state_to_str(DEV_RECORD *rec)
  *  tools (e.g. bls, bextract, bscan, ...)
  */
 JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr,
-              const char *VolumeName, int mode)
+               const char *VolumeName, int mode)
 {
    DCR *dcr;
    JCR *jcr = new_jcr(sizeof(JCR), my_free_jcr);
@@ -114,7 +114,8 @@ JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr,
  *   If the caller wants read access, acquire the device, otherwise,
  *     the caller will do it.
  */
-static DCR *setup_to_access_device(JCR *jcr, char *dev_name, const char *VolumeName, int mode)
+static DCR *setup_to_access_device(JCR *jcr, char *dev_name, 
+              const char *VolumeName, int mode)
 {
    DEVICE *dev;
    char *p;
@@ -133,21 +134,21 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name, const char *VolumeN
    }
    if (!jcr->bsr && VolName[0] == 0) {
       if (strncmp(dev_name, "/dev/", 5) != 0) {
-        /* Try stripping file part */
-        p = dev_name + strlen(dev_name);
+         /* Try stripping file part */
+         p = dev_name + strlen(dev_name);
 
          while (p >= dev_name && *p != '/')
-           p--;
+            p--;
          if (*p == '/') {
-           bstrncpy(VolName, p+1, sizeof(VolName));
-           *p = 0;
-        }
+            bstrncpy(VolName, p+1, sizeof(VolName));
+            *p = 0;
+         }
       }
    }
 
    if ((device=find_device_res(dev_name, mode)) == NULL) {
       Jmsg2(jcr, M_FATAL, 0, _("Cannot find device \"%s\" in config file %s.\n"),
-          dev_name, configfile);
+           dev_name, configfile);
       return NULL;
    }
 
@@ -162,17 +163,17 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name, const char *VolumeN
       bstrncpy(dcr->VolumeName, VolName, sizeof(dcr->VolumeName));
    }
    bstrncpy(dcr->dev_name, device->device_name, sizeof(dcr->dev_name));
-   if (!first_open_device(dev)) {
-      Jmsg1(jcr, M_FATAL, 0, _("Cannot open %s\n"), dcr->dev_name);
-      return NULL;
-   }
-   Dmsg0(90, "Device opened for read.\n");
 
    create_vol_list(jcr);
 
-   if (mode) {                       /* read only access? */
+   if (mode) {                        /* read only access? */
       if (!acquire_device_for_read(dcr)) {
-        return NULL;
+         return NULL;
+      }
+   } else {
+      if (!first_open_device(dev)) {
+         Jmsg1(jcr, M_FATAL, 0, _("Cannot open %s\n"), dcr->dev_name);
+         return NULL;
       }
    }
    return dcr;
@@ -217,7 +218,7 @@ static void my_free_jcr(JCR *jcr)
  * device name on command line (or default).
  *
  * Returns: NULL on failure
- *         Device resource pointer on success
+ *          Device resource pointer on success
  */
 static DEVRES *find_device_res(char *device_name, int read_access)
 {
@@ -227,31 +228,31 @@ static DEVRES *find_device_res(char *device_name, int read_access)
    LockRes();
    foreach_res(device, R_DEVICE) {
       if (strcmp(device->device_name, device_name) == 0) {
-        found = true;
-        break;
+         found = true;
+         break;
       }
    }
    if (!found) {
       /* Search for name of Device resource rather than archive name */
       if (device_name[0] == '"') {
-        int len = strlen(device_name);
-        bstrncpy(device_name, device_name+1, len+1);
-        len--;
-        if (len > 0) {
+         int len = strlen(device_name);
+         bstrncpy(device_name, device_name+1, len+1);
+         len--;
+         if (len > 0) {
             device_name[len-1] = 0;   /* zap trailing " */
-        }
+         }
       }
       foreach_res(device, R_DEVICE) {
-        if (strcmp(device->hdr.name, device_name) == 0) {
-           found = true;
-           break;
-        }
+         if (strcmp(device->hdr.name, device_name) == 0) {
+            found = true;
+            break;
+         }
       }
    }
    UnlockRes();
    if (!found) {
       Pmsg2(0, _("Could not find device \"%s\" in config file %s.\n"), device_name,
-           configfile);
+            configfile);
       return NULL;
    }
    Pmsg2(0, _("Using device: \"%s\" for %s.\n"), device_name,
index 7aeae4d7e8b4423aee7c444b6348e2c01aba4c3c..e95896d6d7a3d214955528dd596e2f2776a4da01 100644 (file)
@@ -499,10 +499,9 @@ int open_next_part(DEVICE *dev) {
    
    if (open_dev(dev, dev->VolCatInfo.VolCatName, dev->openmode) < 0) {
       return -1;
-   } else {
-      dev->state = state;
-      return dev->fd;
-   }
+   } 
+   dev->state = state;
+   return dev->fd;
 }
 
 /* Open the first part file.
@@ -524,12 +523,11 @@ int open_first_part(DEVICE *dev) {
    dev->part_start = 0;
    dev->part = 0;
    
-   if (open_dev(dev, dev->VolCatInfo.VolCatName, dev->openmode)) {
-      dev->state = state;
-      return dev->fd;
-   } else {
-      return 0;
+   if (open_dev(dev, dev->VolCatInfo.VolCatName, dev->openmode) < 0) {
+      return -1;
    }
+   dev->state = state;
+   return dev->fd;
 }
 
 
index 1da390d3999b10090c8b2a290bd9814e3f72b719..bb304093ee9db036a1feb5e4f3ee565efc22d5ea 100644 (file)
@@ -29,21 +29,25 @@ EXTRAOBJS = @OBJLIST@
 MONITOR_CPPFLAGS=@TRAY_MONITOR_CPPFLAGS@
 MONITOR_LDFLAGS=@TRAY_MONITOR_LDFLAGS@ @X_LIBS@ -lX11
 
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+
 .SUFFIXES:     .c .o
 .PHONY:
 .DONTCARE:
 
 # inference rules
 .c.o:
-       $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(MONITOR_CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $<
+       $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(MONITOR_CPPFLAGS) \
+ $(OPENSSL_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $<
 #-------------------------------------------------------------------------
 all: Makefile bacula-tray-monitor @STATIC_CONS@
        @echo "==== Make of bacula-tray-monitor is good ===="
        @echo " "
 
 bacula-tray-monitor: $(MONITOROBJS) ../lib/libbac.a
-       $(CXX) $(LDFLAGS) $(MONITOR_LDFLAGS) -L../lib -L../cats -o $@ $(MONITOROBJS) \
            $(DLIB) -lbac -lm $(LIBS) 
+       $(CXX) $(LDFLAGS) $(MONITOR_LDFLAGS) -L../lib -L../cats -o $@ \
$(MONITOROBJS) $(DLIB) $(OPENSSL_LIBS) -lbac -lm $(LIBS) 
 
 
 Makefile: $(srcdir)/Makefile.in $(topdir)/config.status
index 34e07fa659404aa6404cdafe10ef2b2a17826a7c..3cf760a3bfd9b4a809310832d4d10024f28e2caa 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #undef  VERSION
 #define VERSION "1.37.14"
-#define BDATE   "21 April 2005"
-#define LSMDATE "21Apr05"
+#define BDATE   "22 April 2005"
+#define LSMDATE "22Apr05"
 
 /* Debug flags */
 #undef  DEBUG
index 91a4edfe38eac351a91f31858f1cd89516b96ab5..452715b147fb472e86973e5dcf9e241d08310ab5 100644 (file)
@@ -45,6 +45,9 @@ _cppflags =
 # wx-config generated by configure
 CONS_CPPFLAGS=-DHAVE_WXCONSOLE @WXCONS_CPPFLAGS@ $(@MACOSX@_cppflags)
 CONS_LDFLAGS=@WXCONS_LDFLAGS@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+
 
 .SUFFIXES:     .cpp .c .o
 .PHONY:
@@ -52,12 +55,12 @@ CONS_LDFLAGS=@WXCONS_LDFLAGS@
 
 # inference rules
 .c.o:
-       $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(CONS_CPPFLAGS) $(CONS_INC) -I$(srcdir) \
         -I$(basedir) $(DINCLUDE) $(WCFLAGS) $(CFLAGS) $<
+       $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(CONS_CPPFLAGS) $(CONS_INC) \
$(OPENSSL_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(WCFLAGS) $(CFLAGS) $<
 
 .cpp.o:
-       $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(CONS_CPPFLAGS) $(CONS_INC) -I$(srcdir) \
         -I$(basedir) $(DINCLUDE) $(WCFLAGS) $(CFLAGS) $<
+       $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(CONS_CPPFLAGS) $(CONS_INC) \
$(OPENSSL_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(WCFLAGS) $(CFLAGS) $<
 
 
 #-------------------------------------------------------------------------
@@ -79,7 +82,8 @@ wx-console.app: wx-console
        cp wx-console.conf /Library/Preferences/org.bacula.wxconsole.conf
 
 wx-console: $(CONSOBJS) @WIN32@ ../lib/libbac.a
-       $(CXX) $(CONSOBJS) $(WIN32RES) -o $@ $(LIBS) -L../lib $(CONS_LDFLAGS) -lbac
+       $(CXX) $(CONSOBJS) $(WIN32RES) -o $@ $(LIBS) -L../lib $(CONS_LDFLAGS) \
+ $(OPENSSL_LIBS) -lbac
 
 win32: wx-console_private.res