]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport bacula/src/findlib/create_file.c
authorAlain Spineux <alain@baculasystems.com>
Mon, 20 Apr 2020 14:40:37 +0000 (16:40 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 29 Apr 2021 08:44:16 +0000 (10:44 +0200)
This commit is the result of the squash of the following main commits:

Author: Alain Spineux <alain@baculasystems.com>
Date:   Mon Nov 12 11:07:04 2018 +0100

    win32: Fix #4286 about the restore of a volume root directory with the hidden & system attributes

    - Detect root directories like C:\ or C:\mount_point
      and setup st_rdev=WIN32_ROOT_POINT to tell restore to not restore
      the hidden and system attributes
    - Be aware that there is 2 different "directories" (1) the parent
      directory like c:\mount_point and (2) the root directory of the volume
      that your are attaching to the parent. The attributes that you see is
      the attribute of (1) but for drive letters, their is no (1) then
      you see always (2) (that are hidden and system).
      When VSS snapshot is used

bacula/src/findlib/create_file.c

index 8a7102a7b29e9f722805ba59213c99e7834ad553..088834d105428e263d07ce2c62b53bf7c14a2d3c 100644 (file)
@@ -365,6 +365,13 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
    case FT_DIRBEGIN:
    case FT_DIREND:
       Dmsg2(200, "Make dir mode=%o dir=%s\n", new_mode, attr->ofname);
+      if (is_win32_stream(attr->data_stream) && attr->statp.st_rdev == WIN32_ROOT_POINT) {
+         /* this is a root directory like C:\ or C:\anymountpoint,
+          * don't restore HIDDEN and SYSTEM attributes
+          */
+         new_mode &= ~S_ISVTX; // remove FILE_ATTRIBUTE_HIDDEN
+         new_mode |= S_IRWXO;  // remove FILE_ATTRIBUTE_SYSTEM
+      }
       if (!makepath(attr, attr->ofname, new_mode, parent_mode, uid, gid, 0)) {
          return CF_ERROR;
       }