Browse Source

set_flags: better give up than corrupt

Thanks to Earnestly for the feedback on IRC.
Thomas Waldmann 2 weeks ago
parent
commit
9c600a9571
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/borg/platform/linux.pyx

+ 5 - 2
src/borg/platform/linux.pyx

@@ -149,9 +149,12 @@ def set_flags(path, bsd_flags, fd=None):
     if open_fd:
         fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
     try:
-        # Get current flags. If this fails, fall back to 0 so we can still attempt to set.
+        # Get current flags.
         if ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1:
-            flags = 0
+            # If this fails, give up because it is either not supported by the fs
+            # or maybe not permitted? If we can't determine the current flags,
+            # we better not risk corrupting them by setflags, see the comment below.
+            return  # give up silently
 
         # Replace only the bits we actually want to influence, keep others.
         # We can't just set all flags to the archived value, because we might