Browse Source

Fix crash regression for UDS introduced in 805f631

Marian Beermann 9 years ago
parent
commit
ce6b838da8
2 changed files with 15 additions and 3 deletions
  1. 4 3
      borg/platform_linux.pyx
  2. 11 0
      borg/testsuite/archiver.py

+ 4 - 3
borg/platform_linux.pyx

@@ -86,10 +86,11 @@ def set_flags(path, bsd_flags, fd=None):
 
 
 def get_flags(path, st):
-    if stat.S_ISLNK(st.st_mode):
-        return 0
     cdef int linux_flags
-    fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
+    try:
+        fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
+    except OSError:
+        return 0
     try:
         if ioctl(fd, FS_IOC_GETFLAGS, &linux_flags) == -1:
             return 0

+ 11 - 0
borg/testsuite/archiver.py

@@ -5,6 +5,7 @@ import inspect
 from io import StringIO
 import logging
 import random
+import socket
 import stat
 import subprocess
 import sys
@@ -357,6 +358,16 @@ class ArchiverTestCase(ArchiverTestCaseBase):
         # the interesting parts of info_output2 and info_output should be same
         self.assert_equal(filter(info_output), filter(info_output2))
 
+    def test_unix_socket(self):
+        self.cmd('init', self.repository_location)
+        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        sock.bind(os.path.join(self.input_path, 'unix-socket'))
+        self.cmd('create', self.repository_location + '::test', 'input')
+        sock.close()
+        with changedir('output'):
+            self.cmd('extract', self.repository_location + '::test')
+            assert not os.path.exists('input/unix-socket')
+
     def test_symlink_extract(self):
         self.create_test_files()
         self.cmd('init', self.repository_location)