Christian Heimes <li...@cheimes.de> added the comment:

No, CPython's stdlib doesn't use libselinux.

I talked to an engineer from Red Hat's SELinux team today. SELinux returns 
EACCES for policy violations like in this case. The _copyxattr() helper 
function ignores EPERM but not EACCES. You are seeing a PermissionError 
exception because Python maps both EPERM and EACCES to PermissionError.

As first fix the _copyxattr() helper could ignore all permission errors for 
"security.*" namespace and just continue. This will get rid of the error but 
may still cause lots of AVC audit events.

A better but backwards incompatible approach is to handle the xattr namespaces 
differently. Linux defines four xattr namespaces: security, system, trusted, 
and user. The security namespace is used by security policies like Smack or 
SELinux. IMHO _copyxattr() should only copy user xattrs by default. The 
security namespace should only be copied when the caller opts-in. The cp tool 
has separate preserve settings for context (SELinux security context) and xattr 
(other extended attributes).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38893>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to