Skip to content

Commit

Permalink
Fixed check for extended attributes
Browse files Browse the repository at this point in the history
Only if libc reports errno 95 Operation not supported the method
should return that extended attributes are not supported. Also
add a debug information about the result of the call to get further
information in the log file
  • Loading branch information
schaefi committed Jul 25, 2023
1 parent 600a6f9 commit 3669d8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion kiwi/utils/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ def target_supports_extended_attributes(self) -> bool:
try:
os.getxattr(self.target_dir, 'user.mime_type')
except OSError as e:
if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA):
log.debug(
f'Check for extended attributes on {self.target_dir} said: {e}'
)
if e.errno == errno.ENOTSUP:
return False
return True
7 changes: 4 additions & 3 deletions test/unit/utils/sync_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import errno
import logging
from pytest import fixture
from stat import ST_MODE
Expand Down Expand Up @@ -66,7 +67,7 @@ def test_target_supports_extended_attributes(self, mock_getxattr):

@patch('os.getxattr')
def test_target_does_not_support_extended_attributes(self, mock_getxattr):
mock_getxattr.side_effect = OSError(
"""[Errno 95] Operation not supported: b'/boot/efi"""
)
effect = OSError()
effect.errno = errno.ENOTSUP
mock_getxattr.side_effect = effect
assert self.sync.target_supports_extended_attributes() is False

0 comments on commit 3669d8c

Please sign in to comment.