-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os.setxattr PermissionError on panfs propagates up causing copystat
, copytree
, and pip install .
to fail unhepfully
#68726
Comments
PermissionError Traceback (most recent call last)
<ipython-input-55-139c9fc77184> in <module>()
----> 1 shutil.copystat("/home/users/gholl/checkouts/pyatmlab/.git/objects/pack/pack-c1449559ec4287b3830efe2913608dddf2f21391.pack", "/tmp/fubar")
/home/users/gholl/lib/python3.4/shutil.py in copystat(src, dst, follow_symlinks)
211 else:
212 raise
--> 213 _copyxattr(src, dst, follow_symlinks=follow)
214
215 def copy(src, dst, *, follow_symlinks=True):
/home/users/gholl/lib/python3.4/shutil.py in _copyxattr(src, dst, follow_symlinks)
151 try:
152 value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
--> 153 os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
154 except OSError as e:
155 if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA):
PermissionError: [Errno 13] Permission denied: '/tmp/fubar' This occurs for any source file where the user write bit is not set. Now, I'm not sure if this should be addressed in |
There are a couple of related open issues. I think there is an stdlib problem here, but I"m not sure what the solution is. |
Perhaps the solution would be some kind of flag, at least for copytree and possibly others, on what to do when attributes cannot be completely copied — a bit like numpys options to raise, warn, or ignore? |
The issue can be avoided by calling _copyxattr *before* instead of after os.chmod in shutil.copystat. That way the file is still writable. The same issue happens on the Lustre parallel file system, with the lustre.lov extended attribute. |
This old bug now has a PR on Github authored by myself that may be reviewed. |
Patch LGTM. I'd like to point out one thing for posterity. Current shutil code catches EPERM but not EACCES. While reviewing the patch I wondered whether simply catching (and ignoring) both error codes instead, but it turns out they are supposed to have 2 different meanings: |
This seems complete, can it be closed? |
Yes, it may be closed. The fix was merged in time to make it into Python 3.7.4 and 3.8.0, and solved the problems we were facing with fancy filesystem xattrs on read-only files. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: