]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/findlib/bfile.c
- Start implementing Christopher's St.Bernard code.
[bacula/bacula] / bacula / src / findlib / bfile.c
index f9f66652d938616086978ce96715bd64b89e02eb..cab8c54c025b2685a38f5da90d4202552d81c16f 100644 (file)
@@ -9,7 +9,7 @@
  *
  */
 /*
-   Copyright (C) 2003-2005 Kern Sibbald
+   Copyright (C) 2003-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -48,6 +48,8 @@ bool is_win32_stream(int stream)
    switch (stream) {
    case STREAM_WIN32_DATA:
    case STREAM_WIN32_GZIP_DATA:
+   case STREAM_ENCRYPTED_WIN32_DATA:
+   case STREAM_ENCRYPTED_WIN32_GZIP_DATA:
       return true;
    }
    return false;
@@ -92,6 +94,16 @@ const char *stream_to_ascii(int stream)
       return _("SHA512 digest");
    case STREAM_SIGNED_DIGEST:
       return _("Signed digest");
+   case STREAM_ENCRYPTED_FILE_DATA:
+      return _("Encrypted File data");
+   case STREAM_ENCRYPTED_FILE_GZIP_DATA:
+      return _("Encrypted GZIP data");
+   case STREAM_ENCRYPTED_WIN32_DATA:
+      return _("Encrypted Win32 data");
+   case STREAM_ENCRYPTED_WIN32_GZIP_DATA:
+      return _("Encrypted Win32 GZIP data");
+   case STREAM_ENCRYPTED_MACOS_FORK_DATA:
+      return _("Encrypted HFS+ resource fork");
    default:
       sprintf(buf, "%d", stream);
       return (const char *)buf;
@@ -317,6 +329,7 @@ bool is_restore_stream_supported(int stream)
 #endif
    case STREAM_MACOS_FORK_DATA:
    case STREAM_HFSPLUS_ATTRIBUTES:
+   case STREAM_ENCRYPTED_MACOS_FORK_DATA:
       return false;
 
    /* Known streams */
@@ -340,6 +353,10 @@ bool is_restore_stream_supported(int stream)
 #endif
 #ifdef HAVE_CRYPTO
    case STREAM_SIGNED_DIGEST:
+   case STREAM_ENCRYPTED_FILE_DATA:
+   case STREAM_ENCRYPTED_FILE_GZIP_DATA:
+   case STREAM_ENCRYPTED_WIN32_DATA:
+   case STREAM_ENCRYPTED_WIN32_GZIP_DATA:
 #endif
    case 0:                            /* compatibility with old tapes */
       return true;
@@ -369,7 +386,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
       return 0;
 
    if (p_CreateFileW && p_MultiByteToWideChar)               
-      UTF8_2_wchar(&win32_fname_wchar, win32_fname);
+      make_win32_path_UTF8_2_wchar(&win32_fname_wchar, fname);
 
    if (flags & O_CREAT) {             /* Create */
       if (bfd->use_backup_api) {
@@ -380,26 +397,24 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
          dwflags = 0;
       }
 
-   // unicode or ansii open for create write
-   if (p_CreateFileW && p_MultiByteToWideChar) {   
-      bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
-             dwaccess,                /* Requested access */
-             0,                       /* Shared mode */
-             NULL,                    /* SecurityAttributes */
-             CREATE_ALWAYS,           /* CreationDisposition */
-             dwflags,                 /* Flags and attributes */
-             NULL);                   /* TemplateFile */
-   }
-   else {
-      bfd->fh = p_CreateFileA(win32_fname,
-             dwaccess,                /* Requested access */
-             0,                       /* Shared mode */
-             NULL,                    /* SecurityAttributes */
-             CREATE_ALWAYS,           /* CreationDisposition */
-             dwflags,                 /* Flags and attributes */
-             NULL);                   /* TemplateFile */
-   }
-
+      // unicode or ansii open for create write
+      if (p_CreateFileW && p_MultiByteToWideChar) {   
+         bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
+                dwaccess,                /* Requested access */
+                0,                       /* Shared mode */
+                NULL,                    /* SecurityAttributes */
+                CREATE_ALWAYS,           /* CreationDisposition */
+                dwflags,                 /* Flags and attributes */
+                NULL);                   /* TemplateFile */
+      } else {
+         bfd->fh = p_CreateFileA(win32_fname,
+                dwaccess,                /* Requested access */
+                0,                       /* Shared mode */
+                NULL,                    /* SecurityAttributes */
+                CREATE_ALWAYS,           /* CreationDisposition */
+                dwflags,                 /* Flags and attributes */
+                NULL);                   /* TemplateFile */
+      }
 
       bfd->mode = BF_WRITE;
 
@@ -412,26 +427,25 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
          dwflags = 0;
       }
 
-   // unicode or ansii open for open existing write
-   if (p_CreateFileW && p_MultiByteToWideChar) {   
-      bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
-             dwaccess,                /* Requested access */
-             0,                       /* Shared mode */
-             NULL,                    /* SecurityAttributes */
-             OPEN_EXISTING,           /* CreationDisposition */
-             dwflags,                 /* Flags and attributes */
-             NULL);                   /* TemplateFile */
-   }
-   else {
-      bfd->fh = p_CreateFileA(win32_fname,
-             dwaccess,                /* Requested access */
-             0,                       /* Shared mode */
-             NULL,                    /* SecurityAttributes */
-             OPEN_EXISTING,           /* CreationDisposition */
-             dwflags,                 /* Flags and attributes */
-             NULL);                   /* TemplateFile */
+      // unicode or ansii open for open existing write
+      if (p_CreateFileW && p_MultiByteToWideChar) {   
+         bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
+                dwaccess,                /* Requested access */
+                0,                       /* Shared mode */
+                NULL,                    /* SecurityAttributes */
+                OPEN_EXISTING,           /* CreationDisposition */
+                dwflags,                 /* Flags and attributes */
+                NULL);                   /* TemplateFile */
+      } else {
+         bfd->fh = p_CreateFileA(win32_fname,
+                dwaccess,                /* Requested access */
+                0,                       /* Shared mode */
+                NULL,                    /* SecurityAttributes */
+                OPEN_EXISTING,           /* CreationDisposition */
+                dwflags,                 /* Flags and attributes */
+                NULL);                   /* TemplateFile */
 
-   }
+      }
 
       bfd->mode = BF_WRITE;
 
@@ -447,24 +461,23 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
       }
 
       // unicode or ansii open for open existing read
-   if (p_CreateFileW && p_MultiByteToWideChar) {   
-      bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
-             dwaccess,                /* Requested access */
-             dwshare,                 /* Share modes */
-             NULL,                    /* SecurityAttributes */
-             OPEN_EXISTING,           /* CreationDisposition */
-             dwflags,                 /* Flags and attributes */
-             NULL);                   /* TemplateFile */
-   }
-   else {
-      bfd->fh = p_CreateFileA(win32_fname,
-             dwaccess,                /* Requested access */
-             dwshare,                 /* Share modes */
-             NULL,                    /* SecurityAttributes */
-             OPEN_EXISTING,           /* CreationDisposition */
-             dwflags,                 /* Flags and attributes */
-             NULL);                   /* TemplateFile */
-   }
+      if (p_CreateFileW && p_MultiByteToWideChar) {   
+         bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
+                dwaccess,                /* Requested access */
+                dwshare,                 /* Share modes */
+                NULL,                    /* SecurityAttributes */
+                OPEN_EXISTING,           /* CreationDisposition */
+                dwflags,                 /* Flags and attributes */
+                NULL);                   /* TemplateFile */
+      } else {
+         bfd->fh = p_CreateFileA(win32_fname,
+                dwaccess,                /* Requested access */
+                dwshare,                 /* Share modes */
+                NULL,                    /* SecurityAttributes */
+                OPEN_EXISTING,           /* CreationDisposition */
+                dwflags,                 /* Flags and attributes */
+                NULL);                   /* TemplateFile */
+      }
 
       bfd->mode = BF_READ;
    }
@@ -714,10 +727,20 @@ bool is_restore_stream_supported(int stream)
    case STREAM_SHA256_DIGEST:
    case STREAM_SHA512_DIGEST:
 #endif
+#ifdef HAVE_CRYPTO
+   case STREAM_SIGNED_DIGEST:
+   case STREAM_ENCRYPTED_FILE_DATA:
+   case STREAM_ENCRYPTED_FILE_GZIP_DATA:
+   case STREAM_ENCRYPTED_WIN32_DATA:
+   case STREAM_ENCRYPTED_WIN32_GZIP_DATA:
+#endif
 #ifdef HAVE_DARWIN_OS
    case STREAM_MACOS_FORK_DATA:
    case STREAM_HFSPLUS_ATTRIBUTES:
-#endif
+#ifdef HAVE_CRYPTO
+   case STREAM_ENCRYPTED_MACOS_FORK_DATA:
+#endif /* HAVE_CRYPTO */
+#endif /* HAVE_DARWIN_OS */
    case 0:   /* compatibility with old tapes */
       return true;
 
@@ -734,6 +757,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
    }
 
    /* Normal file open */
+   Dmsg1(400, "open file %s\n", fname);
    bfd->fid = open(fname, flags, mode);
    bfd->berrno = errno;
    Dmsg1(400, "Open file %d\n", bfd->fid);