classification
Title: Do not automount in stat() by default
Type: behavior Stage: patch review
Components: Extension Modules Versions: Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: larry, serhiy.storchaka, vstinner
Priority: normal Keywords: patch, patch, patch

Created on 2019-01-07 09:17 by serhiy.storchaka, last changed 2019-01-09 06:53 by serhiy.storchaka.

Pull Requests
URL Status Linked Edit
PR 11455 open serhiy.storchaka, 2019-01-07 09:30
PR 11455 open serhiy.storchaka, 2019-01-07 09:30
PR 11455 open serhiy.storchaka, 2019-01-07 09:30
Messages (3)
msg333143 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-01-07 09:17
There is a subtle difference between implementations of os.stat() that use system calls stat() and fstatat(). On Linux, fstatat() by default automounts the terminal ("basename") component of pathname if it is a directory that is an automount point. The Linux-specific AT_NO_AUTOMOUNT flag should be set to prevent automounting. Both stat() and lstat() act as though AT_NO_AUTOMOUNT was set.

Therefore os.stat() should set AT_NO_AUTOMOUNT if it is defined to simulate the behavior of stat() and lstat(). New keyword parameter can be added to os.stat() in new Python release to control this behavior.

There is the same issue with DirEntry.stat().
msg333155 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-07 14:40
What if someone relies on the current behavior of os.stat(filename, dir_fd=fd)? Would it make sense to add a new "automount=False" optional parameter to os.stat()? AT_NO_AUTOMOUNT would only be added if automount is false.
msg333291 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-01-09 06:53
I was going to merge PR 11455 as a bug fix and backport it to 3.7, and add a new "automount=False" optional parameter in a separate issue.
History
Date User Action Args
2019-01-09 06:53:06serhiy.storchakasetkeywords: patch, patch, patch

messages: + msg333291
2019-01-07 14:40:56vstinnersetkeywords: patch, patch, patch
nosy: + vstinner
messages: + msg333155

2019-01-07 09:30:45serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request10926
2019-01-07 09:30:40serhiy.storchakasetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10925
2019-01-07 09:30:35serhiy.storchakasetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10924
2019-01-07 09:17:58serhiy.storchakacreate