From: Kern Sibbald Date: Fri, 22 Apr 2005 10:12:46 +0000 (+0000) Subject: - Landon Fuller committed his TLS patch. X-Git-Tag: Release-1.38.0~546 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8b078861e11b9f4da47ebd7fbce34f754e4e55d2;p=bacula%2Fbacula - Landon Fuller committed his TLS patch. - 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 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index e8d0299ea4..0af666a9b1 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -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' diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index b97887a96c..f6a6d98510 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -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 */ diff --git a/bacula/src/stored/butil.c b/bacula/src/stored/butil.c index 47b42a5146..2d11d91286 100644 --- a/bacula/src/stored/butil.c +++ b/bacula/src/stored/butil.c @@ -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, diff --git a/bacula/src/stored/dvd.c b/bacula/src/stored/dvd.c index 7aeae4d7e8..e95896d6d7 100644 --- a/bacula/src/stored/dvd.c +++ b/bacula/src/stored/dvd.c @@ -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; } diff --git a/bacula/src/tray-monitor/Makefile.in b/bacula/src/tray-monitor/Makefile.in index 1da390d399..bb304093ee 100644 --- a/bacula/src/tray-monitor/Makefile.in +++ b/bacula/src/tray-monitor/Makefile.in @@ -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 diff --git a/bacula/src/version.h b/bacula/src/version.h index 34e07fa659..3cf760a3bf 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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 diff --git a/bacula/src/wx-console/Makefile.in b/bacula/src/wx-console/Makefile.in index 91a4edfe38..452715b147 100644 --- a/bacula/src/wx-console/Makefile.in +++ b/bacula/src/wx-console/Makefile.in @@ -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