From bf0ceda4c4864c0eba6e548a0017afa0ccaa3e7b Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 28 Sep 2008 15:44:29 +0000 Subject: [PATCH] kes Add cmd_plugin flag to jcr so we can globally know if a command plugin is running. kes If command plugin running, do not attempt (for the moment) to get Win32 extended attributes. kes Ensure that proper Win32 flags are set in bfile packet if plugin_bopen() works on Win32. kes Remove generated src/plugins/fd/Makefile git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7657 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/scripts/Makefile.in | 2 +- bacula/src/filed/fd_plugins.c | 2 + bacula/src/findlib/attribs.c | 9 ++- bacula/src/findlib/bfile.c | 11 ++- bacula/src/jcr.h | 2 +- bacula/src/plugins/fd/Makefile | 141 --------------------------------- bacula/src/version.h | 6 +- bacula/technotes-2.5 | 8 ++ 8 files changed, 32 insertions(+), 149 deletions(-) delete mode 100644 bacula/src/plugins/fd/Makefile diff --git a/bacula/scripts/Makefile.in b/bacula/scripts/Makefile.in index 6438f56f97..d3a1629e20 100755 --- a/bacula/scripts/Makefile.in +++ b/bacula/scripts/Makefile.in @@ -47,7 +47,7 @@ install: installdirs fi $(INSTALL_SCRIPT) mtx-changer $(DESTDIR)$(scriptdir)/mtx-changer @if test -f ${DESTDIR}${scriptdir}/mtx-changer.conf; then \ - echo " ==> Saving existing mtx-changer.conf to mtx-changer.conf.new"; \ + echo " ==> Installing mtx-changer.conf to mtx-changer.conf.new"; \ $(INSTALL_SCRIPT) mtx-changer.conf $(DESTDIR)$(scriptdir)/mtx-changer.conf.new; \ else \ $(INSTALL_SCRIPT) mtx-changer.conf $(DESTDIR)$(scriptdir)/mtx-changer.conf; \ diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index b0bc92ff1e..6ef67bcda4 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -144,6 +144,7 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) return 1; /* Return if no plugins loaded */ } + jcr->cmd_plugin = true; bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; event.eventType = bEventBackupCommand; @@ -206,6 +207,7 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) Jmsg1(jcr, M_ERROR, 0, "Command plugin \"%s\" not found.\n", cmd); bail_out: + jcr->cmd_plugin = false; return 1; } diff --git a/bacula/src/findlib/attribs.c b/bacula/src/findlib/attribs.c index 9b51d1a903..03770212cc 100644 --- a/bacula/src/findlib/attribs.c +++ b/bacula/src/findlib/attribs.c @@ -551,14 +551,19 @@ int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt) attribsEx[0] = 0; /* no extended attributes */ + if (jcr->cmd_plugin) { + return STREAM_UNIX_ATTRIBUTES; + } + unix_name_to_win32(&ff_pkt->sys_fname, ff_pkt->fname); // try unicode version if (p_GetFileAttributesExW) { - POOLMEM* pwszBuf = get_pool_memory (PM_FNAME); + POOLMEM* pwszBuf = get_pool_memory(PM_FNAME); make_win32_path_UTF8_2_wchar(&pwszBuf, ff_pkt->fname); - BOOL b=p_GetFileAttributesExW((LPCWSTR) pwszBuf, GetFileExInfoStandard, (LPVOID)&atts); + BOOL b=p_GetFileAttributesExW((LPCWSTR)pwszBuf, GetFileExInfoStandard, + (LPVOID)&atts); free_pool_memory(pwszBuf); if (!b) { diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index 658d7577a8..cab610346c 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -422,9 +422,18 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) int rtnstat; Dmsg1(000, "call plugin_bopen fname=%s\n", fname); rtnstat = plugin_bopen(bfd, fname, flags, mode); + if (rtnstat >= 0) { + if (flags & O_CREAT || flags & O_WRONLY) { /* Open existing for write */ + bfd->mode = BF_WRITE; + } else { + bfd->mode = BF_READ; + } + } else { + bfd->mode = BF_CLOSED; + } free_pool_memory(win32_fname_wchar); free_pool_memory(win32_fname); - return rtnstat; + return bfd->mode == BF_CLOSED ? -1 : 1; } if (!(p_CreateFileA || p_CreateFileW)) diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 1beb79e91d..4150332e4a 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -244,6 +244,7 @@ public: Plugin *plugin; /* plugin instance */ save_pkt *plugin_sp; /* plugin save packet */ char *plugin_options; /* user set options for plugin */ + bool cmd_plugin; /* Set when processing a command Plugin = */ /* Daemon specific part of JCR */ /* This should be empty in the library */ @@ -325,7 +326,6 @@ public: POOLMEM *last_fname; /* last file saved/verified */ POOLMEM *acl_text; /* text of ACL for backup */ int32_t last_type; /* type of last file saved/verified */ - /*********FIXME********* add missing files and files to be retried */ int incremental; /* set if incremental for SINCE */ time_t mtime; /* begin time for SINCE */ int listing; /* job listing in estimate */ diff --git a/bacula/src/plugins/fd/Makefile b/bacula/src/plugins/fd/Makefile deleted file mode 100644 index 2e61bf2930..0000000000 --- a/bacula/src/plugins/fd/Makefile +++ /dev/null @@ -1,141 +0,0 @@ -# -# Simple Makefile for building test FD plugins for Bacula -# -# Version $Id: Makefile.in 7638 2008-09-25 14:04:17Z kerns $ -# -# -# This file is pulled in by all the Unix Bacula Makefiles -# so it has all the "common" definitions -# - -DATE="26 September 2008" -LSMDATE=26Sep08 -VERSION=2.5.5 -VERNAME=bacula-$(VERSION)# -MAINT=Kern Sibbald# -MAINTEMAIL=# -WEBMAINT=# -WEBMAINTEMAIL=# -WEBPAGE=# -FTPSITENAME=# -FTPSITEDIR=# -#------------------------------------------------------------------------- - -SHELL = /bin/sh - -# Installation target directories & other installation stuff -prefix = -exec_prefix = -binprefix = -manprefix = -datarootdir = ${prefix}/share -sbindir = /home/kern/bacula/bin -sysconfdir = /home/kern/bacula/bin -plugindir = /home/kern/bacula/bin -scriptdir = /home/kern/bacula/bin -mandir = /home/kern/bacula/bin -manext = 8 - -NO_ECHO = @ - -# Tools & program stuff -CC = gcc -CPP = gcc -E -CXX = /usr/bin/g++ -MV = /bin/mv -RM = /bin/rm -RMF = /bin/rm -f -CP = /bin/cp -SED = /bin/sed -AWK = /usr/bin/mawk -ECHO = /bin/echo -CMP = /usr/bin/cmp -TBL = /usr/bin/tbl -AR = /usr/bin/ar -RANLIB = ranlib -MKDIR = /home/kern/bacula/k/autoconf/mkinstalldirs -INSTALL = /usr/bin/install -c -# add the -s to the following in PRODUCTION mode -INSTALL_PROGRAM = /usr/bin/install -c -m 0754 -INSTALL_DATA = /usr/bin/install -c -m 644 -INSTALL_SCRIPT = /usr/bin/install -c -m 0754 -INSTALL_CONFIG = /usr/bin/install -c -m 640 - -# Flags & libs -CFLAGS = -g -O2 -Wall -fno-strict-aliasing -fno-exceptions -fno-rtti - -CPPFLAGS = -fno-strict-aliasing -fno-exceptions -fno-rtti -LDFLAGS = -TTOOL_LDFLAGS = -#DEFS = -DHAVE_CONFIG_H -LIBS = -lpthread -ldl -WRAPLIBS = -lwrap -DINCLUDE = -DLIB = -DB_LIBS = -L/home/kern/bacula/depkgs/sqlite3 -lsqlite3 -PYTHON_LIBS = -L/usr/lib/python2.5/config -lpython2.5 -lutil -lrt -PYTHON_INC = -I/usr/include/python2.5 -OPENSSL_LIBS = -lssl -lcrypto -BDB_CPPFLAGS = -BDB_LIBS = - - -# Windows (cygwin) flags -WCFLAGS = -WLDFLAGS = - -# X Include directory -#XINC = @XPM_CFLAGS@ - -# extra libraries needed by X on some systems, X library location -#XLIB = @XPM_LIBS@ -lX11 - -# End of common section of the Makefile -#------------------------------------------------------------------------- - - -# No optimization for now for easy debugging - -FDDIR=../../filed -SRCDIR=../.. -LIBDIR=../../lib - -.SUFFIXES: .c .o -.c.o: - $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) -I${SRCDIR} -I${FDDIR} -DTEST_PROGRAM -c $< - -all: bpipe-fd.so - -test: main example-plugin-fd.so - -fd_plugins.o: ${FDDIR}/fd_plugins.h ${FDDIR}/fd_plugins.c - $(CXX) -I${SRCDIR} -I${FDDIR} -DTEST_PROGRAM -c ${FDDIR}/fd_plugins.c - -main: fd_plugins.o - $(CXX) $(LDFLAGS) -L${LIBDIR} fd_plugins.o -o main -lbac -lpthread -lssl -l crypto -ldl - -example-plugin-fd.o: example-plugin-fd.c ${FDDIR}/fd_plugins.h - $(CXX) -fPIC -I../.. -I${FDDIR} -c example-plugin-fd.c - -example-plugin-fd.so: example-plugin-fd.o - $(CXX) $(LDFLAGS) -shared example-plugin-fd.o -o example-plugin-fd.so - -bpipe-fd.o: bpipe-fd.c ${FDDIR}/fd_plugins.h - $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) -fPIC -I../.. -I${FDDIR} -c bpipe-fd.c - -bpipe-fd.so: bpipe-fd.o - $(CXX) $(LDFLAGS) -shared bpipe-fd.o -o bpipe-fd.so - -install: all - $(INSTALL_PROGRAM) bpipe-fd.so $(DESTDIR)$(plugindir)/bpipe-fd.so - -clean: - rm -f main *.so *.o 1 2 3 - -distclean: clean - rm -f Makefile - -uninstall: - $(RMF) $(DESTDIR)$(plugindir)/bpipe-fd.so - -depend: diff --git a/bacula/src/version.h b/bacula/src/version.h index d0a7c8c77a..152c07dfe0 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "2.5.6" -#define BDATE "27 September 2008" -#define LSMDATE "27Sep08" +#define VERSION "2.5.7" +#define BDATE "28 September 2008" +#define LSMDATE "28Sep08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 43a9bfe2b2..d7d52e4d7a 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -17,6 +17,14 @@ dbdriver remove reader/writer in FOPTS???? General: +28Sep08 +kes Add cmd_plugin flag to jcr so we can globally know if a + command plugin is running. +kes If command plugin running, do not attempt (for the moment) + to get Win32 extended attributes. +kes Ensure that proper Win32 flags are set in bfile packet + if plugin_bopen() works on Win32. +kes Remove generated src/plugins/fd/Makefile 27Sep08 kes Implement build and install of bpipe-fd.so plugin. kes Rework the interface that passes packets to the plugin -- 2.39.5