Browse Source

create/extract: add --noacls option, #3955

when given with borg create, borg will not get ACLs from input files (and thus, it will not archive ACLs).

when given with borg extract, borg will not read ACLs from archive and it will not set ACLs on extracted files.
Thomas Waldmann 4 years ago
parent
commit
b40544ddba
2 changed files with 13 additions and 4 deletions
  1. 7 3
      src/borg/archive.py
  2. 6 1
      src/borg/archiver.py

+ 7 - 3
src/borg/archive.py

@@ -315,7 +315,8 @@ class Archive:
         """Failed to encode filename "{}" into file system encoding "{}". Consider configuring the LANG environment variable."""
 
     def __init__(self, repository, key, manifest, name, cache=None, create=False,
-                 checkpoint_interval=1800, numeric_owner=False, noatime=False, noctime=False, nobirthtime=False, nobsdflags=False,
+                 checkpoint_interval=1800, numeric_owner=False, noatime=False, noctime=False, nobirthtime=False,
+                 nobsdflags=False, noacls=False,
                  progress=False, chunker_params=CHUNKER_PARAMS, start=None, start_monotonic=None, end=None,
                  consider_part_files=False, log_json=False):
         self.cwd = os.getcwd()
@@ -335,6 +336,7 @@ class Archive:
         self.noctime = noctime
         self.nobirthtime = nobirthtime
         self.nobsdflags = nobsdflags
+        self.noacls = noacls
         assert (start is None) == (start_monotonic is None), 'Logic error: if start is given, start_monotonic must be given as well and vice versa.'
         if start is None:
             start = datetime.utcnow()
@@ -762,7 +764,8 @@ Utilization of max. archive size: {csize_max:.0%}
         except OSError:
             # some systems don't support calling utime on a symlink
             pass
-        acl_set(path, item, self.numeric_owner)
+        if not self.noacls:
+            acl_set(path, item, self.numeric_owner)
         # chown removes Linux capabilities, so set the extended attributes at the end, after chown, since they include
         # the Linux capabilities in the "security.capability" attribute.
         xattrs = item.get('xattrs', {})
@@ -912,7 +915,8 @@ Utilization of max. archive size: {csize_max:.0%}
             xattrs = xattr.get_all(path, follow_symlinks=False)
             if not self.nobsdflags:
                 bsdflags = get_flags(path, st)
-            acl_get(path, attrs, st, self.numeric_owner)
+            if not self.noacls:
+                acl_get(path, attrs, st, self.numeric_owner)
         if xattrs:
             attrs['xattrs'] = StableDict(xattrs)
         if bsdflags:

+ 6 - 1
src/borg/archiver.py

@@ -185,6 +185,7 @@ def with_archive(method):
         archive = Archive(repository, key, manifest, args.location.archive,
                           numeric_owner=getattr(args, 'numeric_owner', False),
                           nobsdflags=getattr(args, 'nobsdflags', False),
+                          noacls=getattr(args, 'noacls', False),
                           cache=kwargs.get('cache'),
                           consider_part_files=args.consider_part_files, log_json=args.log_json)
         return method(self, args, repository=repository, manifest=manifest, key=key, archive=archive, **kwargs)
@@ -587,7 +588,7 @@ class Archiver:
                 archive = Archive(repository, key, manifest, args.location.archive, cache=cache,
                                   create=True, checkpoint_interval=args.checkpoint_interval,
                                   numeric_owner=args.numeric_owner, noatime=args.noatime, noctime=args.noctime, nobirthtime=args.nobirthtime,
-                                  nobsdflags=args.nobsdflags, progress=args.progress,
+                                  nobsdflags=args.nobsdflags, noacls=args.noacls, progress=args.progress,
                                   chunker_params=args.chunker_params, start=t0, start_monotonic=t0_monotonic,
                                   log_json=args.log_json)
                 create_inner(archive, cache)
@@ -3473,6 +3474,8 @@ class Archiver:
                               help='do not store birthtime (creation date) into archive')
         fs_group.add_argument('--nobsdflags', dest='nobsdflags', action='store_true',
                               help='do not read and store bsdflags (e.g. NODUMP, IMMUTABLE) into archive')
+        fs_group.add_argument('--noacls', dest='noacls', action='store_true',
+                              help='do not read and store ACLs into archive')
         fs_group.add_argument('--ignore-inode', dest='ignore_inode', action='store_true',
                               help='ignore inode data in the file metadata cache used to detect unchanged files.')
         fs_group.add_argument('--files-cache', metavar='MODE', dest='files_cache_mode',
@@ -3541,6 +3544,8 @@ class Archiver:
                                help='only obey numeric user and group identifiers')
         subparser.add_argument('--nobsdflags', dest='nobsdflags', action='store_true',
                                help='do not extract/set bsdflags (e.g. NODUMP, IMMUTABLE)')
+        subparser.add_argument('--noacls', dest='noacls', action='store_true',
+                               help='do not extract/set ACLs')
         subparser.add_argument('--stdout', dest='stdout', action='store_true',
                                help='write all extracted data to stdout')
         subparser.add_argument('--sparse', dest='sparse', action='store_true',