From: Kern Sibbald Date: Wed, 21 May 2003 13:58:08 +0000 (+0000) Subject: Finish Win32 backup add DESTDIR to autostart code X-Git-Tag: Release-1.31~131 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c1472cee63bc4d51a3ffafe8404b0a0ba7750141;p=bacula%2Fbacula Finish Win32 backup add DESTDIR to autostart code git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@525 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 2aad564d6d..e910991967 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -25,7 +25,10 @@ Testing to do: (painful) - Figure out how to use ssh or stunnel to protect Bacula communications. For 1.31 release: -- Finish WIN32_DATA stream code (bextract, check if can handle stream) +- Investigate doing RAW backup of Win32 partition. +- Add JobName= to VerifyToCatalog so that all verifies can be done at the end. +- Add thread specific data to hold the jcr -- send error messages from + low level routines by accessing it and using Jmsg(). - Default duration with no qualifier is sec should be 1 day - Find a solution for the multiple FileSet problem (when it is changed). Add date? - Cancel waiting for Client connect in SD if FD goes away. @@ -875,4 +878,4 @@ Done: (see kernsdone for more) - Count errors during restore and print them in the Job report. - Bug: fix access problems on files restored on WinXP. - Put system type returned by FD into catalog. - +- Finish WIN32_DATA stream code (bextract, check if can handle stream) diff --git a/bacula/platforms/redhat/Makefile.in b/bacula/platforms/redhat/Makefile.in index 36975919cc..e46588fd1b 100644 --- a/bacula/platforms/redhat/Makefile.in +++ b/bacula/platforms/redhat/Makefile.in @@ -18,30 +18,36 @@ install-autostart: install-autostart-fd install-autostart-sd install-autostart-d install-autostart-fd: - @if test -f $(DESTDIR)/etc/rc.d/init.d/bacula-fd; then \ - /sbin/chkconfig --del bacula-fd; \ + @if test x$(DESTDIR) = x -a -f /etc/rc.d/init.d/bacula-fd; then \ + /sbin/chkconfig --del bacula-fd; \ fi @$(INSTALL_PROGRAM) -m 744 bacula-fd $(DESTDIR)/etc/rc.d/init.d/bacula-fd # set symlinks for script at startup and shutdown - @/sbin/chkconfig --add bacula-fd + @if test x$(DESTDIR) = x ; then \ + /sbin/chkconfig --add bacula-fd; \ + fi install-autostart-sd: - @if test -f $(DESTDIR)/etc/rc.d/init.d/bacula-sd; then \ + @if test x$(DESTDIR) = x -a -f /etc/rc.d/init.d/bacula-sd; then \ /sbin/chkconfig --del bacula-sd; \ fi @$(INSTALL_PROGRAM) -m 744 bacula-sd $(DESTDIR)/etc/rc.d/init.d/bacula-sd # set symlinks for script at startup and shutdown - @/sbin/chkconfig --add bacula-sd + @if test x$(DESTDIR) = x ; then \ + /sbin/chkconfig --add bacula-sd; \ + fi install-autostart-dir: - @if test -f $(DESTDIR)/etc/rc.d/init.d/bacula-dir; then \ + @if test x$(DESTDIR) = x -a -f /etc/rc.d/init.d/bacula-dir; then \ /sbin/chkconfig --del bacula-dir; \ fi @$(INSTALL_PROGRAM) -m 744 bacula-dir $(DESTDIR)/etc/rc.d/init.d/bacula-dir # set symlinks for script at startup and shutdown - @/sbin/chkconfig --add bacula-dir + @if test x$(DESTDIR) = x ; then \ + /sbin/chkconfig --add bacula-dir; \ + fi uninstall: uninstall-autostart @@ -49,20 +55,20 @@ uninstall: uninstall-autostart uninstall-autostart: uninstall-autostart-fd uninstall-autostart-sd uninstall-autostart-dir uninstall-autostart-fd: - @if test -f $(DESTDIR)/etc/rc.d/init.d/bacula-fd; then \ + @if test x$(DESTDIR) = x -a -f /etc/rc.d/init.d/bacula-fd; then \ /sbin/chkconfig --del bacula-fd; \ fi @rm -f $(DESTDIR)/etc/rc.d/init.d/bacula-fd uninstall-autostart-sd: - @if test -f $(DESTDIR)/etc/rc.d/init.d/bacula-sd; then \ + @if test x$(DESTDIR) = x -a -f /etc/rc.d/init.d/bacula-sd; then \ /sbin/chkconfig --del bacula-sd; \ fi @rm -f $(DESTDIR)/etc/rc.d/init.d/bacula-sd uninstall-autostart-dir: - @if test -f $(DESTDIR)/etc/rc.d/init.d/bacula-dir; then \ + @if test x$(DESTDIR) = x -a -f /etc/rc.d/init.d/bacula-dir; then \ /sbin/chkconfig --del bacula-dir; \ fi @rm -f $(DESTDIR)/etc/rc.d/init.d/bacula-dir diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index 3823180cc8..89a81bfb6a 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -182,6 +182,7 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock) if (fgets(UA_sock->msg, len, input) == NULL) { stat = -1; } else { + sendit("%s", UA_sock->msg); /* echo to terminal */ strip_trailing_junk(UA_sock->msg); UA_sock->msglen = strlen(UA_sock->msg); stat = 1; diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index fbc0726a3f..85b5d24501 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -88,10 +88,15 @@ int do_verify(JCR *jcr) if (jcr->JobLevel == L_VERIFY_CATALOG || jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG) { memcpy(&jr, &(jcr->jr), sizeof(jr)); if (!db_find_last_jobid(jcr, jcr->db, &jr)) { - Jmsg(jcr, M_FATAL, 0, _( - "Unable to find JobId of previous InitCatalog Job.\n" - "Please run a Verify with Level=InitCatalog before\n" - "running the current Job.\n")); + if (jcr->JobLevel == L_VERIFY_CATALOG) { + Jmsg(jcr, M_FATAL, 0, _( + "Unable to find JobId of previous InitCatalog Job.\n" + "Please run a Verify with Level=InitCatalog before\n" + "running the current Job.\n")); + } else { + Jmsg(jcr, M_FATAL, 0, _( + "Unable to find JobId of previous Job for this client.\n")); + } goto bail_out; } JobId = jr.JobId; @@ -120,7 +125,8 @@ int do_verify(JCR *jcr) memset(&jr, 0, sizeof(jr)); jr.JobId = JobId; if (!db_get_job_record(jcr, jcr->db, &jr)) { - Jmsg(jcr, M_FATAL, 0, _("Could not get job record. %s"), db_strerror(jcr->db)); + Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), + db_strerror(jcr->db)); goto bail_out; } if (jr.JobStatus != 'T') { @@ -145,7 +151,7 @@ int do_verify(JCR *jcr) jcr->VolumeName[0] = 0; if (!db_get_job_volume_names(jcr, jcr->db, jr.JobId, &jcr->VolumeName) || jcr->VolumeName[0] == 0) { - Jmsg(jcr, M_FATAL, 0, _("Cannot find Volume Name for verify JobId=%d. %s"), + Jmsg(jcr, M_FATAL, 0, _("Cannot find Volume Name for verify JobId=%u. ERR=%s"), jr.JobId, db_strerror(jcr->db)); goto bail_out; } diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 2338290b4b..8db9a7ebbb 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -154,14 +154,17 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) case FT_NOACCESS: Jmsg(jcr, M_NOTSAVED, -1, _(" Could not access %s: ERR=%s\n"), ff_pkt->fname, strerror(ff_pkt->ff_errno)); + jcr->Errors++; return 1; case FT_NOFOLLOW: Jmsg(jcr, M_NOTSAVED, -1, _(" Could not follow link %s: ERR=%s\n"), ff_pkt->fname, strerror(ff_pkt->ff_errno)); + jcr->Errors++; return 1; case FT_NOSTAT: Jmsg(jcr, M_NOTSAVED, -1, _(" Could not stat %s: ERR=%s\n"), ff_pkt->fname, strerror(ff_pkt->ff_errno)); + jcr->Errors++; return 1; case FT_DIRNOCHG: case FT_NOCHG: @@ -181,9 +184,11 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) case FT_NOOPEN: Jmsg(jcr, M_NOTSAVED, -1, _(" Could not open directory %s: ERR=%s\n"), ff_pkt->fname, strerror(ff_pkt->ff_errno)); + jcr->Errors++; return 1; default: Jmsg(jcr, M_NOTSAVED, 0, _(" Unknown file type %d; not saved: %s\n"), ff_pkt->type, ff_pkt->fname); + jcr->Errors++; return 1; } @@ -192,11 +197,8 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) /* Open any file with data that we intend to save */ if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && ff_pkt->statp.st_size > 0) || - ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO -#ifdef HAVE_CYGWIN - || ff_pkt->type == FT_DIR -#endif - ) { + ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO || + (is_win32_backup() && ff_pkt->type == FT_DIR)) { btimer_id tid; if (ff_pkt->type == FT_FIFO) { tid = start_thread_timer(pthread_self(), 60); @@ -207,6 +209,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) ff_pkt->ff_errno = errno; Jmsg(jcr, M_NOTSAVED, -1, _(" Cannot open %s: ERR=%s.\n"), ff_pkt->fname, berror(&ff_pkt->bfd)); + jcr->Errors++; stop_thread_timer(tid); return 1; } @@ -289,7 +292,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) Dmsg1(100, "Saving data, type=%d\n", ff_pkt->type); /* Note, no sparse option for win32_data */ - if (is_win32_data(&ff_pkt->bfd)) { + if (is_win32_backup()) { stream = STREAM_WIN32_DATA; ff_pkt->flags &= ~FO_SPARSE; } else if (ff_pkt->flags & FO_SPARSE) { diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 8f4e21cdf8..1ec68dad02 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -264,6 +264,9 @@ void do_restore(JCR *jcr) } } + P(jcr->mutex); + pm_strcpy(&jcr->last_fname, fname); + V(jcr->mutex); jcr->num_files_examined++; Dmsg1(30, "Outfile=%s\n", ofile); @@ -299,6 +302,11 @@ void do_restore(JCR *jcr) /* Data stream */ } else if (stream == STREAM_FILE_DATA || stream == STREAM_SPARSE_DATA || stream == STREAM_WIN32_DATA) { + if (stream == STREAM_WIN32_DATA && !is_win32_backup()) { + Jmsg(jcr, M_ERROR, 0, _("Win32 backup data not supported on this Client.\n")); + extract = FALSE; + continue; + } if (extract) { if (stream == STREAM_SPARSE_DATA) { ser_declare; @@ -314,7 +322,8 @@ void do_restore(JCR *jcr) if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) { Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"), edit_uint64(fileAddr, ec1), ofile, berror(&bfd)); - goto bail_out; + extract = FALSE; + continue; } } } else { @@ -325,8 +334,9 @@ void do_restore(JCR *jcr) if ((uint32_t)bwrite(&bfd, wbuf, wsize) != wsize) { Dmsg0(0, "===Write error===\n"); Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: ERR=%s\n"), ofile, berror(&bfd)); - goto bail_out; - } + extract = FALSE; + continue; + } total += wsize; jcr->JobBytes += wsize; fileAddr += wsize; @@ -335,6 +345,11 @@ void do_restore(JCR *jcr) /* GZIP data stream */ } else if (stream == STREAM_GZIP_DATA || stream == STREAM_SPARSE_GZIP_DATA || stream == STREAM_WIN32_GZIP_DATA) { + if (stream == STREAM_WIN32_GZIP_DATA && !is_win32_backup()) { + Jmsg(jcr, M_ERROR, 0, _("Win32 GZIP backup data not supported on this Client.\n")); + extract = FALSE; + continue; + } #ifdef HAVE_LIBZ if (extract) { ser_declare; @@ -353,7 +368,8 @@ void do_restore(JCR *jcr) if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) { Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"), edit_uint64(fileAddr, ec1), ofile, berror(&bfd)); - goto bail_out; + extract = FALSE; + continue; } } } else { @@ -365,14 +381,16 @@ void do_restore(JCR *jcr) if ((stat=uncompress((Byte *)jcr->compress_buf, &compress_len, (const Byte *)wbuf, (uLong)wsize)) != Z_OK) { Jmsg(jcr, M_ERROR, 0, _("Uncompression error. ERR=%d\n"), stat); - goto bail_out; + extract = FALSE; + continue; } Dmsg2(100, "Write uncompressed %d bytes, total before write=%d\n", compress_len, total); if ((uLong)bwrite(&bfd, jcr->compress_buf, compress_len) != compress_len) { Dmsg0(0, "===Write error===\n"); Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), ofile, berror(&bfd)); - goto bail_out; + extract = FALSE; + continue; } total += compress_len; jcr->JobBytes += compress_len; @@ -381,7 +399,8 @@ void do_restore(JCR *jcr) #else if (extract) { Jmsg(jcr, M_ERROR, 0, _("GZIP data stream found, but GZIP not configured!\n")); - goto bail_out; + extract = FALSE; + continue; } #endif /* If extracting, wierd stream (not 1 or 2), close output file anyway */ diff --git a/bacula/src/filed/win32/winmain.cpp b/bacula/src/filed/win32/winmain.cpp index ccb1cfff6e..23df92aa28 100755 --- a/bacula/src/filed/win32/winmain.cpp +++ b/bacula/src/filed/win32/winmain.cpp @@ -325,17 +325,25 @@ int BaculaAppMain() p_BackupWrite = (t_BackupWrite) GetProcAddress(hLib, "BackupWrite"); FreeLibrary(hLib); - } - hLib = LoadLibrary("ADVAPI32.DLL"); - if (hLib) { - p_OpenProcessToken = (t_OpenProcessToken) - GetProcAddress(hLib, "OpenProcessToken"); - p_AdjustTokenPrivileges = (t_AdjustTokenPrivileges) - GetProcAddress(hLib, "AdjustTokenPrivileges"); - p_LookupPrivilegeValue = (t_LookupPrivilegeValue) - GetProcAddress(hLib, "LookupPrivilegeValueA"); - FreeLibrary(hLib); - } + } + hLib = LoadLibrary("ADVAPI32.DLL"); + if (hLib) { + p_OpenProcessToken = (t_OpenProcessToken) + GetProcAddress(hLib, "OpenProcessToken"); + p_AdjustTokenPrivileges = (t_AdjustTokenPrivileges) + GetProcAddress(hLib, "AdjustTokenPrivileges"); + p_LookupPrivilegeValue = (t_LookupPrivilegeValue) + GetProcAddress(hLib, "LookupPrivilegeValueA"); + FreeLibrary(hLib); + } + /* + * Even if these are defined, don't use on old + * platforms. + */ + if (bacService::IsWin95()) { + p_BackupRead = NULL; + p_BackupWrite = NULL; + } // Set this process to be the last application to be shut down. if (p_SetProcessShutdownParameters) { diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index 30378c3d29..8c15b961c1 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -52,7 +52,7 @@ void binit(BFILE *bfd) * Returns 1 if function worked * Returns 0 if failed (i.e. do not have Backup API on this machine) */ -int set_win32_data(BFILE *bfd, int enable) +int set_win32_backup(BFILE *bfd, int enable) { if (!enable) { bfd->use_backup_api = 0; @@ -63,68 +63,77 @@ int set_win32_data(BFILE *bfd, int enable) return bfd->use_backup_api; } -int is_win32_data(BFILE *bfd) +int is_win32_backup(void) { - return bfd->use_backup_api; + return p_BackupRead && p_BackupWrite; } HANDLE bget_handle(BFILE *bfd) { -#ifdef xxx - if (!bfd->use_win_api) { - return get_osfhandle(bfd->fid); - } -#endif return bfd->fh; } int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) { POOLMEM *win32_fname; - -#ifdef xxx - if (!bfd->use_win_api) { - bfd->fid = open(fname, flags, mode); - if (bfd->fid >= 0) { - bfd->mode = BF_READ; /* not important if BF_READ or BF_WRITE */ - } - return bfd->fid; - } -#endif + DWORD dwaccess, dwflags; /* Convert to Windows path format */ win32_fname = get_pool_memory(PM_FNAME); unix_name_to_win32(&win32_fname, (char *)fname); - if (flags & O_CREAT) { + if (flags & O_CREAT) { /* Create */ + if (bfd->use_backup_api) { + dwaccess = GENERIC_WRITE|FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY; + dwflags = FILE_FLAG_BACKUP_SEMANTICS; + } else { + dwaccess = GENERIC_WRITE|FILE_ALL_ACCESS; + dwflags = 0; + } bfd->fh = CreateFile(win32_fname, - GENERIC_WRITE|FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY, /* access */ - 0, - NULL, /* SecurityAttributes */ - CREATE_ALWAYS, /* CreationDisposition */ - FILE_FLAG_BACKUP_SEMANTICS, /* Flags and attributes */ - NULL); /* TemplateFile */ + dwaccess, /* Requested access */ + 0, /* Shared mode */ + NULL, /* SecurityAttributes */ + CREATE_ALWAYS, /* CreationDisposition */ + dwflags, /* Flags and attributes */ + NULL); /* TemplateFile */ bfd->mode = BF_WRITE; - } else if (flags & O_WRONLY) { /* creating */ + + } else if (flags & O_WRONLY) { /* Open existing for write */ + if (bfd->use_backup_api) { + dwaccess = FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY; + dwflags = FILE_FLAG_BACKUP_SEMANTICS; + } else { + dwaccess = FILE_ALL_ACCESS; + dwflags = 0; + } bfd->fh = CreateFile(win32_fname, - FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY, /* access */ - 0, - NULL, /* SecurityAttributes */ - OPEN_EXISTING, /* CreationDisposition */ - FILE_FLAG_BACKUP_SEMANTICS, /* Flags and attributes */ - NULL); + dwaccess, /* Requested access */ + 0, /* Shared mode */ + NULL, /* SecurityAttributes */ + OPEN_EXISTING, /* CreationDisposition */ + dwflags, /* Flags and attributes */ + NULL); /* TemplateFile */ bfd->mode = BF_WRITE; - } else { - bfd->fh = CreateFile(win32_fname, - GENERIC_READ|READ_CONTROL|ACCESS_SYSTEM_SECURITY, /* access */ - FILE_SHARE_READ, /* shared mode */ - NULL, /* SecurityAttributes */ - OPEN_EXISTING, /* CreationDisposition */ - FILE_FLAG_BACKUP_SEMANTICS, /* Flags and attributes */ - NULL); /* TemplateFile */ + } else { /* Read */ + if (bfd->use_backup_api) { + dwaccess = GENERIC_READ|READ_CONTROL|ACCESS_SYSTEM_SECURITY; + dwflags = FILE_FLAG_BACKUP_SEMANTICS; + } else { + dwaccess = GENERIC_READ; + dwflags = 0; + } + bfd->fh = CreateFile(win32_fname, + dwaccess, /* Requested access */ + FILE_SHARE_READ, /* Shared mode */ + NULL, /* SecurityAttributes */ + OPEN_EXISTING, /* CreationDisposition */ + dwflags, /* Flags and attributes */ + NULL); /* TemplateFile */ bfd->mode = BF_READ; } + if (bfd->fh == INVALID_HANDLE_VALUE) { bfd->lerror = GetLastError(); bfd->mode = BF_CLOSED; @@ -141,14 +150,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) int bclose(BFILE *bfd) { int stat = 0; -#ifdef xxx - if (!bfd->use_win_api) { - int stat = close(bfd->fid); - bfd->fid = -1; - bfd->mode = BF_CLOSED; - return stat; - } -#endif + if (bfd->errmsg) { free_pool_memory(bfd->errmsg); bfd->errmsg = NULL; @@ -193,11 +195,7 @@ int bclose(BFILE *bfd) char *berror(BFILE *bfd) { LPTSTR msg; -#ifdef xxx - if (!bfd->use_win_api) { - return strerror(errno); - } -#endif + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER| FORMAT_MESSAGE_FROM_SYSTEM, NULL, @@ -221,11 +219,6 @@ char *berror(BFILE *bfd) */ ssize_t bread(BFILE *bfd, void *buf, size_t count) { -#ifdef xxx - if (!bfd->use_win_api) { - return read(bfd->fid, buf, count); - } -#endif bfd->rw_bytes = 0; if (bfd->use_backup_api) { @@ -255,11 +248,6 @@ ssize_t bread(BFILE *bfd, void *buf, size_t count) ssize_t bwrite(BFILE *bfd, void *buf, size_t count) { -#ifdef xxx - if (!bfd->use_win_api) { - return write(bfd->fid, buf, count); - } -#endif bfd->rw_bytes = 0; if (bfd->use_backup_api) { @@ -293,11 +281,6 @@ int is_bopen(BFILE *bfd) off_t blseek(BFILE *bfd, off_t offset, int whence) { -#ifdef xxx - if (!bfd->use_win_api) { - return lseek(bfd->fid, offset, whence); - } -#endif /* ****FIXME**** this is needed if we want to read Win32 Archives */ return -1; } @@ -315,7 +298,12 @@ void binit(BFILE *bfd) bfd->fid = -1; } -int is_win32_data(BFILE *bfd) +int set_win32_backup(BFILE *bfd, int enable) +{ + return 0; +} + +int is_win32_backup(void) { return 0; } diff --git a/bacula/src/findlib/bfile.h b/bacula/src/findlib/bfile.h index 1b917fa54b..a666072e3e 100644 --- a/bacula/src/findlib/bfile.h +++ b/bacula/src/findlib/bfile.h @@ -34,33 +34,33 @@ #include "winapi.h" #define BF_CLOSED 0 -#define BF_READ 1 /* BackupRead */ -#define BF_WRITE 2 /* BackupWrite */ +#define BF_READ 1 /* BackupRead */ +#define BF_WRITE 2 /* BackupWrite */ /* In bfile.c */ /* Basic low level I/O file packet */ typedef struct s_bfile { #ifdef xxx - int use_win_api; /* set if using WinAPI */ + int use_win_api; /* set if using WinAPI */ #endif - int use_backup_api; /* set if using BackupRead/Write */ - int mode; /* set if file is open */ - HANDLE fh; /* Win32 file handle */ - int fid; /* fd if doing Unix style */ - LPVOID lpContext; /* BackupRead/Write context */ - POOLMEM *errmsg; /* error message buffer */ - DWORD rw_bytes; /* Bytes read or written */ - DWORD lerror; /* Last error code */ + int use_backup_api; /* set if using BackupRead/Write */ + int mode; /* set if file is open */ + HANDLE fh; /* Win32 file handle */ + int fid; /* fd if doing Unix style */ + LPVOID lpContext; /* BackupRead/Write context */ + POOLMEM *errmsg; /* error message buffer */ + DWORD rw_bytes; /* Bytes read or written */ + DWORD lerror; /* Last error code */ } BFILE; HANDLE bget_handle(BFILE *bfd); -#else /* Linux/Unix systems */ +#else /* Linux/Unix systems */ /* Basic low level I/O file packet */ typedef struct s_bfile { - int fid; /* file id on Unix */ + int fid; /* file id on Unix */ int berrno; } BFILE; @@ -68,7 +68,8 @@ typedef struct s_bfile { void binit(BFILE *bfd); int is_bopen(BFILE *bfd); -int is_win32_data(BFILE *bfd); +int set_win32_backup(BFILE *bfd, int enable); +int is_win32_backup(); char *berror(BFILE *bfd); int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode); int bclose(BFILE *bfd); diff --git a/bacula/src/findlib/create_file.c b/bacula/src/findlib/create_file.c index bf31722815..88ec8ee1c3 100644 --- a/bacula/src/findlib/create_file.c +++ b/bacula/src/findlib/create_file.c @@ -226,16 +226,21 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname, if (make_path(jcr, ofile, new_mode, parent_mode, uid, gid, 0, NULL) != 0) { return CF_ERROR; } -#ifdef HAVE_CYGWIN - if ((bopen(ofd, ofile, O_WRONLY|O_BINARY, 0)) < 0) { - Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"), - ofile, berror(ofd)); - return CF_ERROR; + /* + * If we are using the Win32 Backup API, we open the + * directory so that the security info will be read + * and saved. + */ + if (is_win32_backup()) { + if ((bopen(ofd, ofile, O_WRONLY|O_BINARY, 0)) < 0) { + Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"), + ofile, berror(ofd)); + return CF_ERROR; + } + return CF_EXTRACT; + } else { + return CF_CREATED; } - return CF_EXTRACT; -#else - return CF_CREATED; -#endif /* The following should not occur */ case FT_NOACCESS: diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index f95c6d3ce8..35f5624023 100755 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -197,18 +197,23 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt), int status; dev_t our_device = ff_pkt->statp.st_dev; -#ifndef HAVE_CYGWIN - if (access(fname, R_OK) == -1 && geteuid() != 0) { - /* Could not access() directory */ - ff_pkt->type = FT_NOACCESS; - ff_pkt->ff_errno = errno; - rtn_stat = handle_file(ff_pkt, pkt); - if (ff_pkt->linked) { - ff_pkt->linked->FileIndex = ff_pkt->FileIndex; + /* + * If we are using Win32 backup API, don't check + * access as everything is more complicated, and + * in principle, we should be able to access everything. + */ + if (!is_win32_backup()) { + if (access(fname, R_OK) == -1 && geteuid() != 0) { + /* Could not access() directory */ + ff_pkt->type = FT_NOACCESS; + ff_pkt->ff_errno = errno; + rtn_stat = handle_file(ff_pkt, pkt); + if (ff_pkt->linked) { + ff_pkt->linked->FileIndex = ff_pkt->FileIndex; + } + return rtn_stat; } - return rtn_stat; } -#endif /* Build a canonical directory name with a trailing slash in link var */ len = strlen(fname); diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index ad2e7ad65a..5e507ebe09 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -63,6 +63,7 @@ static POOLMEM *compress_buf; static int type; static int stream; static int prog_name_msg = 0; +static int win32_data_msg = 0; static char *VolumeName = NULL; static char *wbuf; /* write buffer address */ @@ -187,6 +188,14 @@ int main (int argc, char *argv[]) if (bsr) { free_bsr(bsr); } + if (prog_name_msg) { + Pmsg1(000, "%d Program Name and/or Program Data Stream records ignored.\n", + prog_name_msg); + } + if (win32_data_msg) { + Pmsg1(000, "%d Win32 data or Win32 gzip data stream records. Ignored.\n", + win32_data_msg); + } return 0; } @@ -480,7 +489,12 @@ static void record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec) } else if (rec->Stream == STREAM_PROGRAM_NAMES || rec->Stream == STREAM_PROGRAM_DATA) { if (!prog_name_msg) { Pmsg0(000, "Got Program Name or Data Stream. Ignored.\n"); - prog_name_msg = 1; + prog_name_msg++; + } + } else if (rec->Stream == STREAM_WIN32_DATA || rec->Stream == STREAM_WIN32_GZIP_DATA) { + if (!win32_data_msg) { + Pmsg0(000, "Got Win32 data or Win32 gzip data stream. Ignored.\n"); + win32_data_msg++; } } else if (!(rec->Stream == STREAM_MD5_SIGNATURE || rec->Stream == STREAM_SHA1_SIGNATURE)) { diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index a606979e30..99b9f23be9 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -626,6 +626,35 @@ static void record_cb(JCR *bjcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec) mjcr->JobBytes += rec->data_len - sizeof(uint64_t); /* No correct, we should expand it */ free_jcr(mjcr); /* done using JCR */ + /* Win32 Data stream */ + } else if (rec->Stream == STREAM_WIN32_DATA) { + mjcr = get_jcr_by_session(rec->VolSessionId, rec->VolSessionTime); + if (!mjcr) { + if (mr.VolJobs > 0) { + Pmsg2(000, _("Could not find Job SessId=%d SessTime=%d for Win32 Data record.\n"), + rec->VolSessionId, rec->VolSessionTime); + } else { + ignored_msgs++; + } + return; + } + mjcr->JobBytes += rec->data_len; + free_jcr(mjcr); /* done using JCR */ + + /* Win32 GZIP stream */ + } else if (rec->Stream == STREAM_WIN32_GZIP_DATA) { + mjcr = get_jcr_by_session(rec->VolSessionId, rec->VolSessionTime); + if (!mjcr) { + if (mr.VolJobs > 0) { + Pmsg2(000, _("Could not find Job SessId=%d SessTime=%d for Win32 GZIP Data record.\n"), + rec->VolSessionId, rec->VolSessionTime); + } else { + ignored_msgs++; + } + return; + } + mjcr->JobBytes += rec->data_len; + free_jcr(mjcr); /* done using JCR */ } else if (rec->Stream == STREAM_MD5_SIGNATURE) { char MD5buf[50]; diff --git a/bacula/src/stored/record.c b/bacula/src/stored/record.c index 2257a1b63e..22b3c4ebdf 100644 --- a/bacula/src/stored/record.c +++ b/bacula/src/stored/record.c @@ -92,6 +92,10 @@ char *stream_to_ascii(int stream, int fi) return "UATTR"; case STREAM_FILE_DATA: return "DATA"; + case STREAM_WIN32_DATA: + return "WIN32-DATA"; + case STREAM_WIN32_GZIP_DATA: + return "WIN32-GZIP"; case STREAM_MD5_SIGNATURE: return "MD5"; case STREAM_SHA1_SIGNATURE: @@ -112,6 +116,10 @@ char *stream_to_ascii(int stream, int fi) return "contUATTR"; case -STREAM_FILE_DATA: return "contDATA"; + case -STREAM_WIN32_DATA: + return "contWIN32-DATA"; + case -STREAM_WIN32_GZIP_DATA: + return "contWIN32-GZIP"; case -STREAM_MD5_SIGNATURE: return "contMD5"; case -STREAM_SHA1_SIGNATURE: