]> arthur.barton.de Git - bup.git/commitdiff
metadata: accept EOPNOTSUPP for lchmod()
authorJohannes Berg <johannes@sipsolutions.net>
Sun, 12 Sep 2021 18:58:45 +0000 (20:58 +0200)
committerRob Browning <rlb@defaultvalue.org>
Sun, 12 Sep 2021 20:36:54 +0000 (15:36 -0500)
On some systems (e.g. mine, Fedora 33) python2 has
(started to have?) lchmod(), as glibc has it, but
that always only returns EOPNOTSUPP if you really
try to operate on a symlink. Allow for that and
handle it just like ENOSYS.

Note that the handling of ENOSYS is wrong, since
integers can't be thrown or caught - pylint found
this as well, but since I'm fixing EOPNOTSUPP here
I need to fix that at the same time.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/metadata.py

index a20b67b492425a3462c16a49b5b0c95402c57f0a..83f04f771475457641c96e369d500b45be946a0b 100644 (file)
@@ -453,8 +453,13 @@ class Metadata:
         if _have_lchmod:
             try:
                 os.lchmod(path, stat.S_IMODE(self.mode))
-            except errno.ENOSYS:  # Function not implemented
-                pass
+            except OSError as e:
+                # - "Function not implemented"
+                # - "Operation not supported" might be generated by glibc
+                if e.errno in (errno.ENOSYS, errno.EOPNOTSUPP):
+                    pass
+                else:
+                    raise
         elif not stat.S_ISLNK(self.mode):
             os.chmod(path, stat.S_IMODE(self.mode))